Package org.springframework.aop.framework

Examples of org.springframework.aop.framework.ProxyFactory.addAdvice()


        SecurityAdvice advice = new SecurityAdvice();
       
        // get the proxy
        ProxyFactory factory = new ProxyFactory();
        factory.setTarget(target);
        factory.addAdvice(advice);
        SecureBean proxy = (SecureBean)factory.getProxy();
       
        return proxy;
       
    }
View Full Code Here


       
        KeyGenerator target = new KeyGenerator();
       
        ProxyFactory factory = new ProxyFactory();
        factory.setTarget(target);
        factory.addAdvice(new WeakKeyCheckAdvice());
       
        return (KeyGenerator)factory.getProxy();
    }
}
View Full Code Here

      pf.setInterfaces(ClassUtils.getAllInterfacesForClass(beanType, cbf.getBeanClassLoader()));
    }

    // Add an introduction that implements only the methods on ScopedObject.
    ScopedObject scopedObject = new DefaultScopedObject(cbf, this.scopedTargetSource.getTargetBeanName());
    pf.addAdvice(new DelegatingIntroductionInterceptor(scopedObject));

    // Add the AopInfrastructureBean marker to indicate that the scoped proxy
    // itself is not subject to auto-proxying! Only its target bean is.
    pf.addInterface(AopInfrastructureBean.class);
View Full Code Here

    checkServiceInterface();
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.addInterface(getServiceInterface());
    if (this.registerTraceInterceptor != null ?
        this.registerTraceInterceptor.booleanValue() : this.interceptors == null) {
      proxyFactory.addAdvice(new RemoteInvocationTraceInterceptor(getExporterName()));
    }
    if (this.interceptors != null) {
      AdvisorAdapterRegistry adapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
      for (int i = 0; i < this.interceptors.length; i++) {
        proxyFactory.addAdvisor(adapterRegistry.wrap(this.interceptors[i]));
View Full Code Here


  public void testClassLevelOnly() {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setTarget(new TestClassLevelOnly());
    proxyFactory.addAdvice(this.ti);

    TestClassLevelOnly proxy = (TestClassLevelOnly) proxyFactory.getProxy();

    proxy.doSomething();
    assertGetTransactionAndCommitCount(1);
View Full Code Here

  }

  public void testWithSingleMethodOverride() {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setTarget(new TestWithSingleMethodOverride());
    proxyFactory.addAdvice(this.ti);

    TestWithSingleMethodOverride proxy = (TestWithSingleMethodOverride) proxyFactory.getProxy();

    proxy.doSomething();
    assertGetTransactionAndCommitCount(1);
View Full Code Here

  }

  public void testWithSingleMethodOverrideInverted() {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setTarget(new TestWithSingleMethodOverrideInverted());
    proxyFactory.addAdvice(this.ti);

    TestWithSingleMethodOverrideInverted proxy = (TestWithSingleMethodOverrideInverted) proxyFactory.getProxy();

    proxy.doSomething();
    assertGetTransactionAndCommitCount(1);
View Full Code Here

  }

  public void testWithMultiMethodOverride() {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setTarget(new TestWithMultiMethodOverride());
    proxyFactory.addAdvice(this.ti);

    TestWithMultiMethodOverride proxy = (TestWithMultiMethodOverride) proxyFactory.getProxy();

    proxy.doSomething();
    assertGetTransactionAndCommitCount(1);
View Full Code Here


  public void testWithRollback() {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setTarget(new TestWithRollback());
    proxyFactory.addAdvice(this.ti);

    TestWithRollback proxy = (TestWithRollback) proxyFactory.getProxy();

    try {
      proxy.doSomethingErroneous();
View Full Code Here

  public void testWithInterface() {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setTarget(new TestWithInterfaceImpl());
    proxyFactory.addInterface(TestWithInterface.class);
    proxyFactory.addAdvice(this.ti);

    TestWithInterface proxy = (TestWithInterface) proxyFactory.getProxy();

    proxy.doSomething();
    assertGetTransactionAndCommitCount(1);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.