001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.geronimo.axis.builder;
018
019 import java.lang.reflect.Method;
020 import java.net.MalformedURLException;
021 import java.net.URI;
022 import java.net.URISyntaxException;
023 import java.net.URL;
024 import java.util.ArrayList;
025 import java.util.Collection;
026 import java.util.Collections;
027 import java.util.HashMap;
028 import java.util.HashSet;
029 import java.util.Iterator;
030 import java.util.List;
031 import java.util.Map;
032 import java.util.Set;
033 import java.util.jar.JarFile;
034
035 import javax.wsdl.Binding;
036 import javax.wsdl.BindingOperation;
037 import javax.wsdl.Definition;
038 import javax.wsdl.Operation;
039 import javax.wsdl.Port;
040 import javax.wsdl.PortType;
041 import javax.wsdl.extensions.soap.SOAPAddress;
042 import javax.wsdl.extensions.soap.SOAPBinding;
043 import javax.xml.namespace.QName;
044 import javax.xml.rpc.handler.HandlerInfo;
045
046 import org.apache.axis.constants.Style;
047 import org.apache.axis.description.JavaServiceDesc;
048 import org.apache.axis.handlers.HandlerInfoChainFactory;
049 import org.apache.axis.handlers.soap.SOAPService;
050 import org.apache.axis.providers.java.RPCProvider;
051 import org.apache.axis.soap.SOAPConstants;
052 import org.apache.geronimo.axis.client.AxisServiceReference;
053 import org.apache.geronimo.axis.client.OperationInfo;
054 import org.apache.geronimo.axis.client.SEIFactory;
055 import org.apache.geronimo.axis.client.SEIFactoryImpl;
056 import org.apache.geronimo.axis.server.AxisWebServiceContainer;
057 import org.apache.geronimo.axis.server.POJOProvider;
058 import org.apache.geronimo.axis.server.ServiceInfo;
059 import org.apache.geronimo.common.DeploymentException;
060 import org.apache.geronimo.gbean.GBeanData;
061 import org.apache.geronimo.gbean.GBeanInfo;
062 import org.apache.geronimo.gbean.GBeanInfoBuilder;
063 import org.apache.geronimo.gbean.AbstractName;
064 import org.apache.geronimo.j2ee.deployment.Module;
065 import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
066 import org.apache.geronimo.j2ee.deployment.HandlerInfoInfo;
067 import org.apache.geronimo.j2ee.deployment.WebModule;
068 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
069 import org.apache.geronimo.xbeans.geronimo.naming.GerPortCompletionType;
070 import org.apache.geronimo.xbeans.geronimo.naming.GerPortType;
071 import org.apache.geronimo.xbeans.geronimo.naming.GerServiceCompletionType;
072 import org.apache.geronimo.xbeans.geronimo.naming.GerServiceRefType;
073 import org.apache.geronimo.xbeans.j2ee.JavaWsdlMappingType;
074 import org.apache.geronimo.xbeans.j2ee.JavaXmlTypeMappingType;
075 import org.apache.geronimo.xbeans.j2ee.ServiceEndpointInterfaceMappingType;
076 import org.apache.geronimo.xbeans.j2ee.ServiceEndpointMethodMappingType;
077 import org.apache.geronimo.deployment.util.DeploymentUtil;
078 import org.apache.geronimo.deployment.DeploymentContext;
079 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
080 import org.apache.geronimo.webservices.SerializableWebServiceContainerFactoryGBean;
081 import org.apache.geronimo.webservices.builder.PortInfo;
082 import org.apache.geronimo.webservices.builder.SchemaInfoBuilder;
083 import org.apache.geronimo.webservices.builder.WSDescriptorParser;
084 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
085 import org.apache.geronimo.kernel.repository.Environment;
086
087 /**
088 * @version $Rev: 487175 $ $Date: 2006-12-14 03:10:31 -0800 (Thu, 14 Dec 2006) $
089 */
090 public class AxisBuilder implements WebServiceBuilder {
091
092 private static final SOAPConstants SOAP_VERSION = SOAPConstants.SOAP11_CONSTANTS;
093
094 private final Environment defaultEnvironment;
095 private static final String KEY = AxisBuilder.class.getName();
096
097 public AxisBuilder() {
098 defaultEnvironment = null;
099 }
100
101 public AxisBuilder(Environment defaultEnvironment) {
102 this.defaultEnvironment = defaultEnvironment;
103 }
104
105
106 public void findWebServices(JarFile moduleFile, boolean isEJB, Map servletLocations, Environment environment, Map sharedContext) throws DeploymentException {
107 final String path = isEJB ? "META-INF/webservices.xml" : "WEB-INF/webservices.xml";
108 try {
109 URL wsDDUrl = DeploymentUtil.createJarURL(moduleFile, path);
110 Map portMap = WSDescriptorParser.parseWebServiceDescriptor(wsDDUrl, moduleFile, isEJB, servletLocations);
111 if (portMap != null) {
112 if (defaultEnvironment != null) {
113 EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
114 }
115 sharedContext.put(KEY, portMap);
116 }
117 } catch (MalformedURLException e) {
118 // The webservices.xml file doesn't exist.
119 }
120 }
121
122 public boolean configurePOJO(GBeanData targetGBean, String servletName, Module module, String seiClassName, DeploymentContext context) throws DeploymentException {
123 ClassLoader cl = context.getClassLoader();
124 Map sharedContext = ((WebModule) module).getSharedContext();
125 Map portInfoMap = (Map) sharedContext.get(KEY);
126 PortInfo portInfo = (PortInfo) portInfoMap.get(servletName);
127 if (portInfo == null) {
128 //not ours
129 return false;
130 }
131 ServiceInfo serviceInfo = AxisServiceBuilder.createServiceInfo(portInfo, cl);
132 JavaServiceDesc serviceDesc = serviceInfo.getServiceDesc();
133
134 targetGBean.setAttribute("pojoClassName", seiClassName);
135 RPCProvider provider = new POJOProvider();
136
137 SOAPService service = new SOAPService(null, provider, null);
138 service.setServiceDescription(serviceDesc);
139 service.setOption("className", seiClassName);
140
141 HandlerInfoChainFactory handlerInfoChainFactory = new HandlerInfoChainFactory(serviceInfo.getHandlerInfos());
142 service.setOption(org.apache.axis.Constants.ATTR_HANDLERINFOCHAIN, handlerInfoChainFactory);
143
144 URI location;
145 try {
146 location = new URI(serviceDesc.getEndpointURL());
147 } catch (URISyntaxException e) {
148 throw new DeploymentException("Invalid webservice endpoint URI", e);
149 }
150 URI wsdlURI;
151 try {
152 wsdlURI = new URI(serviceDesc.getWSDLFile());
153 } catch (URISyntaxException e) {
154 throw new DeploymentException("Invalid wsdl URI", e);
155
156 }
157
158 AxisWebServiceContainer axisWebServiceContainer = new AxisWebServiceContainer(location, wsdlURI, service, serviceInfo.getWsdlMap(), cl);
159 AbstractName webServiceContainerFactoryName = context.getNaming().createChildName(targetGBean.getAbstractName(), "webServiceContainer", NameFactory.GERONIMO_SERVICE);
160 GBeanData webServiceContainerFactoryGBean = new GBeanData(webServiceContainerFactoryName, SerializableWebServiceContainerFactoryGBean.GBEAN_INFO);
161 webServiceContainerFactoryGBean.setAttribute("webServiceContainer", axisWebServiceContainer);
162 try {
163 context.addGBean(webServiceContainerFactoryGBean);
164 } catch (GBeanAlreadyExistsException e) {
165 throw new DeploymentException("Could not add webServiceContainerFactoryGBean", e);
166 }
167 targetGBean.setReferencePattern("WebServiceContainerFactory", webServiceContainerFactoryName);
168 return true;
169 }
170
171 public boolean configureEJB(GBeanData targetGBean, String ejbName, JarFile moduleFile, Map sharedContext, ClassLoader classLoader) throws DeploymentException {
172 Map portInfoMap = (Map) sharedContext.get(KEY);
173 PortInfo portInfo = (PortInfo) portInfoMap.get(ejbName);
174 if (portInfo == null) {
175 //not ours
176 return false;
177 }
178 ServiceInfo serviceInfo = AxisServiceBuilder.createServiceInfo(portInfo, classLoader);
179 targetGBean.setAttribute("serviceInfo", serviceInfo);
180 JavaServiceDesc serviceDesc = serviceInfo.getServiceDesc();
181 URI location = portInfo.getContextURI();
182 targetGBean.setAttribute("location", location);
183 URI wsdlURI;
184 try {
185 wsdlURI = new URI(serviceDesc.getWSDLFile());
186 } catch (URISyntaxException e) {
187 throw new DeploymentException("Invalid wsdl URI", e);
188 }
189 targetGBean.setAttribute("wsdlURI", wsdlURI);
190 return true;
191 }
192
193
194 //ServicereferenceBuilder
195 public Object createService(Class serviceInterface, URI wsdlURI, URI jaxrpcMappingURI, QName serviceQName, Map portComponentRefMap, List handlerInfos, Object serviceRefType, Module module, ClassLoader classLoader) throws DeploymentException {
196 GerServiceRefType gerServiceRefType = (GerServiceRefType) serviceRefType;
197 JarFile moduleFile = module.getModuleFile();
198 SchemaInfoBuilder schemaInfoBuilder = null;
199 JavaWsdlMappingType mapping = null;
200 if (wsdlURI != null) {
201 schemaInfoBuilder = new SchemaInfoBuilder(moduleFile, wsdlURI);
202
203 mapping = WSDescriptorParser.readJaxrpcMapping(moduleFile, jaxrpcMappingURI);
204 }
205
206 return createService(serviceInterface, schemaInfoBuilder, mapping, serviceQName, SOAP_VERSION, handlerInfos, gerServiceRefType, module, classLoader);
207 }
208
209 public Object createService(Class serviceInterface, SchemaInfoBuilder schemaInfoBuilder, JavaWsdlMappingType mapping, QName serviceQName, SOAPConstants soapVersion, List handlerInfos, GerServiceRefType serviceRefType, Module module, ClassLoader classloader) throws DeploymentException {
210 Map seiPortNameToFactoryMap = new HashMap();
211 Map seiClassNameToFactoryMap = new HashMap();
212 if (schemaInfoBuilder != null) {
213 buildSEIFactoryMap(schemaInfoBuilder, serviceRefType, mapping, handlerInfos, serviceQName, soapVersion, seiPortNameToFactoryMap, seiClassNameToFactoryMap, classloader);
214 }
215 return new AxisServiceReference(serviceInterface.getName(), seiPortNameToFactoryMap, seiClassNameToFactoryMap);
216 }
217
218 public void buildSEIFactoryMap(SchemaInfoBuilder schemaInfoBuilder, GerServiceRefType serviceRefType, JavaWsdlMappingType mapping, List handlerInfos, QName serviceQName, SOAPConstants soapVersion, Map seiPortNameToFactoryMap, Map seiClassNameToFactoryMap, ClassLoader classLoader) throws DeploymentException {
219 Map exceptionMap = WSDescriptorParser.getExceptionMap(mapping);
220
221 Definition definition = schemaInfoBuilder.getDefinition();
222 //check for consistency
223 if (definition.getServices().size() == 0) {
224 //partial wsdl
225 if (serviceRefType == null || !serviceRefType.isSetServiceCompletion()) {
226 throw new DeploymentException("Partial wsdl, but no service completion supplied");
227 }
228 GerServiceCompletionType serviceCompletion = serviceRefType.getServiceCompletion();
229 String serviceLocalName = serviceCompletion.getServiceName().trim();
230 String namespace = definition.getTargetNamespace();
231 serviceQName = new QName(namespace, serviceLocalName);
232 javax.wsdl.Service service = definition.createService();
233 service.setQName(serviceQName);
234 GerPortCompletionType[] portCompletions = serviceCompletion.getPortCompletionArray();
235 for (int i = 0; i < portCompletions.length; i++) {
236 GerPortCompletionType portCompletion = portCompletions[i];
237 GerPortType port = portCompletion.getPort();
238 URL location = getLocation(port);
239 String portName = port.getPortName().trim();
240 String bindingName = portCompletion.getBindingName().trim();
241 QName bindingQName = new QName(namespace, bindingName);
242 Binding binding = definition.getBinding(bindingQName);
243 if (binding == null) {
244 throw new DeploymentException("No binding found with qname: " + bindingQName);
245 }
246 String credentialsName = port.isSetCredentialsName() ? port.getCredentialsName().trim() : null;
247 mapBinding(binding, mapping, serviceQName, classLoader, soapVersion, schemaInfoBuilder, portName, location, handlerInfos, seiPortNameToFactoryMap, seiClassNameToFactoryMap, credentialsName, exceptionMap);
248
249 }
250 } else {
251 //full wsdl
252 if (serviceRefType != null && serviceRefType.isSetServiceCompletion()) {
253 throw new DeploymentException("Full wsdl, but service completion supplied");
254 }
255 //organize the extra port info
256 Map portMap = new HashMap();
257 if (serviceRefType != null) {
258 GerPortType[] ports = serviceRefType.getPortArray();
259 for (int i = 0; i < ports.length; i++) {
260 GerPortType port = ports[i];
261 String portName = port.getPortName().trim();
262 portMap.put(portName, port);
263 }
264 }
265
266 //find the service we are working with
267 javax.wsdl.Service service = getService(serviceQName, schemaInfoBuilder.getDefinition());
268 if (serviceQName == null) {
269 serviceQName = service.getQName();
270 }
271
272 Map wsdlPortMap = service.getPorts();
273 for (Iterator iterator = wsdlPortMap.entrySet().iterator(); iterator.hasNext();) {
274 Map.Entry entry = (Map.Entry) iterator.next();
275 String portName = (String) entry.getKey();
276 Port port = (Port) entry.getValue();
277
278 GerPortType gerPort = (GerPortType) portMap.get(portName);
279
280 URL location = gerPort == null ? getAddressLocation(port) : getLocation(gerPort);
281 //skip non-soap ports
282 if (location == null) {
283 continue;
284 }
285 String credentialsName = gerPort == null || gerPort.getCredentialsName() == null ? null : gerPort.getCredentialsName().trim();
286
287 Binding binding = port.getBinding();
288
289 mapBinding(binding, mapping, serviceQName, classLoader, soapVersion, schemaInfoBuilder, portName, location, handlerInfos, seiPortNameToFactoryMap, seiClassNameToFactoryMap, credentialsName, exceptionMap);
290 }
291 }
292 }
293
294 private void mapBinding(Binding binding, JavaWsdlMappingType mapping, QName serviceQName, ClassLoader classLoader, SOAPConstants soapVersion, SchemaInfoBuilder schemaInfoBuilder, String portName, URL location, List handlerInfos, Map seiPortNameToFactoryMap, Map seiClassNameToFactoryMap, String credentialsName, Map exceptionMap) throws DeploymentException {
295 Style portStyle = getStyle(binding);
296
297 PortType portType = binding.getPortType();
298
299 ServiceEndpointInterfaceMappingType[] endpointMappings = mapping.getServiceEndpointInterfaceMappingArray();
300
301 //port type corresponds to SEI
302 List operations = portType.getOperations();
303 OperationInfo[] operationInfos = new OperationInfo[operations.size()];
304 if (endpointMappings.length == 0) {
305 doLightweightMapping(serviceQName, portType, mapping, classLoader, operations, binding, portStyle, soapVersion, operationInfos, schemaInfoBuilder, portName, location, handlerInfos, seiPortNameToFactoryMap, seiClassNameToFactoryMap, credentialsName);
306 } else {
307 doHeavyweightMapping(serviceQName, portType, endpointMappings, classLoader, operations, binding, portStyle, soapVersion, exceptionMap, schemaInfoBuilder, mapping, operationInfos, portName, location, handlerInfos, seiPortNameToFactoryMap, seiClassNameToFactoryMap, credentialsName);
308 }
309 }
310
311 private URL getLocation(GerPortType port) throws DeploymentException {
312 String protocol = port.getProtocol().trim();
313 String host = port.getHost().trim();
314 int portNum = port.getPort();
315 String uri = port.getUri().trim();
316 String locationURIString = protocol + "://" + host + ":" + portNum + uri;
317 URL location;
318 try {
319 location = new URL(locationURIString);
320 } catch (MalformedURLException e) {
321 throw new DeploymentException("Could not construct web service location URL from " + locationURIString);
322 }
323 return location;
324 }
325
326 private javax.wsdl.Service getService(QName serviceQName, Definition definition) throws DeploymentException {
327 javax.wsdl.Service service;
328 if (serviceQName != null) {
329 service = definition.getService(serviceQName);
330 if (service == null) {
331 throw new DeploymentException("No service wsdl for supplied service qname " + serviceQName);
332 }
333 } else {
334 Map services = definition.getServices();
335 if (services.size() > 1) {
336 throw new DeploymentException("no serviceQName supplied, and there are " + services.size() + " services");
337 }
338 if (services.size() == 0) {
339 throw new DeploymentException("No service in wsdl, and no service completion supplied!");
340 } else {
341 service = (javax.wsdl.Service) services.values().iterator().next();
342 }
343 }
344 return service;
345 }
346
347 private Style getStyle(Binding binding) throws DeploymentException {
348 SOAPBinding soapBinding = (SOAPBinding) SchemaInfoBuilder.getExtensibilityElement(SOAPBinding.class, binding.getExtensibilityElements());
349 // String transportURI = soapBinding.getTransportURI();
350 String portStyleString = soapBinding.getStyle();
351 return Style.getStyle(portStyleString);
352 }
353
354 private URL getAddressLocation(Port port) throws DeploymentException {
355 SOAPAddress soapAddress;
356 try {
357 soapAddress = (SOAPAddress) SchemaInfoBuilder.getExtensibilityElement(SOAPAddress.class, port.getExtensibilityElements());
358 } catch (DeploymentException e) {
359 //a http: protocol REST service. Skip it.
360 return null;
361 }
362 String locationURIString = soapAddress.getLocationURI();
363 URL location;
364 try {
365 location = new URL(locationURIString);
366 } catch (MalformedURLException e) {
367 throw new DeploymentException("Could not construct web service location URL from " + locationURIString);
368 }
369 return location;
370 }
371
372 private void doHeavyweightMapping(QName serviceName, PortType portType, ServiceEndpointInterfaceMappingType[] endpointMappings, ClassLoader classLoader, List operations, Binding binding, Style portStyle, SOAPConstants soapVersion, Map exceptionMap, SchemaInfoBuilder schemaInfoBuilder, JavaWsdlMappingType mapping, OperationInfo[] operationInfos, String portName, URL location, List handlerInfos, Map seiPortNameToFactoryMap, Map seiClassNameToFactoryMap, String credentialsName) throws DeploymentException {
373 Class serviceEndpointInterface;
374 SEIFactory seiFactory;
375 //complete jaxrpc mapping file supplied
376 QName portTypeQName = portType.getQName();
377 ServiceEndpointInterfaceMappingType endpointMapping = WSDescriptorParser.getServiceEndpointInterfaceMapping(endpointMappings, portTypeQName);
378 String fqcn = endpointMapping.getServiceEndpointInterface().getStringValue();
379 try {
380 serviceEndpointInterface = classLoader.loadClass(fqcn);
381 } catch (ClassNotFoundException e) {
382 throw new DeploymentException("Could not load service endpoint interface", e);
383 }
384 // Class enhancedServiceEndpointClass = enhanceServiceEndpointInterface(serviceEndpointInterface, context, module, classLoader);
385
386 Collection operationDescs = new ArrayList();
387 ServiceEndpointMethodMappingType[] methodMappings = endpointMapping.getServiceEndpointMethodMappingArray();
388 int i = 0;
389 Set wrapperElementQNames = new HashSet();
390 JavaXmlTypeMappingType[] javaXmlTypeMappings = mapping.getJavaXmlTypeMappingArray();
391 boolean hasEncoded = false;
392 for (Iterator ops = operations.iterator(); ops.hasNext();) {
393 Operation operation = (Operation) ops.next();
394 String operationName = operation.getName();
395 //the obvious method seems to be buggy
396 // BindingOperation bindingOperation = binding.getBindingOperation(operationName, operation.getInput().getName(), operation.getOutput() == null ? null : operation.getOutput().getName());
397 BindingOperation bindingOperation = null;
398 List bops = binding.getBindingOperations();
399 for (Iterator iterator = bops.iterator(); iterator.hasNext();) {
400 BindingOperation bindingOperation1 = (BindingOperation) iterator.next();
401 if (bindingOperation1.getOperation().equals(operation)) {
402 bindingOperation = bindingOperation1;
403 break;
404 }
405 }
406 if (bindingOperation == null) {
407 throw new DeploymentException("No BindingOperation for operation: " + operationName + ", input: " + operation.getInput().getName() + ", output: " + (operation.getOutput() == null ? "<none>" : operation.getOutput().getName()));
408 }
409 ServiceEndpointMethodMappingType methodMapping = WSDescriptorParser.getMethodMappingForOperation(operationName, methodMappings);
410 HeavyweightOperationDescBuilder operationDescBuilder = new HeavyweightOperationDescBuilder(bindingOperation, mapping, methodMapping, portStyle, exceptionMap, schemaInfoBuilder, javaXmlTypeMappings, classLoader, serviceEndpointInterface);
411 OperationInfo operationInfo = operationDescBuilder.buildOperationInfo(soapVersion);
412 operationInfos[i++] = operationInfo;
413 operationDescs.add(operationInfo.getOperationDesc());
414 wrapperElementQNames.addAll(operationDescBuilder.getWrapperElementQNames());
415 hasEncoded |= operationDescBuilder.isEncoded();
416 }
417 HeavyweightTypeInfoBuilder builder = new HeavyweightTypeInfoBuilder(classLoader, schemaInfoBuilder.getSchemaTypeKeyToSchemaTypeMap(), wrapperElementQNames, operationDescs, hasEncoded);
418 List typeInfo = builder.buildTypeInfo(mapping);
419
420 seiFactory = createSEIFactory(serviceName, portName, serviceEndpointInterface.getName(), typeInfo, location, operationInfos, handlerInfos, credentialsName);
421 seiPortNameToFactoryMap.put(portName, seiFactory);
422 seiClassNameToFactoryMap.put(serviceEndpointInterface.getName(), seiFactory);
423 }
424
425 private void doLightweightMapping(QName serviceName, PortType portType, JavaWsdlMappingType mapping, ClassLoader classLoader, List operations, Binding binding, Style portStyle, SOAPConstants soapVersion, OperationInfo[] operationInfos, SchemaInfoBuilder schemaInfoBuilder, String portName, URL location, List handlerInfos, Map seiPortNameToFactoryMap, Map seiClassNameToFactoryMap, String credentialsName) throws DeploymentException {
426 Class serviceEndpointInterface;
427 SEIFactory seiFactory;
428 //lightweight jaxrpc mapping supplied
429 serviceEndpointInterface = getServiceEndpointInterfaceLightweight(portType, mapping, classLoader);
430 // Class enhancedServiceEndpointClass = enhanceServiceEndpointInterface(serviceEndpointInterface, context, module, classLoader);
431
432 int i = 0;
433 for (Iterator ops = operations.iterator(); ops.hasNext();) {
434 Operation operation = (Operation) ops.next();
435 Method method = WSDescriptorParser.getMethodForOperation(serviceEndpointInterface, operation);
436 BindingOperation bindingOperation = binding.getBindingOperation(operation.getName(), operation.getInput().getName(), operation.getOutput() == null ? null : operation.getOutput().getName());
437 operationInfos[i++] = buildOperationInfoLightweight(method, bindingOperation, portStyle, soapVersion);
438 }
439 LightweightTypeInfoBuilder builder = new LightweightTypeInfoBuilder(classLoader, schemaInfoBuilder.getSchemaTypeKeyToSchemaTypeMap(), Collections.EMPTY_SET);
440 List typeInfo = builder.buildTypeInfo(mapping);
441
442 seiFactory = createSEIFactory(serviceName, portName, serviceEndpointInterface.getName(), typeInfo, location, operationInfos, handlerInfos, credentialsName);
443 seiPortNameToFactoryMap.put(portName, seiFactory);
444 seiClassNameToFactoryMap.put(serviceEndpointInterface.getName(), seiFactory);
445 }
446
447 private Class getServiceEndpointInterfaceLightweight(PortType portType, JavaWsdlMappingType mappings, ClassLoader classLoader) throws DeploymentException {
448 QName portTypeQName = portType.getQName();
449 String portTypeNamespace = portTypeQName.getNamespaceURI();
450 String portTypePackage = WSDescriptorParser.getPackageFromNamespace(portTypeNamespace, mappings);
451 StringBuffer shortInterfaceName = new StringBuffer(portTypeQName.getLocalPart());
452 shortInterfaceName.setCharAt(0, Character.toUpperCase(shortInterfaceName.charAt(0)));
453 //TODO just use one buffer!
454 String fqcn = portTypePackage + "." + shortInterfaceName.toString();
455 try {
456 return classLoader.loadClass(fqcn);
457 } catch (ClassNotFoundException e) {
458 throw new DeploymentException("Could not load service endpoint interface type", e);
459 }
460 }
461
462
463 public SEIFactory createSEIFactory(QName serviceName, String portName, String enhancedServiceEndpointClassName, List typeInfo, URL location, OperationInfo[] operationInfos, List handlerInfoInfos, String credentialsName) throws DeploymentException {
464 List handlerInfos = buildHandlerInfosForPort(portName, handlerInfoInfos);
465 return new SEIFactoryImpl(serviceName, portName, enhancedServiceEndpointClassName, operationInfos, typeInfo, location, handlerInfos, credentialsName);
466 }
467
468 private List buildHandlerInfosForPort(String portName, List handlerInfoInfos) {
469 List handlerInfos = new ArrayList();
470 for (Iterator iterator = handlerInfoInfos.iterator(); iterator.hasNext();) {
471 HandlerInfoInfo handlerInfoInfo = (HandlerInfoInfo) iterator.next();
472 Set portNames = handlerInfoInfo.getPortNames();
473 if (portNames.isEmpty() || portNames.contains(portName)) {
474 HandlerInfo handlerInfo = new HandlerInfo(handlerInfoInfo.getHandlerClass(), handlerInfoInfo.getHandlerConfig(), handlerInfoInfo.getSoapHeaders());
475 handlerInfos.add(handlerInfo);
476
477 //TODO what about the soap roles??
478 }
479 }
480 return handlerInfos;
481 }
482
483 public OperationInfo buildOperationInfoLightweight(Method method, BindingOperation bindingOperation, Style defaultStyle, SOAPConstants soapVersion) throws DeploymentException {
484 LightweightOperationDescBuilder operationDescBuilder = new LightweightOperationDescBuilder(bindingOperation, method);
485 return operationDescBuilder.buildOperationInfo(soapVersion);
486 }
487
488
489 public static final GBeanInfo GBEAN_INFO;
490
491 static {
492 GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(AxisBuilder.class, NameFactory.MODULE_BUILDER);
493 infoBuilder.addInterface(WebServiceBuilder.class);
494 infoBuilder.addAttribute("defaultEnvironment", Environment.class, true, true);
495
496 infoBuilder.setConstructor(new String[]{"defaultEnvironment"});
497
498 GBEAN_INFO = infoBuilder.getBeanInfo();
499 }
500
501 public static GBeanInfo getGBeanInfo() {
502 return GBEAN_INFO;
503 }
504
505 }