/Users/lyon/j4p/src/javassist/sample/rmi/Counter.java

1    package javassist.sample.rmi; 
2     
3    import javassist.CannotCompileException; 
4    import javassist.NotFoundException; 
5    import javassist.rmi.AppletServer; 
6     
7    import java.io.IOException; 
8     
9    public class Counter { 
10       private int count = 0; 
11    
12       public int get() { 
13           return count; 
14       } 
15    
16       synchronized public int increase() { 
17           count += 1; 
18           return count; 
19       } 
20    
21       public static void main(String[] args) 
22               throws IOException, NotFoundException, CannotCompileException { 
23           if (args.length == 1) { 
24               AppletServer web = new AppletServer(args[0]); 
25               web.exportObject("counter", new Counter()); 
26               web.run(); 
27           } else 
28               System.err.println( 
29                       "Usage: java sample.rmi.Counter <port number>"); 
30       } 
31   } 
32