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.

1234567891011121314151617181920212223242526272829303132333435363738
  1. package sample.evolve;
  2. import javassist.*;
  3. /**
  4. * DemoLoader is a class loader for running a program including
  5. * an updatable class. This simple loader allows only a single
  6. * class to be updatable. (Extending it for supporting multiple
  7. * updatable classes is easy.)
  8. *
  9. * To run, type as follows:
  10. *
  11. * % java sample.evolve.DemoLoader <port number>
  12. *
  13. * Then DemoLoader launches sample.evolve.DemoServer with <port number>.
  14. * It also translates sample.evolve.WebPage, which sample.evolve.DemoServer
  15. * uses, so that it is an updable class.
  16. *
  17. * Note: JDK 1.2 or later only.
  18. */
  19. public class DemoLoader {
  20. private static final int initialVersion = 0;
  21. private String updatableClassName = null;
  22. private CtClass updatableClass = null;
  23. /* Creates a <code>DemoLoader</code> for making class WebPage
  24. * updatable. Then it runs main() in sample.evolve.DemoServer.
  25. */
  26. public static void main(String[] args) throws Throwable {
  27. Evolution translator = new Evolution();
  28. ClassPool cp = ClassPool.getDefault();
  29. Loader cl = new Loader();
  30. cl.addTranslator(cp, translator);
  31. translator.makeUpdatable("sample.evolve.WebPage");
  32. cl.run("sample.evolve.DemoServer", args);
  33. }
  34. }