169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalpackage sample.rmi; 269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalimport javassist.tools.rmi.AppletServer; 469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalimport java.io.IOException; 569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalimport javassist.CannotCompileException; 669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalimport javassist.NotFoundException; 769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalpublic class Counter { 969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal private int count = 0; 1069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 1169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal public int get() { 1269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal return count; 1369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal } 1469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 1569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal synchronized public int increase() { 1669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal count += 1; 1769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal return count; 1869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal } 1969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 2069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal public static void main(String[] args) 2169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal throws IOException, NotFoundException, CannotCompileException 2269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal { 2369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal if (args.length == 1) { 2469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal AppletServer web = new AppletServer(args[0]); 2569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal web.exportObject("counter", new Counter()); 2669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal web.run(); 2769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal } 2869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal else 2969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal System.err.println( 3069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal "Usage: java sample.rmi.Counter <port number>"); 3169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal } 3269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal} 33