You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ba...@apache.org on 2008/01/11 04:56:17 UTC
svn commit: r611042 [3/4] - in /webservices/axis2/trunk/java/modules:
jaxws/src/org/apache/axis2/jaxws/ jaxws/src/org/apache/axis2/jaxws/spi/
jaxws/test-resources/wsdl/ jaxws/test/org/apache/axis2/jaxws/description/
jaxws/test/org/apache/axis2/jaxws/sp...
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/WebServiceClientAnnot.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/WebServiceClientAnnot.java?rev=611042&r1=611041&r2=611042&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/WebServiceClientAnnot.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/WebServiceClientAnnot.java Thu Jan 10 19:56:14 2008
@@ -19,6 +19,8 @@
package org.apache.axis2.jaxws.description.builder;
+import org.apache.axis2.jaxws.ExceptionFactory;
+
import java.lang.annotation.Annotation;
public class WebServiceClientAnnot implements javax.xml.ws.WebServiceClient {
@@ -27,7 +29,6 @@
private String targetNamespace;
private String wsdlLocation;
-
/** A WebServiceClientAnnot cannot be instantiated. */
private WebServiceClientAnnot() {
@@ -56,6 +57,80 @@
wsdlLocation);
}
+ /**
+ * Create an instance of this annotation using the values from the annotation instance
+ * passed in.
+ *
+ * @param annotation Use the values to create a new instance of annotation. Note this could
+ * be an instance of the java annotation superclass as well.
+ * @return a new instance of this annotation or null if one could not be created with the
+ * annotation passed in.
+ */
+ public static WebServiceClientAnnot createFromAnnotation(Annotation annotation) {
+ WebServiceClientAnnot returnAnnot = null;
+ if (annotation != null && annotation instanceof javax.xml.ws.WebServiceClient) {
+ javax.xml.ws.WebServiceClient wsc = (javax.xml.ws.WebServiceClient) annotation;
+ returnAnnot = new WebServiceClientAnnot(wsc.name(),
+ wsc.targetNamespace(),
+ wsc.wsdlLocation());
+ }
+ return returnAnnot;
+ }
+
+ /**
+ * Create a new instance of this annotation using the values from the two annotations passed
+ * in as arguments. If either is null, the new annotation is created with the non-null
+ * annotation's values. If both are null, then no annotation is created. Non-empty values in
+ * the sparse annotation (if any) will override the values in the base annotation.
+ *
+ * @param baseAnnotation Initial values to be used in creating the annotation. May be null.
+ * @param sparseAnnotation Non-empty values (not null and not "") will override values in
+ * the base annotation.
+ * @return A new annotation created from the arguments, or null if one could not be created.
+ */
+ public static WebServiceClientAnnot createFromAnnotation(Annotation baseAnnotation,
+ Annotation sparseAnnotation) {
+ WebServiceClientAnnot returnAnnot = null;
+ javax.xml.ws.WebServiceClient baseWSCAnnotation = null;
+ javax.xml.ws.WebServiceClient sparseWSCAnnotation = null;
+
+ if (baseAnnotation != null && baseAnnotation instanceof javax.xml.ws.WebServiceClient) {
+ baseWSCAnnotation = (javax.xml.ws.WebServiceClient) baseAnnotation;
+ }
+
+ if (sparseAnnotation != null && sparseAnnotation instanceof javax.xml.ws.WebServiceClient) {
+ sparseWSCAnnotation = (javax.xml.ws.WebServiceClient) sparseAnnotation;
+ }
+
+ if (baseWSCAnnotation != null && sparseWSCAnnotation != null) {
+ // Both specified, create based on the base annotation merged with the sparse
+ // annotation
+ returnAnnot = WebServiceClientAnnot.createFromAnnotation(baseWSCAnnotation);
+ if (!DescriptionBuilderUtils.isEmpty(sparseWSCAnnotation.name())) {
+ returnAnnot.setName(sparseWSCAnnotation.name());
+ }
+ if (!DescriptionBuilderUtils.isEmpty(sparseWSCAnnotation.targetNamespace())) {
+ returnAnnot.setTargetNamespace(sparseWSCAnnotation.targetNamespace());
+ }
+ if (!DescriptionBuilderUtils.isEmpty(sparseWSCAnnotation.wsdlLocation())) {
+ returnAnnot.setWsdlLocation(sparseWSCAnnotation.wsdlLocation());
+ }
+ } else if (baseWSCAnnotation != null && sparseWSCAnnotation == null) {
+ // There's no sparse information, so just create from the base annotation
+ returnAnnot = WebServiceClientAnnot.createFromAnnotation(baseWSCAnnotation);
+ } else if (baseWSCAnnotation == null && sparseWSCAnnotation != null) {
+ // There's only sparse information, so create a new annotation based on that
+ returnAnnot = WebServiceClientAnnot.createFromAnnotation(sparseWSCAnnotation);
+ } else if (baseWSCAnnotation == null && sparseWSCAnnotation == null) {
+ // No anntotation specifed, so just return null which was initialized above
+ } else {
+ // This should never happen; all the cases are covered above
+ // TODO: (JLB) RAS/NLS
+ throw ExceptionFactory.makeWebServiceException("Programming error! annot = " + baseAnnotation + "; sparseAnnot = " + sparseAnnotation);
+ }
+
+ return returnAnnot;
+ }
/** @return Returns the name. */
public String name() {
@@ -108,5 +183,4 @@
sb.append(newLine);
return sb.toString();
}
-
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/WebServiceProviderAnnot.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/WebServiceProviderAnnot.java?rev=611042&r1=611041&r2=611042&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/WebServiceProviderAnnot.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/WebServiceProviderAnnot.java Thu Jan 10 19:56:14 2008
@@ -61,6 +61,20 @@
portName,
targetNamespace);
}
+
+ public static WebServiceProviderAnnot createFromAnnotation(Annotation annotation) {
+ WebServiceProviderAnnot returnAnnot = null;
+ if (annotation != null && annotation instanceof javax.xml.ws.WebServiceProvider) {
+ javax.xml.ws.WebServiceProvider wsp = (javax.xml.ws.WebServiceProvider) annotation;
+ returnAnnot = new WebServiceProviderAnnot(wsp.wsdlLocation(),
+ wsp.serviceName(),
+ wsp.portName(),
+ wsp.targetNamespace());
+
+ }
+
+ return returnAnnot;
+ }
/** @return Returns the portName. */
public String portName() {
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/WebServiceRefAnnot.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/WebServiceRefAnnot.java?rev=611042&r1=611041&r2=611042&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/WebServiceRefAnnot.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/WebServiceRefAnnot.java Thu Jan 10 19:56:14 2008
@@ -28,7 +28,8 @@
private Class type;
private Class value;
private String mappedName = "";
-
+
+ // TODO: (JLB) Remove the String versions of the Class attributes?
private String typeString = "";
private String valueString = "";
@@ -42,6 +43,20 @@
String wsdlLocation,
Class type,
Class value,
+ String mappedName) {
+ this.name = name;
+ this.wsdlLocation = wsdlLocation;
+ this.type = type;
+ this.value = value;
+ this.mappedName = mappedName;
+ }
+
+ // TODO: (JLB) Deprecate or remove this; has both Class and String for value and type
+ private WebServiceRefAnnot(
+ String name,
+ String wsdlLocation,
+ Class type,
+ Class value,
String mappedName,
String typeString,
String valueString) {
@@ -63,6 +78,25 @@
String wsdlLocation,
Class type,
Class value,
+ String mappedName) {
+ return new WebServiceRefAnnot(name,
+ wsdlLocation,
+ type,
+ value,
+ mappedName);
+ }
+
+ // TODO: (JLB) Why is there both a class and String for type and value?
+ // There isn't on the actual annotation, only the class is there
+ // Looks like SERV1/ws/code/websvcs/src/com/ibm/ws/websvcs/annotations/adapters/WebServiceRefAdapter.java
+ // only reference in WAS to the string "createWebServiceRefAnnotImpl", and it sets the String values, not the classes
+ // Check with Dustin, can they give us the class (instead of string) since we may not have the right classloader
+ // to create the class when the getter is called.
+ public static WebServiceRefAnnot createWebServiceRefAnnotImpl(
+ String name,
+ String wsdlLocation,
+ Class type,
+ Class value,
String mappedName,
String typeString,
String valueString
@@ -102,11 +136,13 @@
return wsdlLocation;
}
+ // TODO: (JLB) Remove this?
/** @return Returns the typeString. */
public String getTypeString() {
return typeString;
}
+ // TODO: (JLB) Remove this?
/** @return Returns the valueString. */
public String getValueString() {
return valueString;
@@ -142,11 +178,13 @@
return wsdlLocation;
}
+ // TODO: (JLB) Remove this?
/** @param typeString The typeString to set. */
public void setTypeString(String typeString) {
this.typeString = typeString;
}
+ // TODO: (JLB) Remove this?
/** @param valueString The valueString to set. */
public void setValueString(String valueString) {
this.valueString = valueString;
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=611042&r1=611041&r2=611042&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 Thu Jan 10 19:56:14 2008
@@ -66,12 +66,24 @@
}
/**
+ * @see org.apache.axis2.jaxws.description.DescriptionFactory#createServiceDescription(URL, QName, Class, DescriptionBuilderComposite)
+ */
+ public static ServiceDescription createServiceDescription(URL wsdlURL,
+ QName serviceQName,
+ Class serviceClass) {
+ return createServiceDescription(wsdlURL, serviceQName, serviceClass, null, null);
+
+ }
+
+ /**
* @see org.apache.axis2.jaxws.description.DescriptionFactory#createServiceDescription(URL,
* QName, Class)
*/
public static ServiceDescription createServiceDescription(URL wsdlURL,
QName serviceQName,
- Class serviceClass) {
+ Class serviceClass,
+ DescriptionBuilderComposite sparseComposite,
+ Object sparseCompositeKey) {
ConfigurationContext configContext = DescriptionFactory.createClientConfigurationFactory()
.getClientConfigurationContext();
DescriptionKey key = new DescriptionKey(serviceQName, wsdlURL, serviceClass, configContext);
@@ -99,7 +111,21 @@
log.debug(" creating new ServiceDescriptionImpl");
}
- ServiceDescriptionImpl serviceDescImpl = new ServiceDescriptionImpl(wsdlURL, serviceQName, serviceClass);
+ ServiceDescriptionImpl serviceDescImpl = null;
+ if (sparseComposite != null) {
+ serviceDescImpl = new ServiceDescriptionImpl(wsdlURL, serviceQName,
+ serviceClass, sparseComposite,
+ sparseCompositeKey);
+ if (log.isDebugEnabled()) {
+ log.debug("Client-side service description created with service class: " + serviceClass
+ + ", Service QN: " + serviceQName
+ + ", and DBC: " + sparseComposite);
+ log.debug(serviceDesc.toString());
+ }
+
+ } else {
+ serviceDescImpl = new ServiceDescriptionImpl(wsdlURL, serviceQName, serviceClass);
+ }
serviceDescImpl.setAxisConfigContext(configContext);
serviceDesc = serviceDescImpl;
@@ -112,6 +138,11 @@
log.debug("Caching new ServiceDescription in the cache");
}
cache.put(key, serviceDesc);
+ } else {
+ // A service description was found in the cache. If a sparse composite was
+ // specified, then set it on the found service desc
+ ((ServiceDescriptionImpl) serviceDesc).getDescriptionBuilderComposite().
+ setSparseComposite(sparseCompositeKey, sparseComposite);
}
}
return serviceDesc;
@@ -254,11 +285,22 @@
public static EndpointDescription updateEndpoint(
ServiceDescription serviceDescription, Class sei, QName portQName,
DescriptionFactory.UpdateType updateType) {
+ return updateEndpoint(serviceDescription, sei, portQName, updateType, null, null);
+ }
+
+ /**
+ * @see org.apache.axis2.jaxws.description.DescriptionFactory#updateEndpoint(ServiceDescription, Class, QName, org.apache.axis2.jaxws.description.DescriptionFactory.UpdateType, DescriptionBuilderComposite)
+ */
+ public static EndpointDescription updateEndpoint(
+ ServiceDescription serviceDescription, Class sei, QName portQName,
+ DescriptionFactory.UpdateType updateType,
+ DescriptionBuilderComposite composite,
+ Object compositeKey) {
EndpointDescription endpointDesc = null;
synchronized(serviceDescription) {
endpointDesc =
((ServiceDescriptionImpl)serviceDescription)
- .updateEndpointDescription(sei, portQName, updateType);
+ .updateEndpointDescription(sei, portQName, updateType, composite, compositeKey);
}
EndpointDescriptionValidator endpointValidator = new EndpointDescriptionValidator(endpointDesc);
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionUtils.java?rev=611042&r1=611041&r2=611042&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionUtils.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionUtils.java Thu Jan 10 19:56:14 2008
@@ -145,25 +145,6 @@
}
/**
- * Return the name of the class without any package qualifier. This method should be DEPRECATED
- * when DBC support is complete
- *
- * @param theClass
- * @return the name of the class sans package qualification.
- */
- static String getSimpleJavaClassName(Class theClass) {
- String returnName = null;
- if (theClass != null) {
- String fqName = theClass.getName();
- // We need the "simple name", so strip off any package information from the name
- int endOfPackageIndex = fqName.lastIndexOf('.');
- int startOfClassIndex = endOfPackageIndex + 1;
- returnName = fqName.substring(startOfClassIndex);
- }
- return returnName;
- }
-
- /**
* Return the name of the class without any package qualifier.
*
* @param theClass
@@ -181,26 +162,6 @@
returnName = fqName.substring(startOfClassIndex);
}
return returnName;
- }
-
- /**
- * Returns the package name from the class. If no package, then returns null This method should
- * be DEPRECATED when DBC support is complete
- *
- * @param theClass
- * @return
- */
- static String getJavaPackageName(Class theClass) {
- String returnPackage = null;
- if (theClass != null) {
- String fqName = theClass.getName();
- // Get the package name, if there is one
- int endOfPackageIndex = fqName.lastIndexOf('.');
- if (endOfPackageIndex >= 0) {
- returnPackage = fqName.substring(0, endOfPackageIndex);
- }
- }
- return returnPackage;
}
/**
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=611042&r1=611041&r2=611042&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 Thu Jan 10 19:56:14 2008
@@ -106,12 +106,6 @@
// it will NOT be set for a Provider-based implementation
private EndpointInterfaceDescription endpointInterfaceDescription;
- // This can be an SEI (on the client or server) or a Service implentation (server only)
- // Note that for clients that are Dispatch, this will be null. Also note that a client that was initially
- // dispatch (sei = null) could later do a getPort(sei), at which time the original EndpointDescription will be
- // updated with the SEI information.
- private Class implOrSEIClass;
-
//On Client side, there should be One ServiceClient instance per AxisSerivce
private ServiceClient serviceClient = null;
@@ -178,7 +172,8 @@
private Map<String, CustomAnnotationProcessor> customAnnotationProcessors;
/**
- * Create an EndpointDescription based on the WSDL port. Note that per the JAX-WS Spec (Final
+ * Create a service-requester side EndpointDescription based on the WSDL port.
+ * Note that per the JAX-WS Spec (Final
* Release, 4/19/2006 Section 4.2.3 Proxies, page 55)the "namespace component of the port is the
* target namespace of the WSDL definition document". Note this is currently only used on the
* client-side (this may change).
@@ -187,23 +182,41 @@
* don't use an SEI
*/
EndpointDescriptionImpl(Class theClass, QName portName, ServiceDescriptionImpl parent) {
- this(theClass, portName, false, parent);
+ this(theClass, portName, parent, null, null);
+ }
+ EndpointDescriptionImpl(Class theClass, QName portName, ServiceDescriptionImpl parent,
+ DescriptionBuilderComposite dbc, Object compositeKey ) {
+ this(theClass, portName, false, parent, dbc, compositeKey);
}
-
EndpointDescriptionImpl(Class theClass, QName portName, boolean dynamicPort,
ServiceDescriptionImpl parent) {
-
+ this(theClass, portName, dynamicPort, parent, null, null);
+ }
+
+ EndpointDescriptionImpl(Class theClass, QName portName, boolean dynamicPort,
+ ServiceDescriptionImpl parent,
+ DescriptionBuilderComposite sparseComposite,
+ Object sparseCompositeKey) {
+
// TODO: This and the other constructor will (eventually) take the same args, so the logic needs to be combined
// TODO: If there is WSDL, could compare the namespace of the defn against the portQName.namespace
this.parentServiceDescription = parent;
- this.implOrSEIClass = theClass;
+ composite = new DescriptionBuilderComposite();
+ composite.setSparseComposite(sparseCompositeKey, sparseComposite);
+ composite.setCorrespondingClass(theClass);
+ composite.setClassLoader(this.getClass().getClassLoader());
+ composite.setIsServiceProvider(false);
// REVIEW: setting these should probably be done in the getters! It needs to be done before we try to select a
// port to use if one wasn't specified because we'll try to get to the annotations to get the PortType
- if (this.implOrSEIClass != null) {
- webServiceAnnotation = (WebService)getAnnotation(implOrSEIClass,WebService.class);
- webServiceProviderAnnotation =
- (WebServiceProvider)getAnnotation(implOrSEIClass,WebServiceProvider.class);
- }
+ // TODO: (JLB) REmove commented out code
+// if (this.implOrSEIClass != null) {
+// webServiceAnnotation = (WebService)getAnnotation(implOrSEIClass,WebService.class);
+// // TODO: (JLB) Seems like the provider annotation is only for the deprecated service construction and can be removed
+// webServiceProviderAnnotation =
+// (WebServiceProvider)getAnnotation(implOrSEIClass,WebServiceProvider.class);
+// }
+ webServiceAnnotation = composite.getWebServiceAnnot();
+
this.isDynamicPort = dynamicPort;
if (DescriptionUtils.isEmpty(portName)) {
// If the port name is null, then per JAX-WS 2.0 spec p. 55, the runtime is responsible for selecting the port.
@@ -238,7 +251,8 @@
}
/**
- * Create an EndpointDescription based on the DescriptionBuilderComposite. Note that per the
+ * Create a service-provider side EndpointDescription based on the DescriptionBuilderComposite.
+ * Note that per the
* JAX-WS Spec (Final Release, 4/19/2006 Section 4.2.3 Proxies, page 55)the "namespace component
* of the port is the target namespace of the WSDL definition document".
*
@@ -256,8 +270,6 @@
// TODO: If there is WSDL, could compare the namespace of the defn against the portQName.namespace
this.parentServiceDescription = parent;
this.serviceImplName = serviceImplName;
- this.implOrSEIClass = null;
-
composite = getServiceDescriptionImpl().getDescriptionBuilderComposite();
if (composite == null) {
@@ -470,18 +482,24 @@
}
/**
- * Create from an annotated implementation or SEI class. Note this is
+ * Create a service-provider side EndpointDescription from an annotated implementation class. Note this is
* currently used only on the server-side (this probably won't change).
*
* @param theClass An implemntation or SEI class
* @param portName May be null; if so the annotation is used
* @param parent
+ *
+ * @deprecated
*/
EndpointDescriptionImpl(Class theClass, QName portName, AxisService axisService,
ServiceDescriptionImpl parent) {
this.parentServiceDescription = parent;
+ composite = new DescriptionBuilderComposite();
+ composite.setIsDeprecatedServiceProviderConstruction(true);
+ composite.setIsServiceProvider(true);
this.portQName = portName;
- this.implOrSEIClass = theClass;
+ composite.setCorrespondingClass(theClass);
+ composite.setClassLoader(this.getClass().getClassLoader());
this.axisService = axisService;
addToAxisService();
@@ -529,17 +547,16 @@
// Verify that one (and only one) of the required annotations is present.
// TODO: Add tests to verify this error checking
+ if (composite.isDeprecatedServiceProviderConstruction()) {
+// if (!getServiceDescriptionImpl().isDBCMap()) {
- if (!getServiceDescriptionImpl().isDBCMap()) {
-
- webServiceAnnotation = (WebService)getAnnotation(implOrSEIClass,WebService.class);
- webServiceProviderAnnotation =
- (WebServiceProvider)getAnnotation(implOrSEIClass,WebServiceProvider.class);
+ webServiceAnnotation = composite.getWebServiceAnnot();
+ webServiceProviderAnnotation = composite.getWebServiceProviderAnnot();
if (webServiceAnnotation == null && webServiceProviderAnnotation == null)
- throw ExceptionFactory.makeWebServiceException(Messages.getMessage("endpointDescriptionErr6",implOrSEIClass.getName()));
+ throw ExceptionFactory.makeWebServiceException(Messages.getMessage("endpointDescriptionErr6",composite.getClassName()));
else if (webServiceAnnotation != null && webServiceProviderAnnotation != null)
- throw ExceptionFactory.makeWebServiceException(Messages.getMessage("endpointDescriptionErr7",implOrSEIClass.getName()));
+ throw ExceptionFactory.makeWebServiceException(Messages.getMessage("endpointDescriptionErr7",composite.getClassName()));
}
// If portName was specified, set it. Otherwise, we will get it from the appropriate
// annotation when the getter is called.
@@ -557,14 +574,18 @@
// that this is also called with just an SEI interface from svcDesc.updateWithSEI()
String seiClassName = getAnnoWebServiceEndpointInterface();
- if (!getServiceDescriptionImpl().isDBCMap()) {
+ if (composite.isDeprecatedServiceProviderConstruction()
+ || !composite.isServiceProvider()) {
+// if (!getServiceDescriptionImpl().isDBCMap()) {
Class seiClass = null;
if (DescriptionUtils.isEmpty(seiClassName)) {
+ // TODO: (JLB) This is the client code path; the @WebServce will not have an endpointInterface member
// For now, just build the EndpointInterfaceDesc based on the class itself.
// TODO: The EID ctor doesn't correctly handle anything but an SEI at this
// point; e.g. it doesn't publish the correct methods of just an impl.
- seiClass = implOrSEIClass;
+ seiClass = composite.getCorrespondingClass();
} else {
+ // TODO: (JLB) This is the deprecated server-side introspection code for an impl that references an SEI
try {
// TODO: Using Class forName() is probably not the best long-term way to get the SEI class from the annotation
seiClass = ClassLoaderUtils.forName(seiClassName, false,
@@ -660,7 +681,7 @@
return isDynamicPort;
}
- void updateWithSEI(Class sei) {
+ void updateWithSEI(Class sei, DescriptionBuilderComposite sparseComposite, Object sparseCompositeKey) {
// Updating with an SEI is only valid for declared ports; it is not valid for dynamic ports.
if (isDynamicPort()) {
throw ExceptionFactory.makeWebServiceException(Messages.getMessage("updateWithSEIErr1",portQName.toString()));
@@ -668,6 +689,8 @@
if (sei == null) {
throw ExceptionFactory.makeWebServiceException(Messages.getMessage("updateWithSEIErr2",portQName.toString()));
}
+
+ composite.setSparseComposite(sparseCompositeKey, sparseComposite);
if (endpointInterfaceDescription != null) {
// The EndpointInterfaceDescription was created previously based on the port declaration (i.e. WSDL)
@@ -722,7 +745,7 @@
// Store the sei class fully qualified name, if it is available
Parameter seiClassNameParam = new Parameter();
seiClassNameParam.setName(MDQConstants.CLIENT_SEI_CLASS);
- String seiClassName = implOrSEIClass != null ? implOrSEIClass.getName() : null;
+ String seiClassName = composite.getClassName();
if(log.isDebugEnabled()) {
log.debug("Setting sei class name parameter to: " + seiClassName +
" on AxisService: " + axisService + "@" + axisService.hashCode());
@@ -821,7 +844,8 @@
log.debug("Building AxisService from wsdl: " + getServiceDescriptionImpl().getWSDLWrapper().getWSDLLocation());
}
- if (getServiceDescriptionImpl().isDBCMap()) {
+ if (composite.isServiceProvider()) {
+// if (getServiceDescriptionImpl().isDBCMap()) {
//this.class.getClass().getClassLoader();
URIResolverImpl uriResolver =
new URIResolverImpl(composite.getClassLoader());
@@ -854,12 +878,7 @@
// Note that if we choose to fail, we need to distinguish the partial WSDL case (which can not fail)
String wsdlLocation = (getServiceDescriptionImpl().getWSDLLocation() != null) ?
getServiceDescriptionImpl().getWSDLLocation().toString() : null;
- String implClassName = null;
- if (getServiceDescriptionImpl().isDBCMap()) {
- implClassName = composite.getClassName();
- } else {
- implClassName = (implOrSEIClass != null) ? implOrSEIClass.getName() : null;
- }
+ String implClassName = composite.getClassName();
log.warn(Messages.getMessage("bldAxisSrvcFromWSDLErr",implClassName,wsdlLocation),e);
isBuiltFromWSDL = false;
@@ -892,7 +911,8 @@
//First, check to see if we can build this with the DBC List
//TODO: When MDQ input is the only possible input, then we can remove the check for
// the DBC list, until that time the code in here may appear somewhat redundant
- if (getServiceDescriptionImpl().isDBCMap()) {
+ // TODO: (JLB) Can this logic be combined?
+ if (composite.isServiceProvider()) {
if (!isDynamicPort && isWSDLFullySpecified())
buildEndpointDescriptionFromWSDL();
else
@@ -902,7 +922,7 @@
// This path was not updated
if (!isDynamicPort && isWSDLFullySpecified()) {
buildEndpointDescriptionFromWSDL();
- } else if (implOrSEIClass != null) {
+ } else if (composite.getCorrespondingClass() != null) {
// Create the rest of the description hierachy from annotations on the class.
// If there is no SEI class, then this is a Distpach case, and we currently
// don't create the rest of the description hierachy (since it is not an SEI and thus
@@ -933,7 +953,7 @@
// Build the EndpointInterface based on the specified SEI if there is one
// or on the service impl class (i.e. an implicit SEI).
- if (getServiceDescriptionImpl().isDBCMap()) {
+ if (composite.isServiceProvider()) {
String seiClassName = getAnnoWebServiceEndpointInterface();
if (DescriptionUtils.isEmpty(seiClassName)) {
// No SEI specified, so use the service impl as an implicit SEI
@@ -954,7 +974,7 @@
// Update the EndpointInterfaceDescription created with WSDL with information from the
// annotations in the SEI
((EndpointInterfaceDescriptionImpl)endpointInterfaceDescription)
- .updateWithSEI(implOrSEIClass);
+ .updateWithSEI(composite.getCorrespondingClass());
}
wsdlPortFound = true;
}
@@ -1040,7 +1060,7 @@
annotation_WsdlLocation = getAnnoWebService().wsdlLocation();
//If this is not an implicit SEI, then make sure that its not on the SEI
- if (getServiceDescriptionImpl().isDBCMap()) {
+ if (composite.isServiceProvider() && !composite.isDeprecatedServiceProviderConstruction()) {
if (!DescriptionUtils.isEmpty(getAnnoWebServiceEndpointInterface())) {
DescriptionBuilderComposite seic =
@@ -1073,13 +1093,7 @@
} else {
// Default value is the "simple name" of the class or interface + "Service"
// Per JSR-181 MR Sec 4.1, pg 15
- if (getServiceDescriptionImpl().isDBCMap()) {
- annotation_ServiceName = DescriptionUtils
- .getSimpleJavaClassName(composite.getClassName()) + "Service";
- } else {
- annotation_ServiceName =
- DescriptionUtils.getSimpleJavaClassName(implOrSEIClass) + "Service";
- }
+ annotation_ServiceName = DescriptionUtils.getSimpleJavaClassName(composite.getClassName()) + "Service";
}
}
return annotation_ServiceName;
@@ -1104,11 +1118,8 @@
// Note that this is really the same thing as the call to getWebServiceName()
// in the WebService case; it is done sepertely just to be clear there is no
// name element on the WebServiceProvider annotation
-
- annotation_PortName = (getServiceDescriptionImpl().isDBCMap()) ?
- DescriptionUtils.getSimpleJavaClassName(composite.getClassName()) +
- "Port"
- : DescriptionUtils.getSimpleJavaClassName(implOrSEIClass) + "Port";
+ annotation_PortName = DescriptionUtils.getSimpleJavaClassName(composite.getClassName())
+ + "Port";
} else {
// This is the @WebService annotation path
// Default value is the @WebService.name of the class or interface + "Port"
@@ -1132,16 +1143,10 @@
// Default value per JSR-181 MR Sec 4.1 pg 15 defers to "Implementation defined,
// as described in JAX-WS 2.0, section 3.2" which is JAX-WS 2.0 Sec 3.2, pg 29.
// FIXME: Hardcoded protocol for namespace
- if (getServiceDescriptionImpl().isDBCMap())
- annotation_TargetNamespace =
- DescriptionUtils.makeNamespaceFromPackageName(
- DescriptionUtils.getJavaPackageName(composite.getClassName()),
- "http");
- else
- annotation_TargetNamespace =
- DescriptionUtils.makeNamespaceFromPackageName(
- DescriptionUtils.getJavaPackageName(implOrSEIClass), "http");
-
+ annotation_TargetNamespace =
+ DescriptionUtils.makeNamespaceFromPackageName(
+ DescriptionUtils.getJavaPackageName(composite.getClassName()),
+ "http");
}
}
return annotation_TargetNamespace;
@@ -1196,14 +1201,8 @@
&& !DescriptionUtils.isEmpty(getAnnoWebService().name())) {
webService_Name = getAnnoWebService().name();
} else {
- if (getServiceDescriptionImpl().isDBCMap()) {
- //The name is the simple name of the class or interface
- webService_Name =
- DescriptionUtils.getSimpleJavaClassName(composite.getClassName());
- } else {
- // Default per JSR-181 Sec 4.1, pg 15
- webService_Name = DescriptionUtils.getSimpleJavaClassName(implOrSEIClass);
- }
+ webService_Name =
+ DescriptionUtils.getSimpleJavaClassName(composite.getClassName());
}
} else {
// This element is not valid on a WebServiceProvider annotation
@@ -1221,14 +1220,7 @@
public ServiceMode getAnnoServiceMode() {
if (serviceModeAnnotation == null) {
- if (getServiceDescriptionImpl().isDBCMap()) {
- serviceModeAnnotation = composite.getServiceModeAnnot();
- } else {
- if (implOrSEIClass != null) {
- serviceModeAnnotation =
- (ServiceMode)getAnnotation(implOrSEIClass,ServiceMode.class);
- }
- }
+ serviceModeAnnotation = composite.getServiceModeAnnot();
}
return serviceModeAnnotation;
}
@@ -1256,14 +1248,7 @@
public BindingType getAnnoBindingType() {
if (bindingTypeAnnotation == null) {
- if (getServiceDescriptionImpl().isDBCMap()) {
- bindingTypeAnnotation = composite.getBindingTypeAnnot();
- } else {
- if (implOrSEIClass != null) {
- bindingTypeAnnotation =
- (BindingType)getAnnotation(implOrSEIClass,BindingType.class);
- }
- }
+ bindingTypeAnnotation = composite.getBindingTypeAnnot();
}
return bindingTypeAnnotation;
}
@@ -1310,10 +1295,10 @@
log.debug(Messages.getMessage("handlerChainsTypeErr",handlerFileName,composite.getClassName()));
}
- String className = getServiceDescriptionImpl().isDBCMap() ?
- composite.getClassName() : implOrSEIClass.getName();
+ String className = composite.getClassName();
- ClassLoader classLoader = getServiceDescriptionImpl().isDBCMap() ?
+ // TODO: (JLB) This is using the classloader for EndpointDescriptionImpl; is that OK?
+ ClassLoader classLoader = (composite.isServiceProvider() && !composite.isDeprecatedServiceProviderConstruction()) ?
composite.getClassLoader() : this.getClass().getClassLoader();
InputStream is = DescriptionUtils.openHandlerConfigStream(
@@ -1342,7 +1327,8 @@
public HandlerChain getAnnoHandlerChainAnnotation() {
if (this.handlerChainAnnotation == null) {
- if (getServiceDescriptionImpl().isDBCMap()) {
+ if (composite.isServiceProvider() && !composite.isDeprecatedServiceProviderConstruction()) {
+// if (getServiceDescriptionImpl().isDBCMap()) {
/*
* Per JSR-181 The @HandlerChain annotation MAY be present on
* the endpoint interface and service implementation bean. The
@@ -1369,10 +1355,7 @@
}
}
} else {
- if (implOrSEIClass != null) {
- handlerChainAnnotation =
- (HandlerChain)getAnnotation(implOrSEIClass,HandlerChain.class);
- }
+ handlerChainAnnotation = composite.getHandlerChainAnnot();
}
}
@@ -1737,6 +1720,10 @@
return customAnnotationProcessors != null ?
customAnnotationProcessors.get(annotationInstanceClassName) : null;
}
+
+ public DescriptionBuilderComposite getDescriptionBuilderComposite() {
+ return composite;
+ }
public String toString() {
final String newline = "\n";
@@ -1788,20 +1775,6 @@
return string.toString();
}
return string.toString();
- }
-
- /**
- * Get an annotation. This is wrappered to avoid a Java2Security violation.
- * @param cls Class that contains annotation
- * @param annotation Class of requrested Annotation
- * @return annotation or null
- */
- private static Annotation getAnnotation(final Class cls, final Class annotation) {
- return (Annotation) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return cls.getAnnotation(annotation);
- }
- });
}
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java?rev=611042&r1=611041&r2=611042&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java Thu Jan 10 19:56:14 2008
@@ -68,7 +68,8 @@
private Map<QName, List<OperationDescription>> dispatchableOperations = new HashMap<QName, List<OperationDescription>>();
// This may be an actual Service Endpoint Interface -OR- it may be a service implementation class that did not
// specify an @WebService.endpointInterface.
- private Class seiClass;
+ // TODO: (JLB) Remove commented out code
+// private Class seiClass;
private DescriptionBuilderComposite dbc;
//Logging setup
@@ -114,27 +115,38 @@
}
}
+ /**
+ * Construct a service requester (aka client-side) EndpointInterfaceDescription for the
+ * given SEI class. This constructor is used if hierachy is being built fully from annotations
+ * and not WSDL.
+ * @param sei
+ * @param parent
+ */
EndpointInterfaceDescriptionImpl(Class sei, EndpointDescriptionImpl parent) {
- seiClass = sei;
parentEndpointDescription = parent;
+ dbc = new DescriptionBuilderComposite();
+ dbc.setCorrespondingClass(sei);
// Per JSR-181 all methods on the SEI are mapped to operations regardless
// of whether they include an @WebMethod annotation. That annotation may
// be present to customize the mapping, but is not required (p14)
- // TODO: Testcases that do and do not include @WebMethod anno
- for (Method method : getSEIMethods(seiClass)) {
+ for (Method method : getSEIMethods(dbc.getCorrespondingClass())) {
OperationDescription operation = new OperationDescriptionImpl(method, this);
addOperation(operation);
}
}
/**
- * Build from AxisService
+ * Construct a service requester (aka client-side) EndpointInterfaceDescrption for
+ * an SEI represented by an AxisService. This constructor is used if the hierachy is
+ * being built fully from WSDL. The AxisService and underlying AxisOperations were built
+ * based on the WSDL, so we will use them to create the necessary objects.
*
* @param parent
*/
EndpointInterfaceDescriptionImpl(EndpointDescriptionImpl parent) {
parentEndpointDescription = parent;
+ dbc = new DescriptionBuilderComposite();
AxisService axisService = parentEndpointDescription.getAxisService();
if (axisService != null) {
ArrayList publishedOperations = axisService.getPublishedOperations();
@@ -207,8 +219,6 @@
// of whether they include an @WebMethod annotation. That annotation may
// be present to customize the mapping, but is not required (p14)
- // TODO: Testcases that do and do not include @WebMethod anno
-
//We are processing the SEI composite
//For every MethodDescriptionComposite in this list, call OperationDescription
//constructor for it, then add this operation
@@ -300,13 +310,17 @@
* @param sei
*/
void updateWithSEI(Class sei) {
- if (seiClass != null && seiClass != sei)
- throw ExceptionFactory.makeWebServiceException(new UnsupportedOperationException(Messages.getMessage("seiProcessingErr")));
- else if (seiClass != null && seiClass == sei)
+ Class seiClass = dbc.getCorrespondingClass();
+ if (seiClass != null && seiClass != sei) {
+ throw ExceptionFactory.makeWebServiceException(new UnsupportedOperationException(Messages.getMessage("seiProcessingErr")));
+ }
+ else if (seiClass != null && seiClass == sei) {
// We've already done the necessary updates for this SEI
return;
+ }
else if (sei != null) {
seiClass = sei;
+ dbc.setCorrespondingClass(sei);
// Update (or possibly add) the OperationDescription for each of the methods on the SEI.
for (Method seiMethod : getSEIMethods(seiClass)) {
@@ -537,7 +551,7 @@
}
public Class getSEIClass() {
- return seiClass;
+ return dbc.getCorrespondingClass();
}
// Annotation-realted getters
@@ -548,20 +562,12 @@
// TODO: Test with sei Null, not null, SOAP Binding annotated, not annotated
if (soapBindingAnnotation == null) {
- if (dbc != null) {
- soapBindingAnnotation = dbc.getSoapBindingAnnot();
- } else {
- if (seiClass != null) {
- soapBindingAnnotation =
- (SOAPBinding)getAnnotation(seiClass,SOAPBinding.class);
- }
- }
+ soapBindingAnnotation = dbc.getSoapBindingAnnot();
}
return soapBindingAnnotation;
}
public javax.jws.soap.SOAPBinding.Style getSoapBindingStyle() {
- // REVIEW: Implement WSDL/Anno merge
return getAnnoSoapBindingStyle();
}
@@ -577,7 +583,6 @@
}
public javax.jws.soap.SOAPBinding.Use getSoapBindingUse() {
- // REVIEW: Implement WSDL/Anno merge
return getAnnoSoapBindingUse();
}
@@ -593,7 +598,6 @@
}
public javax.jws.soap.SOAPBinding.ParameterStyle getSoapBindingParameterStyle() {
- // REVIEW: Implement WSDL/Anno merge
return getAnnoSoapBindingParameterStyle();
}
@@ -913,20 +917,12 @@
public String getTargetNamespace() {
- // REVIEW: WSDL/Anno mertge
return getAnnoWebServiceTargetNamespace();
}
public WebService getAnnoWebService() {
- // TODO Auto-generated method stub
if (webServiceAnnotation == null) {
- if (dbc != null) {
- webServiceAnnotation = dbc.getWebServiceAnnot();
- } else {
- if (seiClass != null) {
- webServiceAnnotation = (WebService)getAnnotation(seiClass,WebService.class);
- }
- }
+ webServiceAnnotation = dbc.getWebServiceAnnot();
}
return webServiceAnnotation;
}
@@ -940,16 +936,10 @@
// Default value per JSR-181 MR Sec 4.1 pg 15 defers to "Implementation defined,
// as described in JAX-WS 2.0, section 3.2" which is JAX-WS 2.0 Sec 3.2, pg 29.
// FIXME: Hardcoded protocol for namespace
- if (dbc != null)
- webServiceTargetNamespace =
- DescriptionUtils.makeNamespaceFromPackageName(
- DescriptionUtils.getJavaPackageName(dbc.getClassName()),
- "http");
- else
- webServiceTargetNamespace =
- DescriptionUtils.makeNamespaceFromPackageName(
- DescriptionUtils.getJavaPackageName(seiClass), "http");
-
+ webServiceTargetNamespace =
+ DescriptionUtils.makeNamespaceFromPackageName(
+ DescriptionUtils.getJavaPackageName(dbc.getClassName()),
+ "http");
}
}
return webServiceTargetNamespace;
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=611042&r1=611041&r2=611042&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 Thu Jan 10 19:56:14 2008
@@ -56,6 +56,7 @@
import javax.xml.bind.JAXBElement;
import javax.xml.bind.Unmarshaller;
import javax.xml.namespace.QName;
+import javax.xml.ws.WebServiceClient;
import javax.xml.ws.soap.SOAPBinding;
import java.io.File;
@@ -85,10 +86,6 @@
private URL wsdlURL;
private QName serviceQName;
- // Only ONE of the following will be set in a ServiceDescription, depending on whether this Description
- // was created from a service-requester or service-provider flow.
- private Class serviceClass; // A service-requester generated service or generic service class
-
// TODO: Possibly remove Definition and delegate to the Defn on the AxisSerivce set as a paramater by WSDLtoAxisServicBuilder?
private WSDLWrapper wsdlWrapper;
private WSDLWrapper generatedWsdlWrapper;
@@ -113,7 +110,8 @@
/**
- * This is (currently) the client-side-only constructor Construct a service description hierachy
+ * Create a service-requester side (aka client-side) service description.
+ * Construct a service description hierachy
* based on WSDL (may be null), the Service class, and a service QName.
*
* @param wsdlURL The WSDL file (this may be null).
@@ -124,6 +122,23 @@
* not be null.
*/
ServiceDescriptionImpl(URL wsdlURL, QName serviceQName, Class serviceClass) {
+ this(wsdlURL, serviceQName, serviceClass, null, null);
+ }
+
+ /**
+ * Create a service-requester side service description. Same as constructor above with an
+ * additonal composite paramater. Note that the composite is "sparse" in that any values it
+ * contains overrides any values on the corresponding class annotation HOWEVER if the composite
+ * doesn't specify a value, it is gotten from the class annotation.
+ * @param wsdlURL
+ * @param serviceQName
+ * @param serviceClass
+ * @param sparseComposite a composite with any annotation overrides such as from a client deployment
+ * descriptor. CAN NOT BE NULL, but it can be an object created with a default constructor
+ */
+ ServiceDescriptionImpl(URL wsdlURL, QName serviceQName, Class serviceClass,
+ DescriptionBuilderComposite sparseComposite,
+ Object sparseCompositeKey) {
if (serviceQName == null) {
throw ExceptionFactory.makeWebServiceException(Messages.getMessage("serviceDescErr0"));
}
@@ -136,25 +151,95 @@
Messages.getMessage("serviceDescErr1", serviceClass.getName()));
}
+ composite = new DescriptionBuilderComposite();
+ composite.setIsServiceProvider(false);
+ composite.setCorrespondingClass(serviceClass);
+ composite.setSparseComposite(sparseCompositeKey, sparseComposite);
+ URL sparseCompositeWsdlURL = getWsdlURL(serviceClass, sparseComposite);
+ // The classloader was originally gotten off this class, but it seems more logical to
+ // get it off the application service class.
+// composite.setClassLoader(this.getClass().getClassLoader());
+ composite.setClassLoader(serviceClass.getClassLoader());
+
// TODO: On the client side, we should not support partial WSDL; i.e. if the WSDL is specified it must be
// complete and must contain the ServiceQName. This is how the Sun RI behaves on the client.
// When this is fixed, the check in ServiceDelegate(URL, QName, Class) should be removed
- this.wsdlURL = wsdlURL;
+
+ // If there's a WSDL URL specified in the sparse composite, that is a override, for example
+ // from a JSR-109 deployment descriptor, and that's the one to use.
+ if (sparseCompositeWsdlURL != null) {
+ this.wsdlURL = sparseCompositeWsdlURL;
+ } else {
+ this.wsdlURL = wsdlURL;
+ }
// TODO: The serviceQName needs to be verified between the argument/WSDL/Annotation
this.serviceQName = serviceQName;
- this.serviceClass = serviceClass;
setupWsdlDefinition();
}
+
+ URL getWsdlURL(Class clazz, DescriptionBuilderComposite sparseComposite) {
+ // Use the WSDL file if it is specified in the composite
+ // TODO: (JLB) This logic is common with stuff Dustin put in ServiceDescriptionImpl to
+ // do WSDL file reading in MDQ; refactor them into common helper class.
+ URL url = null;
+ if (sparseComposite != null) {
+ WebServiceClient wsc = (WebServiceClient) sparseComposite.getWebServiceClientAnnot();
+ if (wsc != null && wsc.wsdlLocation() != null) {
+ String wsdlLocation = wsc.wsdlLocation();
+ // Look for the WSDL file as follows:
+ // 1) As a resource on the classpath
+ // 2) As a fully specified URL
+ // 3) As a file on the filesystem. This is analagous to what the generated
+ // Service client does. Is prepends "file:/" to whatever is specified in the
+ // @WegServiceClient.wsdlLocation element.
+ URL wsdlUrl = null;
+ wsdlUrl = clazz.getClassLoader().getResource(wsdlLocation);
+ if (wsdlUrl == null) {
+ wsdlUrl = createWsdlURL(wsdlLocation);
+ }
+ if (wsdlUrl == null) {
+ wsdlUrl = createWsdlURL("file:/" + wsdlLocation);
+ }
+
+ if (wsdlUrl == null) {
+ // TODO: (JLB) NLS
+ throw ExceptionFactory.makeWebServiceException("Unable to access wsdlLocation: "
+ + wsdlLocation);
+ } else {
+ url = wsdlUrl;
+ }
+ }
+ }
+ return url;
+ }
+ private static URL createWsdlURL(String wsdlLocation) {
+ URL theUrl = null;
+ try {
+ theUrl = new URL(wsdlLocation);
+ } catch (Exception ex) {
+ // Just return a null to indicate we couldn't create a URL from the string
+ }
+ return theUrl;
+ }
+
+
/**
- * This is (currently) the service-provider-side-only constructor. Create a service Description
- * based on a service implementation class
+ * Create a service-provider side ServiceDesci. Create a service Description
+ * based on a service implementation class. Note this is for test-only code; it should not be
+ * used in production code. And it is being removed from the test code as well.
*
+ * @deprecated
* @param serviceImplClass
*/
ServiceDescriptionImpl(Class serviceImplClass, AxisService axisService) {
+ composite = new DescriptionBuilderComposite();
+ composite.setIsDeprecatedServiceProviderConstruction(true);
+ composite.setIsServiceProvider(true);
+ // TODO: (JLB) does the composite corresponding class AND the classloader need to be set here?
isServerSide = true;
+
// Create the EndpointDescription hierachy from the service impl annotations; Since the PortQName is null,
// it will be set to the annotation value.
EndpointDescriptionImpl endpointDescription =
@@ -165,10 +250,11 @@
}
/**
- * This is (currently) the service-provider-side-only constructor. Create a service Description
- * based on a service implementation class
- *
- * @param serviceImplClass
+ * 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
+ * composite must be included in the map.
+ * @param dbcMap
+ * @param composite
*/
ServiceDescriptionImpl(
HashMap<String, DescriptionBuilderComposite> dbcMap,
@@ -219,6 +305,11 @@
* port is one that is not defined (e.g. not via WSDL or annotations) and has been added via
* Serivce.addPort.
* <p/>
+ * For predefined ports, a composite of sparse metadata, such as from a deployment descriptor
+ * may be supplied. This can be used to modify the endpoint interfaceannotations such as
+ * adding a handler chain. The sparse composite is NOT supported for dynamic (i.e. ADD_PORT)
+ * or dispatch clients.
+ * <p/>
* Notes on how an EndpointDescription can be updated or created: 1) Service.createDispatch can
* create a Dispatch client for either a declared or dynamic port 2) Note that creating a
* Dispatch does not associate an SEI with an endpoint 3) Service.getPort will associate an SEI
@@ -235,20 +326,37 @@
* non-existent dynamic port CREATE_DISPATCH is an attempt to create a
* Dispatch-based client to either a declared port or a pre-existing dynamic
* port.
+ * @param composite May contain sparse metadata, for example from a deployment descriptor, that
+ * should be used in conjuction with the class annotations to update the
+ * description hierachy. For example, it may contain a HandlerChain annotation
+ * based on information in a JSR-109 deploment descriptor.
*/
EndpointDescription updateEndpointDescription(Class sei, QName portQName,
- DescriptionFactory.UpdateType updateType) {
+ DescriptionFactory.UpdateType updateType,
+ DescriptionBuilderComposite composite,
+ Object compositeKey) {
EndpointDescriptionImpl endpointDescription = getEndpointDescriptionImpl(portQName);
boolean isPortDeclared = isPortDeclared(portQName);
+ // If no QName was specified in the arguments, one may have been specified in the sparse
+ // composite metadata when the service was created.
+ if (DescriptionUtils.isEmpty(portQName)) {
+ QName preferredPortQN = getPreferredPort(compositeKey);
+ if (!DescriptionUtils.isEmpty(preferredPortQN)) {
+ portQName = preferredPortQN;
+ }
+ }
switch (updateType) {
case ADD_PORT:
+ if (composite != null) {
+ // TODO: (JLB) NLS
+ throw ExceptionFactory.makeWebServiceException("AddPort can not have a composite");
+ }
// Port must NOT be declared (e.g. can not already exist in WSDL)
// If an EndpointDesc doesn't exist; create it as long as it doesn't exist in the WSDL
- // TODO: This test can be simplified once isPortDeclared(QName) understands annotations and WSDL as ways to declare a port.
if (DescriptionUtils.isEmpty(portQName)) {
throw ExceptionFactory
.makeWebServiceException(Messages.getMessage("addPortErr2"));
@@ -290,8 +398,7 @@
Messages.getMessage("updateEPDescrErr2",(portQName != null ? portQName.toString() : "not specified")));
} else if (endpointDescription == null) {
// Use the SEI Class and its annotations to finish creating the Description hierachy: Endpoint, EndpointInterface, Operations, Parameters, etc.
- // TODO: Need to create the Axis Description objects after we have all the config info (i.e. from this SEI)
- endpointDescription = new EndpointDescriptionImpl(sei, portQName, this);
+ endpointDescription = new EndpointDescriptionImpl(sei, portQName, this, composite, compositeKey);
addEndpointDescription(endpointDescription);
/*
* We must reset the service runtime description after adding a new endpoint
@@ -302,19 +409,36 @@
resetServiceRuntimeDescription();
} else
if (getEndpointSEI(portQName) == null && !endpointDescription.isDynamicPort()) {
- // Existing endpointDesc from a declared port needs to be updated with an SEI
- // Note that an EndpointDescritption created from an addPort (i.e. a dynamic port) can not do this.
- endpointDescription.updateWithSEI(sei);
+ // Existing endpointDesc from a declared port needs to be updated with an SEI.
+ // This could happen if the client first did a CREATE_DISPATCH on a declared
+ // port, which would cause it to be created, and then did a GET_PORT on the
+ // same port later, providing an SEI.
+ // Notes
+ // 1) An EndpointDescritption created from an addPort (i.e. a dynamic port) can
+ // not do this.
+ // 2) A sparse composite may be specified. We don't allow mixing JAX-WS unmanaged
+ // apis (CREATE_DISPATCH) with JSR-109 managed apis (GET_PORT with sparse
+ // composite metadata from a DD). Since the sparse composite is stored by
+ // a key AND CREATE_DISPATCH and ADD_PORT will thrown an exception of a composite
+ // is specified, having a composite and key on the GET_PORTs shouldn't be
+ // a problem.
+ endpointDescription.updateWithSEI(sei, composite, compositeKey);
} else if (getEndpointSEI(portQName) != sei) {
throw ExceptionFactory.makeWebServiceException(
Messages.getMessage("updateEPDescrErr3",portQName.toString(),
sei.getName(),getEndpointSEI(portQName).getName()));
} else {
// All error check above passed, the EndpointDescription already exists and needs no updating
+ // Just add the sparse composite if one was specified.
+ endpointDescription.getDescriptionBuilderComposite().setSparseComposite(compositeKey, composite);
}
break;
case CREATE_DISPATCH:
+ if (composite != null) {
+ // TODO: (JLB) NLS
+ throw ExceptionFactory.makeWebServiceException("CreateDispatch can not have a composite");
+ }
// Port may or may not exist in WSDL.
// If an endpointDesc doesn't exist and it is in the WSDL, it can be created
// Otherwise, it is an error.
@@ -423,7 +547,7 @@
return null;
}
- DescriptionBuilderComposite getDescriptionBuilderComposite() {
+ public DescriptionBuilderComposite getDescriptionBuilderComposite() {
return composite;
}
@@ -451,16 +575,6 @@
return returnEndpointDesc;
}
- /*
- * @return True - if we are processing with the DBC List instead of reflection
- */
- boolean isDBCMap() {
- if (dbcMap == null)
- return false;
- else
- return true;
- }
-
// END of public accessor methods
/*=======================================================================*/
/*=======================================================================*/
@@ -472,7 +586,7 @@
// Note that there may be no WSDL provided, for example when called from
// Service.create(QName serviceName).
- if (isDBCMap()) {
+ 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
@@ -749,7 +863,23 @@
serviceQName = theName;
}
-
+ /* (non-Javadoc)
+ * @see org.apache.axis2.jaxws.description.ServiceDescription#isMTOMEnabled(java.lang.Object)
+ */
+ public boolean isMTOMEnabled(Object key) {
+ return getDescriptionBuilderComposite().isMTOMEnabled(key);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.jaxws.description.ServiceDescription#getPreferredPort(java.lang.Object)
+ */
+ public QName getPreferredPort(Object key) {
+ return getDescriptionBuilderComposite().getPreferredPort(key);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.jaxws.description.ServiceDescription#isServerSide()
+ */
public boolean isServerSide() {
return isServerSide;
}
@@ -1504,22 +1634,13 @@
String handlerFileName = handlerChainAnnotation.file();
if (log.isDebugEnabled()) {
- if (composite != null) {
- log.debug("EndpointDescriptionImpl.getHandlerChain: fileName: "
- + handlerFileName + " className: " + composite.getClassName());
- }
- else {
- log.debug("EndpointDescriptionImpl.getHandlerChain: fileName: "
- + handlerFileName + " className: " + serviceClass.getName());
- }
+ log.debug("EndpointDescriptionImpl.getHandlerChain: fileName: "
+ + handlerFileName + " className: " + composite.getClassName());
}
- String className =
- (composite != null) ? composite.getClassName() : serviceClass.getName();
+ String className = composite.getClassName();
- ClassLoader classLoader =
- (composite != null) ? composite.getClassLoader() : this.getClass()
- .getClassLoader();
+ ClassLoader classLoader = composite.getClassLoader();
InputStream is =
DescriptionUtils.openHandlerConfigStream(handlerFileName,
@@ -1545,6 +1666,7 @@
*/
public HandlerChain getAnnoHandlerChainAnnotation() {
if (this.handlerChainAnnotation == null) {
+ Class serviceClass = composite.getCorrespondingClass();
if (serviceClass != null) {
handlerChainAnnotation =
(HandlerChain) getAnnotation(serviceClass, HandlerChain.class);
@@ -1679,7 +1801,9 @@
* Return the name of the client-side service class if it exists.
*/
protected String getServiceClassName() {
- return (this.serviceClass != null ? this.serviceClass.getName() : null);
+ return composite.getClassName();
+ // TODO: (JLB) Remove commented out code from 1/7/08 merge
+// return (this.serviceClass != null ? this.serviceClass.getName() : null);
}
/** Return a string representing this Description object and all the objects it contains. */
Added: webservices/axis2/trunk/java/modules/metadata/test-resources/wsdl/ClientEndpointMetadata.wsdl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/test-resources/wsdl/ClientEndpointMetadata.wsdl?rev=611042&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/test-resources/wsdl/ClientEndpointMetadata.wsdl (added)
+++ webservices/axis2/trunk/java/modules/metadata/test-resources/wsdl/ClientEndpointMetadata.wsdl Thu Jan 10 19:56:14 2008
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions targetNamespace="http://org.apache.axis2.jaxws.description.impl.ClientDBCSupportEndpointTests"
+ xmlns:tns="http://org.apache.axis2.jaxws.description.impl.ClientDBCSupportEndpointTests"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema targetNamespace="http://description.jaxws.axis2.apache.org"
+ xmlns:ts="http://description.jaxws.axis2.apache.org/xsd"
+ xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+ <complexType name="echoMessage">
+ <sequence>
+ <element name="request" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ <complexType name="echoMessageResponse">
+ <sequence>
+ <element name="response" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ <element name="echoMessage" type="tns:echoMessage"/>
+ <element name="echoMessageResponse" type="tns:echoMessageResponse"/>
+ </xsd:schema>
+ </types>
+
+ <message name="echoMessage">
+ <part name="message" element="tns:echoMessage"/>
+ </message>
+
+ <message name="echoMessageResponse">
+ <part name="result" element="tns:echoMessageResponse"/>
+ </message>
+
+ <portType name="EchoMessagePortType">
+ <operation name="echoMessage">
+ <input message="tns:echoMessage" />
+ <output message="tns:echoMessageResponse" />
+ </operation>
+ </portType>
+
+ <binding name="EchoMessageBinding" type="tns:EchoMessagePortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="echoMessage">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal" namespace="http://org.apache.binding.ns"/>
+ </input>
+ <output>
+ <soap:body use="literal" namespace="http://org.apache.binding.ns"/>
+ </output>
+ </operation>
+ </binding>
+
+ <service name="svcLocalPart">
+ <port binding="tns:EchoMessageBinding" name="portLocalPart">
+ <soap:address location="http://localhost:8080/EchoMessageService/EchoMessageService"/>
+ </port>
+ </service>
+</definitions>
Modified: webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/DescriptionTestUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/DescriptionTestUtils.java?rev=611042&r1=611041&r2=611042&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/DescriptionTestUtils.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/DescriptionTestUtils.java Thu Jan 10 19:56:14 2008
@@ -20,9 +20,14 @@
package org.apache.axis2.jaxws.description;
+import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
+
import javax.wsdl.Definition;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLReader;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.net.URL;
/**
@@ -40,12 +45,17 @@
return getWSDLURL("WSDLTests.wsdl");
}
+
+ static public String getWSDLLocation(String wsdlFileName) {
+ String basedir = System.getProperty("basedir", ".");
+ String urlString = "file://localhost/" + basedir + "/test-resources/wsdl/" + wsdlFileName;
+ return urlString;
+ }
static public URL getWSDLURL(String wsdlFileName) {
URL wsdlURL = null;
+ String urlString = getWSDLLocation(wsdlFileName);
// Get the URL to the WSDL file. Note that 'basedir' is setup by Maven
- String basedir = System.getProperty("basedir", ".");
- String urlString = "file://localhost/" + basedir + "/test-resources/wsdl/" + wsdlFileName;
try {
wsdlURL = new URL(urlString);
} catch (Exception e) {
@@ -71,4 +81,32 @@
return wsdlDefinition;
}
+ static public DescriptionBuilderComposite getServiceDescriptionComposite(ServiceDescription svcDesc) {
+ DescriptionBuilderComposite returnComposite = null;
+ // Need to get the composite off the implementation using the getter method, but it is all
+ // packaged protected and not part of the interface.
+ try {
+ Method getComposite = svcDesc.getClass().getDeclaredMethod("getDescriptionBuilderComposite");
+ getComposite.setAccessible(true);
+ returnComposite = (DescriptionBuilderComposite) getComposite.invoke(svcDesc, null);
+ } catch (SecurityException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return returnComposite;
+ }
+
}
Modified: webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/builder/DescriptionBuilderTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/builder/DescriptionBuilderTests.java?rev=611042&r1=611041&r2=611042&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/builder/DescriptionBuilderTests.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/builder/DescriptionBuilderTests.java Thu Jan 10 19:56:14 2008
@@ -70,7 +70,7 @@
descriptionBuilderComposite.setWebServiceAnnot(webServiceAnnotImpl2);
- WebServiceAnnot webServiceAnnotImpl3 =
+ WebService webServiceAnnotImpl3 =
descriptionBuilderComposite.getWebServiceAnnot();
assertNotNull("WebService name not set", webServiceAnnotImpl3.name());
@@ -105,7 +105,7 @@
descriptionBuilderComposite.setWebServiceProviderAnnot(webServiceProviderAnnot);
- WebServiceProviderAnnot webServiceProviderAnnot3 =
+ javax.xml.ws.WebServiceProvider webServiceProviderAnnot3 =
descriptionBuilderComposite.getWebServiceProviderAnnot();
assertEquals("WebServiceProvider port name not set properly",
Added: webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/builder/SparseAnnotTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/builder/SparseAnnotTests.java?rev=611042&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/builder/SparseAnnotTests.java (added)
+++ webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/builder/SparseAnnotTests.java Thu Jan 10 19:56:14 2008
@@ -0,0 +1,85 @@
+/*
+ * 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.axis2.jaxws.description.builder;
+
+import org.apache.axis2.jaxws.description.DescriptionFactory;
+import org.apache.axis2.jaxws.description.DescriptionTestUtils;
+import org.apache.axis2.jaxws.description.ServiceDescription;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebServiceClient;
+
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ */
+public class SparseAnnotTests extends TestCase {
+ private String namespaceURI = "http://org.apache.axis2.jaxws.description.builder.SparseAnnotTests";
+ private String svcLocalPart = "svcLocalPart";
+
+ public void testNoSparseAnnot() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ ServiceDescription svcDesc =
+ DescriptionFactory.createServiceDescription(null, serviceQName,
+ SparseAnnotServiceSubclass.class);
+ assertNotNull(svcDesc);
+ // A DBC will be created for us
+ DescriptionBuilderComposite svcDescComposite = DescriptionTestUtils.getServiceDescriptionComposite(svcDesc);
+ assertNotNull(svcDescComposite);
+ WebServiceClient wsClient = svcDescComposite.getWebServiceClientAnnot();
+ // There is no DBC Annot in this case; it is the class annotation but it should be
+ // returned as an instance of a WebServiceClientAnnot
+ assertTrue(wsClient instanceof WebServiceClientAnnot);
+ }
+
+ public void testAssociatedClass() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ // Create a composite with a WebServiceClient override of the WSDL location.
+ DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
+ String overridenWsdlLocation = DescriptionTestUtils.getWSDLLocation("ClientEndpointMetadata.wsdl");
+ WebServiceClientAnnot wsClientAnno =
+ WebServiceClientAnnot.createWebServiceClientAnnotImpl(null, null, overridenWsdlLocation);
+ composite.setWebServiceClientAnnot(wsClientAnno);
+ Object compositeKey = "CompositeKey";
+ ServiceDescription svcDesc =
+ DescriptionFactory.createServiceDescription(null, serviceQName,
+ SparseAnnotServiceSubclass.class,
+ composite, compositeKey);
+ assertNotNull(svcDesc);
+ DescriptionBuilderComposite svcDescComposite = DescriptionTestUtils.getServiceDescriptionComposite(svcDesc);
+ assertNotNull(svcDescComposite);
+ assertNotSame(composite, svcDescComposite);
+ assertSame(SparseAnnotServiceSubclass.class, svcDescComposite.getCorrespondingClass());
+ assertSame(composite, svcDescComposite.getSparseComposite(compositeKey));
+ WebServiceClient wsClient = svcDescComposite.getWebServiceClientAnnot();
+ assertTrue(wsClient instanceof WebServiceClientAnnot);
+ }
+
+}
+
+@WebServiceClient(targetNamespace="originalTNS", wsdlLocation="originalWsdlLocation")
+class SparseAnnotServiceSubclass extends javax.xml.ws.Service {
+
+ protected SparseAnnotServiceSubclass(URL wsdlDocumentLocation, QName serviceName) {
+ super(wsdlDocumentLocation, serviceName);
+ }
+}
Modified: webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/builder/converter/ReflectiveConverterTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/builder/converter/ReflectiveConverterTests.java?rev=611042&r1=611041&r2=611042&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/builder/converter/ReflectiveConverterTests.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/builder/converter/ReflectiveConverterTests.java Thu Jan 10 19:56:14 2008
@@ -60,7 +60,7 @@
public static void testCreateImplDBC() {
assertNotNull(implDBC);
- WebServiceAnnot wsAnnot = implDBC.getWebServiceAnnot();
+ WebService wsAnnot = implDBC.getWebServiceAnnot();
assertNotNull(wsAnnot);
assertEquals("SimpleService", wsAnnot.serviceName());
}
@@ -114,7 +114,7 @@
public static void testCreateSEIDBC() {
assertNotNull(seiDBC);
- WebServiceAnnot wsAnnot = seiDBC.getWebServiceAnnot();
+ WebService wsAnnot = seiDBC.getWebServiceAnnot();
assertNotNull(wsAnnot);
assertEquals("SimpleServicePort", wsAnnot.name());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org