Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems about KeyEvent and Policy file.

 
HiBob Chu
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends:
I meet such two problem:
1. I want to catch Ctrl+c key event so that I
can do something before that the server is
terminated. I don't want to use GUI. I
have tried by adding a Container object which
has the key listener--- the class implements
KeyListener interface. But it doesn't work.
2. My policy file contains as following:
******************************************
grant{
permission java.security.AllPermission;
};
******************************************
Need I add any more safe setting?
Please give me some advise.
Regards.
[ November 26, 2002: Message edited by: HiBob Chu ]
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Check out Runtime.addShutdownHook().
2. Security is not a requirement; you can leave it as is, or remove it altogether. I did go through the trouble of providing a security policy which is as tight as I could make it without knowing anything about the hardware it was to be deployed on, but with the benefit of hindsight I think I wasted my time.
- Peter
 
HiBob Chu
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peter:
Thank you for your advice.
But I wonder how do you get to know you had wasted time on providing more security setting?
And when I started to catching ^C , I found I
meeted anthor problem: is it really need? I wanted
to catch it just for doing unlock all and clear
the set of locked record number. But they could be
init correctly when server start again.
For clients which are booking when server is terminated, this is not a problem yet: a RemoteException will occured.
So the most simple way is just as you did : just using ^C .
But I will do smoe test still.
Thank you again. You really got a great score.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by HiBob Chu:
But I wonder how do you get to know you had wasted time on providing more security setting?
Just my impression from the scores given to people who don't bother with this
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic