Package jodd.proxetta.impl

Examples of jodd.proxetta.impl.ProxyProxetta


    Class proxyClass = proxyClasses.get(beanType);

    if (proxyClass == null) {
      // create proxy class only once

      ProxyProxetta proxetta = ProxyProxetta.withAspects(aspect);

      proxetta.setClassNameSuffix("$ScopedProxy");
      proxetta.setVariableClassName(true);

      ProxyProxettaBuilder builder = proxetta.builder(beanType);

      proxyClass = builder.define();

      proxyClasses.put(beanType, proxyClass);
    }
View Full Code Here


    Methref<? extends Oink> m = Methref.on(Oink.class);
    m.to().woink();
    assertEquals("woink", m.ref());

    ProxyAspect a1 = new ProxyAspect(DummyAdvice.class, new AllTopMethodsPointcut());
    ProxyProxetta pp = ProxyProxetta.withAspects(a1);
    Oink oink = (Oink) pp.builder(Oink.class).newInstance();

    assertFalse(oink.getClass().equals(Oink.class));

    m = Methref.on(oink.getClass());
    m.to().woink();
View Full Code Here

public class AnnTest {

  @Test
  public void testMethodAnnotationsProxy() {
    ProxyProxetta proxetta = ProxyProxetta
        .withAspects(
          new ProxyAspect(HeroProxyAdvice.class,
              new AllRealMethodsPointcut() {
                @Override
                public boolean apply(MethodInfo methodInfo) {
                  if (!methodInfo.isTopLevelMethod()) {
                    return false;
                  }
                  return super.apply(methodInfo);
                }
              }))
        //.setDebugFolder("/Users/igor/")
        ;

    ProxettaBuilder proxettaBuilder = proxetta.builder();
    proxettaBuilder.setTarget(Hero.class);
    proxetta.setVariableClassName(true);
    Hero hero = (Hero) proxettaBuilder.newInstance();

    assertEquals("BatmanHero37W88.3CatWoman99speeeeedXRAYnull", hero.name());
  }
View Full Code Here

    assertEquals("BatmanHero37W88.3CatWoman99speeeeedXRAYnull", hero.name());
  }

  @Test
  public void testClassAnnotationsProxy() {
    ProxyProxetta proxetta = ProxyProxetta
        .withAspects(
          new ProxyAspect(HeroProxyAdvice2.class,
              new AllRealMethodsPointcut() {
                @Override
                public boolean apply(MethodInfo methodInfo) {
                  if (!methodInfo.isTopLevelMethod()) {
                    return false;
                  }
                  return super.apply(methodInfo);
                }
              }))
        //.setDebugFolder("/Users/igor/")
        ;

    ProxettaBuilder proxettaBuilder = proxetta.builder();
    proxettaBuilder.setTarget(Hero.class);
    proxetta.setVariableClassName(true);
    Hero hero = (Hero) proxettaBuilder.newInstance();

    assertEquals("SilverHero89W99.222None1000speeeeedXRAYnull", hero.name());
  }
View Full Code Here

public class AdviceWithMethodTest {

