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

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

Introduction

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

Prototype

public Object getProxy() 

Source Link

Document

Create a new proxy according to the settings in this factory.

Usage

From source file:org.LexGrid.LexBIG.caCore.utils.LexEVSCaCoreUtils.java

public static Object createProxy(Object objectToProxy, ApplicationService advice, ProxyHelper proxyHelper) {
    ProxyFactory pf = new ProxyFactory(objectToProxy);
    pf.setProxyTargetClass(true);/*from ww  w.  j a v  a 2 s .  c o m*/
    pf.addAdvice(new LexEVSBeanProxy(advice, proxyHelper));
    pf.setExposeProxy(true);
    return pf.getProxy();
}

From source file:oz.hadoop.yarn.api.YarnAssembly.java

/**
 * //from  w  w  w  .j a v  a 2s  . com
 */
@SuppressWarnings("unchecked")
private static WithVcPrMemCount<Void> createV(String command,
        Class<? extends ApplicationContainerProcessor> applicationContainer, ByteBuffer arguments,
        String javaShellPath) {
    ProxyFactory pf = new ProxyFactory();
    pf.setInterfaces(WithVcPrMemCount.class);
    AssemblyAdvice assemblyAdvice = new AssemblyAdvice(command, applicationContainer, arguments, javaShellPath);
    pf.addAdvice(assemblyAdvice);
    WithVcPrMemCount<Void> builder = (WithVcPrMemCount<Void>) pf.getProxy();
    return builder;
}

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();//from ww w  .  j a  v  a 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:oz.hadoop.yarn.api.YarnAssembly.java

/**
 * /*from  www  . j a  va2 s.  co m*/
 */
@SuppressWarnings("unchecked")
private static WithVcPrMemCount<DataProcessor> createC(String command,
        Class<? extends ApplicationContainerProcessor> applicationContainer, ByteBuffer arguments,
        String javaShellPath) {
    ProxyFactory pf = new ProxyFactory();
    pf.setInterfaces(WithVcPrMemCount.class);
    AssemblyAdvice assemblyAdvice = new AssemblyAdvice(command, applicationContainer, arguments, javaShellPath);
    pf.addAdvice(assemblyAdvice);
    WithVcPrMemCount<DataProcessor> builder = (WithVcPrMemCount<DataProcessor>) pf.getProxy();
    return builder;
}

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.//from  ww w . j  ava2s .co  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.arrow.data.neo4j.postprocess.infrastructure.GraphRepositoryBeanPostProcessor.java

/**
 * {@inheritDoc}/*  w  w w. j a v  a  2 s.  c  om*/
 */
@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:no.abakus.bedcard.storage.ws.XFireAcegiWSSPropagatingClientFactoryBean.java

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

    // ?? myServiceProxy = ProxyFactory.getProxy(getServiceClass(), interceptor);
    Object client = super.getObject();
    Advice advice = new WSSAcegiPropagationAdvice(username, password);
    addOutHandlers(client);/*from   w w  w  .  jav a  2s.  com*/

    ProxyFactory proxyFactory = new ProxyFactory(client);
    proxyFactory.addAdvice(advice);
    myServiceProxy = proxyFactory.getProxy();
}

From source file:net.bioclipse.recording.WrapInProxyAdvice.java

public Object invoke(MethodInvocation invocation) throws Throwable {
    Object returnValue = invocation.proceed();
    if (returnValue instanceof IBioObject && !(returnValue instanceof net.sf.cglib.proxy.Factory)) {
        ProxyFactory pf = new ProxyFactory();
        pf.addAdvice(this);
        //            pf.addAdvice(Activator.getDefault().getRecordingAdvice());
        pf.setTarget(returnValue);/*ww  w.  j a va  2 s .co  m*/
        returnValue = pf.getProxy();
    }
    return returnValue;
}

From source file:org.springmodules.validation.valang.javascript.taglib.ValangRulesExporterInterceptorTests.java

/**
 * Verify that if the {@link #controller} is a proxies <code>BaseCommandController</code>,
 * it still works correctly.//  w  ww.ja va2 s  . c o  m
 */
public void testHappyCaseWithProxiedBaseCommandController() throws Exception {
    ProxyFactory factory = new ProxyFactory(this.controller);
    Object proxiedController = factory.getProxy();

    this.interceptor.postHandle(this.request, this.response, proxiedController, this.modelAndView);

    Map map = this.modelAndView.getModel();
    assertTrue("expected validation rule to be added", map.containsKey("ValangRules.command"));
}