01: package sample.rmi;
02:
03: import javassist.tools.rmi.AppletServer;
04: import java.io.IOException;
05: import javassist.CannotCompileException;
06: import javassist.NotFoundException;
07:
08: public class Counter {
09: private int count = 0;
10:
11: public int get() {
12: return count;
13: }
14:
15: synchronized public int increase() {
16: count += 1;
17: return count;
18: }
19:
20: public static void main(String[] args) throws IOException,
21: NotFoundException, CannotCompileException {
22: if (args.length == 1) {
23: AppletServer web = new AppletServer(args[0]);
24: web.exportObject("counter", new Counter());
25: web.run();
26: } else
27: System.err
28: .println("Usage: java sample.rmi.Counter <port number>");
29: }
30: }
|