How do I RELOAD a class file?
I have a class called RecipeNode that I am creating an instance of when Apache-Tomcat starts (ie: When the machine boots). This class is wrapped in another class, RecipeService, that starts by creating a thread running RecipeNode;
class RecipeService
{
...
private static RecipeNode = null;
public static void create( String runDirectory)
{
...
node = new RecipeNode( runDirectory );
new Thread( node ).start();
...
}
}
When I make changes to the RecipeNode class, and then copy the new RecipeNode.class file to the server, I would like to end the RecipeNode thread, and start a new one using the code in the new class file.
I tried this using a reload() method in the RecipeService class. (The RecipeNode class has a shutdown method for this purpose, and runDirectory is static);
public static void reload()
{
if ( node != null )
{
node.shutdown();
}
node = new RecipeNode( runDirectory );
new Thread( node ).start();
}
A new thread is started properly when reload() is called (using a SOAP request), however, the new thread does not use the code in the new class file...
The only way I can reload the class at the moment is to restart Tomcat, and I want to avoid this unless I really have to.
Any ideas?
Thanks in anticipation!

