List of usage examples for org.springframework.aop.framework ProxyFactory setTargetClass
public void setTargetClass(@Nullable Class<?> targetClass)
From source file:fr.pilato.spring.elasticsearch.ElasticsearchNodeFactoryBean.java
@Override public void afterPropertiesSet() throws Exception { if (async) {// ww w .j av a 2 s .com Assert.notNull(taskExecutor); Future<Node> nodeFuture = taskExecutor.submit(new Callable<Node>() { @Override public Node call() throws Exception { return initialize(); } }); ProxyFactory proxyFactory = new ProxyFactory(); proxyFactory.setProxyTargetClass(true); proxyFactory.setTargetClass(Node.class); proxyFactory.addAdvice(new GenericInvocationHandler(nodeFuture)); proxyfiedNode = (Node) proxyFactory.getProxy(); } else { node = initialize(); } }
From source file:net.paslavsky.springrest.SpringRestClientFactoryBean.java
@Override @SuppressWarnings("unchecked") protected T createInstance() throws Exception { ProxyFactory factory = new ProxyFactory(); if (getObjectType().isInterface()) { factory.setInterfaces(getObjectType()); } else {//from w w w . j av a 2 s. c o m factory.setTargetClass(getObjectType()); } factory.addAdvisor(createRestMethodAdvisor()); factory.addAdvisor(createToStringPointcutAdvisor()); return (T) factory.getProxy(); }
From source file:org.LexGrid.LexBIG.caCore.client.proxy.LexEVSProxyHelperImpl.java
@Override protected Object convertObjectToProxy(ApplicationService as, Object obj) { if (null == obj) return null; //Check to see if the returned object is an EVSRemoteExecutionResults. //If so, unwrap it and update the proxy target if (obj instanceof RemoteExecutionResults) { RemoteExecutionResults results = (RemoteExecutionResults) obj; //if the returned results are null, return null if (results.getReturnValue() == null) return null; //Get the current proxy target and update it with the retuned value //from the server Advised advised = (Advised) AopContext.currentProxy(); advised.setTargetSource(new SingletonTargetSource(results.getObj())); obj = results.getReturnValue();//w ww . jav a 2s . c om } if (obj instanceof RemoteShell) { Class<?>[] targetInterfaces = ((RemoteShell) obj).getTargetInterfaces(); Class<?> targetClass = ((RemoteShell) obj).getTargetClass(); ProxyFactory pf = new ProxyFactory(targetInterfaces); pf.addAdvice(new LexEVSBeanProxy(as, this)); pf.setProxyTargetClass(true); pf.setTargetClass(targetClass); pf.setTarget(obj); return pf.getProxy(); } if (obj instanceof Integer || obj instanceof Float || obj instanceof Double || obj instanceof Character || obj instanceof Long || obj instanceof Boolean || obj instanceof String || obj instanceof Date || obj instanceof LexEVSBeanProxy || obj instanceof BeanProxy) return obj; if (!LexEVSCaCoreUtils.isLexBigClass(obj.getClass())) { return obj; } // Don't proxy client-safe LexBig objects if (isClientSafe(obj.getClass())) { return obj; } else { return LexEVSCaCoreUtils.createProxy(obj, as, this); } }
From source file:fr.pilato.spring.elasticsearch.ElasticsearchAbstractClientFactoryBean.java
@Override public void afterPropertiesSet() throws Exception { logger.info("Starting ElasticSearch client"); if (async) {/* ww w . j a v a 2 s .c o m*/ Assert.notNull(taskExecutor); Future<Client> future = taskExecutor.submit(new Callable<Client>() { @Override public Client call() throws Exception { return initialize(); } }); ProxyFactory proxyFactory = new ProxyFactory(); proxyFactory.setProxyTargetClass(true); proxyFactory.setTargetClass(Client.class); proxyFactory.addAdvice(new GenericInvocationHandler(future)); proxyfiedClient = (Client) proxyFactory.getProxy(); } else { client = initialize(); } }
From source file:org.beangle.model.persist.hibernate.internal.ClassUtils.java
/** * Based on the given class, properly instructs the ProxyFactory proxies. * For additional sanity checks on the passed classes, check the methods * below./* w ww . j av a 2s.co m*/ * * @see #containsUnrelatedClasses(Class[]) * @see #removeParents(Class[]) * @param factory * @param classes */ public static void configureFactoryForClass(ProxyFactory factory, Class<?>[] classes) { if (ObjectUtils.isEmpty(classes)) return; for (int i = 0; i < classes.length; i++) { Class<?> clazz = classes[i]; if (clazz.isInterface()) { factory.addInterface(clazz); } else { factory.setTargetClass(clazz); factory.setProxyTargetClass(true); } } }