Package jodd.proxetta.impl

Examples of jodd.proxetta.impl.WrapperProxetta


    assertEquals("SilverHero89W99.222None1000speeeeedXRAYnull", hero.name());
  }

  @Test
  public void testMethodAnnotationsWrapper() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
    WrapperProxetta proxetta = WrapperProxetta
        .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/")
        ;

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

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


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

  @Test
  public void testClassAnnotationsWrapper() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
    WrapperProxetta proxetta = WrapperProxetta
        .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/")
        ;

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

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

  @Test
  public void testClassWrapper() throws Exception {
    Calc calc = new CalcImpl();

    WrapperProxetta proxetta = WrapperProxetta.withAspects(new ProxyAspect(StatCounterAdvice.class, new ProxyPointcutSupport() {
      public boolean apply(MethodInfo methodInfo) {
        return !isRootMethod(methodInfo) && isPublic(methodInfo);
      }
    }));

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

    // wrapper over CLASS
    // resulting object has ALL interfaces
    // resulting object wraps ALL target class methods
    WrapperProxettaBuilder builder = proxetta.builder(calc.getClass());

    Class calc2Class = builder.define();

    Object object = calc2Class.newInstance();
View Full Code Here

  @Test
  public void testClassWrapperCastToInterface() throws Exception {
    Calc calc = new CalcImpl();

    WrapperProxetta proxetta = WrapperProxetta.withAspects(new ProxyAspect(StatCounterAdvice.class, new ProxyPointcutSupport() {
      public boolean apply(MethodInfo methodInfo) {
        return !isRootMethod(methodInfo) && isPublic(methodInfo);
      }
    }));

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

    // wrapper over CLASS casted to interface,
    // resulting object has ONE interface
    // ALL target methods are wrapped
    WrapperProxettaBuilder builder = proxetta.builder(calc.getClass(), Calc.class, ".CalcImpl2");

    Class<Calc> calc2Class = builder.define();

    Calc calc2 = calc2Class.newInstance();
View Full Code Here

  @Test
  public void testInterfaceWrapper() throws Exception {
    Calc calc = new CalcImpl();

    WrapperProxetta proxetta = WrapperProxetta.withAspects(new ProxyAspect(StatCounterAdvice.class, new ProxyPointcutSupport() {
      public boolean apply(MethodInfo methodInfo) {
        return isTopLevelMethod(methodInfo) && isPublic(methodInfo);
      }
    }));

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

    // wrapper over INTERFACE
    // resulting object has ONE interface
    // only interface methods are wrapped
    WrapperProxettaBuilder builder = proxetta.builder(Calc.class, ".CalcImpl3");

    Class<Calc> calc2Class = builder.define();

    Calc calc2 = calc2Class.newInstance();
View Full Code Here

  @Test
  public void testPartialMethodsWrapped() throws Exception {

    Calc calc = new CalcSuperImpl();

    WrapperProxetta proxetta = WrapperProxetta.withAspects(new ProxyAspect(StatCounterAdvice.class, new ProxyPointcutSupport() {
      public boolean apply(MethodInfo methodInfo) {
        return
            isPublic(methodInfo) &&
                (methodInfo.getMethodName().equals("hello") || methodInfo.getMethodName().equals("ola"));
      }
    }));

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

    WrapperProxettaBuilder builder = proxetta.builder(CalcSuper.class);

    Class<CalcSuper> calc2Class = builder.define();

    CalcSuper calc2 = calc2Class.newInstance();
View Full Code Here

  @Test
  public void testNoPointcutMatched() throws Exception {

    Calc calc = new CalcSuperImpl();

    WrapperProxetta proxetta = WrapperProxetta.withAspects(new ProxyAspect(StatCounterAdvice.class, new ProxyPointcutSupport() {
      public boolean apply(MethodInfo methodInfo) {
        return false;
      }
    }));

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

    WrapperProxettaBuilder builder = proxetta.builder(CalcSuper.class, ".CalcSuper22");

    Class<CalcSuper> calc2Class = builder.define();

    CalcSuper calc2 = calc2Class.newInstance();
View Full Code Here

TOP

Related Classes of jodd.proxetta.impl.WrapperProxetta

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.