Sponsored Link •
|
Advertisement
|
Advertisement
|
This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.
Message:
Hello everybody, I have a question related to dynamic reloading of Java classes. I'm building an application where a client application downloads through the network (TCP connection) objects with persistent state. These objects definitions (class files) are located on a local client directory. In case that no dynamic reloading is considered, the object's state may be restored by invoking the readObject() method. ServerSocket serSock = new ServerSocket(1000, 3); In case that the downloaded object's class file directory belongs in the CLASSPATH, the readObject() restores the object's state normally (I believe because the object's class definition is loaded by the default ClassLoader), otherwise a ClassNotFoundException is thrown. My problem is that the downloaded objects class definitions are modified in runtime, so they have to be reloaded by the client applications. In order to do that, I followed Bill Venners advice and I create a new instance of a custom ClassLoader (new name space) whenever a class definition is updated. However a came across the problem that I described previously. If I just needed to create a new instance of the updated class, that would be easy, through: NewClassLoader loader = new NewClassLoader(directory); // The downloadedClass is updated However the situation is different here, where an existing object's state needs to be reconstructed. Is there any way to force the dataIn.readObject() object to be loaded by a custom ClassLoader (NewClassLoader) ???? Could anybody suggest any way to work around the problem? Thanks very much in advance, Replies: |
Sponsored Links
|