01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package edu.iu.uis.eden.messaging;
17:
18: import java.util.ArrayList;
19: import java.util.List;
20:
21: import org.apache.log4j.Logger;
22: import org.kuali.rice.util.ClassLoaderUtils;
23: import org.springframework.aop.framework.ProxyFactory;
24: import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean;
25:
26: public class KEWHttpInvokerProxyFactoryBean extends
27: HttpInvokerProxyFactoryBean {
28: private static final Logger LOG = Logger
29: .getLogger(KEWHttpInvokerProxyFactoryBean.class);
30:
31: private Object serviceProxy;
32:
33: private ServiceInfo serviceInfo;
34:
35: public ServiceInfo getServiceInfo() {
36: return this .serviceInfo;
37: }
38:
39: public void setServiceInfo(ServiceInfo serviceInfo) {
40: this .serviceInfo = serviceInfo;
41: }
42:
43: @Override
44: public void afterPropertiesSet() {
45: ProxyFactory proxyFactory = new ProxyFactory(
46: getServiceInterfaces());
47: proxyFactory.addAdvice(this );
48: LOG.debug("Http proxying service " + this .serviceInfo);
49: this .serviceProxy = proxyFactory.getProxy();
50: }
51:
52: @Override
53: public Object getObject() {
54: return this .serviceProxy;
55: }
56:
57: @Override
58: public Class getObjectType() {
59: return getObject().getClass();
60: }
61:
62: @Override
63: public boolean isSingleton() {
64: return false;
65: }
66:
67: public Class[] getServiceInterfaces() {
68: List<Class<?>> serviceInterfaces = new ArrayList<Class<?>>();
69: JavaServiceDefinition javaServiceDefinition = (JavaServiceDefinition) this .serviceInfo
70: .getServiceDefinition();
71: try {
72: for (String interfaceName : javaServiceDefinition
73: .getServiceInterfaces()) {
74: Class<?> clazz = Class.forName(interfaceName, true,
75: ClassLoaderUtils.getDefaultClassLoader());
76: LOG.debug("Adding service interface '" + clazz
77: + "' to proxy object for service "
78: + this .serviceInfo);
79: serviceInterfaces.add(clazz);
80: }
81: } catch (ClassNotFoundException e) {
82: throw new RuntimeException(e);
83: }
84: return serviceInterfaces.toArray(new Class[0]);
85: }
86: }
|