Search in sources :

Example 11 with ProxyProxetta

use of jodd.proxetta.impl.ProxyProxetta in project jodd by oblac.

the class SubclassTest method testInnerOverride.

@Test
public void testInnerOverride() {
    ProxyProxetta proxyProxetta = ProxyProxetta.withAspects(new ProxyAspect(FooProxyAdvice.class, new AllMethodsPointcut()));
    ProxyProxettaBuilder builder = proxyProxetta.builder();
    builder.setTarget(Two.class);
    builder.setTargetProxyClassName("foo.");
    Two two = (Two) builder.newInstance();
    assertNotNull(two);
    assertEquals("foo.Two$$Proxetta", two.getClass().getName());
}
Also used : ProxyProxetta(jodd.proxetta.impl.ProxyProxetta) AllMethodsPointcut(jodd.proxetta.pointcuts.AllMethodsPointcut) ProxyProxettaBuilder(jodd.proxetta.impl.ProxyProxettaBuilder) Test(org.junit.Test)

Example 12 with ProxyProxetta

use of jodd.proxetta.impl.ProxyProxetta in project jodd by oblac.

the class SubclassTest method test1.

@Test
public void test1() {
    ProxyAspect a1 = new ProxyAspect(FooProxyAdvice.class, new ProxyPointcut() {

        public boolean apply(MethodInfo methodInfo) {
            return true;
        }
    });
    /*
		byte[] b = Proxetta.withAspects(a1).createProxy(Foo.class);
		try {
			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);
    Method[] methods = fooProxyClass.getMethods();
    assertEquals(12, methods.length);
    try {
        fooProxyClass.getMethod("m1");
    } catch (NoSuchMethodException nsmex) {
        fail(nsmex.toString());
    }
    methods = fooProxyClass.getDeclaredMethods();
    assertEquals(15, methods.length);
    try {
        fooProxyClass.getDeclaredMethod("m2");
    } catch (NoSuchMethodException nsmex) {
        fail(nsmex.toString());
    }
}
Also used : ProxyProxetta(jodd.proxetta.impl.ProxyProxetta) ProxyProxettaBuilder(jodd.proxetta.impl.ProxyProxettaBuilder) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 13 with ProxyProxetta

use of jodd.proxetta.impl.ProxyProxetta in project jodd by oblac.

the class MixedScope343Test method setupPetiteContainer.

@Before
public void setupPetiteContainer() {
    PetiteConfig petiteConfig = PetiteHelper.createPetiteConfig();
    ProxyProxetta proxyProxetta = PetiteHelper.createProxyProxetta();
    petiteContainer = new ProxettaAwarePetiteContainer(proxyProxetta, petiteConfig);
    AutomagicPetiteConfigurator petiteConfigurator = new AutomagicPetiteConfigurator();
    petiteConfigurator.setIncludedEntries(this.getClass().getPackage().getName() + ".*");
    petiteConfigurator.configure(petiteContainer);
}
Also used : ProxyProxetta(jodd.proxetta.impl.ProxyProxetta) ProxettaAwarePetiteContainer(jodd.petite.proxetta.ProxettaAwarePetiteContainer) PetiteConfig(jodd.petite.PetiteConfig) AutomagicPetiteConfigurator(jodd.petite.config.AutomagicPetiteConfigurator) Before(org.junit.Before)

Example 14 with ProxyProxetta

use of jodd.proxetta.impl.ProxyProxetta in project jodd by oblac.

the class PetiteHelper method createProxyProxetta.

public static ProxyProxetta createProxyProxetta() {
    ProxyPointcut pointcut_logged = new MethodAnnotationPointcut(Logged.class);
    ProxyAspect aspect_logged = new ProxyAspect(LogProxyAdvice.class, pointcut_logged);
    ProxyProxetta proxetta = ProxyProxetta.withAspects(aspect_logged);
    return proxetta;
}
Also used : ProxyProxetta(jodd.proxetta.impl.ProxyProxetta) MethodAnnotationPointcut(jodd.proxetta.pointcuts.MethodAnnotationPointcut) ProxyAspect(jodd.proxetta.ProxyAspect) ProxyPointcut(jodd.proxetta.ProxyPointcut)

Example 15 with ProxyProxetta

use of jodd.proxetta.impl.ProxyProxetta in project jodd by oblac.

the class WireBeansWithProxettaTest method setupPetiteContainer.

@Before
public void setupPetiteContainer() {
    PetiteConfig petiteConfig = PetiteHelper.createPetiteConfig();
    ProxyProxetta proxyProxetta = PetiteHelper.createProxyProxetta();
    petiteContainer = new PetiteProxettaContainer(proxyProxetta, petiteConfig);
    //AutomagicPetiteConfigurator petiteConfigurator = new AutomagicPetiteConfigurator();
    //petiteConfigurator.configure(petiteContainer);
    petiteContainer.registerPetiteBean(Bean1.class);
    petiteContainer.registerPetiteBean(Bean2.class);
}
Also used : ProxyProxetta(jodd.proxetta.impl.ProxyProxetta) PetiteConfig(jodd.petite.PetiteConfig) PetiteProxettaContainer(jodd.proxetta.petite.data.PetiteProxettaContainer) Before(org.junit.Before)

Aggregations

ProxyProxetta (jodd.proxetta.impl.ProxyProxetta)19 Test (org.junit.Test)15 ProxyProxettaBuilder (jodd.proxetta.impl.ProxyProxettaBuilder)10 AllMethodsPointcut (jodd.proxetta.pointcuts.AllMethodsPointcut)5 ProxyAspect (jodd.proxetta.ProxyAspect)4 Field (java.lang.reflect.Field)3 AllRealMethodsPointcut (jodd.proxetta.pointcuts.AllRealMethodsPointcut)3 List (java.util.List)2 PetiteConfig (jodd.petite.PetiteConfig)2 ProxettaAwarePetiteContainer (jodd.petite.proxetta.ProxettaAwarePetiteContainer)2 Foo (jodd.proxetta.data.Foo)2 Hero (jodd.proxetta.data.Hero)2 Retro (jodd.proxetta.data.Retro)2 WrapperProxettaBuilder (jodd.proxetta.impl.WrapperProxettaBuilder)2 AllTopMethodsPointcut (jodd.proxetta.pointcuts.AllTopMethodsPointcut)2 Before (org.junit.Before)2 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1