01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.messaging.serviceexporters;
18:
19: import java.util.ArrayList;
20:
21: import org.codehaus.xfire.spring.remoting.XFireExporter;
22: import org.codehaus.xfire.util.dom.DOMInHandler;
23: import org.codehaus.xfire.util.dom.DOMOutHandler;
24: import org.kuali.bus.services.KSBServiceLocator;
25: import org.kuali.rice.config.xfire.WorkflowXFireWSS4JInHandler;
26: import org.kuali.rice.config.xfire.WorkflowXFireWSS4JOutHandler;
27:
28: import edu.iu.uis.eden.messaging.SOAPServiceDefinition;
29: import edu.iu.uis.eden.messaging.ServerSideRemotedServiceHolder;
30: import edu.iu.uis.eden.messaging.ServiceInfo;
31: import edu.iu.uis.eden.messaging.bam.BAMServerProxy;
32:
33: /**
34: *
35: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
36: */
37: public class SOAPServiceExporter implements ServiceExporter {
38:
39: private ServiceInfo serviceInfo;
40:
41: public SOAPServiceExporter(ServiceInfo serviceInfo) {
42: this .serviceInfo = serviceInfo;
43: }
44:
45: public ServerSideRemotedServiceHolder getServiceExporter(
46: Object serviceImpl) {
47: try {
48: XFireExporter serviceExporter = new XFireExporter();
49: serviceExporter.setServiceFactory(KSBServiceLocator
50: .getXFireServiceFactory());
51: serviceExporter.setXfire(KSBServiceLocator.getXFire());
52: serviceExporter.setName(getServiceInfo().getQname()
53: .toString());
54: serviceExporter.setServiceBean(serviceImpl);
55: //when xfire supports service by service level securing
56: serviceExporter.setInHandlers(new ArrayList());
57: serviceExporter.getInHandlers().add(new DOMInHandler());
58: serviceExporter.getInHandlers().add(
59: new org.codehaus.xfire.util.LoggingHandler());
60: serviceExporter.getInHandlers().add(
61: new WorkflowXFireWSS4JInHandler(serviceInfo));
62: serviceExporter.setOutHandlers(new ArrayList());
63: serviceExporter.getOutHandlers().add(new DOMOutHandler());
64: serviceExporter.getOutHandlers().add(
65: new org.codehaus.xfire.util.LoggingHandler());
66: serviceExporter.getOutHandlers().add(
67: new WorkflowXFireWSS4JOutHandler(serviceInfo));
68: serviceExporter.setFaultHandlers(new ArrayList());
69: serviceExporter.getFaultHandlers().add(new DOMOutHandler());
70: serviceExporter.getFaultHandlers().add(
71: new org.codehaus.xfire.util.LoggingHandler());
72: serviceExporter.getFaultHandlers().add(
73: new WorkflowXFireWSS4JOutHandler(serviceInfo));
74: SOAPServiceDefinition serviceDef = (SOAPServiceDefinition) getServiceInfo()
75: .getServiceDefinition();
76: serviceExporter.setServiceClass(Class.forName(serviceDef
77: .getServiceInterface()));
78: serviceExporter.afterPropertiesSet();
79: return new ServerSideRemotedServiceHolder(
80: wrapExporterInBamService(serviceExporter),
81: this .serviceInfo.getServiceDefinition()
82: .getService(), getServiceInfo());
83: } catch (Exception e) {
84: throw new RuntimeException(e);
85: }
86: }
87:
88: protected Object wrapExporterInBamService(
89: XFireExporter serviceExporter) {
90: return BAMServerProxy.wrap(serviceExporter, this
91: .getServiceInfo());
92: }
93:
94: public ServiceInfo getServiceInfo() {
95: return this.serviceInfo;
96: }
97:
98: }
|