Search in sources :

Example 76 with ProxyFactory

use of org.springframework.aop.framework.ProxyFactory in project spring-framework by spring-projects.

the class AnnotationTransactionInterceptorTests method withMultiMethodOverride.

@Test
public void withMultiMethodOverride() {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setTarget(new TestWithMultiMethodOverride());
    proxyFactory.addAdvice(this.ti);
    TestWithMultiMethodOverride proxy = (TestWithMultiMethodOverride) proxyFactory.getProxy();
    proxy.doSomething();
    assertGetTransactionAndCommitCount(1);
    proxy.doSomethingElse();
    assertGetTransactionAndCommitCount(2);
    proxy.doSomethingCompletelyElse();
    assertGetTransactionAndCommitCount(3);
    proxy.doSomething();
    assertGetTransactionAndCommitCount(4);
}
Also used : ProxyFactory(org.springframework.aop.framework.ProxyFactory) Test(org.junit.Test)

Example 77 with ProxyFactory

use of org.springframework.aop.framework.ProxyFactory in project spring-framework by spring-projects.

the class AnnotationTransactionInterceptorTests method withSingleMethodOverride.

@Test
public void withSingleMethodOverride() {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setTarget(new TestWithSingleMethodOverride());
    proxyFactory.addAdvice(this.ti);
    TestWithSingleMethodOverride proxy = (TestWithSingleMethodOverride) proxyFactory.getProxy();
    proxy.doSomething();
    assertGetTransactionAndCommitCount(1);
    proxy.doSomethingElse();
    assertGetTransactionAndCommitCount(2);
    proxy.doSomethingCompletelyElse();
    assertGetTransactionAndCommitCount(3);
    proxy.doSomething();
    assertGetTransactionAndCommitCount(4);
}
Also used : ProxyFactory(org.springframework.aop.framework.ProxyFactory) Test(org.junit.Test)

Example 78 with ProxyFactory

use of org.springframework.aop.framework.ProxyFactory in project spring-framework by spring-projects.

the class AnnotationTransactionInterceptorTests method crossClassInterfaceOnJdkProxy.

@Test
public void crossClassInterfaceOnJdkProxy() throws Exception {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setTarget(new OtherServiceImpl());
    proxyFactory.addInterface(OtherService.class);
    proxyFactory.addAdvice(this.ti);
    OtherService otherService = (OtherService) proxyFactory.getProxy();
    otherService.foo();
    assertGetTransactionAndCommitCount(1);
}
Also used : ProxyFactory(org.springframework.aop.framework.ProxyFactory) Test(org.junit.Test)

Aggregations

ProxyFactory (org.springframework.aop.framework.ProxyFactory)78 Test (org.junit.Test)48 ITestBean (org.springframework.tests.sample.beans.ITestBean)20 TestBean (org.springframework.tests.sample.beans.TestBean)20 TimeStamped (org.springframework.tests.TimeStamped)8 INestedTestBean (org.springframework.tests.sample.beans.INestedTestBean)8 NestedTestBean (org.springframework.tests.sample.beans.NestedTestBean)8 Method (java.lang.reflect.Method)6 HashMap (java.util.HashMap)5 MethodBeforeAdvice (org.springframework.aop.MethodBeforeAdvice)4 NopInterceptor (org.springframework.tests.aop.interceptor.NopInterceptor)4 Context (javax.naming.Context)3 TargetSource (org.springframework.aop.TargetSource)3 Advised (org.springframework.aop.framework.Advised)3 DefaultPointcutAdvisor (org.springframework.aop.support.DefaultPointcutAdvisor)3 IOException (java.io.IOException)2 EJBLocalObject (javax.ejb.EJBLocalObject)2 Message (javax.jms.Message)2 TextMessage (javax.jms.TextMessage)2 ObjectName (javax.management.ObjectName)2