/Users/lyon/j4p/src/net/compute/ReloadThread.java

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