You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by da...@apache.org on 2008/07/09 18:07:38 UTC
svn commit: r675243 - in
/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description:
builder/ impl/
Author: damrhei
Date: Wed Jul 9 09:07:37 2008
New Revision: 675243
URL: http://svn.apache.org/viewvc?rev=675243&view=rev
Log:
These changes will enable a single server-side DescriptionBuilderComposite to result
in multiple ServiceDescriptions being created. This allows multiple wsdl:services to
map to a single implementation class which could be the case when extra metadata, besides
annotations, is used to describe a web service.
Modified:
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderComposite.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/PortComposite.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderComposite.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderComposite.java?rev=675243&r1=675242&r2=675243&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderComposite.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderComposite.java Wed Jul 9 09:07:37 2008
@@ -40,9 +40,12 @@
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.WeakHashMap;
public class DescriptionBuilderComposite implements TMAnnotationComposite, TMFAnnotationComposite {
@@ -95,6 +98,14 @@
private List<Annotation> features;
+ private Map<QName, Definition> wsdlDefs = new HashMap<QName, Definition>();
+
+ private Map<QName, URL> wsdlURLs = new HashMap<QName, URL>();
+
+ private Set<QName> serviceQNames = new HashSet<QName>();
+
+ private Map<QName, List<PortComposite>> sQNameToPC = new HashMap<QName, List<PortComposite>>();
+
// Class information
private String className;
/**
@@ -745,6 +756,49 @@
public Map<String, Object> getProperties() {
return properties;
}
+
+ /**
+ * Store a WSDL Definition keyed by a service QName
+ */
+ public void setWsdlDefinition(QName serviceQName, Definition definition) {
+ this.wsdlDefs.put(serviceQName, definition);
+ }
+
+ /**
+ * Retrive a WSDL Definition by a service QName
+ */
+ public Definition getWsdlDefinition(QName serviceQName) {
+ return wsdlDefs.get(serviceQName);
+ }
+
+ /**
+ * Store a WSDL URL keyed by a service QName
+ */
+ public void setwsdlURL(QName serviceQName, URL url) {
+ wsdlURLs.put(serviceQName, url);
+ }
+
+ /**
+ * Retrive a WSDL URL by a service QName
+ */
+ public URL getWsdlURL(QName serviceQName) {
+ return wsdlURLs.get(serviceQName);
+ }
+
+ /**
+ * Add the set of wsdl:service QNames that are represented by this DBC's metadata
+ */
+ public void setServiceQNames(Set<QName> serviceQNames) {
+ this.serviceQNames = serviceQNames;
+ }
+
+ /**
+ * Get the set of wsdl:service QNames represented by this DBC's metadata
+ * @return
+ */
+ public Set<QName> getServiceQNames() {
+ return serviceQNames;
+ }
/**
@@ -929,12 +983,39 @@
return myConfigContext;
}
+ /**
+ * Adds a PortComposite to the generic list. This list of PortComposite objects
+ * is not keyed by wsdl:service QName.
+ */
public void addPortComposite(PortComposite portDBC) {
portCompositeList.add(portDBC);
}
+ /**
+ * Adds a PortComposite to a list that is keyed by a wsdl:service QName.
+ */
+ public void addPortComposite(QName serviceQName, PortComposite portDBC) {
+ List<PortComposite> pcList = sQNameToPC.get(serviceQName);
+ if(pcList == null) {
+ pcList = new LinkedList<PortComposite>();
+ sQNameToPC.put(serviceQName, pcList);
+ }
+ pcList.add(portDBC);
+ }
+
+ /**
+ * Gets the generic PortComposite instances.
+ */
public List<PortComposite> getPortComposites() {
return portCompositeList;
}
+ /**
+ * Gets all the PortComposite instances associated with a particular wsdl:service QName.
+ * @return
+ */
+ public List<PortComposite> getPortComposites(QName serviceQName) {
+ return sQNameToPC.get(serviceQName);
+ }
+
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/PortComposite.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/PortComposite.java?rev=675243&r1=675242&r2=675243&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/PortComposite.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/PortComposite.java Wed Jul 9 09:07:37 2008
@@ -19,14 +19,14 @@
package org.apache.axis2.jaxws.description.builder;
-import java.util.Iterator;
+import java.net.URL;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.wsdl.Definition;
import javax.xml.namespace.QName;
-import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.jaxws.catalog.JAXWSCatalogManager;
import org.apache.axis2.jaxws.description.xml.handler.HandlerChainsType;
@@ -69,7 +69,6 @@
public PortComposite(DescriptionBuilderComposite baseDBC) {
this.baseDBC = baseDBC;
- this.baseDBC.addPortComposite(this);
}
@@ -241,6 +240,30 @@
return baseDBC.getWsdlDefinition();
}
+ public Set<QName> getServiceQNames() {
+ return baseDBC.getServiceQNames();
+ }
+
+ public Definition getWsdlDefinition(QName serviceQName) {
+ return baseDBC.getWsdlDefinition(serviceQName);
+ }
+
+ public void setServiceQNames(Set<QName> serviceQNames) {
+ baseDBC.setServiceQNames(serviceQNames);
+ }
+
+ public void setWsdlDefinition(QName serviceQName, Definition definition) {
+ baseDBC.setWsdlDefinition(serviceQName, definition);
+ }
+
+ public void setwsdlURL(QName serviceQName, URL url) {
+ baseDBC.setwsdlURL(serviceQName, url);
+ }
+
+ public URL getWsdlURL(QName serviceQName) {
+ return baseDBC.getWsdlURL(serviceQName);
+ }
+
public String toString() {
StringBuffer sb = new StringBuffer();
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java?rev=675243&r1=675242&r2=675243&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java Wed Jul 9 09:07:37 2008
@@ -51,6 +51,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
/**
* Creates the JAX-WS metadata descritpion hierachy from some combinations of WSDL, Java classes
@@ -238,25 +239,68 @@
DescriptionBuilderComposite serviceImplComposite = nameIter.next();
if (isImpl(serviceImplComposite)) {
// process this impl class
- ServiceDescriptionImpl serviceDescription = new ServiceDescriptionImpl(
- dbcMap, serviceImplComposite, configContext);
- ServiceDescriptionValidator validator =
+
+ // the implementation class represented by this DBC represents a single wsdl:service
+ Set<QName> sQNames = serviceImplComposite.getServiceQNames();
+ if(sQNames == null
+ ||
+ sQNames.isEmpty()) {
+
+ if(log.isDebugEnabled()) {
+ log.debug("Adding ServiceDescription instances from composite");
+ }
+ ServiceDescriptionImpl serviceDescription = new ServiceDescriptionImpl(
+ dbcMap, serviceImplComposite, configContext);
+ ServiceDescriptionValidator validator =
new ServiceDescriptionValidator(serviceDescription);
- if (validator.validate()) {
- serviceDescriptionList.add(serviceDescription);
- if (log.isDebugEnabled()) {
- log.debug("Service Description created from DescriptionComposite: " +
- serviceDescription);
+ if (validator.validate()) {
+ serviceDescriptionList.add(serviceDescription);
+ if (log.isDebugEnabled()) {
+ log.debug("Service Description created from DescriptionComposite: " +
+ serviceDescription);
+ }
+ } else {
+
+ String msg = Messages.getMessage("createSrvcDescrDBCMapErr",
+ validator.toString(),
+ serviceImplComposite.toString(),
+ serviceDescription.toString());
+ throw ExceptionFactory.makeWebServiceException(msg);
}
- } else {
-
- String msg = Messages.getMessage("createSrvcDescrDBCMapErr",
- validator.toString(),
- serviceImplComposite.toString(),
- serviceDescription.toString());
- throw ExceptionFactory.makeWebServiceException(msg);
}
- } else {
+
+ // the implementation class represented by this DBC represents multiple wsdl:services
+ else {
+ Iterator<QName> sQNameIter = sQNames.iterator();
+ while(sQNameIter.hasNext()) {
+ QName sQName = sQNameIter.next();
+ if(log.isDebugEnabled()) {
+ log.debug("Adding ServiceDescription from service QName set for : " + sQName);
+ }
+ ServiceDescriptionImpl serviceDescription = new ServiceDescriptionImpl(dbcMap,
+ serviceImplComposite,
+ configContext,
+ sQName);
+ ServiceDescriptionValidator validator =
+ new ServiceDescriptionValidator(serviceDescription);
+ if (validator.validate()) {
+ serviceDescriptionList.add(serviceDescription);
+ if (log.isDebugEnabled()) {
+ log.debug("Service Description created from DescriptionComposite: " +
+ serviceDescription);
+ }
+ } else {
+
+ String msg = Messages.getMessage("createSrvcDescrDBCMapErr",
+ validator.toString(),
+ serviceImplComposite.toString(),
+ serviceDescription.toString());
+ throw ExceptionFactory.makeWebServiceException(msg);
+ }
+ }
+ }
+ }
+ else {
if (log.isDebugEnabled()) {
log.debug("DBC is not a service impl: " + serviceImplComposite.toString());
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java?rev=675243&r1=675242&r2=675243&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java Wed Jul 9 09:07:37 2008
@@ -318,7 +318,19 @@
this.parentServiceDescription = parent;
this.serviceImplName = serviceImplName;
- composite = getServiceDescriptionImpl().getDescriptionBuilderComposite(portCompositeIndex);
+ // if the ServiceDescription's service QName is specified, let's use that to get the
+ // correct DescriptionBuilderComposite
+ if(parent.getServiceQName() != null) {
+ composite = getServiceDescriptionImpl().getDescriptionBuilderComposite(parent.getServiceQName(),
+ portCompositeIndex);
+ }
+
+ // otherwise we will get the DescriptionBuilderComposite by the current index
+ else {
+ composite = getServiceDescriptionImpl().getDescriptionBuilderComposite(null,
+ portCompositeIndex);
+ }
+
if (composite == null) {
throw ExceptionFactory.makeWebServiceException(Messages.getMessage("endpointDescriptionErr3"));
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java?rev=675243&r1=675242&r2=675243&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java Wed Jul 9 09:07:37 2008
@@ -256,6 +256,12 @@
this(dbcMap, composite, null);
}
+ ServiceDescriptionImpl(HashMap<String, DescriptionBuilderComposite> dbcMap,
+ DescriptionBuilderComposite composite,
+ ConfigurationContext configContext) {
+ this(dbcMap, composite, configContext, null);
+ }
+
/**
* Create a service-provider side Service description hierachy. The hierachy is created entirely
* from composite. All relevant classes and interfaces referenced from the class represented by
@@ -266,7 +272,8 @@
ServiceDescriptionImpl(
HashMap<String, DescriptionBuilderComposite> dbcMap,
DescriptionBuilderComposite composite,
- ConfigurationContext configContext) {
+ ConfigurationContext configContext,
+ QName serviceQName) {
this.composite = composite;
this.configContext = configContext;
@@ -278,6 +285,21 @@
this.dbcMap = dbcMap;
this.isServerSide = true;
+ this.serviceQName = serviceQName;
+
+
+ // if the ServiceDescriptionImpl was constructed with a specific service QName
+ // we should use that to retrieve the potential list of PortComposite objects
+ List<PortComposite> portComposites = null;
+
+ if(this.serviceQName != null) {
+ portComposites = composite.getPortComposites(this.serviceQName);
+ }
+ else {
+ portComposites = composite.getPortComposites();
+ }
+
+
//capture the WSDL, if there is any...to be used for later processing
setupWsdlDefinition();
@@ -290,7 +312,7 @@
// It will be set by the EndpointDescriptionImpl since it is the one that knows
// how to process the annotations and the defaults.
- List<PortComposite> portComposites = composite.getPortComposites();
+
// If PortComposite instances were specified on the DBC we are currently processing
// we want to switch the context of processing to the PortComposites
@@ -729,7 +751,7 @@
}
public DescriptionBuilderComposite getDescriptionBuilderComposite() {
- return getDescriptionBuilderComposite(null);
+ return getDescriptionBuilderComposite(null, null);
}
/**
@@ -738,17 +760,38 @@
* then the indiciated PortComposite will be returned. Otherwise, the instance DBC
* will be returned.
*/
- public DescriptionBuilderComposite getDescriptionBuilderComposite(Integer portCompositeIndex) {
+ public DescriptionBuilderComposite getDescriptionBuilderComposite(QName serviceQName,
+ Integer portCompositeIndex) {
+
+ DescriptionBuilderComposite dbc = null;
+
+ // if the service QName was specified let's attempt to get the correct
+ // PortComposite list
+ if(serviceQName != null
+ &&
+ composite.getServiceQNames() != null
+ &&
+ !composite.getServiceQNames().isEmpty()
+ &&
+ portCompositeIndex != null) {
+ List<PortComposite> pcList = composite.getPortComposites(serviceQName);
+ if(pcList != null) {
+ dbc = pcList.get(portCompositeIndex);
+ }
+ else {
+ dbc = composite;
+ }
+ }
// ignore null values or values that would cause an IndexOutOfBoundsException
- if(portCompositeIndex == null
+ else if(portCompositeIndex == null
||
composite.getPortComposites() == null
||
portCompositeIndex < 0
||
portCompositeIndex >= composite.getPortComposites().size()) {
- return composite;
+ dbc = composite;
}
// return the appropriate PortComposite instance
@@ -757,8 +800,10 @@
log.debug("Returning PortComposite at index: " + portCompositeIndex +
" from ServiceDescriptionImpl: " + this.hashCode());
}
- return composite.getPortComposites().get(portCompositeIndex);
+ dbc = composite.getPortComposites().get(portCompositeIndex);
}
+
+ return dbc;
}
/* (non-Javadoc)
@@ -801,12 +846,40 @@
}
if (composite.isServiceProvider()) {
-
+
// Currently, there is a bug which allows the wsdlDefinition to be placed
// on either the impl class composite or the sei composite, or both. We need to
// look in both places and find the correct one, if it exists.
+
+ if(serviceQName != null
+ &&
+ composite.getWsdlDefinition(serviceQName) != null) {
+ if(log.isDebugEnabled()) {
+ log.debug("Found WSDL definition by service QName");
+ }
+ Definition def = composite.getWsdlDefinition(serviceQName);
+ URL url = composite.getWsdlURL(serviceQName);
+ this.wsdlURL = url != null ? url.toString() : null;
+ try {
+ if (log.isDebugEnabled() ) {
+ if (configContext != null) {
+ log.debug("new WSDL4JWrapper-ConfigContext not null1");
+ } else {
+ log.debug("new WSDL4JWrapper-ConfigContext null1");
+ }
+ }
- if (((composite.getWebServiceAnnot() != null) &&
+ this.wsdlWrapper = new WSDL4JWrapper(url,
+ def,
+ configContext,
+ this.catalogManager);
+ } catch (WSDLException e) {
+ throw ExceptionFactory.makeWebServiceException(
+ Messages.getMessage("wsdlException", e.getMessage()), e);
+ }
+ }
+
+ else if (((composite.getWebServiceAnnot() != null) &&
DescriptionUtils.isEmpty(composite.getWebServiceAnnot().endpointInterface()))
||
(!(composite.getWebServiceProviderAnnot() == null))) {
@@ -839,7 +912,7 @@
if(wsdlLocation != null
&&
!"".equals(wsdlLocation)) {
- setWSDLDefinitionOnDBC(wsdlLocation);
+ setWSDLDefinitionOnDBC(wsdlLocation);
}
}
@@ -880,6 +953,7 @@
this.catalogManager);
} else if (composite.getWsdlDefinition() != null) {
+
//set the wsdl def from the impl. class composite
if (log.isDebugEnabled()) {
log.debug("Get the wsdl definition from the impl class composite.");
@@ -909,7 +983,7 @@
}
wsdlLocation = seic.getWebServiceAnnot().wsdlLocation();
}
-
+
// now check the impl
if(wsdlLocation == null
||
@@ -926,8 +1000,9 @@
if (log.isDebugEnabled()) {
log.debug("wsdl location =" + wsdlLocation);
}
- this.wsdlURL = wsdlLocation;
- setWSDLDefinitionOnDBC(wsdlLocation);
+
+ this.wsdlURL = wsdlLocation;
+ setWSDLDefinitionOnDBC(wsdlLocation);
}
}
} catch (WSDLException e) {