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.Arrays;
19: import java.util.List;
20:
21: import org.kuali.rice.resourceloader.ContextClassLoaderProxy;
22: import org.springframework.aop.framework.ProxyFactory;
23: import org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter;
24: import org.springframework.remoting.support.RemoteInvocationTraceInterceptor;
25:
26: import edu.iu.uis.eden.messaging.bam.BAMServerProxy;
27:
28: public class KEWHttpInvokerServiceExporter extends
29: HttpInvokerServiceExporter {
30:
31: private List<Class> serviceInterfaces;
32: private ServiceInfo serviceInfo;
33:
34: public ServiceInfo getServiceInfo() {
35: return this .serviceInfo;
36: }
37:
38: public void setServiceInfo(ServiceInfo serviceInfo) {
39: this .serviceInfo = serviceInfo;
40: }
41:
42: protected Object getProxyForService() {
43: checkService();
44: checkServiceInterface();
45: ProxyFactory proxyFactory = new ProxyFactory();
46: for (Class serviceInterface : getServiceInterfaces()) {
47: proxyFactory.addInterface(serviceInterface);
48: }
49: if (isRegisterTraceInterceptor()) {
50: proxyFactory
51: .addAdvice(new RemoteInvocationTraceInterceptor(
52: getExporterName()));
53: }
54:
55: Object service = BAMServerProxy.wrap(getService(),
56: this .serviceInfo);
57: proxyFactory.setTarget(service);
58: return proxyFactory.getProxy();
59: }
60:
61: @Override
62: protected void checkServiceInterface()
63: throws IllegalArgumentException {
64: if (this .serviceInterfaces == null) {
65: this .serviceInterfaces = Arrays
66: .asList(ContextClassLoaderProxy
67: .getInterfacesToProxy(getService()));
68: }
69: if (getServiceInterfaces().isEmpty()) {
70: throw new IllegalArgumentException(
71: "At least one service interface should be defined.");
72: }
73: }
74:
75: public List<Class> getServiceInterfaces() {
76: return this .serviceInterfaces;
77: }
78:
79: public void setServiceInterfaces(List<Class> serviceInterfaces) {
80: this .serviceInterfaces = serviceInterfaces;
81: }
82:
83: public Object getService() {
84: return super.getService();
85: }
86:
87: }
|