  @Test
  public void testCollector() throws NoSuchFieldException, IllegalAccessException {
    ProxyProxetta proxetta = ProxyProxetta.withAspects(
        new ProxyAspect(CollectorAdvice.class, new AllTopMethodsPointcut())
    );

//    proxetta.setDebugFolder("d:\\");

    Foo foo = (Foo) proxetta.builder(Foo.class).newInstance();

    Field field = foo.getClass().getDeclaredField("$__methods$0");

    field.setAccessible(true);
View Full Code Here

public class ReturnTest {

  @Test
  public void testWrapperWithProxyReturns() throws Exception {
    ProxyProxetta proxetta = ProxyProxetta.withAspects(
        new ProxyAspect(ReflectionReplacementAdvice.class, new AllMethodsPointcut()));

    ProxyProxettaBuilder builder = proxetta.builder(Retro.class, ".Retro2");

//    proxetta.setDebugFolder("d:\\");

    Class proxyClass = builder.define();
View Full Code Here

    retro.method10();
  }

  @Test
  public void testNullReturns() throws Exception {
    ProxyProxetta proxetta = ProxyProxetta.withAspects(
        new ProxyAspect(ReturnNullAdvice.class, new AllMethodsPointcut()));

    ProxyProxettaBuilder builder = proxetta.builder(Retro.class, ".Retro3");

//    proxetta.setDebugFolder("d:\\");

    Class proxyClass = builder.define();
View Full Code Here

            }
            return false;
          }
    });

    ProxyProxetta proxyProxetta = ProxyProxetta.withAspects(proxyAspect);
    proxyProxetta.setClassNameSuffix("$$$Proxetta888");
    ProxyProxettaBuilder pb = proxyProxetta.builder();
    pb.setTarget(Foo.class);
    Foo foo = (Foo) pb.newInstance();

    assertNotNull(foo);
View Full Code Here

      FileUtil.writeBytes("d:\\Foo.class", b);
    } catch (IOException e) {
      e.printStackTrace();
    }
*/
    ProxyProxetta proxyProxetta = ProxyProxetta.withAspects(a1);
    proxyProxetta.setClassNameSuffix("$$$Proxetta");
    ProxyProxettaBuilder pb = proxyProxetta.builder();
    pb.setTarget(Foo.class);
    Foo foo = (Foo) pb.newInstance();

    Class fooProxyClass = foo.getClass();
    assertNotNull(fooProxyClass);
View Full Code Here

  }

  @Test
  public void testProxyClassNames() {
    ProxyProxetta proxyProxetta = ProxyProxetta.withAspects(new ProxyAspect(FooProxyAdvice.class, new AllMethodsPointcut()));
    proxyProxetta.setVariableClassName(true);

    ProxyProxettaBuilder builder = proxyProxetta.builder();
    builder.setTarget(Foo.class);
    Foo foo = (Foo) builder.newInstance();

    assertNotNull(foo);
    assertEquals(Foo.class.getName() + "$$Proxetta", StringUtil.substring(foo.getClass().getName(), 0, -1));

    builder = proxyProxetta.builder();
    builder.setTarget(Foo.class);
    foo = (Foo) builder.newInstance();

    assertNotNull(foo);
    assertEquals(Foo.class.getName() + "$$Proxetta", StringUtil.substring(foo.getClass().getName(), 0, -1));

    proxyProxetta.setClassNameSuffix("$$Ppp");
    builder = proxyProxetta.builder();
    builder.setTarget(Foo.class);
    foo = (Foo) builder.newInstance();

    assertNotNull(foo);
    assertEquals(Foo.class.getName() + "$$Ppp", StringUtil.substring(foo.getClass().getName(), 0, -1));

    proxyProxetta.setClassNameSuffix("$$Proxetta");
    proxyProxetta.setVariableClassName(false);
    builder = proxyProxetta.builder(Foo.class, ".Too");
    foo = (Foo) builder.newInstance();

    assertNotNull(foo);
    assertEquals(Foo.class.getPackage().getName() + ".Too$$Proxetta", foo.getClass().getName());

    builder = proxyProxetta.builder();
    builder.setTarget(Foo.class);
    builder.setTargetProxyClassName("foo.");
    foo = (Foo) builder.newInstance();

    assertNotNull(foo);
    assertEquals("foo.Foo$$Proxetta", foo.getClass().getName());

    proxyProxetta.setClassNameSuffix(null);
    builder = proxyProxetta.builder();
    builder.setTargetProxyClassName("foo.Fff");
    builder.setTarget(Foo.class);
    foo = (Foo) builder.newInstance();

    assertNotNull(foo);
View Full Code Here

TOP

Related Classes of jodd.proxetta.impl.ProxyProxetta

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.