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

@SuppressWarnings("unchecked")
public static <T> T getProxy(Class<T> proxyInterface, TargetSource targetSource) 

Source Link

Document

Create a proxy for the specified TargetSource , implementing the specified interface.

Usage

From source file:org.logicblaze.lingo.jms.JmsProxyFactoryBean.java

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

From source file:org.vaadin.spring.security.config.AbstractVaadinSecurityConfiguration.java

@Bean(name = CURRENT_USER_BEAN)
Authentication currentUser() {/*w  w w.j  a  v  a2 s .  com*/

    return ProxyFactory.getProxy(Authentication.class, new MethodInterceptor() {

        @Override
        public Object invoke(MethodInvocation invocation) throws Throwable {
            SecurityContext securityContext = SecurityContextHolder.getContext();
            Authentication authentication = securityContext.getAuthentication();
            if (authentication == null) {
                throw new AuthenticationCredentialsNotFoundException(
                        "No authentication found in current security context");
            }
            return invocation.getMethod().invoke(authentication, invocation.getArguments());
        }

    });

}

From source file:org.vaadin.spring.security.config.VaadinSecurityConfiguration.java

@Bean
Authentication currentUser() {//from   w ww .  j  a  v a2  s  .  com
    return ProxyFactory.getProxy(Authentication.class, new MethodInterceptor() {
        @Override
        public Object invoke(MethodInvocation invocation) throws Throwable {
            SecurityContext securityContext = SecurityContextHolder.getContext();
            Authentication authentication = securityContext.getAuthentication();
            if (authentication == null) {
                throw new AuthenticationCredentialsNotFoundException(
                        "No authentication found in current security context");
            }
            return invocation.getMethod().invoke(authentication, invocation.getArguments());
        }
    });
}

From source file:org.piraso.proxy.RegexProxyFactory.java

@SuppressWarnings("unchecked")
public ProxyInterceptorAware<T> getProxyInterceptor(T object) {
    RegexMethodInterceptor<T> wrapper = new RegexMethodInterceptorWrapper(new RegexMethodInterceptor<T>(),
            object);//from   w w  w  .  j  ava 2  s.  c o  m
    wrapper.addAllMethodListener(listeners);

    T proxy;

    if (clazz.isInterface()) {
        proxy = ProxyFactory.getProxy(clazz, wrapper);
    } else {
        AdvisedSupport advisedSupport = new AdvisedSupport();
        advisedSupport.setTarget(object);
        advisedSupport.addAdvice(wrapper);
        AopProxy aopProxy = new DefaultAopProxyFactory().createAopProxy(advisedSupport);
        proxy = (T) aopProxy.getProxy();
    }

    return new ProxyInterceptorAware<T>(proxy, wrapper);
}

From source file:com.nabla.project.application.tool.runner.ServiceInvokerFactoryBean.java

/**
 * DOCUMENT ME!//from ww  w .  j av  a2s .c o  m
 */
public void afterPropertiesSet() {

    super.afterPropertiesSet();
    this.serviceProxy = ProxyFactory.getProxy(getServiceInterface(), this);

}

From source file:net.unicon.mycourses.services.DisguisedJaxRpcPortProxyFactoryBean.java

public void afterPropertiesSet() {
    if (getServiceInterface() == null) {
        // Use JAX-RPC port interface (a traditional RMI interface)
        // as service interface if none explicitly specified.
        if (getPortInterface() != null) {
            setServiceInterface(getPortInterface());
        } else {//  w ww  .ja va 2s.c o  m
            throw new IllegalArgumentException("serviceInterface is required");
        }
    }
    super.afterPropertiesSet();
    this.serviceProxy = ProxyFactory.getProxy(getServiceInterface(), this);
}

From source file:com.googlecode.jsonrpc4j.spring.JsonProxyFactoryBean.java

/**
 * {@inheritDoc}/*  w  w  w  . j a v  a  2s  .  c o m*/
 */
@Override
@SuppressWarnings("unchecked")
public void afterPropertiesSet() {
    super.afterPropertiesSet();

    // create proxy
    proxyObject = ProxyFactory.getProxy(getServiceInterface(), this);

    // find the ObjectMapper
    if (objectMapper == null && applicationContext != null && applicationContext.containsBean("objectMapper")) {
        objectMapper = (ObjectMapper) applicationContext.getBean("objectMapper");
    }
    if (objectMapper == null && applicationContext != null) {
        try {
            objectMapper = (ObjectMapper) BeanFactoryUtils.beanOfTypeIncludingAncestors(applicationContext,
                    ObjectMapper.class);
        } catch (Exception e) {
            /* no-op */ }
    }
    if (objectMapper == null) {
        objectMapper = new ObjectMapper();
    }

    // create JsonRpcHttpClient
    try {
        jsonRpcHttpClient = new JsonRpcHttpClient(objectMapper, new URL(getServiceUrl()), extraHttpHeaders);
        jsonRpcHttpClient.setRequestListener(requestListener);
    } catch (MalformedURLException mue) {
        throw new RuntimeException(mue);
    }
}

From source file:org.lareferencia.backend.util.StatelessSessionFactoryBean.java

@Override
public StatelessSession getObject() throws Exception {
    StatelessSessionInterceptor statelessSessionInterceptor = new StatelessSessionInterceptor(
            entityManagerFactory, sessionFactory);
    return ProxyFactory.getProxy(StatelessSession.class, statelessSessionInterceptor);
}