/Users/lyon/j4p/src/classUtils/loaders/ReloadThread.java

1    package classUtils.loaders; 
2     
3    //package net.compute; 
4     
5    import java.io.IOException; 
6    import java.io.ObjectInputStream; 
7    import java.io.ObjectOutputStream; 
8    import java.net.Socket; 
9     
10   public class ReloadThread extends 
11           Thread { 
12       ObjectInputStream ois; 
13       ObjectOutputStream oos; 
14    
15       ReloadThread(Socket s) 
16               throws IOException { 
17           // read the computable object from the 
18           // object input stream. 
19           // write the answer to the object output stream. 
20           oos = 
21                   new ObjectOutputStream( 
22                           s.getOutputStream()); 
23    
24           ois = 
25                   new ObjectInputStream( 
26                           s.getInputStream()); 
27       } 
28    
29       public void run() { 
30           try { 
31               // This should be the bytecodes for 
32               // a class! 
33               Object o = ois.readObject(); 
34    
35               if (o == null) { 
36                   System.out.println("The Object is null"); 
37                   return; 
38               } 
39    
40               if (!(o instanceof ByteCodeContainer)) { 
41                   System.out.println("Bad object! this is not a RemoteClassLoader! we are here"); 
42                   return; 
43               } 
44               ByteCodeContainer 
45                       bcc = (ByteCodeContainer) o; 
46    
47               oos.writeObject(bcc.compute()); 
48               oos.close(); 
49               ois.close(); 
50           } catch (Exception e) { 
51               e.printStackTrace(); 
52           } 
53       } 
54   }