Package org.springframework.aop.framework

Examples of org.springframework.aop.framework.ProxyFactory


   * creates a proxy that dispatches invocations to the currently bound {@link ProcessInstance}
   *
   * @return shareable {@link ProcessInstance}
   */
  private Object createSharedProcessInstance()   {
    ProxyFactory proxyFactoryBean = new ProxyFactory(ProcessInstance.class, new MethodInterceptor() {
      public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        String methodName = methodInvocation.getMethod().getName() ;

        logger.info("method invocation for " + methodName+ ".");
        if(methodName.equals("toString"))
          return "SharedProcessInstance";


        ProcessInstance processInstance = Context.getExecutionContext().getProcessInstance();
        Method method = methodInvocation.getMethod();
        Object[] args = methodInvocation.getArguments();
        Object result = method.invoke(processInstance, args);
        return result;
      }
    });
    return proxyFactoryBean.getProxy(this.classLoader);
  }
View Full Code Here


    Assert.notNull(this.processEngine, "the 'processEngine' must not be null!");
    this.runtimeService = this.processEngine.getRuntimeService();
  }

  private Object createDirtyCheckingProxy(final String name, final Object scopedObject) throws Throwable {
    ProxyFactory proxyFactoryBean = new ProxyFactory(scopedObject);
    proxyFactoryBean.setProxyTargetClass(this.proxyTargetClass);
    proxyFactoryBean.addAdvice(new MethodInterceptor() {
      public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        Object result = methodInvocation.proceed();
        persistVariable(name, scopedObject);
        return result;
      }
    });
    return proxyFactoryBean.getProxy(this.classLoader);
  }
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

public class HelloWorldWithPointcut {

    public static void main(String[] args) {

        // get proxy
        ProxyFactory pf = new ProxyFactory();
        pf.addAdvisor(new DefaultPointcutAdvisor(new SimpleBeforeAdvice()));
       
        pf.setTarget(new MessageWriter());
        MessageWriter proxy1 = (MessageWriter)pf.getProxy();
       
        pf.setTarget(new MessageWriter());
        MessageWriter proxy2 = (MessageWriter)pf.getProxy();
        proxy2.writeMessage();
       
        pf.setTarget(new ErrorBean());
        ErrorBean proxy3 = (ErrorBean)pf.getProxy();
        proxy3.hashCode();
       
    }
View Full Code Here

public class SimpleThrowsAdvice implements ThrowsAdvice {

    public static void main(String[] args) throws Exception {
        ErrorBean errorBean = new ErrorBean();

        ProxyFactory pf = new ProxyFactory();
        pf.setTarget(errorBean);
        pf.addAdvice(new SimpleThrowsAdvice());

        ErrorBean proxy = (ErrorBean) pf.getProxy();

        try {
            proxy.errorProneMethod();
        } catch (Exception ignored) {
View Full Code Here

    public static void main(String[] args) {
        MessageWriter target = new MessageWriter();

        // create the proxy
        ProxyFactory pf = new ProxyFactory();

        pf.addAdvice(new SimpleAfterReturningAdvice());
        pf.setTarget(target);

        MessageWriter proxy = (MessageWriter) pf.getProxy();

        // write the messages
        proxy.writeMessage();
    }
View Full Code Here

    public static void main(String[] args) {
        MessageWriter target = new MessageWriter();
       
        // create the proxy
        ProxyFactory pf = new ProxyFactory();

        pf.addAdvice(new MessageDecorator());
        pf.setTarget(target);


        MessageWriter proxy = (MessageWriter) pf.getProxy();
       
        // write the messages
        target.writeMessage();
        System.out.println("");
        proxy.writeMessage();
View Full Code Here

        Pointcut pc = new SimpleStaticPointcut();
        Advice advice = new SimpleAdvice();
        Advisor advisor = new DefaultPointcutAdvisor(pc, advice);
       
        // create BeanOne proxy
        ProxyFactory pf = new ProxyFactory();
        pf.addAdvisor(advisor);
        pf.setTarget(one);
        proxyOne = (BeanOne)pf.getProxy();
       
        // create BeanTwo proxy
        pf = new ProxyFactory();
        pf.addAdvisor(advisor);
        pf.setTarget(two);
        proxyTwo = (BeanTwo)pf.getProxy();
       
        proxyOne.foo();
        proxyTwo.foo();
       
        proxyOne.bar();
View Full Code Here

    public static void main(String[] args) {
        MessageWriter target = new MessageWriter();

        // create the proxy
        ProxyFactory pf = new ProxyFactory();

        pf.addAdvice(new SimpleBeforeAdvice());
        pf.setTarget(target);

        MessageWriter proxy = (MessageWriter) pf.getProxy();

        // write the messages
        proxy.writeMessage();
    }
View Full Code Here

    }
   
    private static WorkerBean getWorkerBean() {
        WorkerBean target = new WorkerBean();
       
        ProxyFactory factory = new ProxyFactory();
        factory.setTarget(target);
        factory.addAdvice(new ProfilingInterceptor());
       
        return (WorkerBean)factory.getProxy();
    }
View Full Code Here

TOP

Related Classes of org.springframework.aop.framework.ProxyFactory

Copyright © 2018 www.massapicom. 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.