Return-Path: X-Original-To: apmail-geronimo-scm-archive@www.apache.org Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 210C34376 for ; Mon, 6 Jun 2011 13:58:46 +0000 (UTC) Received: (qmail 17101 invoked by uid 500); 6 Jun 2011 13:58:46 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 16970 invoked by uid 500); 6 Jun 2011 13:58:45 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 16963 invoked by uid 99); 6 Jun 2011 13:58:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Jun 2011 13:58:45 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Jun 2011 13:58:43 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 020C623889C5; Mon, 6 Jun 2011 13:58:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1132647 - in /geronimo/server/trunk/plugins: axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/ axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/p... Date: Mon, 06 Jun 2011 13:58:22 -0000 To: scm@geronimo.apache.org From: xuhaihong@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110606135823.020C623889C5@eris.apache.org> Author: xuhaihong Date: Mon Jun 6 13:58:21 2011 New Revision: 1132647 URL: http://svn.apache.org/viewvc?rev=1132647&view=rev Log: GERONIMO-5990 A JAXWSApplicationContext GBean is added to hold all the available port info in the current web or ejb module I hope that in the future, we could have a way to avoid create each factory gbean for each web service endpoint, and there will be a method like getWebServiceContainer method in this gbean Added: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSApplicationContext.java geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSEJBApplicationContext.java geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSWebApplicationContext.java Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceGBean.java geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/WSDLQueryHandler.java geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2WebServiceContainerTest.java geronimo/server/trunk/plugins/cxf/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainer.java geronimo/server/trunk/plugins/cxf/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/pojo/POJOWebServiceContainerFactoryGBean.java geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AdvancedWARWebServiceFinder.java geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/EJBWebServiceFinder.java geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/WSDLUtils.java Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java?rev=1132647&r1=1132646&r2=1132647&view=diff ============================================================================== --- geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java (original) +++ geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java Mon Jun 6 13:58:21 2011 @@ -17,6 +17,9 @@ package org.apache.geronimo.axis2.ejb; +import java.util.Collection; +import java.util.Collections; + import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; @@ -29,6 +32,7 @@ import org.apache.geronimo.axis2.AxisSer import org.apache.geronimo.axis2.GeronimoFactoryRegistry; import org.apache.geronimo.axis2.osgi.Axis2ModuleRegistry; import org.apache.geronimo.jaxws.JAXWSAnnotationProcessor; +import org.apache.geronimo.jaxws.JAXWSEJBApplicationContext; import org.apache.geronimo.jaxws.JAXWSUtils; import org.apache.geronimo.jaxws.JNDIResolver; import org.apache.geronimo.jaxws.PortInfo; @@ -47,8 +51,9 @@ public class EJBWebServiceContainer exte Bundle bundle, Context context, Axis2ModuleRegistry axis2ModuleRegistry, - BeanContext deploymnetInfo) { - super(portInfo, endpointClassName, bundle, context, axis2ModuleRegistry); + BeanContext deploymnetInfo, + String ejbModuleName) { + super(portInfo, endpointClassName, bundle, context, axis2ModuleRegistry, ejbModuleName); this.deploymnetInfo = deploymnetInfo; } @@ -85,6 +90,12 @@ public class EJBWebServiceContainer exte } @Override + protected Collection getPortInfos(Bundle bundle) { + JAXWSEJBApplicationContext jaxwsEJBApplicationContext = JAXWSEJBApplicationContext.get(moduleName); + return jaxwsEJBApplicationContext == null ? Collections.emptyList() : jaxwsEJBApplicationContext.getPortInfos(); + } + + @Override protected AxisServiceGenerator createServiceGenerator() { AxisServiceGenerator serviceGenerator = super.createServiceGenerator(); serviceGenerator.setCatalogName(JAXWSUtils.DEFAULT_CATALOG_EJB); Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceGBean.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceGBean.java?rev=1132647&r1=1132646&r2=1132647&view=diff ============================================================================== --- geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceGBean.java (original) +++ geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceGBean.java Mon Jun 6 13:58:21 2011 @@ -23,6 +23,7 @@ import java.util.Properties; import javax.naming.Context; import org.apache.geronimo.axis2.osgi.Axis2ModuleRegistry; +import org.apache.geronimo.gbean.AbstractName; import org.apache.geronimo.gbean.GBeanLifecycle; import org.apache.geronimo.gbean.annotation.GBean; import org.apache.geronimo.gbean.annotation.ParamAttribute; @@ -54,6 +55,7 @@ public class EJBWebServiceGBean implemen @ParamAttribute(name="portInfo")PortInfo portInfo, @ParamSpecial(type = SpecialAttributeType.kernel)Kernel kernel, @ParamSpecial(type = SpecialAttributeType.bundle)Bundle bundle, + @ParamSpecial(type = SpecialAttributeType.abstractName)AbstractName abName, @ParamReference(name="WebServiceContainer")Collection webContainers, @ParamAttribute(name="policyContextID")String policyContextID, @ParamReference(name="ConfigurationFactory")ConfigurationFactory configurationFactory, @@ -76,7 +78,7 @@ public class EJBWebServiceGBean implemen BeanContext deploymnetInfo = ejbDeploymentContext.getDeploymentInfo(); Context context = deploymnetInfo.getJndiEnc(); - this.container = new EJBWebServiceContainer(portInfo, beanClassName, bundle, context, axis2ModuleRegistry, deploymnetInfo); + this.container = new EJBWebServiceContainer(portInfo, beanClassName, bundle, context, axis2ModuleRegistry, deploymnetInfo, abName.getNameProperty(NameFactory.EJB_MODULE)); this.container.init(); soapHandler.addWebService(this.location, Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java?rev=1132647&r1=1132646&r2=1132647&view=diff ============================================================================== --- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java (original) +++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java Mon Jun 6 13:58:21 2011 @@ -21,6 +21,8 @@ import java.io.PrintWriter; import java.net.HttpURLConnection; import java.net.URI; import java.net.URL; +import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -76,6 +78,7 @@ import org.apache.geronimo.axis2.client. import org.apache.geronimo.axis2.osgi.Axis2ModuleRegistry; import org.apache.geronimo.jaxws.JAXWSAnnotationProcessor; import org.apache.geronimo.jaxws.JAXWSUtils; +import org.apache.geronimo.jaxws.JAXWSWebApplicationContext; import org.apache.geronimo.jaxws.JNDIResolver; import org.apache.geronimo.jaxws.PortInfo; import org.apache.geronimo.jaxws.ServerJNDIResolver; @@ -131,13 +134,16 @@ public abstract class Axis2WebServiceCon protected Axis2ModuleRegistry axis2ModuleRegistry; - public Axis2WebServiceContainer(PortInfo portInfo, String endpointClassName, Bundle bundle, Context context, Axis2ModuleRegistry axis2ModuleRegistry) { + protected String moduleName; + + public Axis2WebServiceContainer(PortInfo portInfo, String endpointClassName, Bundle bundle, Context context, Axis2ModuleRegistry axis2ModuleRegistry, String moduleName) { this.endpointClassName = endpointClassName; this.portInfo = portInfo; this.bundle = bundle; this.context = context; this.jndiResolver = new ServerJNDIResolver(context); this.axis2ModuleRegistry = axis2ModuleRegistry; + this.moduleName = moduleName; } public void init() throws Exception { @@ -172,7 +178,7 @@ public abstract class Axis2WebServiceCon service.setScope(Constants.SCOPE_APPLICATION); configurationContext.getAxisConfiguration().addService(service); - this.wsdlQueryHandler = new WSDLQueryHandler(this.service); + this.wsdlQueryHandler = new WSDLQueryHandler(this.service, portInfo, getPortInfos(bundle)); /* * This replaces HandlerLifecycleManagerFactory for all web services. @@ -189,6 +195,11 @@ public abstract class Axis2WebServiceCon this.service.addParameter(new Parameter(org.apache.axis2.jaxws.spi.Constants.CACHE_CLASSLOADER, new BundleClassLoader(bundle))); } + protected Collection getPortInfos(Bundle bundle) { + JAXWSWebApplicationContext jaxwsWebApplicationContext = JAXWSWebApplicationContext.get(moduleName); + return jaxwsWebApplicationContext == null ? Collections.emptyList() : jaxwsWebApplicationContext.getPortInfos(); + } + static String getBaseUri(URI request) { return request.getScheme() + "://" + request.getHost() + ":" + request.getPort() + request.getPath(); } @@ -490,7 +501,7 @@ public abstract class Axis2WebServiceCon */ protected void configureHandlers() throws Exception { EndpointDescription desc = AxisServiceGenerator.getEndpointDescription(this.service); - + if(portInfo.getHandlerChainsInfo() != null) { desc.setHandlerChain(toAxis2HandlerChainsType(portInfo.getHandlerChainsInfo())); } @@ -503,7 +514,7 @@ public abstract class Axis2WebServiceCon DescriptionUtils.registerHandlerHeaders(desc.getAxisService(), this.binding.getHandlerChain()); } - + private HandlerChainsType toAxis2HandlerChainsType(HandlerChainsInfo handlerChainsInfo) { HandlerChainsType handlerChains = new HandlerChainsType(); for (HandlerChainInfo handlerChainInfo : handlerChainsInfo.handleChains) { @@ -525,7 +536,7 @@ public abstract class Axis2WebServiceCon } return handlerChains; } - + private void logHandlers(HandlerChainsType handlerChains) { if (handlerChains == null || handlerChains.getHandlerChain() == null || handlerChains.getHandlerChain().isEmpty()) { LOG.debug("No handlers"); Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/WSDLQueryHandler.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/WSDLQueryHandler.java?rev=1132647&r1=1132646&r2=1132647&view=diff ============================================================================== --- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/WSDLQueryHandler.java (original) +++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/WSDLQueryHandler.java Mon Jun 6 13:58:21 2011 @@ -23,8 +23,10 @@ import java.io.FileNotFoundException; import java.io.OutputStream; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import javax.wsdl.Definition; import javax.wsdl.Import; @@ -37,6 +39,7 @@ import javax.wsdl.extensions.schema.Sche import javax.wsdl.factory.WSDLFactory; import javax.wsdl.xml.WSDLReader; import javax.wsdl.xml.WSDLWriter; +import javax.xml.namespace.QName; import javax.xml.transform.OutputKeys; import javax.xml.transform.Source; import javax.xml.transform.Transformer; @@ -48,7 +51,7 @@ import javax.xml.transform.stream.Stream import org.apache.axis2.description.AxisService; import org.apache.axis2.jaxws.catalog.JAXWSCatalogManager; import org.apache.axis2.jaxws.description.EndpointDescription; - +import org.apache.geronimo.jaxws.PortInfo; import org.apache.geronimo.jaxws.WSDLUtils; import org.apache.geronimo.jaxws.wsdl.CatalogWSDLLocator; import org.apache.xml.resolver.Catalog; @@ -61,32 +64,70 @@ import org.w3c.dom.NodeList; public class WSDLQueryHandler { private static final Logger LOG = LoggerFactory.getLogger(WSDLQueryHandler.class); - - private static TransformerFactory transformerFactory = TransformerFactory.newInstance(); - + + public static final String WSDL_QUERY_MULTIPLE_PORT = "org.apache.geronimo.webservices.wsdlquery.multipleport"; + + private static final boolean multiplePortInWSDLQuery = Boolean.getBoolean(WSDL_QUERY_MULTIPLE_PORT); + + private static TransformerFactory transformerFactory = TransformerFactory.newInstance(); + private Map wsdlMap; private Map schemaMap; private Map importMap; private int wsdlCounter; private int schemaCounter; private AxisService service; - private Catalog catalog; - + private Catalog catalog; + private Map> servicePortNameLocationMap; + private Map> servicePortNamesMap; + private PortInfo portInfo; + public WSDLQueryHandler(AxisService service) { + this(service, null, null); + } + + public WSDLQueryHandler(AxisService service, PortInfo portInfo, Collection portInfos) { this.service = service; EndpointDescription ed = AxisServiceGenerator.getEndpointDescription(this.service); JAXWSCatalogManager catalogManager = ed.getServiceDescription().getCatalogManager(); if (catalogManager != null) { this.catalog = catalogManager.getCatalog(); } + if (portInfo != null && portInfos != null) { + this.portInfo = portInfo; + servicePortNameLocationMap = new HashMap>(); + servicePortNamesMap = new HashMap>(); + for (PortInfo p : portInfos) { + if (p.getWsdlFile() == null || !p.getWsdlFile().equals(portInfo.getWsdlFile())) { + continue; + } + QName serviceName = p.getWsdlService(); + QName portName = p.getWsdlPort(); + if (serviceName == null || portName == null) { + continue; + } + Map portNameLocationMap = servicePortNameLocationMap.get(serviceName); + if (portNameLocationMap == null) { + portNameLocationMap = new HashMap(); + servicePortNameLocationMap.put(serviceName, portNameLocationMap); + } + portNameLocationMap.put(portName.getLocalPart(), p.getLocation()); + Set portNames = servicePortNamesMap.get(serviceName); + if(portNames == null) { + portNames = new HashSet(); + servicePortNamesMap.put(serviceName, portNames); + } + portNames.add(portName.getLocalPart()); + } + } } - + public void writeResponse(String baseUri, String wsdlUri, OutputStream os) throws Exception { String base = null; String wsdlKey = ""; String xsdKey = null; - + int idx = baseUri.toLowerCase().indexOf("?wsdl"); if (idx != -1) { base = baseUri.substring(0, idx); @@ -118,29 +159,43 @@ public class WSDLQueryHandler { } // update service port location on each request - if (wsdlKey.equals("")) { - WSDLUtils.updateLocations(def, base); + if (wsdlKey.isEmpty()) { + if(multiplePortInWSDLQuery && servicePortNameLocationMap != null) { + String serverUrl = base.substring(0, base.length() - portInfo.getLocation().length()); + Map> updatedServicePortNameLocationMap = new HashMap>(); + for(Map.Entry> servicePortNameLocationEntry : servicePortNameLocationMap.entrySet()) { + Map updatedPortNameLocationMap = new HashMap(); + for(Map.Entry portNameLocationEntry : servicePortNameLocationEntry.getValue().entrySet()) { + updatedPortNameLocationMap.put(portNameLocationEntry.getKey(), serverUrl + portNameLocationEntry.getValue()); + } + updatedServicePortNameLocationMap.put(servicePortNameLocationEntry.getKey(), updatedPortNameLocationMap); + } + WSDLUtils.updateLocations(def, updatedServicePortNameLocationMap); + } + else { + WSDLUtils.updateLocations(def, base); + } } - + WSDLFactory factory = WSDLFactory.newInstance(); WSDLWriter writer = factory.newWSDLWriter(); rootElement = writer.getDocument(def).getDocumentElement(); - + updateWSDLImports(rootElement, base, wsdlKey); updateSchemaImports(rootElement, base, wsdlKey); } else { SchemaReference si = schemaMap.get(xsdKey); - + if (si == null) { throw new FileNotFoundException("Schema not found: " + xsdKey); } - + rootElement = si.getReferencedSchema().getElement(); - + updateSchemaImports(rootElement, base, xsdKey); } - + writeTo(rootElement, os); } @@ -149,24 +204,26 @@ public class WSDLQueryHandler { wsdlMap = new HashMap(); schemaMap = new HashMap(); importMap = new HashMap(); - - Map docMap = new HashMap(); - + + Map docMap = new HashMap(); + WSDLFactory factory = WSDLFactory.newInstance(); WSDLReader reader = factory.newWSDLReader(); reader.setFeature("javax.wsdl.importDocuments", true); - reader.setFeature("javax.wsdl.verbose", false); + reader.setFeature("javax.wsdl.verbose", false); Definition def = reader.readWSDL(new CatalogWSDLLocator(wsdlUri, this.catalog)); updateDefinition("", def, docMap, base); - // remove other services and ports from wsdl - WSDLUtils.trimDefinition(def, this.service.getName(), this.service.getEndpointName()); - + if (multiplePortInWSDLQuery) { + WSDLUtils.trimDefinition(def, servicePortNamesMap); + } else { + WSDLUtils.trimDefinition(def, this.service.getName(), this.service.getEndpointName()); + } wsdlMap.put("", def); } } private void updateWSDLImports(Element rootElement, String base, String parentDocKey) { - NodeList nl = rootElement.getElementsByTagNameNS("http://schemas.xmlsoap.org/wsdl/", "import"); + NodeList nl = rootElement.getElementsByTagNameNS("http://schemas.xmlsoap.org/wsdl/", "import"); for (int x = 0; x < nl.getLength(); x++) { Element el = (Element) nl.item(x); String location = el.getAttribute("location"); @@ -189,7 +246,7 @@ public class WSDLQueryHandler { el.setAttribute("schemaLocation", base + "?xsd=" + docKey); } } - + nl = rootElement.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "include"); for (int x = 0; x < nl.getLength(); x++) { Element el = (Element) nl.item(x); @@ -201,19 +258,18 @@ public class WSDLQueryHandler { } } } - + protected void updateDefinition(String parentDocKey, Definition def, - Map docMap, + Map docMap, String base) { - Collection imports = def.getImports().values(); - for (List lst : imports) { - List impLst = lst; + Collection> imports = def.getImports().values(); + for (List impLst : imports) { for (Import imp : impLst) { String docURI = imp.getDefinition().getDocumentBaseURI(); - String location = imp.getLocationURI(); + String location = imp.getLocationURI(); String importId = parentDocKey + "/" + location; - String docKey = docMap.get(docURI); + String docKey = docMap.get(docURI); if (docKey == null) { docKey = getUniqueWSDLId(); docMap.put(docURI, docKey); @@ -222,8 +278,8 @@ public class WSDLQueryHandler { } importMap.put(importId, docKey); } - } - + } + Types types = def.getTypes(); if (types != null) { for (ExtensibilityElement el : (List)types.getExtensibilityElements()) { @@ -234,33 +290,34 @@ public class WSDLQueryHandler { } } } - - protected void updateSchemaImports(String parentDocKey, + + protected void updateSchemaImports(String parentDocKey, Schema schema, - Map docMap, + Map docMap, String base) { - Collection imports = schema.getImports().values(); - for (List list : imports) { - List impList = list; + @SuppressWarnings("unchecked") + Collection> imports = schema.getImports().values(); + for (List impList : imports) { for (SchemaImport s : impList) { Schema importedSchema = s.getReferencedSchema(); if (importedSchema == null) { continue; } String docURI = importedSchema.getDocumentBaseURI(); - String location = s.getSchemaLocationURI(); - String importId = parentDocKey + "/" + location; - String docKey = docMap.get(docURI); + String location = s.getSchemaLocationURI(); + String importId = parentDocKey + "/" + location; + String docKey = docMap.get(docURI); if (docKey == null) { docKey = getUniqueSchemaId(); docMap.put(docURI, docKey); schemaMap.put(docKey, s); updateSchemaImports(docKey, importedSchema, docMap, base); - } + } importMap.put(importId, docKey); } } - + + @SuppressWarnings("unchecked") List includes = schema.getIncludes(); for (SchemaReference s : includes) { Schema includedSchema = s.getReferencedSchema(); @@ -268,31 +325,31 @@ public class WSDLQueryHandler { continue; } String docURI = includedSchema.getDocumentBaseURI(); - String location = s.getSchemaLocationURI(); - String importId = parentDocKey + "/" + location; - String docKey = docMap.get(docURI); + String location = s.getSchemaLocationURI(); + String importId = parentDocKey + "/" + location; + String docKey = docMap.get(docURI); if (docKey == null) { docKey = getUniqueSchemaId(); docMap.put(docURI, docKey); schemaMap.put(docKey, s); updateSchemaImports(docKey, includedSchema, docMap, base); - } + } importMap.put(importId, docKey); } } - + private String getUniqueSchemaId() { return "xsd" + ++schemaCounter; } - + private String getUniqueWSDLId() { return "wsdl" + ++wsdlCounter; - } - + } + public static void writeTo(Node node, OutputStream os) { writeTo(new DOMSource(node), os); } - + public static void writeTo(Source src, OutputStream os) { Transformer it; try { @@ -304,9 +361,8 @@ public class WSDLQueryHandler { it.setOutputProperty(OutputKeys.ENCODING, "utf-8"); it.transform(src, new StreamResult(os)); } catch (TransformerException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + LOG.error("Fail to output wsdl", e); } } - + } Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java?rev=1132647&r1=1132646&r2=1132647&view=diff ============================================================================== --- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java (original) +++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java Mon Jun 6 13:58:21 2011 @@ -19,7 +19,6 @@ package org.apache.geronimo.axis2.pojo; import java.io.PrintWriter; import java.net.HttpURLConnection; - import javax.naming.Context; import javax.xml.ws.WebServiceException; @@ -64,8 +63,9 @@ public class POJOWebServiceContainer ext Context context, Axis2ModuleRegistry axis2ModuleRegistry, AnnotationHolder holder, - String contextRoot) { - super(portInfo, endpointClassName, bundle, context, axis2ModuleRegistry); + String contextRoot, + String moduleName) { + super(portInfo, endpointClassName, bundle, context, axis2ModuleRegistry, moduleName); this.holder = holder; this.contextRoot = contextRoot; } Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java?rev=1132647&r1=1132646&r2=1132647&view=diff ============================================================================== --- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java (original) +++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java Mon Jun 6 13:58:21 2011 @@ -24,12 +24,14 @@ import javax.naming.NamingException; import javax.transaction.TransactionManager; import org.apache.geronimo.axis2.osgi.Axis2ModuleRegistry; +import org.apache.geronimo.gbean.AbstractName; import org.apache.geronimo.gbean.annotation.GBean; import org.apache.geronimo.gbean.annotation.ParamAttribute; import org.apache.geronimo.gbean.annotation.ParamReference; import org.apache.geronimo.gbean.annotation.ParamSpecial; import org.apache.geronimo.gbean.annotation.SpecialAttributeType; import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; +import org.apache.geronimo.jaxws.PortInfo; import org.apache.geronimo.jaxws.annotations.AnnotationHolder; import org.apache.geronimo.kernel.Kernel; import org.apache.geronimo.naming.enc.EnterpriseNamingContext; @@ -50,16 +52,17 @@ public class POJOWebServiceContainerFact private static final Logger LOG = LoggerFactory.getLogger(POJOWebServiceContainerFactoryGBean.class); private final ClassLoader classLoader; - private final org.apache.geronimo.jaxws.PortInfo portInfo; + private final PortInfo portInfo; private final String endpointClassName; private Context context; private AnnotationHolder holder; private String contextRoot; private Bundle bundle; private Axis2ModuleRegistry axis2ModuleRegistry; + private String webModuleName; public POJOWebServiceContainerFactoryGBean( - @ParamAttribute(name="portInfo") org.apache.geronimo.jaxws.PortInfo portInfo, + @ParamAttribute(name="portInfo") PortInfo portInfo, @ParamAttribute(name="endpointClassName") String endpointClassName, @ParamAttribute(name="componentContext") Map componentContext, @ParamReference(name="TransactionManager", namingType=NameFactory.JTA_RESOURCE) TransactionManager transactionManager, @@ -68,7 +71,8 @@ public class POJOWebServiceContainerFact @ParamReference(name="Axis2ModuleRegistry") Axis2ModuleRegistry axis2ModuleRegistry, @ParamSpecial(type = SpecialAttributeType.kernel) Kernel kernel, @ParamSpecial(type = SpecialAttributeType.bundle) Bundle bundle, - @ParamSpecial(type = SpecialAttributeType.classLoader) ClassLoader classLoader) + @ParamSpecial(type = SpecialAttributeType.classLoader) ClassLoader classLoader, + @ParamSpecial(type = SpecialAttributeType.abstractName) AbstractName abName) throws InstantiationException, IllegalAccessException, ClassNotFoundException { if (componentContext != null) { @@ -89,10 +93,11 @@ public class POJOWebServiceContainerFact this.holder = holder; this.contextRoot = contextRoot; this.axis2ModuleRegistry = axis2ModuleRegistry; + this.webModuleName = abName.getNameProperty(NameFactory.WEB_MODULE); } public WebServiceContainer getWebServiceContainer() { - POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo, endpointClassName, bundle, context, axis2ModuleRegistry, holder, contextRoot); + POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo, endpointClassName, bundle, context, axis2ModuleRegistry, holder, contextRoot, webModuleName); try { container.init(); } catch (Exception e) { Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2WebServiceContainerTest.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2WebServiceContainerTest.java?rev=1132647&r1=1132646&r2=1132647&view=diff ============================================================================== --- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2WebServiceContainerTest.java (original) +++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2WebServiceContainerTest.java Mon Jun 6 13:58:21 2011 @@ -77,7 +77,7 @@ public class Axis2WebServiceContainerTes String endpointClassName = "org.apache.geronimo.axis2.testdata.simple.HelloWorld"; Bundle mockBundle = new MockBundle(cl, null, 11L); - POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo, endpointClassName, mockBundle, null, new Axis2ModuleRegistry(mockBundle.getBundleContext()), AnnotationHolder.EMPTY, "/axis2"); + POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo, endpointClassName, mockBundle, null, new Axis2ModuleRegistry(mockBundle.getBundleContext()), AnnotationHolder.EMPTY, "/axis2", "TestWebModuleName"); container.init(); container.invoke(req, res); out.flush(); @@ -152,7 +152,7 @@ public class Axis2WebServiceContainerTes Axis2Response res = new Axis2Response("text/xml; charset=utf-8", "127.0.0.1", null, null, 8080, out); Bundle mockBundle = new MockBundle(cl, null, 11L); POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo, endPointClassName, mockBundle, null, new Axis2ModuleRegistry(mockBundle.getBundleContext()), - AnnotationHolder.EMPTY, "/axis2"); + AnnotationHolder.EMPTY, "/axis2","TestWebModuleName"); container.init(); container.invoke(req, res); System.out.println("Response "+out); Modified: geronimo/server/trunk/plugins/cxf/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainer.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/cxf/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainer.java?rev=1132647&r1=1132646&r2=1132647&view=diff ============================================================================== --- geronimo/server/trunk/plugins/cxf/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainer.java (original) +++ geronimo/server/trunk/plugins/cxf/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainer.java Mon Jun 6 13:58:21 2011 @@ -49,7 +49,7 @@ public abstract class CXFWebServiceConta public CXFWebServiceContainer(Bus bus, Object target, Bundle bundle) { this.bus = bus; this.bundle = bundle; - List ids = new ArrayList(); + List ids = new ArrayList(); ids.add("http://schemas.xmlsoap.org/wsdl/soap/"); DestinationFactoryManager destinationFactoryManager = bus Modified: geronimo/server/trunk/plugins/cxf/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/pojo/POJOWebServiceContainerFactoryGBean.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/cxf/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/pojo/POJOWebServiceContainerFactoryGBean.java?rev=1132647&r1=1132646&r2=1132647&view=diff ============================================================================== --- geronimo/server/trunk/plugins/cxf/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/pojo/POJOWebServiceContainerFactoryGBean.java (original) +++ geronimo/server/trunk/plugins/cxf/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/pojo/POJOWebServiceContainerFactoryGBean.java Mon Jun 6 13:58:21 2011 @@ -66,7 +66,6 @@ public class POJOWebServiceContainerFact Kernel kernel, Bundle bundle, TransactionManager transactionManager, - URL configurationBaseUrl, AnnotationHolder holder, String contextRoot) throws ClassNotFoundException, @@ -128,7 +127,6 @@ public class POJOWebServiceContainerFact infoBuilder.addAttribute("kernel", Kernel.class, false); infoBuilder.addAttribute("bundle", Bundle.class, false); infoBuilder.addReference("TransactionManager", TransactionManager.class, NameFactory.JTA_RESOURCE); - infoBuilder.addAttribute("configurationBaseUrl", URL.class, true); infoBuilder.addAttribute("holder", AnnotationHolder.class, true); infoBuilder.addAttribute("contextRoot", String.class, true, true); @@ -140,7 +138,6 @@ public class POJOWebServiceContainerFact "kernel", "bundle", "TransactionManager", - "configurationBaseUrl", "holder", "contextRoot" }); Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AdvancedWARWebServiceFinder.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AdvancedWARWebServiceFinder.java?rev=1132647&r1=1132646&r2=1132647&view=diff ============================================================================== --- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AdvancedWARWebServiceFinder.java (original) +++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AdvancedWARWebServiceFinder.java Mon Jun 6 13:58:21 2011 @@ -118,6 +118,8 @@ public class AdvancedWARWebServiceFinder PortInfo portInfo = new PortInfo(); portInfo.setLocation(contextRoot + location); portInfo.setHandlerChainsInfo(annotationHandlerChainFinder.buildHandlerChainFromClass(service)); + portInfo.setWsdlService(JAXWSUtils.getServiceQName(service)); + portInfo.setWsdlPort(JAXWSUtils.getPortQName(service)); servletNamePortInfoMap.put(service.getName(), portInfo); } else { // found at least one mapped entry @@ -126,6 +128,8 @@ public class AdvancedWARWebServiceFinder LOG.debug("POJO Web Service class {} is mapped to {} servlet", service.getName(), servlet); } PortInfo portInfo = createPortInfo(servlet, portLocations); + portInfo.setWsdlService(JAXWSUtils.getServiceQName(service)); + portInfo.setWsdlPort(JAXWSUtils.getPortQName(service)); servletNamePortInfoMap.put(servlet, portInfo); } } @@ -158,6 +162,8 @@ public class AdvancedWARWebServiceFinder String servletName = servletType.getServletName().trim(); portInfo = createPortInfo(servletName, portLocations); portInfo.setHandlerChainsInfo(annotationHandlerChainFinder.buildHandlerChainFromClass(servletClass)); + portInfo.setWsdlService(JAXWSUtils.getServiceQName(servletClass)); + portInfo.setWsdlPort(JAXWSUtils.getPortQName(servletClass)); } } catch (ClassNotFoundException e) { throw new DeploymentException("Failed to load servlet class " + servletClassName, e); Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java?rev=1132647&r1=1132646&r2=1132647&view=diff ============================================================================== --- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java (original) +++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java Mon Jun 6 13:58:21 2011 @@ -19,6 +19,7 @@ package org.apache.geronimo.jaxws.builde import java.io.InputStream; import java.net.URL; +import java.util.HashMap; import java.util.Map; import javax.xml.bind.JAXBException; @@ -38,7 +39,9 @@ import org.apache.geronimo.j2ee.deployme import org.apache.geronimo.j2ee.deployment.Module; import org.apache.geronimo.j2ee.deployment.WebModule; import org.apache.geronimo.j2ee.deployment.WebServiceBuilder; +import org.apache.geronimo.jaxws.JAXWSEJBApplicationContext; import org.apache.geronimo.jaxws.JAXWSUtils; +import org.apache.geronimo.jaxws.JAXWSWebApplicationContext; import org.apache.geronimo.jaxws.PortInfo; import org.apache.geronimo.jaxws.annotations.AnnotationHolder; import org.apache.geronimo.jaxws.feature.AddressingFeatureInfo; @@ -253,6 +256,21 @@ public abstract class JAXWSServiceBuilde return false; } + Map servletNamePortInfoMap = null; + AbstractName jaxwsWebApplicationContextName = context.getNaming().createChildName(module.getModuleName(), "JAXWSWebApplicationContext", "JAXWSWebApplicationContext"); + try { + servletNamePortInfoMap = (Map)(context.getGBeanInstance(jaxwsWebApplicationContextName).getAttribute("servletNamePortInfoMap")); + } catch (GBeanNotFoundException e) { + GBeanData jaxwsWebApplicationContextGBeanData = new GBeanData(jaxwsWebApplicationContextName, JAXWSWebApplicationContext.class); + try { + context.addGBean(jaxwsWebApplicationContextGBeanData); + } catch (GBeanAlreadyExistsException e1) { + } + servletNamePortInfoMap = new HashMap(); + jaxwsWebApplicationContextGBeanData.setAttribute("servletNamePortInfoMap", servletNamePortInfoMap); + } + servletNamePortInfoMap.put(servletName, portInfo); + Map componentContext = null; Holder moduleHolder = null; try { @@ -335,9 +353,23 @@ public abstract class JAXWSServiceBuilde throw new DeploymentException("Endpoint URI for EJB WebService is missing"); } - if (LOG.isDebugEnabled()) { - LOG.info("Configuring EJB JAX-WS Web Service: " + ejbName + " at " + location); + Map ejbNamePortInfoMap = null; + DeploymentContext context = module.getEarContext(); + AbstractName jaxwsEJBApplicationContextName = context.getNaming().createChildName(module.getModuleName(), "JAXWSEJBApplicationContext", "JAXWSEJBApplicationContext"); + try { + ejbNamePortInfoMap = (Map)(context.getGBeanInstance(jaxwsEJBApplicationContextName).getAttribute("ejbNamePortInfoMap")); + } catch (GBeanNotFoundException e) { + GBeanData jaxwsEJBApplicationContextGBeanData = new GBeanData(jaxwsEJBApplicationContextName, JAXWSEJBApplicationContext.class); + try { + context.addGBean(jaxwsEJBApplicationContextGBeanData); + } catch (GBeanAlreadyExistsException e1) { + } + ejbNamePortInfoMap = new HashMap(); + jaxwsEJBApplicationContextGBeanData.setAttribute("ejbNamePortInfoMap", ejbNamePortInfoMap); } + ejbNamePortInfoMap.put(ejbName, portInfo); + + LOG.info("Configuring EJB JAX-WS Web Service: " + ejbName + " at " + location); targetGBean.setAttribute("portInfo", portInfo); Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/EJBWebServiceFinder.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/EJBWebServiceFinder.java?rev=1132647&r1=1132646&r2=1132647&view=diff ============================================================================== --- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/EJBWebServiceFinder.java (original) +++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/EJBWebServiceFinder.java Mon Jun 6 13:58:21 2011 @@ -65,6 +65,8 @@ public class EJBWebServiceFinder impleme location = "/" + JAXWSUtils.getServiceName(ejbClass) + "/" + JAXWSUtils.getName(ejbClass); } portInfo.setLocation(location); + portInfo.setWsdlService(JAXWSUtils.getServiceQName(ejbClass)); + portInfo.setWsdlPort(JAXWSUtils.getPortQName(ejbClass)); map.put(bean.ejbName, portInfo); ejbWebServiceClassNames.add(bean.ejbClass); } Added: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSApplicationContext.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSApplicationContext.java?rev=1132647&view=auto ============================================================================== --- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSApplicationContext.java (added) +++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSApplicationContext.java Mon Jun 6 13:58:21 2011 @@ -0,0 +1,33 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.jaxws; + +import java.util.Collection; +import java.util.Set; + +/** + * @version $Rev$ $Date$ + */ +public interface JAXWSApplicationContext {//extends WebServiceApplicationContext { + + public PortInfo getPortInfo(String id); + + public Collection getPortInfos(); + + public Set getIds(); +} Added: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSEJBApplicationContext.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSEJBApplicationContext.java?rev=1132647&view=auto ============================================================================== --- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSEJBApplicationContext.java (added) +++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSEJBApplicationContext.java Mon Jun 6 13:58:21 2011 @@ -0,0 +1,94 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.jaxws; + +import java.util.Collection; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.geronimo.gbean.AbstractName; +import org.apache.geronimo.gbean.GBeanLifecycle; +import org.apache.geronimo.gbean.annotation.GBean; +import org.apache.geronimo.gbean.annotation.ParamAttribute; +import org.apache.geronimo.gbean.annotation.ParamSpecial; +import org.apache.geronimo.gbean.annotation.SpecialAttributeType; +import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; +import org.osgi.framework.Bundle; + +/** + * @version $Rev$ $Date$ + */ + +@GBean(name = "JAXWSEJBApplicationContext", j2eeType = "JAXWSEJBApplicationContext") +public class JAXWSEJBApplicationContext implements JAXWSApplicationContext, GBeanLifecycle { + + private static Map ejbModuleNameJAXWSEJBApplicationContextMap = new ConcurrentHashMap(); + + private Bundle bundle; + + private Map ejbNamePortInfoMap; + + private String ejbModuleName; + + public JAXWSEJBApplicationContext(@ParamAttribute(name = "ejbNamePortInfoMap") Map ejbNamePortInfoMap, + @ParamSpecial(type = SpecialAttributeType.bundle) Bundle bundle, + @ParamSpecial(type = SpecialAttributeType.abstractName) AbstractName abName) { + this.ejbNamePortInfoMap = ejbNamePortInfoMap; + this.bundle = bundle; + this.ejbModuleName = abName.getNameProperty(NameFactory.EJB_MODULE); + } + + @Override + public Collection getPortInfos() { + return Collections.unmodifiableCollection(ejbNamePortInfoMap.values()); + } + + @Override + public Set getIds() { + return Collections.unmodifiableSet(ejbNamePortInfoMap.keySet()); + } + + @Override + public PortInfo getPortInfo(String ejbName) { + return ejbNamePortInfoMap.get(ejbName); + } + + @Override + public void doFail() { + try { + doStop(); + } catch (Exception e) { + } + } + + @Override + public void doStart() throws Exception { + ejbModuleNameJAXWSEJBApplicationContextMap.put(ejbModuleName, this); + } + + @Override + public void doStop() throws Exception { + ejbModuleNameJAXWSEJBApplicationContextMap.remove(ejbModuleName); + } + + public static JAXWSEJBApplicationContext get(String ejbModuleName) { + return ejbModuleNameJAXWSEJBApplicationContextMap.get(ejbModuleName); + } +} Added: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSWebApplicationContext.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSWebApplicationContext.java?rev=1132647&view=auto ============================================================================== --- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSWebApplicationContext.java (added) +++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSWebApplicationContext.java Mon Jun 6 13:58:21 2011 @@ -0,0 +1,92 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.jaxws; + +import java.util.Collection; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.geronimo.gbean.AbstractName; +import org.apache.geronimo.gbean.GBeanLifecycle; +import org.apache.geronimo.gbean.annotation.GBean; +import org.apache.geronimo.gbean.annotation.ParamAttribute; +import org.apache.geronimo.gbean.annotation.ParamSpecial; +import org.apache.geronimo.gbean.annotation.SpecialAttributeType; +import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; +import org.osgi.framework.Bundle; + +/** + * @version $Rev$ $Date$ + */ +@GBean(name = "JAXWSWebApplicationContext", j2eeType = "JAXWSWebApplicationContext") +public class JAXWSWebApplicationContext implements JAXWSApplicationContext, GBeanLifecycle { + + private static Map webModuleNameJAXWSWebApplicationContextMap = new ConcurrentHashMap(); + + private Bundle bundle; + + private Map servletNamePortInfoMap; + + private String webModuleName; + + public JAXWSWebApplicationContext(@ParamAttribute(name = "servletNamePortInfoMap") Map servletNamePortInfoMap, + @ParamSpecial(type = SpecialAttributeType.bundle) Bundle bundle, + @ParamSpecial(type = SpecialAttributeType.abstractName) AbstractName abName) { + this.servletNamePortInfoMap = servletNamePortInfoMap; + this.webModuleName = abName.getNameProperty(NameFactory.WEB_MODULE); + } + + @Override + public Collection getPortInfos() { + return Collections.unmodifiableCollection(servletNamePortInfoMap.values()); + } + + @Override + public Set getIds() { + return Collections.unmodifiableSet(servletNamePortInfoMap.keySet()); + } + + @Override + public PortInfo getPortInfo(String servletName) { + return servletNamePortInfoMap.get(servletName); + } + + @Override + public void doFail() { + try { + doStop(); + } catch (Exception e) { + } + } + + @Override + public void doStart() throws Exception { + webModuleNameJAXWSWebApplicationContextMap.put(webModuleName, this); + } + + @Override + public void doStop() throws Exception { + webModuleNameJAXWSWebApplicationContextMap.remove(webModuleName); + } + + public static JAXWSWebApplicationContext get(String webModuleName) { + return webModuleNameJAXWSWebApplicationContextMap.get(webModuleName); + } +} Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/WSDLUtils.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/WSDLUtils.java?rev=1132647&r1=1132646&r2=1132647&view=diff ============================================================================== --- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/WSDLUtils.java (original) +++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/WSDLUtils.java Mon Jun 6 13:58:21 2011 @@ -14,12 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.geronimo.jaxws; import java.util.ArrayList; -import java.util.Iterator; +import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import javax.wsdl.Definition; import javax.wsdl.Port; @@ -35,94 +37,142 @@ import org.slf4j.LoggerFactory; public class WSDLUtils { private static final Logger LOG = LoggerFactory.getLogger(WSDLUtils.class); - - public static void trimDefinition(Definition def, - String serviceName, - String portName) { - Map services = def.getServices(); - if (services != null) { - ArrayList servicesToRemove = new ArrayList(services.size()); - - Iterator serviceIterator = services.entrySet().iterator(); - while (serviceIterator.hasNext()) { - Map.Entry serviceEntry = (Map.Entry) serviceIterator.next(); - QName currServiceName = (QName) serviceEntry.getKey(); - if (currServiceName.getLocalPart().equals(serviceName)) { - Service service = (Service) serviceEntry.getValue(); - trimService(service, portName); - } else { - servicesToRemove.add(currServiceName); - } - } - - for (QName serviceToRemove : servicesToRemove) { - def.removeService(serviceToRemove); - } - } - } - - public static void trimService(Service service, - String portName) { - Map ports = service.getPorts(); - if (ports != null) { - ArrayList portsToRemove = new ArrayList(ports.size()); - - Iterator portIterator = ports.entrySet().iterator(); - while (portIterator.hasNext()) { - Map.Entry portEntry = (Map.Entry) portIterator.next(); - String currPortName = (String) portEntry.getKey(); - if (!currPortName.equals(portName)) { - portsToRemove.add(currPortName); - } - } - - for (String portToRemove : portsToRemove) { - service.removePort(portToRemove); - } - } - } - - public static void updateLocations(Definition def, - String location) { - Map services = def.getServices(); - if (services != null) { - Iterator serviceIterator = services.entrySet().iterator(); - while (serviceIterator.hasNext()) { - Map.Entry serviceEntry = (Map.Entry) serviceIterator.next(); - Service service = (Service) serviceEntry.getValue(); - updateLocations(service, location); - } - } - } - - public static void updateLocations(Service service, - String location) { - boolean updated = false; - Map ports = service.getPorts(); - if (ports != null) { - Iterator portIterator = ports.entrySet().iterator(); - while (portIterator.hasNext()) { - Map.Entry portEntry = (Map.Entry) portIterator.next(); - Port port = (Port) portEntry.getValue(); + + public static void trimDefinition(Definition def, Map> servicePortNamesMap) { + @SuppressWarnings("unchecked") + Map services = def.getServices(); + if (services == null) { + return; + } + ArrayList servicesToRemove = new ArrayList(services.size()); + + for (Map.Entry serviceEntry : services.entrySet()) { + QName currServiceName = serviceEntry.getKey(); + if (servicePortNamesMap.containsKey(currServiceName)) { + Service service = serviceEntry.getValue(); + trimService(service, servicePortNamesMap.get(currServiceName)); + } else { + servicesToRemove.add(currServiceName); + } + } + + for (QName serviceToRemove : servicesToRemove) { + def.removeService(serviceToRemove); + } + } + + public static void trimDefinition(Definition def, String serviceName, String portName) { + @SuppressWarnings("unchecked") + Map services = def.getServices(); + if (services == null) { + return; + } + ArrayList servicesToRemove = new ArrayList(services.size()); + + for (Map.Entry serviceEntry : services.entrySet()) { + QName currServiceName = serviceEntry.getKey(); + if (currServiceName.getLocalPart().equals(serviceName)) { + Service service = serviceEntry.getValue(); + trimService(service, portName); + } else { + servicesToRemove.add(currServiceName); + } + } + + for (QName serviceToRemove : servicesToRemove) { + def.removeService(serviceToRemove); + } + } + + public static void trimService(Service service, String portName) { + trimService(service, Collections.singleton(portName)); + } + + public static void trimService(Service service, Set portName) { + @SuppressWarnings("unchecked") + Map ports = service.getPorts(); + if (ports == null) { + return; + } + ArrayList portsToRemove = new ArrayList(ports.size()); + for (Map.Entry portEntry : ports.entrySet()) { + String currPortName = portEntry.getKey(); + if (!portName.contains(currPortName)) { + portsToRemove.add(currPortName); + } + } + for (String portToRemove : portsToRemove) { + service.removePort(portToRemove); + } + } + + public static void updateLocations(Definition def, Map> servicePortNameLocationMap) { + @SuppressWarnings("unchecked") + Map services = def.getServices(); + if (services == null) { + return; + } + for (Map.Entry serviceEntry : services.entrySet()) { + Service service = serviceEntry.getValue(); + Map portNameLocationMap = servicePortNameLocationMap.get(service.getQName()); + if (portNameLocationMap != null) { + updateLocations(service, portNameLocationMap); + } + } + } + + public static void updateLocations(Service service, Map portNameLocationsMap) { + @SuppressWarnings("unchecked") + Map ports = service.getPorts(); + if (ports == null) { + return; + } + for (Map.Entry portEntry : ports.entrySet()) { + Port port = portEntry.getValue(); + String location = portNameLocationsMap.get(port.getName()); + if (location != null) { updateLocations(port, location); } } } - - public static void updateLocations(Port port, - String location) { + + public static void updateLocations(Definition def, String location) { + @SuppressWarnings("unchecked") + Map services = def.getServices(); + if (services == null) { + return; + } + for (Map.Entry serviceEntry : services.entrySet()) { + Service service = serviceEntry.getValue(); + updateLocations(service, location); + } + } + + public static void updateLocations(Service service, String location) { + @SuppressWarnings("unchecked") + Map ports = service.getPorts(); + if (ports == null) { + return; + } + for (Map.Entry portEntry : ports.entrySet()) { + Port port = portEntry.getValue(); + updateLocations(port, location); + } + } + + public static void updateLocations(Port port, String location) { List exts = port.getExtensibilityElements(); - if (exts != null) { - for (Object extension : exts) { - if (extension instanceof SOAP12Address) { - ((SOAP12Address)extension).setLocationURI(location); - } else if (extension instanceof SOAPAddress) { - ((SOAPAddress)extension).setLocationURI(location); - } else if (extension instanceof HTTPAddress) { - ((HTTPAddress)extension).setLocationURI(location); - } + if (exts == null) { + return; + } + for (Object extension : exts) { + if (extension instanceof SOAP12Address) { + ((SOAP12Address) extension).setLocationURI(location); + } else if (extension instanceof SOAPAddress) { + ((SOAPAddress) extension).setLocationURI(location); + } else if (extension instanceof HTTPAddress) { + ((HTTPAddress) extension).setLocationURI(location); } } } - }