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/14 15:54:15 UTC
svn commit: r627767 - in /webservices/axis2/trunk/java/modules:
jaxws/src/org/apache/axis2/jaxws/ jaxws/src/org/apache/axis2/jaxws/handler/
jaxws/src/org/apache/axis2/jaxws/spi/
jaxws/test/org/apache/axis2/jaxws/handler/ jaxws/test/org/apache/axis2/jax...
Author: barrettj
Date: Thu Feb 14 06:54:08 2008
New Revision: 627767
URL: http://svn.apache.org/viewvc?rev=627767&view=rev
Log:
Support for HandlerChainsType specified in a sparse composite on the client requester when a Service is created. This can be used, for example, to associate
Handlers from a deployment descriptor such as JSR-109 client DD on all Ports under a Service.
Added:
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerResolverTest.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataHandlerChainTest.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/BindingProvider.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerResolverImpl.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.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/BindingProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java?rev=627767&r1=627766&r2=627767&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java Thu Feb 14 06:54:08 2008
@@ -98,24 +98,23 @@
// TODO should we allow the ServiceDelegate to figure out the default handlerresolver? Probably yes, since a client app may look for one there.
HandlerResolver handlerResolver = null;
if(serviceDelegate.getHandlerResolver() != null){
-
- // See if the metadata from creating the service indicates that MTOM should be enabled
- if (binding instanceof SOAPBinding) {
- boolean enableMTOMFromMetadata = endpointDesc.getServiceDescription().isMTOMEnabled(serviceDelegate);
- if (enableMTOMFromMetadata) {
- ((SOAPBinding) binding).setMTOMEnabled(true);
- }
- }
-
if(log.isDebugEnabled()){
log.debug("Reading default Handler Resolver ");
}
- handlerResolver= serviceDelegate.getHandlerResolver();
+ handlerResolver = serviceDelegate.getHandlerResolver();
}
else{
- handlerResolver = new HandlerResolverImpl(endpointDesc.getServiceDescription());
+ handlerResolver = new HandlerResolverImpl(endpointDesc.getServiceDescription(), serviceDelegate);
if(log.isDebugEnabled()){
log.debug("Creating new Handler Resolver using HandlerResolverImpl");
+ }
+ }
+
+ // See if the metadata from creating the service indicates that MTOM should be enabled
+ if (binding instanceof SOAPBinding) {
+ boolean enableMTOMFromMetadata = endpointDesc.getServiceDescription().isMTOMEnabled(serviceDelegate);
+ if (enableMTOMFromMetadata) {
+ ((SOAPBinding) binding).setMTOMEnabled(true);
}
}
binding.setHandlerChain(handlerResolver.getHandlerChain(endpointDesc.getPortInfo()));
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=627767&r1=627766&r2=627767&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 06:54:08 2008
@@ -64,13 +64,16 @@
* they could manipulate it.
*/
- // we'll need to refer to this object to get the port, and thus handlers
- //private EndpointDescription endpointDesc;
private ServiceDescription serviceDesc;
+ private Object serviceDelegateKey;
+
+ public HandlerResolverImpl(ServiceDescription sd) {
+ this(sd, null);
+ }
- public HandlerResolverImpl(ServiceDescription sd) { //EndpointDescription ed) {
- //this.endpointDesc = ed;
+ public HandlerResolverImpl(ServiceDescription sd, Object serviceDelegateKey) {
this.serviceDesc = sd;
+ this.serviceDelegateKey = serviceDelegateKey;
}
public List<Handler> getHandlerChain(PortInfo portinfo) {
@@ -136,7 +139,7 @@
* with the PortInfo object before we add it to the chain.
*/
- handlerChainsType = serviceDesc.getHandlerChain();
+ handlerChainsType = serviceDesc.getHandlerChain(serviceDelegateKey);
// if there's a handlerChain on the serviceDesc, it means the WSDL defined an import for a HandlerChain.
// the spec indicates that if a handlerchain also appears on the SEI on the client.
EndpointDescription ed = null;
@@ -149,6 +152,14 @@
if (handlerChainsType == null) {
handlerChainsType = handlerCT_fromEndpointDesc;
}
+ } else {
+ // There is no EndpointDescription that matches the portInfo specified so
+ // return the empty list of handlers since there are no ports that match
+ if (log.isDebugEnabled()) {
+ log.debug("The PortInfo object did not match any ports; returning an empty list of handlers."
+ + " PortInfo QName: " + portinfo.getPortName());
+ }
+ return handlers;
}
Iterator it = handlerChainsType == null ? null : handlerChainsType.getHandlerChain().iterator();
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java?rev=627767&r1=627766&r2=627767&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java Thu Feb 14 06:54:08 2008
@@ -577,7 +577,7 @@
*/
public HandlerResolver getHandlerResolver() {
if (handlerResolver == null) {
- handlerResolver = new HandlerResolverImpl(serviceDescription);
+ handlerResolver = new HandlerResolverImpl(serviceDescription, this);
}
return handlerResolver;
}
Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerResolverTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerResolverTest.java?rev=627767&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerResolverTest.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerResolverTest.java Thu Feb 14 06:54:08 2008
@@ -0,0 +1,181 @@
+/*
+ * 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.handler;
+
+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.impl.DescriptionUtils;
+import org.apache.axis2.jaxws.description.xml.handler.HandlerChainsType;
+
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebServiceClient;
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.HandlerResolver;
+import javax.xml.ws.handler.PortInfo;
+import javax.xml.ws.soap.SOAPBinding;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * Verify the HandlerResolverImpl functionality.
+ */
+public class HandlerResolverTest extends TestCase {
+ private String namespaceURI = "http://www.apache.org/test/namespace";
+ private String svcLocalPart = "DummyService";
+ private String portLocalPart = "DummyPort";
+ private String portWrongLocalPart = "WrongPort";
+
+ /**
+ * Test that setting the handler chain type on a sparse composite, but not
+ * specifying that composite during construction of the HandlerResolver (i.e. no
+ * Delegate key specified) results in no hanlders returned from this resolver.
+ */
+ public void testHandlerResolverNoKey() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ // Create a composite with a JAXB Handler Config
+ DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite();
+
+ HandlerChainsType handlerChainsType = getHandlerChainsType();
+ sparseComposite.setHandlerChainsType(handlerChainsType);
+ Object serviceDelegateKey = "CompositeKey";
+
+ ServiceDescription serviceDesc =
+ DescriptionFactory.createServiceDescription(null, serviceQName, HandlerResolverTestService.class, sparseComposite, serviceDelegateKey);
+ HandlerResolver resolver = new HandlerResolverImpl(serviceDesc);
+ assertNotNull(resolver);
+ PortInfo pi = new DummyPortInfo();
+ List<Handler> list = resolver.getHandlerChain(pi);
+ assertEquals(0, list.size());
+ }
+
+ /**
+ * The sparse composite has handler config information for the key that the HandlerResolver
+ * is created with, so that handler resolver contains those handlers. However, the
+ * portInfo specified on the getHandlerChain does NOT match the QName in the config file
+ * so no handlers should be returned.
+ */
+ public void testHandlerResolverInvalidPortInfo() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ QName portQName = new QName(namespaceURI, portWrongLocalPart);
+ // Create a composite with a JAXB Handler Config
+ DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite();
+
+ HandlerChainsType handlerChainsType = getHandlerChainsType();
+ sparseComposite.setHandlerChainsType(handlerChainsType);
+ Object serviceDelegateKey = "CompositeKey";
+
+ // The getHandlerChain will do handler lifecycle management as well, so there needs to be
+ // and EnpdointDescription (representing the Port) under the ServiceDescription
+ ServiceDescription serviceDesc =
+ DescriptionFactory.createServiceDescription(null, serviceQName, HandlerResolverTestService.class, sparseComposite, serviceDelegateKey);
+ EndpointDescription endpointDesc =
+ DescriptionFactory.updateEndpoint(serviceDesc, HandlerResolverTestSEI.class, portQName, DescriptionFactory.UpdateType.GET_PORT);
+ HandlerResolver resolver = new HandlerResolverImpl(serviceDesc, serviceDelegateKey);
+ assertNotNull(resolver);
+ PortInfo pi = new DummyPortInfo();
+ List<Handler> list = resolver.getHandlerChain(pi);
+ assertEquals(0, list.size());
+ }
+
+ /**
+ * The sparse composite has handler config information for the key that the HandlerResolver
+ * is created with, so that handler resolver contains those handlers.
+ */
+ public void testHandlerResolverValidPortInfo() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ QName portQName = new QName(namespaceURI, portLocalPart);
+ // Create a composite with a JAXB Handler Config
+ DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite();
+
+ HandlerChainsType handlerChainsType = getHandlerChainsType();
+ sparseComposite.setHandlerChainsType(handlerChainsType);
+ Object serviceDelegateKey = "CompositeKey";
+
+ // The getHandlerChain will do handler lifecycle management as well, so there needs to be
+ // and EnpdointDescription (representing the Port) under the ServiceDescription
+ ServiceDescription serviceDesc =
+ DescriptionFactory.createServiceDescription(null, serviceQName, HandlerResolverTestService.class, sparseComposite, serviceDelegateKey);
+ EndpointDescription endpointDesc =
+ DescriptionFactory.updateEndpoint(serviceDesc, HandlerResolverTestSEI.class, portQName, DescriptionFactory.UpdateType.GET_PORT);
+ HandlerResolver resolver = new HandlerResolverImpl(serviceDesc, serviceDelegateKey);
+ assertNotNull(resolver);
+ PortInfo pi = new DummyPortInfo();
+ List<Handler> list = resolver.getHandlerChain(pi);
+ assertEquals(2, list.size());
+
+ }
+
+ private HandlerChainsType getHandlerChainsType() {
+ InputStream is = getXMLFileStream();
+ assertNotNull(is);
+ HandlerChainsType returnHCT = DescriptionUtils.loadHandlerChains(is, this.getClass().getClassLoader());
+ assertNotNull(returnHCT);
+ return returnHCT;
+ }
+ private InputStream getXMLFileStream() {
+ InputStream is = null;
+ String configLoc = null;
+ try {
+ String sep = "/";
+ configLoc = sep + "test-resources" + sep + "configuration" + sep + "handlers" + sep + "handler.xml";
+ String baseDir = new File(System.getProperty("basedir",".")).getCanonicalPath();
+ is = new File(baseDir + configLoc).toURL().openStream();
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ }
+ return is;
+ }
+
+ public class DummyPortInfo implements PortInfo {
+
+ public String getBindingID() {
+ return SOAPBinding.SOAP11HTTP_BINDING;
+ }
+
+ public QName getPortName() {
+ return new QName("http://www.apache.org/test/namespace", "DummyPort");
+ }
+
+ public QName getServiceName() {
+ return new QName("http://www.apache.org/test/namespace", "DummyService");
+ }
+ }
+
+}
+
+@WebServiceClient
+class HandlerResolverTestService extends javax.xml.ws.Service {
+ protected HandlerResolverTestService(URL wsdlDocumentLocation, QName serviceName) {
+ super(wsdlDocumentLocation, serviceName);
+ }
+}
+
+@WebService
+interface HandlerResolverTestSEI {
+ public String echo(String toEcho);
+}
Added: 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=627767&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataHandlerChainTest.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataHandlerChainTest.java Thu Feb 14 06:54:08 2008
@@ -0,0 +1,224 @@
+/*
+ * 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.spi;
+
+import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
+import org.apache.axis2.jaxws.description.impl.DescriptionUtils;
+import org.apache.axis2.jaxws.description.xml.handler.HandlerChainsType;
+
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.HandlerResolver;
+import javax.xml.ws.handler.PortInfo;
+import javax.xml.ws.soap.SOAPBinding;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * Verify that handler chains specified using the HandlerChainsType in a sparse
+ * composite are correctly applied to Services and Ports on the client requester.
+ */
+public class ClientMetadataHandlerChainTest extends TestCase {
+
+ private String namespaceURI = "http://www.apache.org/test/namespace";
+ private String svcLocalPart = "DummyService";
+ private String portLocalPart = "DummyPort";
+
+ /**
+ * Test creating a service without a sparse composite. This verifies pre-existing default
+ * behavior.
+ */
+ public void testServiceNoComposite() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ QName portQName = new QName(namespaceURI, portLocalPart);
+
+ Service service = Service.create(serviceQName);
+ HandlerResolver resolver = service.getHandlerResolver();
+ assertNotNull(resolver);
+ PortInfo pi = new DummyPortInfo();
+ List<Handler> list = resolver.getHandlerChain(pi);
+ assertEquals(0, list.size());
+
+ ClientMetadataHandlerChainTestSEI port = service.getPort(portQName, ClientMetadataHandlerChainTestSEI.class);
+ // Verify that ports created under the service have no handlers from the sparse composite
+ BindingProvider bindingProvider = (BindingProvider) port;
+ Binding binding = (Binding) bindingProvider.getBinding();
+ List<Handler> portHandlers = binding.getHandlerChain();
+ assertEquals(0, portHandlers.size());
+ }
+
+
+ /**
+ * Test creating a service with a sparse composite that contains handler configuration
+ * information for this service delegate. Verify that the handlers are included in the
+ * chain.
+ */
+ public void testServiceWithComposite() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ QName portQName = new QName(namespaceURI, portLocalPart);
+ // Create a composite with a JAXB Handler Config
+ DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite();
+ HandlerChainsType handlerChainsType = getHandlerChainsType();
+ sparseComposite.setHandlerChainsType(handlerChainsType);
+
+ 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);
+ PortInfo pi = new DummyPortInfo();
+ List<Handler> list = resolver.getHandlerChain(pi);
+ assertEquals(2, list.size());
+
+ // Verify that ports created under the service have handlers
+ BindingProvider bindingProvider = (BindingProvider) port;
+ Binding binding = (Binding) bindingProvider.getBinding();
+ List<Handler> portHandlers = binding.getHandlerChain();
+ assertEquals(2, portHandlers.size());
+ assertTrue(containSameHandlers(portHandlers, list));
+ }
+
+ // TODO: (JLB) Change this test to check the handlers on the ports via the bindingImpl
+ public void _testMultipleServiceDelgates() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ PortInfo pi = new DummyPortInfo();
+
+ // Create a composite with a JAXB Handler Config
+ DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite();
+ HandlerChainsType handlerChainsType = getHandlerChainsType();
+ sparseComposite.setHandlerChainsType(handlerChainsType);
+
+ ServiceDelegate.setServiceMetadata(sparseComposite);
+ Service service = Service.create(serviceQName);
+
+ // No ports created yet, so there should be no relevant handler chains
+ HandlerResolver resolver0 = service.getHandlerResolver();
+ List<Handler> list0 = resolver0.getHandlerChain(pi);
+ assertEquals(0, list0.size());
+
+ QName portQName1 = new QName(namespaceURI, portLocalPart);
+ ClientMetadataHandlerChainTestSEI port1 = service.getPort(portQName1, ClientMetadataHandlerChainTestSEI.class);
+ HandlerResolver resolver1 = service.getHandlerResolver();
+ assertNotNull(resolver1);
+ List<Handler> list1 = resolver1.getHandlerChain(pi);
+ assertEquals(2, list1.size());
+
+ QName portQName2 = new QName(namespaceURI, "NoHandlerPort");
+ ClientMetadataHandlerChainTestSEI port2 = service.getPort(portQName2, ClientMetadataHandlerChainTestSEI.class);
+ HandlerResolver resolver2 = service.getHandlerResolver();
+ assertNotNull(resolver2);
+ // Use the same PortInfo from above
+ // TODO: (JLB) this is returning the resolver on the service, which has the correct port from above.
+ // the real test is that the handlers don't get attached to this port, which means writing some handlers
+ // or maybe checking the handler chain on the binding impl!
+ List<Handler> list2 = resolver2.getHandlerChain(pi);
+ assertEquals(0, list2.size());
+
+ QName portQName3 = new QName(namespaceURI, portLocalPart);
+ ClientMetadataHandlerChainTestSEI port3 = service.getPort(portQName1, ClientMetadataHandlerChainTestSEI.class);
+ HandlerResolver resolver3 = service.getHandlerResolver();
+ assertNotNull(resolver3);
+ List<Handler> list3 = resolver3.getHandlerChain(pi);
+ assertEquals(2, list3.size());
+
+ }
+
+ /**
+ * Answer if two List<Handler> arguments contain the same handler Class files.
+ * @param list1
+ * @param list2
+ * @return
+ */
+ private boolean containSameHandlers(List<Handler> list1, List<Handler> list2) {
+ if (list1.size() != list2.size()) {
+ return false;
+ }
+
+ Iterator<Handler> list1Iterator = list1.iterator();
+ ArrayList<Class> list1Handlers = new ArrayList<Class>();
+ while (list1Iterator.hasNext()) {
+ list1Handlers.add(list1Iterator.next().getClass());
+ }
+ Iterator<Handler> list2Iterator = list2.iterator();
+ ArrayList<Class> list2Handlers = new ArrayList<Class>();
+ while (list2Iterator.hasNext()) {
+ list2Handlers.add(list2Iterator.next().getClass());
+ }
+
+ if (list1Handlers.containsAll(list2Handlers)) {
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+
+ private HandlerChainsType getHandlerChainsType() {
+ InputStream is = getXMLFileStream();
+ assertNotNull(is);
+ HandlerChainsType returnHCT = DescriptionUtils.loadHandlerChains(is, this.getClass().getClassLoader());
+ assertNotNull(returnHCT);
+ return returnHCT;
+ }
+ private InputStream getXMLFileStream() {
+ InputStream is = null;
+ String configLoc = null;
+ try {
+ String sep = "/";
+ configLoc = sep + "test-resources" + sep + "configuration" + sep + "handlers" + sep + "handler.xml";
+ String baseDir = new File(System.getProperty("basedir",".")).getCanonicalPath();
+ is = new File(baseDir + configLoc).toURL().openStream();
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ }
+ return is;
+ }
+
+ public class DummyPortInfo implements PortInfo {
+
+ public String getBindingID() {
+ return SOAPBinding.SOAP11HTTP_BINDING;
+ }
+
+ public QName getPortName() {
+ return new QName("http://www.apache.org/test/namespace", "DummyPort");
+ }
+
+ public QName getServiceName() {
+ return new QName("http://www.apache.org/test/namespace", "DummyService");
+ }
+ }
+
+}
+
+@WebService
+interface ClientMetadataHandlerChainTestSEI {
+ public String echo(String toEcho);
+}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java?rev=627767&r1=627766&r2=627767&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java Thu Feb 14 06:54:08 2008
@@ -88,6 +88,25 @@
public abstract QName getServiceQName();
+ /**
+ * 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();
/**
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=627767&r1=627766&r2=627767&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 06:54:08 2008
@@ -593,13 +593,13 @@
// 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
+ // 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 = composite.getCorrespondingClass();
} else {
- // TODO: (JLB) This is the deprecated server-side introspection code for an impl that references an SEI
+ // 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 = forName(seiClassName, false,
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=627767&r1=627766&r2=627767&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 06:54:08 2008
@@ -1700,14 +1700,33 @@
// ANNOTATION: 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();
Added: 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=627767&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/impl/ClientDBCSupportHandlersTests.java (added)
+++ webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/impl/ClientDBCSupportHandlersTests.java Thu Feb 14 06:54:08 2008
@@ -0,0 +1,95 @@
+/*
+ * 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.impl;
+
+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.xml.namespace.QName;
+import javax.xml.ws.WebServiceClient;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+/**
+ * Test client composite support for handler chains specified via sparse composites
+ * applied to services and ports.
+ */
+public class ClientDBCSupportHandlersTests extends TestCase {
+ private String namespaceURI = "http://org.apache.axis2.jaxws.description.impl.ClientDBCSupportHandlersTests";
+ private String svcLocalPart = "svcLocalPart";
+
+ /**
+ * Create a ServiceDescription specifying a HandlerChain in a sparse composite
+ */
+ public void testHandlersOnService() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ // Create a composite with a JAXB Handler Config
+ DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
+
+ HandlerChainsType handlerChainsType = getHandlerChainsType();
+ composite.setHandlerChainsType(handlerChainsType);
+ Object compositeKey = "CompositeKey";
+ ServiceDescription svcDesc =
+ new ServiceDescriptionImpl(null, serviceQName,
+ ClientDBCSupportHandlersService.class,
+ composite, compositeKey);
+ assertNotNull(svcDesc);
+ // There should only be a handler chain for the given key.
+ assertNull(svcDesc.getHandlerChain());
+ assertNotNull(svcDesc.getHandlerChain("CompositeKey"));
+ assertNull(svcDesc.getHandlerChain("WrongKey"));
+
+ }
+
+ private HandlerChainsType getHandlerChainsType() {
+ InputStream is = getXMLFileStream();
+ assertNotNull(is);
+ HandlerChainsType returnHCT = DescriptionUtils.loadHandlerChains(is, this.getClass().getClassLoader());
+ assertNotNull(returnHCT);
+ return returnHCT;
+ }
+ private InputStream getXMLFileStream() {
+ InputStream is = null;
+ String configLoc = null;
+ try {
+ String sep = "/";
+ configLoc = sep + "test-resources" + sep + "test-handler.xml";
+ String baseDir = new File(System.getProperty("basedir",".")).getCanonicalPath();
+ is = new File(baseDir + configLoc).toURL().openStream();
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ }
+ return is;
+ }
+
+}
+
+@WebServiceClient
+class ClientDBCSupportHandlersService extends javax.xml.ws.Service {
+ protected ClientDBCSupportHandlersService(URL wsdlDocumentLocation, QName serviceName) {
+ super(wsdlDocumentLocation, serviceName);
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org