You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Counter.java 719B

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