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/05/05 23:12:44 UTC
svn commit: r653604 - in /webservices/axis2/trunk/java/modules:
jaxws/src/org/apache/axis2/jaxws/server/
jaxws/src/org/apache/axis2/jaxws/server/endpoint/
metadata/src/org/apache/axis2/jaxws/description/builder/
metadata/src/org/apache/axis2/jaxws/desc...
Author: damrhei
Date: Mon May 5 14:12:43 2008
New Revision: 653604
URL: http://svn.apache.org/viewvc?rev=653604&view=rev
Log:
This is a fix for the issue documented in AXIS2-3780.
Added:
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/PortComposite.java
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/Utils.java
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/impl/EndpointDescriptionImpl.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java?rev=653604&r1=653603&r2=653604&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java Mon May 5 14:12:43 2008
@@ -215,7 +215,7 @@
// Need to make sure the protocol (envelope ns) of the request matches the binding
// expected by the service description
- if (!Utils.bindingTypesMatch(request, endpointDesc.getServiceDescription())) {
+ if (!Utils.bindingTypesMatch(request, endpointDesc)) {
Protocol protocol = request.getMessage().getProtocol();
MessageContext faultContext = Utils.createVersionMismatchMessage(request, protocol);
eic.setResponseMessageContext(faultContext);
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/Utils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/Utils.java?rev=653604&r1=653603&r2=653604&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/Utils.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/Utils.java Mon May 5 14:12:43 2008
@@ -47,6 +47,7 @@
public static final Log log = LogFactory.getLog(Utils.class);
+ @Deprecated
/**
* Compares the version of the message in the MessageContext to what's expected
* given the ServiceDescription. The behavior is described in the SOAP 1.2
@@ -93,6 +94,36 @@
}
/**
+ * Compares the version of the message in the MessageContext to what's expected
+ * given the ServiceDescription. The behavior is described in the SOAP 1.2
+ * specification under Appendix 'A'.
+ *
+ * @param mc
+ * @param serviceDesc
+ * @return
+ */
+ public static boolean bindingTypesMatch(MessageContext mc, EndpointDescription ed) {
+
+ Protocol protocol = mc.getMessage().getProtocol();
+ String bindingType = ed.getBindingType();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Checking for matching binding types.");
+ log.debug(" message protocol: " + protocol);
+ log.debug(" binding type: " + bindingType);
+ }
+
+ if (protocol.equals(Protocol.soap11)) {
+ return (BindingUtils.isSOAP11Binding(bindingType));
+ } else if (protocol.equals(Protocol.soap12)) {
+ return (BindingUtils.isSOAP12Binding(bindingType));
+ } else if (protocol.equals(Protocol.rest)) {
+ return HTTPBinding.HTTP_BINDING.equalsIgnoreCase(bindingType);
+ }
+ return true;
+ }
+
+ /**
* Creates a fault message that reflects a version mismatch for the configured message protocol.
* The returned message will always be a SOAP 1.1 message per the specification.
*
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=653604&r1=653603&r2=653604&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 Mon May 5 14:12:43 2008
@@ -89,6 +89,10 @@
private List<WebServiceRefAnnot> webServiceRefAnnotList;
private BindingTypeAnnot bindingTypeAnnot;
+ // Collection of PortComposite objects which were created from
+ // this DescriptionBuilderComposite instance
+ private List<PortComposite> portCompositeList = new ArrayList<PortComposite>();
+
private List<Annotation> features;
// Class information
@@ -866,8 +870,24 @@
FieldDescriptionComposite fdc = fdcIter.next();
sb.append(fdc.toString());
}
+
+ if(portCompositeList != null
+ &&
+ !portCompositeList.isEmpty()) {
+ sb.append(newLine);
+ sb.append(newLine);
+ sb.append("** PortComposite Objects**");
+ sb.append(newLine);
+ for(PortComposite pc : portCompositeList) {
+ sb.append("PortComposite");
+ sb.append(newLine);
+ sb.append(pc.toString());
+ sb.append(newLine);
+ }
+ }
+
return sb.toString();
- }
+ }
/**
@@ -908,4 +928,13 @@
public ConfigurationContext getConfigurationContext() {
return myConfigContext;
}
+
+ public void addPortComposite(PortComposite portDBC) {
+ portCompositeList.add(portDBC);
+ }
+
+ public List<PortComposite> getPortComposites() {
+ return portCompositeList;
+ }
+
}
Added: 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=653604&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/PortComposite.java (added)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/PortComposite.java Mon May 5 14:12:43 2008
@@ -0,0 +1,290 @@
+/*
+ * 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 java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+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;
+
+/**
+ * This subclass of the DescriptionBuilderComposite will be used to model
+ * information specific to a port. The DescriptionBuilderComposite, when
+ * used in server-side processing, more or less represents a single web
+ * service implementation class. It is possible, and likely, that a single
+ * implementation class will serve multiple ports. The PortComposite allows
+ * metadata that applies at the port level to be separated from the
+ * DescriptionBuilderComposite. This will allow processing and configuring
+ * of multiple ports in the description hierarchy from a single DBC object.
+ *
+ */
+public class PortComposite extends DescriptionBuilderComposite {
+
+ private WsdlGenerator wsdlGenerator;
+
+ // The WebServiceAnnot should have been created from the WebServiceAnnot
+ // that exists on the DBC with which a PortComposite instance was constructed.
+ // It exists here so port-specific values, such as 'portName', can be overridden.
+ private WebServiceAnnot wsAnnot;
+
+ // The WebServiceProviderAnnot should have been created from the WebServiceProviderAnnot
+ // that exists on the DBC with which a PortComposite instance was constructed.
+ // It exists here so port-specific values, such as 'portName', can be overridden.
+ private WebServiceProviderAnnot wspAnnot;
+
+ private BindingTypeAnnot btAnnot;
+
+ private HandlerChainAnnot hcAnnot;
+
+ private HandlerChainsType hcsType;
+
+ private Boolean mtomEnabled;
+
+ private Map<String, Object> properties;
+
+ private DescriptionBuilderComposite baseDBC;
+
+ public PortComposite(DescriptionBuilderComposite baseDBC) {
+ this.baseDBC = baseDBC;
+ this.baseDBC.addPortComposite(this);
+ }
+
+
+ public WsdlGenerator getCustomWsdlGenerator() {
+ if(wsdlGenerator == null) {
+ return baseDBC.getCustomWsdlGenerator();
+ }
+ return wsdlGenerator;
+ }
+
+ public WebServiceAnnot getWebServiceAnnot() {
+ if(wsAnnot == null) {
+ return baseDBC.getWebServiceAnnot();
+ }
+ return wsAnnot;
+ }
+
+ public WebServiceProviderAnnot getWebServiceProviderAnnot() {
+ if(wspAnnot == null) {
+ return baseDBC.getWebServiceProviderAnnot();
+ }
+ return wspAnnot;
+ }
+
+ public void setCustomWsdlGenerator(WsdlGenerator wsdlGenerator) {
+ this.wsdlGenerator = wsdlGenerator;
+ }
+
+ public void setHandlerChainAnnot(HandlerChainAnnot handlerChainAnnot) {
+ this.hcAnnot = handlerChainAnnot;
+ }
+
+ public void setHandlerChainsType(HandlerChainsType handlerChainsType) {
+ this.hcsType = handlerChainsType;
+ }
+
+ public void setIsMTOMEnabled(boolean isMTOMEnabled) {
+ this.mtomEnabled = isMTOMEnabled;
+ }
+
+ public void setProperties(Map<String, Object> properties) {
+ this.properties = properties;
+ }
+
+ public void setWebServiceAnnot(WebServiceAnnot webServiceAnnot) {
+ this.wsAnnot = webServiceAnnot;
+ }
+
+ public void setWebServiceProviderAnnot(WebServiceProviderAnnot webServiceProviderAnnot) {
+ this.wspAnnot = webServiceProviderAnnot;
+ }
+
+ public BindingTypeAnnot getBindingTypeAnnot() {
+ if(btAnnot == null) {
+ return baseDBC.getBindingTypeAnnot();
+ }
+ return btAnnot;
+ }
+
+ public HandlerChainAnnot getHandlerChainAnnot() {
+ if(hcAnnot == null) {
+ return baseDBC.getHandlerChainAnnot();
+ }
+ return hcAnnot;
+ }
+
+ public HandlerChainsType getHandlerChainsType() {
+ if(hcsType == null) {
+ return baseDBC.getHandlerChainsType();
+ }
+ return hcsType;
+ }
+
+ public boolean isMTOMEnabled() {
+ if(mtomEnabled == null) {
+ return baseDBC.isMTOMEnabled();
+ }
+ return mtomEnabled;
+ }
+
+ public void setBindingTypeAnnot(BindingTypeAnnot bindingTypeAnnot) {
+ this.btAnnot = bindingTypeAnnot;
+ }
+
+ public Map<String, Object> getProperties() {
+ if(properties == null) {
+ return baseDBC.getProperties();
+ }
+ return properties;
+ }
+
+ public void addPortComposite(PortComposite portDBC) {
+ // nothing to do here
+ }
+
+ public List<PortComposite> getPortComposites() {
+ return null;
+ }
+
+ public JAXWSCatalogManager getCatalogManager() {
+ return baseDBC.getCatalogManager();
+ }
+
+ public ClassLoader getClassLoader() {
+ return baseDBC.getClassLoader();
+ }
+
+ public String[] getClassModifiers() {
+ return baseDBC.getClassModifiers();
+ }
+
+ public String getClassName() {
+ return baseDBC.getClassName();
+ }
+
+ public List<CustomAnnotationInstance> getCustomAnnotationInstances() {
+ return baseDBC.getCustomAnnotationInstances();
+ }
+
+ public Map<String, CustomAnnotationProcessor> getCustomAnnotationProcessors() {
+ return baseDBC.getCustomAnnotationProcessors();
+ }
+
+ public FieldDescriptionComposite getFieldDescriptionComposite(String fieldName) {
+ return baseDBC.getFieldDescriptionComposite(fieldName);
+ }
+
+ public List<String> getInterfacesList() {
+ return baseDBC.getInterfacesList();
+ }
+
+ public MethodDescriptionComposite getMethodDescriptionComposite(String methodName, int occurence) {
+ return baseDBC.getMethodDescriptionComposite(methodName, occurence);
+ }
+
+ public List<MethodDescriptionComposite> getMethodDescriptionComposite(String methodName) {
+ return baseDBC.getMethodDescriptionComposite(methodName);
+ }
+
+ public List<MethodDescriptionComposite> getMethodDescriptionsList() {
+ return baseDBC.getMethodDescriptionsList();
+ }
+
+ public QName getPreferredPort() {
+ return baseDBC.getPreferredPort();
+ }
+
+ public QName getPreferredPort(Object key) {
+ return baseDBC.getPreferredPort(key);
+ }
+
+ public ServiceModeAnnot getServiceModeAnnot() {
+ return baseDBC.getServiceModeAnnot();
+ }
+
+ public SoapBindingAnnot getSoapBindingAnnot() {
+ return baseDBC.getSoapBindingAnnot();
+ }
+
+ public String getSuperClassName() {
+ return baseDBC.getSuperClassName();
+ }
+
+ public boolean isInterface() {
+ return baseDBC.isInterface();
+ }
+
+ public Definition getWsdlDefinition() {
+ return baseDBC.getWsdlDefinition();
+ }
+
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ final String newLine = "\n";
+ final String sameLine = "; ";
+ sb.append(super.toString());
+ sb.append(newLine);
+ sb.append("ClassName: " + getClassName());
+
+ sb.append(newLine);
+
+ sb.append(newLine);
+ sb.append("has wsdlDefinition?: ");
+ if (getWsdlDefinition() !=null) {
+ sb.append("true");
+ } else {
+ sb.append("false");
+ }
+
+ if (wsAnnot != null) {
+ sb.append(newLine);
+ sb.append("WebService: ");
+ sb.append(wsAnnot.toString());
+ }
+
+ if (wspAnnot != null) {
+ sb.append(newLine);
+ sb.append("WebServiceProvider: ");
+ sb.append(wspAnnot.toString());
+ }
+
+ if (btAnnot != null) {
+ sb.append(newLine);
+ sb.append("BindingType: ");
+ sb.append(btAnnot.toString());
+ }
+
+ if (hcAnnot != null) {
+ sb.append(newLine);
+ sb.append("HandlerChain: ");
+ sb.append(hcAnnot.toString());
+ }
+
+ return sb.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=653604&r1=653603&r2=653604&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 Mon May 5 14:12:43 2008
@@ -181,6 +181,8 @@
// ANNOTATION: @RespectBinding
private Boolean respectBinding = false;
+ private Integer portCompositeIndex = null;
+
private List<CustomAnnotationInstance> customAnnotations;
private Map<String, CustomAnnotationProcessor> customAnnotationProcessors;
@@ -290,7 +292,7 @@
}
EndpointDescriptionImpl(ServiceDescriptionImpl parent, String serviceImplName) {
- this(parent, serviceImplName, null);
+ this(parent, serviceImplName, null, null);
}
/**
@@ -303,11 +305,12 @@
* don't use an SEI
*/
EndpointDescriptionImpl(ServiceDescriptionImpl parent, String serviceImplName, Map<String, Object>
- properties) {
+ properties, Integer portCompositeIndex) {
// initialize CustomAnnotationIntance list and CustomAnnotationProcessor map
customAnnotations = new ArrayList<CustomAnnotationInstance>();
customAnnotationProcessors = new HashMap<String, CustomAnnotationProcessor>();
+ this.portCompositeIndex = portCompositeIndex;
// set properties map
this.properties = properties;
@@ -315,7 +318,7 @@
this.parentServiceDescription = parent;
this.serviceImplName = serviceImplName;
- composite = getServiceDescriptionImpl().getDescriptionBuilderComposite();
+ composite = getServiceDescriptionImpl().getDescriptionBuilderComposite(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=653604&r1=653603&r2=653604&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 Mon May 5 14:12:43 2008
@@ -37,6 +37,8 @@
import org.apache.axis2.jaxws.description.ServiceRuntimeDescription;
import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
import org.apache.axis2.jaxws.description.builder.MDQConstants;
+import org.apache.axis2.jaxws.description.builder.PortComposite;
+
import static org.apache.axis2.jaxws.description.builder.MDQConstants.RETURN_TYPE_FUTURE;
import static org.apache.axis2.jaxws.description.builder.MDQConstants.RETURN_TYPE_RESPONSE;
import org.apache.axis2.jaxws.description.builder.MethodDescriptionComposite;
@@ -274,6 +276,7 @@
this.dbcMap = dbcMap;
this.isServerSide = true;
+
//capture the WSDL, if there is any...to be used for later processing
setupWsdlDefinition();
@@ -285,11 +288,43 @@
// It will be set by the EndpointDescriptionImpl since it is the one that knows
// how to process the annotations and the defaults.
- // Create the EndpointDescription hierachy from the service impl annotations; Since the PortQName is null,
- // it will be set to the annotation value.
- EndpointDescriptionImpl endpointDescription =
- new EndpointDescriptionImpl(this, serviceImplName, composite.getProperties());
- addEndpointDescription(endpointDescription);
+ 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
+ if(portComposites != null
+ &&
+ !portComposites.isEmpty()) {
+ if(log.isDebugEnabled()) {
+ log.debug("Constructing EndpointDescription instance from PortComposites for " +
+ "implementation class: " + composite.getClassName());
+ }
+ int i = 0;
+ for(PortComposite portComposite : portComposites) {
+
+ // here we pass in an index so the EndpointDescriptionImpl instance will know
+ // which PortComposite instance it is associated with and can retrieve that
+ // instance as required
+ EndpointDescriptionImpl endpointDescription =
+ new EndpointDescriptionImpl(this, serviceImplName, portComposite.getProperties(), i);
+ addEndpointDescription(endpointDescription);
+ i++;
+ }
+ }
+
+ // If no PortComposites then we build the EndpointDescriptionImpl instance from the
+ // DBC that was supplied
+ else {
+ if(log.isDebugEnabled()) {
+ log.debug("No PortComposites found for implementation class: " + composite.getClassName());
+ }
+
+ // Create the single EndpointDescription hierachy from the service impl annotations; Since the PortQName is null,
+ // it will be set to the annotation value.
+ EndpointDescriptionImpl endpointDescription =
+ new EndpointDescriptionImpl(this, serviceImplName, composite.getProperties(), null);
+ addEndpointDescription(endpointDescription);
+ }
}
/*=======================================================================*/
@@ -586,9 +621,38 @@
}
return null;
}
-
+
public DescriptionBuilderComposite getDescriptionBuilderComposite() {
- return composite;
+ return getDescriptionBuilderComposite(null);
+ }
+
+ /**
+ * This method provides a means for accessing a DescriptionBuilderComposite instance.
+ * If the integer value passed in is an index in the list of PortComposite objects,
+ * then the indiciated PortComposite will be returned. Otherwise, the instance DBC
+ * will be returned.
+ */
+ public DescriptionBuilderComposite getDescriptionBuilderComposite(Integer portCompositeIndex) {
+
+ // ignore null values or values that would cause an IndexOutOfBoundsException
+ if(portCompositeIndex == null
+ ||
+ composite.getPortComposites() == null
+ ||
+ portCompositeIndex < 0
+ ||
+ portCompositeIndex >= composite.getPortComposites().size()) {
+ return composite;
+ }
+
+ // return the appropriate PortComposite instance
+ else {
+ if(log.isDebugEnabled()) {
+ log.debug("Returning PortComposite at index: " + portCompositeIndex +
+ " from ServiceDescriptionImpl: " + this.hashCode());
+ }
+ return composite.getPortComposites().get(portCompositeIndex);
+ }
}
/* (non-Javadoc)
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org