Package org.springframework.aop.framework

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


        }

        // Add an introduction that implements only the methods on ScopedObject.
        // Not sure if this is useful...
        ScopedObject scopedObject = new DefaultScopedObject(cbf, 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.
        // Not sure if this is needed....
        pf.addInterface(AopInfrastructureBean.class);
View Full Code Here


    public Object getObject() throws Exception {
        if (this.embeddedServlet == null) {
            throw new FactoryBeanNotInitializedException("There might be a circular dependency inside the servlet connections.");
        }
        ProxyFactory proxyFactory = new ProxyFactory(this.embeddedServlet);
        proxyFactory.addAdvice(new ServiceInterceptor());
        if (this.mountPath != null) {
            proxyFactory.addAdvisor(new MountableMixinAdvisor());
        }
        return proxyFactory.getProxy();
    }
View Full Code Here

                    Class<? extends MethodInterceptor> interceptorClass = interceptor.interceptor();
                    //This is the field we want to enhance
                    Object fieldInstance = field.get(testInstance);
                    ProxyFactory factory = new ProxyFactory();
                    factory.setTarget(fieldInstance);
                    factory.addAdvice(interceptorClass.newInstance());
                    Object proxy = factory.getProxy();
                    try{
                        field.set(testInstance,proxy);
                    }catch(Exception e){
                        Assert.fail("Failed while trying to instrument the class for Intercept annotation with exception : " + e.getStackTrace());
View Full Code Here

                    Class<? extends MethodInterceptor> interceptorClass = interceptor.interceptor();
                    //This is the field we want to enhance
                    Object fieldInstance = field.get(testInstance);
                    ProxyFactory factory = new ProxyFactory();
                    factory.setTarget(fieldInstance);
                    factory.addAdvice(interceptorClass.newInstance());
                    Object proxy = factory.getProxy();
                    try{
                        field.set(testInstance,proxy);
                    }catch(Exception e){
                        Assert.fail("Failed while trying to instrument the class for Intercept annotation with exception : " + e.getStackTrace());
View Full Code Here

        }

        DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts);
        introduction.suppressInterface(TargetSource.class);
        if (ts instanceof ReplaceAndRefreshableScriptTargetSource) {
            proxyFactory.addAdvice(new ScriptReplaceClassInfoMethodInterceptor());
        }
        proxyFactory.addAdvice(introduction);
        return proxyFactory.getProxy(classLoader);
    }
View Full Code Here

        DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts);
        introduction.suppressInterface(TargetSource.class);
        if (ts instanceof ReplaceAndRefreshableScriptTargetSource) {
            proxyFactory.addAdvice(new ScriptReplaceClassInfoMethodInterceptor());
        }
        proxyFactory.addAdvice(introduction);
        return proxyFactory.getProxy(classLoader);
    }

    /**
     * Destroy the inner bean factory (used for scripts) on shutdown.
View Full Code Here

        if (type.isInterface()) {
            ProxyFactory factory = new ProxyFactory(EmptyTargetSource.INSTANCE);
            factory.addInterface(type);
            factory.addInterface(MethodInvocationInfo.class);
            factory.addAdvice(interceptor);
            return (T) factory.getProxy();
        } else {
            Enhancer enhancer = new Enhancer();
            enhancer.setSuperclass(type);
            enhancer.setInterfaces(new Class<?>[]{MethodInvocationInfo.class});
View Full Code Here

  @Test
  public void testeHardCoded() {
    Mensagem target = new Mensagem();
    ProxyFactory pf = new ProxyFactory();
    pf.addAdvice(new MensagemInterceptador());
    pf.setTarget(target);
    Mensagem proxy = (Mensagem) pf.getProxy();
    target.imprimirMensagem();
    System.out.println("");
    proxy.imprimirMensagem();
View Full Code Here

  private static <T> T getVerifyingProxy(T target, Class<?> expectedType) {

    ProxyFactory factory = new ProxyFactory();
    factory.setInterfaces(target.getClass().getInterfaces());
    factory.setTarget(target);
    factory.addAdvice(new VerifyingMethodInterceptor(expectedType));

    return (T) factory.getProxy();
  }

  /**
 
View Full Code Here

    ProxyFactory factory = new ProxyFactory();
    factory.setTarget(source);
    factory.setOpaque(true);
    factory.setInterfaces(projectionType, TargetClassAware.class);

    factory.addAdvice(new TargetClassAwareMethodInterceptor(source.getClass()));
    factory.addAdvice(getMethodInterceptor(source, projectionType));

    return (T) factory.getProxy();
  }
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.