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<?> proxyInterface, TargetSource targetSource) 

Source Link

Document

Create a ProxyFactory for the specified TargetSource , making the proxy implement the specified interface.

Usage

From source file:org.openmrs.module.jmx.util.MBeanProxifier.java

/**
 * Gets a proxied MBean/*from  ww  w  . j  a  v  a  2s.  c  o  m*/
 * @param mbean the MBean
 * @return the proxied MBean
 */
public static Object getProxy(Object mbean) {
    Class<?> clazz = getMBeanInterface(mbean);
    if (clazz == null)
        throw new IllegalArgumentException("Object does not implement an MXBean interface");

    ProxyFactory factory = new ProxyFactory(clazz, interceptor);
    factory.setTarget(mbean);
    return factory.getProxy();
}

From source file:org.apache.mina.springrpc.MinaProxyFactoryBean.java

public void afterPropertiesSet() {
    super.afterPropertiesSet();
    if (getServiceInterface() == null) {
        throw new IllegalArgumentException("Property 'serviceInterface' is required");
    }/*from   w ww  .  jav  a 2 s .  c om*/
    this.serviceProxy = new ProxyFactory(getServiceInterface(), this).getProxy(getBeanClassLoader());
}

From source file:org.mule.extras.springproxies.SynchClientFactoryBean.java

@Override
public void afterPropertiesSet() throws Exception {
    super.afterPropertiesSet();

    if (this.serviceInterface == null) {
        throw new IllegalArgumentException("serviceInterface is required");
    }/*from www  .  j  av a  2s .c  o m*/
    this.proxy = new ProxyFactory(this.serviceInterface, this).getProxy(this.beanClassLoader);
}

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

@Override
public Remote getObjectToExport() {
    Remote exportedObject = super.getObjectToExport();

    if (getService() instanceof Remote && (getServiceInterface() == null
            || exportedObject.getClass().isAssignableFrom(getServiceInterface()))) {
        this.remoteService = exportedObject;
    } else {/* ww  w. j  av a  2  s. co  m*/
        // RMI Invokers. 
        ProxyFactory factory = new ProxyFactory(getServiceInterface(),
                new RmiServiceInterceptor((RmiInvocationHandler) exportedObject, remoteServiceName));

        this.remoteService = factory.getProxy();
    }

    return exportedObject;
}

From source file:org.phprpc.spring.remoting.PHPRPC_ProxyFactoryBean.java

public void afterPropertiesSet() {
    super.afterPropertiesSet();
    this.serviceProxy = new ProxyFactory(getServiceInterface(), this).getProxy(this.beanClassLoader);
}

From source file:de.davidbilge.spring.remoting.amqp.client.AmqpProxyFactoryBean.java

@Override
public void afterPropertiesSet() {
    if (getServiceInterface() == null) {
        throw new IllegalArgumentException("Property 'serviceInterface' is required");
    }//from ww w . j a  v  a  2 s.c o  m
    this.serviceProxy = new ProxyFactory(getServiceInterface(), this).getProxy(getBeanClassLoader());
}

From source file:fr.mby.utils.spring.beans.factory.annotation.ProxywiredAnnotationBeanPostProcessor.java

/**
 * Instrumentalize the bean factory to proxy what we need.
 * //from  w  ww. ja  v  a 2  s .  c  o  m
 * @param beanFactory
 * @return
 */
protected ConfigurableListableBeanFactory instrumentBeanFactory(
        final ConfigurableListableBeanFactory beanFactory) {
    if (this.instrumentedBeanFactory == null) {
        final ProxyFactory proxyFactory = new ProxyFactory(ConfigurableListableBeanFactory.class,
                new ResolveDependencyMethodInterceptor());
        proxyFactory.setTarget(beanFactory);

        this.instrumentedBeanFactory = (ConfigurableListableBeanFactory) proxyFactory.getProxy();
    }

    return this.instrumentedBeanFactory;
}

From source file:org.activiti.spring.components.scope.ProcessScope.java

/**
 * creates a proxy that dispatches invocations to the currently bound {@link ProcessInstance}
 *
 * @return shareable {@link ProcessInstance}
 *//*  www. j  av a  2  s  .c  o  m*/
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);
}

From source file:org.camunda.bpm.engine.spring.components.scope.ProcessScope.java

/**
 * creates a proxy that dispatches invocations to the currently bound {@link ProcessInstance}
 *
 * @return shareable {@link ProcessInstance}
 *//*from   w  w  w.  ja v  a  2s.  c om*/
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);
}