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 ba...@apache.org on 2008/02/15 03:13:25 UTC
svn commit: r627929 - in /webservices/axis2/trunk/java/modules:
jaxws/src/org/apache/axis2/jaxws/handler/
jaxws/test/org/apache/axis2/jaxws/spi/
metadata/src/org/apache/axis2/jaxws/description/
metadata/src/org/apache/axis2/jaxws/description/impl/ meta...
Author: barrettj
Date: Thu Feb 14 18:13:18 2008
New Revision: 627929
URL: http://svn.apache.org/viewvc?rev=627929&view=rev
Log:
Add support for sparse composite containing HandlerChainsType when creating a port; handlers will be associated with the port based on the sparse composite
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerResolverImpl.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataHandlerChainTest.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.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
webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/impl/ClientDBCSupportHandlersTests.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerResolverImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerResolverImpl.java?rev=627929&r1=627928&r2=627929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerResolverImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerResolverImpl.java Thu Feb 14 18:13:18 2008
@@ -148,7 +148,7 @@
}
if (ed != null) {
- HandlerChainsType handlerCT_fromEndpointDesc = ed.getHandlerChain();
+ HandlerChainsType handlerCT_fromEndpointDesc = ed.getHandlerChain(serviceDelegateKey);
if (handlerChainsType == null) {
handlerChainsType = handlerCT_fromEndpointDesc;
}
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataHandlerChainTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataHandlerChainTest.java?rev=627929&r1=627928&r2=627929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataHandlerChainTest.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataHandlerChainTest.java Thu Feb 14 18:13:18 2008
@@ -52,7 +52,7 @@
* Test creating a service without a sparse composite. This verifies pre-existing default
* behavior.
*/
- public void testServiceNoComposite() {
+ public void testServiceAndPortNoComposite() {
QName serviceQName = new QName(namespaceURI, svcLocalPart);
QName portQName = new QName(namespaceURI, portLocalPart);
@@ -88,7 +88,7 @@
ServiceDelegate.setServiceMetadata(sparseComposite);
Service service = Service.create(serviceQName);
ClientMetadataHandlerChainTestSEI port = service.getPort(portQName, ClientMetadataHandlerChainTestSEI.class);
-
+
// Verify the HandlerResolver on the service knows about the handlers in the sparse composite
HandlerResolver resolver = service.getHandlerResolver();
assertNotNull(resolver);
@@ -102,6 +102,82 @@
List<Handler> portHandlers = binding.getHandlerChain();
assertEquals(2, portHandlers.size());
assertTrue(containSameHandlers(portHandlers, list));
+
+ // Verify that a subsequent port are different and that they also gets the correct handlers
+ ClientMetadataHandlerChainTestSEI port2 = service.getPort(portQName, ClientMetadataHandlerChainTestSEI.class);
+ BindingProvider bindingProvider2 = (BindingProvider) port2;
+ Binding binding2 = (Binding) bindingProvider2.getBinding();
+ List<Handler> portHandlers2 = binding2.getHandlerChain();
+ assertNotSame(port, port2);
+ assertEquals(2, portHandlers2.size());
+ assertTrue(containSameHandlers(portHandlers2, list));
+ }
+
+ public void testPortWithComposite() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ QName portQName = new QName(namespaceURI, portLocalPart);
+
+ Service service = Service.create(serviceQName);
+
+ // Create a composite with a JAXB Handler Config
+ DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite();
+ HandlerChainsType handlerChainsType = getHandlerChainsType();
+ sparseComposite.setHandlerChainsType(handlerChainsType);
+ ServiceDelegate.setPortMetadata(sparseComposite);
+ ClientMetadataHandlerChainTestSEI port = service.getPort(portQName, ClientMetadataHandlerChainTestSEI.class);
+
+ // Verify the HandlerResolver on the service knows about the handlers in the sparse composite
+ HandlerResolver resolver = service.getHandlerResolver();
+ assertNotNull(resolver);
+ PortInfo pi = new DummyPortInfo();
+ List<Handler> list = resolver.getHandlerChain(pi);
+ assertEquals(2, list.size());
+
+ // Verify that the port created with the sparse metadata has those handlers
+ BindingProvider bindingProvider = (BindingProvider) port;
+ Binding binding = (Binding) bindingProvider.getBinding();
+ List<Handler> portHandlers = binding.getHandlerChain();
+ assertEquals(2, portHandlers.size());
+ assertTrue(containSameHandlers(portHandlers, list));
+
+ // Verify that a creating another instance of the same port also gets those handlers
+ ClientMetadataHandlerChainTestSEI port2 = service.getPort(portQName, ClientMetadataHandlerChainTestSEI.class);
+ BindingProvider bindingProvider2 = (BindingProvider) port2;
+ Binding binding2 = (Binding) bindingProvider2.getBinding();
+ List<Handler> portHandlers2 = binding2.getHandlerChain();
+ assertNotSame(port, port2);
+ assertEquals(2, portHandlers2.size());
+ assertTrue(containSameHandlers(portHandlers2, list));
+
+ // Verify that createing a different port doesn't get the handlers
+ QName portQName3 = new QName(namespaceURI, portLocalPart + "3");
+ ClientMetadataHandlerChainTestSEI port3 = service.getPort(portQName3, ClientMetadataHandlerChainTestSEI.class);
+ BindingProvider bindingProvider3 = (BindingProvider) port3;
+ Binding binding3 = (Binding) bindingProvider3.getBinding();
+ List<Handler> portHandlers3 = binding3.getHandlerChain();
+ assertEquals(0, portHandlers3.size());
+
+ // Verify setting the metadata on a port (with a different name) will get handlers.
+ QName portQName4 = new QName(namespaceURI, portLocalPart + "4");
+ ServiceDelegate.setPortMetadata(sparseComposite);
+ ClientMetadataHandlerChainTestSEI port4 = service.getPort(portQName4, ClientMetadataHandlerChainTestSEI.class);
+ BindingProvider bindingProvider4 = (BindingProvider) port4;
+ Binding binding4 = (Binding) bindingProvider4.getBinding();
+ List<Handler> portHandlers4 = binding4.getHandlerChain();
+ assertEquals(2, portHandlers4.size());
+
+ // Verify the service handler resolver knows about boths sets of handlers
+ // attached to the two different port QNames and none are attached for the third port
+ List<Handler> listForPort = resolver.getHandlerChain(pi);
+ assertEquals(2, listForPort.size());
+
+ PortInfo pi4 = new DummyPortInfo(portQName4);
+ List<Handler> listForPort4 = resolver.getHandlerChain(pi4);
+ assertEquals(2, listForPort4.size());
+
+ PortInfo pi3 = new DummyPortInfo(portQName3);
+ List<Handler> listForPort3 = resolver.getHandlerChain(pi3);
+ assertEquals(0, listForPort3.size());
}
// TODO: (JLB) Change this test to check the handlers on the ports via the bindingImpl
@@ -202,17 +278,29 @@
}
public class DummyPortInfo implements PortInfo {
+ private QName portQN;
+ private QName serviceQN;
+
+ public DummyPortInfo() {
+ this.portQN = new QName("http://www.apache.org/test/namespace", "DummyPort");
+ this.serviceQN = new QName("http://www.apache.org/test/namespace", "DummyService");
+ }
+
+ public DummyPortInfo(QName portQN) {
+ this();
+ this.portQN = portQN;
+ }
public String getBindingID() {
return SOAPBinding.SOAP11HTTP_BINDING;
}
public QName getPortName() {
- return new QName("http://www.apache.org/test/namespace", "DummyPort");
+ return portQN;
}
-
+
public QName getServiceName() {
- return new QName("http://www.apache.org/test/namespace", "DummyService");
+ return serviceQN;
}
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java?rev=627929&r1=627928&r2=627929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java Thu Feb 14 18:13:18 2008
@@ -108,7 +108,26 @@
public abstract void setHandlerChain(HandlerChainsType handlerChain);
- public abstract HandlerChainsType getHandlerChain();
+ /**
+ * Return the handler chain configuration information as a HandlerChainsType object. If the
+ * key is non-null then it is used to look for handler chain configuration information in the
+ * sparse metadata. The order in which the configuration information is resolved is:
+ * 1) Look in sparse composite if the key is not null
+ * 2) Look in the composite
+ * 3) Look for a HandlerChain annotation and read in the file it specifies
+ *
+ * @param serviceDelegateKey May be null. If non-null, used to look for service-delegate
+ * specific sparse composite information.
+ * @return A HandlerChainsType object or null
+ */
+ public abstract HandlerChainsType getHandlerChain(Object serviceDelegateKey);
+
+ /**
+ * Return the handler chain configuration information as a HandlerChainsType object.
+ * This is the same as calling getHandlerChain(null).
+ * @see #getHandlerChain(Object)
+ */
+public abstract HandlerChainsType getHandlerChain();
/**
* Set the binding type FOR A CLIENT. The BindingType annotation is not valid on the client per
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=627929&r1=627928&r2=627929&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 Feb 14 18:13:18 2008
@@ -154,7 +154,6 @@
//ANNOTATION: @HandlerChain
private HandlerChain handlerChainAnnotation;
private HandlerChainsType handlerChainsType;
- private InputStream handlerChainSource;
// Information common to both WebService and WebServiceProvider annotations
private String annotation_WsdlLocation;
@@ -1289,14 +1288,34 @@
public void setHandlerChain(HandlerChainsType handlerChain) {
handlerChainsType = handlerChain;
}
-
+
+ public HandlerChainsType getHandlerChain() {
+ return getHandlerChain(null);
+ }
+
/**
- * Returns a schema derived java class containing the the handler configuration filel
- *
+ * Returns a schema derived java class containing the the handler configuration information.
+ * That information, returned in the HandlerChainsType object, is looked for in the following
+ * places in this order:
+ * - Set on the sparseComposite for the given key
+ * - Set on the composite
+ * - Read in from the file specified on HandlerChain annotation
+ *
* @return HandlerChainsType This is the top-level element for the Handler configuration file
+ *
*/
- public HandlerChainsType getHandlerChain() {
-
+ public HandlerChainsType getHandlerChain(Object sparseCompositeKey) {
+ // If there is a HandlerChainsType in the sparse composite for this ServiceDelegate
+ // (i.e. this sparseCompositeKey), then return that.
+ if (sparseCompositeKey != null) {
+ DescriptionBuilderComposite sparseComposite = composite.getSparseComposite(sparseCompositeKey);
+ if (sparseComposite != null && sparseComposite.getHandlerChainsType() != null) {
+ return sparseComposite.getHandlerChainsType();
+ }
+ }
+
+ // If there is no HandlerChainsType in the composite, then read in the file specified
+ // on the HandlerChain annotation if it is present.
if (handlerChainsType == null) {
getAnnoHandlerChainAnnotation();
if (handlerChainAnnotation != null) {
@@ -1324,14 +1343,6 @@
handlerChainsType =
DescriptionUtils.loadHandlerChains(is, this.getClass().getClassLoader());
}
- }
- else if(handlerChainSource != null) {
-
- if(log.isDebugEnabled()) {
- log.debug("Loading handlers from provided source");
- }
- handlerChainsType = DescriptionUtils.loadHandlerChains(handlerChainSource,
- this.getClass().getClassLoader());
}
}
return handlerChainsType;
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=627929&r1=627928&r2=627929&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 Feb 14 18:13:18 2008
@@ -1700,20 +1700,15 @@
// ANNOTATION: HandlerChain
// ===========================================
+ /* (non-Javadoc)
+ * @see org.apache.axis2.jaxws.description.ServiceDescription#getHandlerChain()
+ */
public HandlerChainsType getHandlerChain() {
return getHandlerChain(null);
}
- /**
- * Returns a schema derived java class containing the the handler configuration information.
- * That information, returned in the HandlerChainsType object, is looked for in the following
- * places in this order:
- * - Set on the sparseComposite for the given key
- * - Set on the composite
- * - Read in from the file specified on HandlerChain annotation
- *
- * @return HandlerChainsType This is the top-level element for the Handler configuration file
- *
+ /* (non-Javadoc)
+ * @see org.apache.axis2.jaxws.description.ServiceDescription#getHandlerChain(java.lang.Object)
*/
public HandlerChainsType getHandlerChain(Object sparseCompositeKey) {
// If there is a HandlerChainsType in the sparse composite for this ServiceDelegate
Modified: webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/impl/ClientDBCSupportHandlersTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/impl/ClientDBCSupportHandlersTests.java?rev=627929&r1=627928&r2=627929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/impl/ClientDBCSupportHandlersTests.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/impl/ClientDBCSupportHandlersTests.java Thu Feb 14 18:13:18 2008
@@ -18,10 +18,13 @@
*/
package org.apache.axis2.jaxws.description.impl;
+import org.apache.axis2.jaxws.description.DescriptionFactory;
+import org.apache.axis2.jaxws.description.EndpointDescription;
import org.apache.axis2.jaxws.description.ServiceDescription;
import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
import org.apache.axis2.jaxws.description.xml.handler.HandlerChainsType;
+import javax.jws.WebService;
import javax.xml.namespace.QName;
import javax.xml.ws.WebServiceClient;
@@ -38,9 +41,11 @@
public class ClientDBCSupportHandlersTests extends TestCase {
private String namespaceURI = "http://org.apache.axis2.jaxws.description.impl.ClientDBCSupportHandlersTests";
private String svcLocalPart = "svcLocalPart";
+ private String svcLocalPart2 = "svcLocalPart2";
+ private String portLocalPart = "portLocalPart";
/**
- * Create a ServiceDescription specifying a HandlerChain in a sparse composite
+ * Create a ServiceDescription specifying a HandlerChains Type in a sparse composite
*/
public void testHandlersOnService() {
QName serviceQName = new QName(namespaceURI, svcLocalPart);
@@ -51,7 +56,7 @@
composite.setHandlerChainsType(handlerChainsType);
Object compositeKey = "CompositeKey";
ServiceDescription svcDesc =
- new ServiceDescriptionImpl(null, serviceQName,
+ DescriptionFactory.createServiceDescription(null, serviceQName,
ClientDBCSupportHandlersService.class,
composite, compositeKey);
assertNotNull(svcDesc);
@@ -61,6 +66,47 @@
assertNull(svcDesc.getHandlerChain("WrongKey"));
}
+
+ /**
+ * Create an EndpointDescritoin specifying a HandlerChainsType in a sparse composite.
+ */
+ public void testHandlersOnEndpoint() {
+ // Note that Unit tests in the Maven environment run within a single instance of the JVM
+ // which means that the ServiceDescription crated by previous tests still exists. So
+ // we have to use a different service QName to be sure to always get a new ServiceDescription
+ // or we could pick up a sparse composite with key "CompositeKey" set on a ServiceDescription
+ // by another test, causing the assertNull(svcDesc.getHandlerChain("CompositeKey")) below
+ // to fail
+ QName serviceQName = new QName(namespaceURI, svcLocalPart2);
+ QName portQName = new QName(namespaceURI, portLocalPart);
+
+ DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
+
+ HandlerChainsType handlerChainsType = getHandlerChainsType();
+ composite.setHandlerChainsType(handlerChainsType);
+ Object compositeKey = "CompositeKey";
+
+ ServiceDescription svcDesc =
+ DescriptionFactory.createServiceDescription(null, serviceQName,
+ ClientDBCSupportHandlersService.class,
+ null, null);
+ assertNotNull(svcDesc);
+
+ EndpointDescription epDesc =
+ DescriptionFactory.updateEndpoint(svcDesc, ClientDBCSupportHandlersSEI.class, portQName,
+ DescriptionFactory.UpdateType.GET_PORT,
+ composite, compositeKey);
+ assertNotNull(epDesc);
+
+ // There should be no handler info on the Service, but there should be on the Endpoint
+ assertNull(svcDesc.getHandlerChain());
+ assertNull(svcDesc.getHandlerChain("CompositeKey"));
+ assertNull(svcDesc.getHandlerChain("WrongKey"));
+
+ assertNull(epDesc.getHandlerChain());
+ assertNotNull(epDesc.getHandlerChain("CompositeKey"));
+ assertNull(epDesc.getHandlerChain("WrongKey"));
+ }
private HandlerChainsType getHandlerChainsType() {
InputStream is = getXMLFileStream();
@@ -91,5 +137,10 @@
protected ClientDBCSupportHandlersService(URL wsdlDocumentLocation, QName serviceName) {
super(wsdlDocumentLocation, serviceName);
}
+}
+@WebService
+interface ClientDBCSupportHandlersSEI {
+ public String echo(String toEcho);
}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org