Search in sources :

Example 1 with HeroProxyAdvice2

use of jodd.proxetta.data.HeroProxyAdvice2 in project jodd by oblac.

the class AnnTest method testClassAnnotationsProxy.

@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);
        }
    }));
    ProxettaBuilder proxettaBuilder = proxetta.builder();
    proxettaBuilder.setTarget(Hero.class);
    proxetta.setVariableClassName(true);
    Hero hero = (Hero) proxettaBuilder.newInstance();
    assertEquals("SilverHero89W99.222None1000speeeeedXRAYnull", hero.name());
}
Also used : ProxyProxetta(jodd.proxetta.impl.ProxyProxetta) WrapperProxettaBuilder(jodd.proxetta.impl.WrapperProxettaBuilder) Hero(jodd.proxetta.data.Hero) AllRealMethodsPointcut(jodd.proxetta.pointcuts.AllRealMethodsPointcut) HeroProxyAdvice2(jodd.proxetta.data.HeroProxyAdvice2) Test(org.junit.Test)

Example 2 with HeroProxyAdvice2

use of jodd.proxetta.data.HeroProxyAdvice2 in project jodd by oblac.

the class AnnTest method testClassAnnotationsWrapper.

@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);
        }
    }));
    WrapperProxettaBuilder proxettaBuilder = proxetta.builder();
    proxettaBuilder.setTarget(Hero.class);
    proxetta.setVariableClassName(true);
    Object hero = proxettaBuilder.newInstance();
    assertEquals("SilverHero89W99.222None1000speeeeedXRAYnull", ReflectUtil.invoke(hero, "name"));
}
Also used : WrapperProxettaBuilder(jodd.proxetta.impl.WrapperProxettaBuilder) WrapperProxetta(jodd.proxetta.impl.WrapperProxetta) AllRealMethodsPointcut(jodd.proxetta.pointcuts.AllRealMethodsPointcut) HeroProxyAdvice2(jodd.proxetta.data.HeroProxyAdvice2) Test(org.junit.Test)

Aggregations

HeroProxyAdvice2 (jodd.proxetta.data.HeroProxyAdvice2)2 WrapperProxettaBuilder (jodd.proxetta.impl.WrapperProxettaBuilder)2 AllRealMethodsPointcut (jodd.proxetta.pointcuts.AllRealMethodsPointcut)2 Test (org.junit.Test)2 Hero (jodd.proxetta.data.Hero)1 ProxyProxetta (jodd.proxetta.impl.ProxyProxetta)1 WrapperProxetta (jodd.proxetta.impl.WrapperProxetta)1