| 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.kuali.rice.ksb.api.bus.support.JavaServiceConfiguration; |
| 24 | |
import org.springframework.aop.framework.ProxyFactory; |
| 25 | |
import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean; |
| 26 | |
|
| 27 | |
|
| 28 | 0 | public class KSBHttpInvokerProxyFactoryBean extends HttpInvokerProxyFactoryBean { |
| 29 | 0 | private static final Logger LOG = Logger.getLogger(KSBHttpInvokerProxyFactoryBean.class); |
| 30 | |
|
| 31 | |
private Object serviceProxy; |
| 32 | |
|
| 33 | |
private JavaServiceConfiguration serviceConfiguration; |
| 34 | |
|
| 35 | |
public JavaServiceConfiguration getServiceConfiguration() { |
| 36 | 0 | return this.serviceConfiguration; |
| 37 | |
} |
| 38 | |
|
| 39 | |
public void setServiceConfiguration(JavaServiceConfiguration serviceConfiguration) { |
| 40 | 0 | this.serviceConfiguration = serviceConfiguration; |
| 41 | 0 | } |
| 42 | |
|
| 43 | |
@Override |
| 44 | |
public void afterPropertiesSet() { |
| 45 | 0 | ProxyFactory proxyFactory = new ProxyFactory(getServiceInterfaces()); |
| 46 | 0 | proxyFactory.addAdvice(this); |
| 47 | 0 | LOG.debug("Http proxying service " + getServiceConfiguration()); |
| 48 | 0 | this.serviceProxy = proxyFactory.getProxy(); |
| 49 | 0 | } |
| 50 | |
|
| 51 | |
@Override |
| 52 | |
public Object getObject() { |
| 53 | 0 | return this.serviceProxy; |
| 54 | |
} |
| 55 | |
|
| 56 | |
@Override |
| 57 | |
public Class<?> getObjectType() { |
| 58 | 0 | return getObject().getClass(); |
| 59 | |
} |
| 60 | |
|
| 61 | |
@Override |
| 62 | |
public boolean isSingleton() { |
| 63 | 0 | return false; |
| 64 | |
} |
| 65 | |
|
| 66 | |
public Class<?>[] getServiceInterfaces() { |
| 67 | 0 | List<Class<?>> serviceInterfaces = new ArrayList<Class<?>>(); |
| 68 | |
try { |
| 69 | 0 | for (String interfaceName : getServiceConfiguration().getServiceInterfaces()) { |
| 70 | 0 | Class<?> clazz = Class.forName(interfaceName, true, ClassLoaderUtils.getDefaultClassLoader()); |
| 71 | 0 | LOG.debug("Adding service interface '" + clazz + "' to proxy object for service " + getServiceConfiguration()); |
| 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 | |
} |