KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sample > rmi > Counter


1 package sample.rmi;
2
3 import javassist.rmi.AppletServer;
4 import java.io.IOException JavaDoc;
5 import javassist.CannotCompileException;
6 import javassist.NotFoundException;
7
8 public 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 JavaDoc[] args)
21     throws IOException JavaDoc, 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
Popular Tags