1package sample.rmi;
2
3import javassist.tools.rmi.AppletServer;
4import java.io.IOException;
5import javassist.CannotCompileException;
6import javassist.NotFoundException;
7
8public class Counter {
9    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)
21	throws IOException, NotFoundException, CannotCompileException
22    {
23	if (args.length == 1) {
24	    AppletServer web = new AppletServer(args[0]);
25	    web.exportObject("counter", new Counter());
26	    web.run();
27	}
28	else
29	    System.err.println(
30			"Usage: java sample.rmi.Counter <port number>");
31    }
32}
33