Example usage for org.springframework.aop.framework ProxyFactory ProxyFactory

List of usage examples for org.springframework.aop.framework ProxyFactory ProxyFactory

Introduction

In this page you can find the example usage for org.springframework.aop.framework ProxyFactory ProxyFactory.

Prototype

public ProxyFactory(Class<?>... proxyInterfaces) 

Source Link

Document

Create a new ProxyFactory.

Usage

From source file:org.jdal.remoting.caucho.HessianProxyFactoryBean.java

@Override
public void afterPropertiesSet() {
    super.afterPropertiesSet();
    ProxyFactory pf = new ProxyFactory(new Class[] { getServiceInterface(), RemoteClient.class });
    pf.addAdvisor(new RemoteClientAdvisor(this));
    pf.addAdvice(this);
    this.serviceProxy = pf.getProxy(getBeanClassLoader());
}

From source file:org.jdal.remoting.caucho.BurlapProxyFactoryBean.java

@Override
public void afterPropertiesSet() {
    super.afterPropertiesSet();
    ProxyFactory pf = new ProxyFactory(new Class[] { getServiceInterface(), RemoteClient.class });
    pf.addAdvisor(new RemoteClientAdvisor(getRemoteReference()));
    pf.addAdvice(this);
    this.serviceProxy = pf.getProxy(getBeanClassLoader());
}

From source file:com.github.jasonruckman.sidney.generator.BeanBuilder.java

public static <R> BeanBuilder<R> stub(final Class<R> type) {
    InstanceFactory<R> fact = new DefaultInstanceFactory<>(type);
    R stub = fact.newInstance();//  w  ww  .ja va 2  s . c o m
    ProxyFactory factory = new ProxyFactory(stub);
    final Stack<Method> m = new Stack<>();
    factory.addAdvice(new MethodInterceptor() {
        @Override
        public Object invoke(MethodInvocation methodInvocation) throws Throwable {
            PropertyDescriptor descriptor = BeanUtils.findPropertyForMethod(methodInvocation.getMethod());
            if (descriptor == null) {
                throw new IllegalStateException(String.format("Method %s is not a getter or setter",
                        methodInvocation.getMethod().getName()));
            }
            m.push(methodInvocation.getMethod());
            return defaultReturnObjects.get(methodInvocation.getMethod().getReturnType());
        }
    });
    return new BeanBuilder<>((R) factory.getProxy(), fact, m);
}

From source file:org.mule.providers.soap.axis.wsdl.wsrf.util.AdviceAdderHelper.java

/**
 * addAdvisors to ProxyfactoryBean given using reflection to find Advices class
 * end with "Advice" suffix. All advisors are mapped on "extend*" pattern string
 * method refer to Target bean.//  w  w  w.  j av a  2s  . c  o  m
 * 
 * @param targetImpl Target Object
 * @return new Proxy
 */
public static IExtendCall addAdvisorsTo(IExtendCall targetImpl) {
    ProxyFactory factory = new ProxyFactory(targetImpl);

    List l = getListAdvisorClass();
    ListIterator li = l.listIterator();
    Advisor advisor = null;

    if (order.size() == 0) {

        while (li.hasNext()) {
            advisor = (Advisor) li.next();
            order.add(advisor);
        }
    }
    Iterator it = order.iterator();

    while (it.hasNext()) {
        advisor = (Advisor) it.next();
        factory.addAdvisor(countAdvice, advisor);
        Logger.getLogger(factory.getClass()).log(Level.DEBUG, factory.getClass().getName() + " : added "
                + advisor.getAdvice().getClass().getName() + " at index position " + countAdvice);
        countAdvice++;
    }

    countAdvice = 0;
    return (IExtendCall) factory.getProxy();
}

From source file:tnt.common.monitoring.GuardedByAnnotationBeanPostProcessor.java

protected Object createProxy(Object target, List<Method> methods) {
    ProxyFactory proxyFactory = new ProxyFactory(target);
    proxyFactory.addAdvice(new HystrixInterceptor());
    return proxyFactory.getProxy();
}

From source file:org.jdal.remoting.httpinvoker.HttpInvokerProxyFactoryBean.java

@Override
public void afterPropertiesSet() {
    super.afterPropertiesSet();
    if (getServiceInterface() == null) {
        throw new IllegalArgumentException("Property 'serviceInterface' is required");
    }/*from   www  .  j a v a 2 s.  c om*/
    ProxyFactory pf = new ProxyFactory(new Class[] { getServiceInterface(), RemoteClient.class });
    pf.addAdvisor(new RemoteClientAdvisor(getRemoteReference()));
    pf.addAdvice(this);

    this.serviceProxy = pf.getProxy(getBeanClassLoader());
}

From source file:org.ext4spring.parameter.ParameterBeanFactory.java

@Override
public Object getObject() throws Exception {
    ProxyFactory proxyFactory = new ProxyFactory(parameterBean);
    proxyFactory.addAdvice(parameterAdvice);
    proxyFactory.setProxyTargetClass(!parameterBean.getClass().isInterface());
    return proxyFactory.getProxy();
}

From source file:org.arrow.data.neo4j.postprocess.infrastructure.GraphRepositoryBeanPostProcessor.java

/**
 * {@inheritDoc}/*w w  w  . j  a v  a 2  s .co  m*/
 */
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) {

    if (bean instanceof GraphRepository<?>) {
        ProxyFactory factory = new ProxyFactory(bean);
        factory.addAdvice(new QueryPostProcessorAdvice());
        return factory.getProxy();
    }
    return bean;
}

From source file:org.jdal.remoting.rmi.RmiNativeRemoteReference.java

/**
 * {@inheritDoc}//from  w  w  w .  j  ava 2 s  .c o m
 */
@SuppressWarnings("unchecked")
public RemoteClient createRemoteClient() {
    ProxyFactory pf = null;
    if (getServiceInterface().isAssignableFrom(remoteService.getClass())) {
        pf = new ProxyFactory(remoteService);
    } else {
        pf = new ProxyFactory(getServiceInterface(),
                new RmiServiceInterceptor((RmiInvocationHandler) remoteService));
    }

    pf.addInterface(RemoteClient.class);
    pf.addAdvisor(new RemoteClientAdvisor(this));

    return (RemoteClient) pf.getProxy();
}

From source file:org.jdal.remoting.rmi.RmiProxyFactoryBean.java

/**
 * {@inheritDoc}/*from   w  ww .ja  v a2 s.  c  om*/
 */
@Override
public void afterPropertiesSet() {
    super.afterPropertiesSet();

    if (getServiceInterface() == null) {
        throw new IllegalArgumentException("Property 'serviceInterface' is required");
    }
    ProxyFactory pf = new ProxyFactory(new Class[] { getServiceInterface(), RemoteClient.class });
    pf.addAdvisor(new RemoteClientAdvisor(getRemoteReference()));
    pf.addAdvice(this);
    serviceProxy = pf.getProxy();
}