• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

any event when system properties are changed?

 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have set a system property same named, say , key via System.setProperty() call. But some how it is reset by some code out of my control. I wonder is there a way I can detect the change of this property. For example, is there any event I can catch when certain property values get reset.
Thanks,
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I don't think there is any way to be notified of changes to system properties.

It is not clear from your description whether you really need to use a system property. What do you need to achieve?
 
Jack Zhou
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was trying find out why some of the system property I set get reseted.
Thanks,
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
System properties apply to the JVM. When the JVM executes multiple apps may be executing in it. Any app in the JVM can change a system property that is not restricted. In general, I don't recommend setting system properties unless it is for a property value that is for all the apps in the JVM.

However, to answer the question, access to the System object is controller by the SecurityManager. When you start the JVM, a security manager can be loaded. This security manager will be notified of any attempt to change a system property. However, if you are on a j2ee web server, you may not be able to load your own security manager as most J2ee environments supply a security manager that you cant override. These seucrity managers usually have a way to restrict system property changes. You can restrict the changes and see who get a the SecurityException.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic