Package org.springsource.loaded

Examples of org.springsource.loaded.ReloadableType$MergedRewrite$ChainedAdapters


  public void basic4() throws Exception {
    binLoader = new TestClassloaderWithRewriting();
    String t = "simple.BasicD";
    String target = "simple.BasicDTarget";
    TypeRegistry r = getTypeRegistry(t + "," + target);
    ReloadableType rtype = r.addType(t, loadBytesForClass(t));
    ReloadableType rtypeTarget = r.addType(target, loadBytesForClass(target));
    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("hello", result.returnValue);
    rtype.loadNewVersion("2", retrieveRename(t, t + "2"));
    rtypeTarget.loadNewVersion("2", retrieveRename(target, target + "2"));
    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("abc", result.returnValue);
  }
View Full Code Here


    String t = "simple.BasicE";
    String target = "simple.BasicETarget";

    TypeRegistry r = getTypeRegistry(t + "," + target);

    ReloadableType rtype = r.addType(t, loadBytesForClass(t));
    ReloadableType rtypeTarget = r.addType(target, loadBytesForClass(target));

    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("hello", result.returnValue);

    rtype.loadNewVersion("2", retrieveRename(t, t + "2"));
    rtypeTarget.loadNewVersion("2", retrieveRename(target, target + "2"));

    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("foobar", result.returnValue);
  }
View Full Code Here

    // GlobalConfiguration.logging = true;
    // GlobalConfiguration.isRuntimeLogging = true;

    TypeRegistry r = getTypeRegistry(t + "," + target);

    ReloadableType rtype = r.addType(t, loadBytesForClass(t));
    ReloadableType rtypeTarget = r.addType(target, loadBytesForClass(target));

    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("123", result.returnValue);

    // rtype.loadNewVersion("2", retrieveRename(t, t + "2"));
    rtypeTarget.loadNewVersion("2", retrieveRename(target, target + "2"));

    result = null;

    // The target method has been removed, should now fail to call it
    try {
      runUnguarded(rtype.getClazz(), "run");
      fail();
    } catch (InvocationTargetException ite) {
      // success
    }

    // Load the original back in, should work again
    rtypeTarget.loadNewVersion("3", retrieveRename(target, target));
    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("123", result.returnValue);

    // rtype.loadNewVersion("2", rtype.bytesInitial); //reload yourself

    // Load a new version that now returns an int
    rtypeTarget.loadNewVersion("4", retrieveRename(target, target + "4"));
    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("4456", result.returnValue);

  }
View Full Code Here

  public void methodCallTargetComingAndGoing() throws Exception {
    binLoader = new TestClassloaderWithRewriting();
    String t = "simple.BasicG";
    String target = "simple.BasicGTarget";
    TypeRegistry r = getTypeRegistry(t + "," + target);
    ReloadableType rtype = r.addType(t, loadBytesForClass(t));
    ReloadableType rtypeTarget = r.addType(target, loadBytesForClass(target));

    // At this point BasicG.run() is calling a method that does not yet
    // exist on BasicGTarget
    try {
      result = runUnguarded(rtype.getClazz(), "run");
      fail();
    } catch (InvocationTargetException ite) {
      ite.printStackTrace();
      assertCause(ite, "MissingMethodException");
    }

    // Now a version of BasicGTarget is loaded that does define the method
    rtypeTarget.loadNewVersion("2", retrieveRename(target, target + "2"));
    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("hw", result.returnValue);

    // Now load the original version so the method is gone again
    rtypeTarget.loadNewVersion("3", rtypeTarget.bytesInitial);// retrieveRename(target,
                                  // target +
                                  // "2"));
    try {
      result = runUnguarded(rtype.getClazz(), "run");
      fail();
View Full Code Here

    // GlobalConfiguration.logging = true;
    // GlobalConfiguration.isRuntimeLogging = true;

    TypeRegistry r = getTypeRegistry(t + "," + target);

    ReloadableType rtype = r.addType(t, loadBytesForClass(t));
    // ReloadableType rtypeTarget = r.addType(target,
    // loadBytesForClass(target));

    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals(new Integer(123), result.returnValue);

    rtype.loadNewVersion("2", retrieveRename(t, t + "2"));
    // rtypeTarget.loadNewVersion("2", retrieveRename(target, target +
    // "2"));
    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals(new Integer(456), result.returnValue);
    //
    // result = null;
    //
    // // The target method has been removed, should now fail to call it
View Full Code Here

  @Test
  public void closure1() throws Exception {
    String t = "simple.BasicWithClosure";
    String c = "simple.BasicWithClosure$_run_closure1";
    TypeRegistry r = getTypeRegistry(t + "," + c);
    ReloadableType ctype = r.addType(c, loadBytesForClass(c));

    ReloadableType rtype = r.addType(t, loadBytesForClass(t));
    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("Executing:hello!", result.stdout);

    rtype.loadNewVersion("2",
        retrieveRename(t, t + "2", "simple.BasicWithClosure2$_run_closure1:simple.BasicWithClosure$_run_closure1"));
    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("Executing:hello!", result.stdout);

    // Change what the closure does and reload it
    ctype.loadNewVersion("3", retrieveRename(c, "simple.BasicWithClosure3$_run_closure1"));
    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("Executing:goodbye!", result.stdout);

    // reload an unchanged version - should behave as before
    rtype.loadNewVersion("3",
        retrieveRename(t, t + "3", "simple.BasicWithClosure3$_run_closure1:simple.BasicWithClosure$_run_closure1"));
    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("Executing:goodbye!", result.stdout);
  }
View Full Code Here

  @Test
  public void closure2() throws Exception {
    String t = "simple.BasicWithClosureB";
    String c = "simple.BasicWithClosureB$_closure1";
    TypeRegistry r = getTypeRegistry(t + "," + c);
    ReloadableType ctype = r.addType(c, loadBytesForClass(c));
    ReloadableType rtype = r.addType(t, loadBytesForClass(t));
    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("Executing:hello!", result.stdout);

    rtype.loadNewVersion("2",
        retrieveRename(t, t + "2", "simple.BasicWithClosureB2$_closure1:simple.BasicWithClosureB$_closure1"));
    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("Executing:hello!", result.stdout);

    // code in closure changes
    ctype.loadNewVersion("3", retrieveRename(c, "simple.BasicWithClosureB3$_closure1"));
    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("Executing:goodbye!", result.stdout);
  }
View Full Code Here

  public void closure3() throws Exception {
    String t = "simple.BasicWithClosureC";
    String c = "simple.BasicWithClosureC$_run_closure1";
    String c2 = "simple.BasicWithClosureC$_run_closure1_closure2";
    TypeRegistry r = getTypeRegistry(t + "," + c + "," + c2);
    ReloadableType ctype = r.addType(c, loadBytesForClass(c));
    ReloadableType c2type = r.addType(c2, loadBytesForClass(c2));
    ReloadableType rtype = r.addType(t, loadBytesForClass(t));
    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("foo() running\nin closure", result.stdout);

    rtype.loadNewVersion(
        "2",
        retrieveRename(t, t + "2", "simple.BasicWithClosureC2$_run_closure1:simple.BasicWithClosureC$_run_closure1",
            "simple.BasicWithClosureC2:simple.BasicWithClosureC"));

    c2type.loadNewVersion(
        "2",
        retrieveRename(c2, "simple.BasicWithClosureC2$_run_closure1_closure2",
            "simple.BasicWithClosureC2$_run_closure1:simple.BasicWithClosureC$_run_closure1",
            "simple.BasicWithClosureC2:simple.BasicWithClosureC"));

    ctype.loadNewVersion(
        "2",
        retrieveRename(c, "simple.BasicWithClosureC2$_run_closure1",
            "simple.BasicWithClosureC2$_run_closure1_closure2:simple.BasicWithClosureC$_run_closure1_closure2",
            "simple.BasicWithClosureC2:simple.BasicWithClosureC"));

    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("in closure\nfoo() running", result.stdout);
    //
    // // code in closure changes
    // ctype.loadNewVersion("3", retrieveRename(c,
    // "simple.BasicWithClosureB3$_closure1"));
View Full Code Here

  public void closure4_oneReference() throws Exception {
    String t = "simple.BasicWithClosureD";
    String c = "simple.BasicWithClosureD$_run_closure1";
    String c2 = "simple.BasicWithClosureD$_run_closure1_closure2";
    TypeRegistry r = getTypeRegistry(t + "," + c + "," + c2);
    ReloadableType ctype = r.addType(c, loadBytesForClass(c));
    ReloadableType rtype = r.addType(t, loadBytesForClass(t));
    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("foo() running\nstring is abc\nowner is not null", result.stdout);

    rtype.loadNewVersion(
        "2",
        retrieveRename(t, t + "2", "simple.BasicWithClosureD2$_run_closure1:simple.BasicWithClosureD$_run_closure1",
            "simple.BasicWithClosureD2:simple.BasicWithClosureD"));

    ctype.loadNewVersion(
        "2",
        retrieveRename(c, "simple.BasicWithClosureD2$_run_closure1",
            "simple.BasicWithClosureD2$_run_closure1_closure2:simple.BasicWithClosureD$_run_closure1_closure2",
            "simple.BasicWithClosureD2:simple.BasicWithClosureD"));

    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("foo() running\nstring is def\nowner is not null", result.stdout);
  }
View Full Code Here

  @Test
  public void closure5_multipleReferences() throws Exception {
    String t = "simple.BasicWithClosureE";
    String c = "simple.BasicWithClosureE$_run_closure1";
    TypeRegistry r = getTypeRegistry(t + "," + c);
    ReloadableType ctype = r.addType(c, loadBytesForClass(c));
    ReloadableType rtype = r.addType(t, loadBytesForClass(t));
    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("foo() running\nstring is abc\nowner is not null", result.stdout);

    rtype.loadNewVersion(
        "2",
        retrieveRename(t, t + "2", "simple.BasicWithClosureE2$_run_closure1:simple.BasicWithClosureE$_run_closure1",
            "simple.BasicWithClosureE2:simple.BasicWithClosureE"));

    ctype.loadNewVersion("2",
        retrieveRename(c, "simple.BasicWithClosureE2$_run_closure1", "simple.BasicWithClosureE2:simple.BasicWithClosureE"));

    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("foo() running\nstring is abc def\nowner is not null", result.stdout);

    rtype.loadNewVersion(
        "3",
        retrieveRename(t, t + "3", "simple.BasicWithClosureE3$_run_closure1:simple.BasicWithClosureE$_run_closure1",
            "simple.BasicWithClosureE3:simple.BasicWithClosureE"));

    ctype.loadNewVersion("3",
        retrieveRename(c, "simple.BasicWithClosureE3$_run_closure1", "simple.BasicWithClosureE3:simple.BasicWithClosureE"));

    result = runUnguarded(rtype.getClazz(), "run");
    assertEquals("foo() running\nstring is xyz\nowner is not null", result.stdout);
  }
View Full Code Here

TOP

Related Classes of org.springsource.loaded.ReloadableType$MergedRewrite$ChainedAdapters

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.