| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.ksb.messaging; |
| 17 | |
|
| 18 | |
import java.util.ArrayList; |
| 19 | |
import java.util.List; |
| 20 | |
|
| 21 | |
import org.apache.log4j.Logger; |
| 22 | |
import org.kuali.rice.core.util.ClassLoaderUtils; |
| 23 | |
import org.springframework.aop.framework.ProxyFactory; |
| 24 | |
import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean; |
| 25 | |
|
| 26 | |
|
| 27 | 0 | public class KSBHttpInvokerProxyFactoryBean extends HttpInvokerProxyFactoryBean { |
| 28 | 0 | private static final Logger LOG = Logger.getLogger(KSBHttpInvokerProxyFactoryBean.class); |
| 29 | |
|
| 30 | |
private Object serviceProxy; |
| 31 | |
|
| 32 | |
private ServiceInfo serviceInfo; |
| 33 | |
|
| 34 | |
public ServiceInfo getServiceInfo() { |
| 35 | 0 | return this.serviceInfo; |
| 36 | |
} |
| 37 | |
|
| 38 | |
public void setServiceInfo(ServiceInfo serviceInfo) { |
| 39 | 0 | this.serviceInfo = serviceInfo; |
| 40 | 0 | } |
| 41 | |
|
| 42 | |
@Override |
| 43 | |
public void afterPropertiesSet() { |
| 44 | 0 | ProxyFactory proxyFactory = new ProxyFactory(getServiceInterfaces()); |
| 45 | 0 | proxyFactory.addAdvice(this); |
| 46 | 0 | LOG.debug("Http proxying service " + this.serviceInfo); |
| 47 | 0 | this.serviceProxy = proxyFactory.getProxy(); |
| 48 | 0 | } |
| 49 | |
|
| 50 | |
@Override |
| 51 | |
public Object getObject() { |
| 52 | 0 | return this.serviceProxy; |
| 53 | |
} |
| 54 | |
|
| 55 | |
@Override |
| 56 | |
public Class getObjectType() { |
| 57 | 0 | return getObject().getClass(); |
| 58 | |
} |
| 59 | |
|
| 60 | |
@Override |
| 61 | |
public boolean isSingleton() { |
| 62 | 0 | return false; |
| 63 | |
} |
| 64 | |
|
| 65 | |
public Class[] getServiceInterfaces() { |
| 66 | 0 | List<Class<?>> serviceInterfaces = new ArrayList<Class<?>>(); |
| 67 | 0 | JavaServiceDefinition javaServiceDefinition = (JavaServiceDefinition) this.serviceInfo.getServiceDefinition(); |
| 68 | |
try { |
| 69 | 0 | for (String interfaceName : javaServiceDefinition.getServiceInterfaces()) { |
| 70 | 0 | Class<?> clazz = Class.forName(interfaceName, true, ClassLoaderUtils.getDefaultClassLoader()); |
| 71 | 0 | LOG.debug("Adding service interface '" + clazz + "' to proxy object for service " + this.serviceInfo); |
| 72 | 0 | serviceInterfaces.add(clazz); |
| 73 | 0 | } |
| 74 | 0 | } catch (ClassNotFoundException e) { |
| 75 | 0 | throw new RuntimeException(e); |
| 76 | 0 | } |
| 77 | 0 | return serviceInterfaces.toArray(new Class[0]); |
| 78 | |
} |
| 79 | |
} |