This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
You can create a new ClassLoader every time you find a changed class file and want to load it. I looked at JUnit source code as an example of how to do it. Google for articles on custom class loaders; it's non-trivial to get completely right.
It's possible to get into weird places with custom class loaders, equals() or compareTo() methods, reflection, static variables, Singletons and such. If you run into trouble later, remember custom loaders might be involved.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Jul 04, 2004
Hi Stan ,
Thanks for responding ...
I dont have much idea about this....Suppose the server has already started and the app. has started ..Later the file /class has changed...
Now how can i load the changed .class file using the classloader...mechanism..
If i understand the problem correctly, you need to reload changes to your configuration etc from a properties file on the fly.
If this properties file is on the filesystem then you can check the timestamp of properties file using . If modified you can invoke the method configuring your application(synchronously) and blocking access to configuration till reloaded. This is fine in case changes are done in off peak hours for the application else handling is complex and better to reload the app, if possible.
Reloading configuration is a very cool capability. In my last big work project I made a "dashboard" with a button to reload part or all of configuration from a variety of sources. In my Wiki I edit the configuration pages through the application and the "save" operation publishes an event that different components listen for.