Author: alessio.soldano(a)jboss.com
Date: 2009-01-14 12:27:29 -0500 (Wed, 14 Jan 2009)
New Revision: 9035
Added:
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientFeatureProcessor.java
Modified:
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/EndpointFeatureProcessor.java
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsaddressing/AddressingStatefulTestCase.java
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsaddressing/StatefulEndpointImpl.java
Log:
[JBWS-2446][JBWS-2447] Enable WS-Addressing using @Addressing and AddressingFeature
Added:
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientFeatureProcessor.java
===================================================================
---
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientFeatureProcessor.java
(rev 0)
+++
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientFeatureProcessor.java 2009-01-14
17:27:29 UTC (rev 9035)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ws.core.jaxws.client;
+
+import java.util.List;
+
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.WebServiceFeature;
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.soap.AddressingFeature;
+
+import org.jboss.ws.core.jaxws.binding.BindingExt;
+import org.jboss.ws.extensions.addressing.jaxws.WSAddressingClientHandler;
+import org.jboss.ws.metadata.umdm.EndpointMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData.HandlerType;
+
+/**
+ * Process WebServiceFeature provided on client side
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 14-Jan-2009
+ *
+ */
+public class ClientFeatureProcessor
+{
+ public static <T> void processFeature(WebServiceFeature feature,
EndpointMetaData epMetaData, T stub)
+ {
+ epMetaData.addFeature(feature);
+ processWSAddressingFeature(feature, epMetaData, stub);
+ }
+
+ @SuppressWarnings("unchecked")
+ private static <T> void processWSAddressingFeature(WebServiceFeature feature,
EndpointMetaData epMetaData, T stub)
+ {
+ if (feature instanceof AddressingFeature && feature.isEnabled())
+ {
+ BindingExt bindingExt = (BindingExt)((BindingProvider)stub).getBinding();
+ List<Handler> handlers = bindingExt.getHandlerChain(HandlerType.POST);
+ handlers.add(new WSAddressingClientHandler());
+ bindingExt.setHandlerChain(handlers, HandlerType.POST);
+ }
+ }
+
+}
Property changes on:
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientFeatureProcessor.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java
===================================================================
---
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java 2009-01-14
17:25:35 UTC (rev 9034)
+++
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java 2009-01-14
17:27:29 UTC (rev 9035)
@@ -54,6 +54,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.core.StubExt;
+import org.jboss.ws.core.jaxws.client.ClientFeatureProcessor;
import org.jboss.ws.core.jaxws.client.ClientImpl;
import org.jboss.ws.core.jaxws.client.ClientProxy;
import org.jboss.ws.core.jaxws.client.DispatchImpl;
@@ -559,7 +560,7 @@
EndpointMetaData epMetaData = ((StubExt)stub).getEndpointMetaData();
for (WebServiceFeature feature : features)
{
- epMetaData.addFeature(feature);
+ ClientFeatureProcessor.processFeature(feature, epMetaData, stub);
}
}
}
Modified:
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/EndpointFeatureProcessor.java
===================================================================
---
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/EndpointFeatureProcessor.java 2009-01-14
17:25:35 UTC (rev 9034)
+++
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/EndpointFeatureProcessor.java 2009-01-14
17:27:29 UTC (rev 9035)
@@ -25,16 +25,25 @@
import java.lang.annotation.Annotation;
import java.net.URL;
+import javax.xml.ws.soap.Addressing;
+import javax.xml.ws.soap.AddressingFeature;
+
import org.jboss.ws.WSException;
import org.jboss.ws.annotation.FastInfoset;
import org.jboss.ws.annotation.JsonEncoding;
import org.jboss.ws.annotation.SchemaValidation;
+import org.jboss.ws.extensions.addressing.jaxws.WSAddressingClientHandler;
+import org.jboss.ws.extensions.addressing.jaxws.WSAddressingServerHandler;
import org.jboss.ws.feature.FastInfosetFeature;
import org.jboss.ws.feature.JsonEncodingFeature;
import org.jboss.ws.feature.SchemaValidationFeature;
+import org.jboss.ws.metadata.umdm.ClientEndpointMetaData;
+import org.jboss.ws.metadata.umdm.EndpointMetaData;
+import org.jboss.ws.metadata.umdm.HandlerMetaDataJAXWS;
import org.jboss.ws.metadata.umdm.ServerEndpointMetaData;
import org.jboss.wsf.spi.deployment.ArchiveDeployment;
import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData.HandlerType;
import org.xml.sax.ErrorHandler;
/**
@@ -49,8 +58,14 @@
{
for (Annotation an : sepClass.getAnnotations())
{
- if (an.annotationType() == SchemaValidation.class)
+ if (an.annotationType() == Addressing.class)
{
+ Addressing anFeature = sepClass.getAnnotation(Addressing.class);
+ AddressingFeature feature = new AddressingFeature(anFeature.enabled(),
anFeature.required());
+ sepMetaData.addFeature(feature);
+ }
+ else if (an.annotationType() == SchemaValidation.class)
+ {
processSchemaValidation(dep, sepMetaData, sepClass);
}
else if (an.annotationType() == FastInfoset.class)
@@ -67,6 +82,25 @@
}
}
}
+
+ protected void setupEndpointFeatures(ServerEndpointMetaData sepMetaData)
+ {
+ setupAddressingFeature(sepMetaData);
+ }
+
+ private static void setupAddressingFeature(ServerEndpointMetaData sepMetaData)
+ {
+ AddressingFeature addressingFeature =
sepMetaData.getFeature(AddressingFeature.class);
+ if (addressingFeature != null && addressingFeature.isEnabled())
+ {
+ HandlerMetaDataJAXWS hmd = new HandlerMetaDataJAXWS(HandlerType.POST);
+ hmd.setEndpointMetaData(sepMetaData);
+ hmd.setHandlerClassName(WSAddressingServerHandler.class.getName());
+ hmd.setHandlerName("WSAddressing Handler");
+ hmd.setProtocolBindings("##SOAP11_HTTP ##SOAP12_HTTP ##SOAP11_HTTP_MTOM
##SOAP12_HTTP_MTOM");
+ sepMetaData.addHandler(hmd);
+ }
+ }
private void processSchemaValidation(Deployment dep, ServerEndpointMetaData
sepMetaData, Class<?> sepClass)
{
Modified:
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java
===================================================================
---
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java 2009-01-14
17:25:35 UTC (rev 9034)
+++
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java 2009-01-14
17:27:29 UTC (rev 9035)
@@ -186,6 +186,9 @@
processHandlerChain(sepMetaData, sepClass);
else if (seiClass.isAnnotationPresent(HandlerChain.class))
processHandlerChain(sepMetaData, seiClass);
+
+ //setup web service feature contributions
+ epFeatureProcessor.setupEndpointFeatures(sepMetaData);
// process webservices.xml contributions
processWSDDContribution(sepMetaData);
Modified:
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsaddressing/AddressingStatefulTestCase.java
===================================================================
---
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsaddressing/AddressingStatefulTestCase.java 2009-01-14
17:25:35 UTC (rev 9034)
+++
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsaddressing/AddressingStatefulTestCase.java 2009-01-14
17:27:29 UTC (rev 9035)
@@ -29,6 +29,7 @@
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Service;
import javax.xml.ws.handler.Handler;
+import javax.xml.ws.soap.AddressingFeature;
import junit.framework.Test;
@@ -71,11 +72,11 @@
bindingProvider.getBinding().setHandlerChain(customHandlerChain);
Service service2 = Service.create(wsdlURL, serviceName);
- port2 = (StatefulEndpoint)service2.getPort(StatefulEndpoint.class);
+ port2 = (StatefulEndpoint)service2.getPort(StatefulEndpoint.class, new
AddressingFeature(true, true));
bindingProvider = (BindingProvider)port2;
List<Handler> customHandlerChain2 = new ArrayList<Handler>();
customHandlerChain2.add(new ClientHandler());
- customHandlerChain2.add(new WSAddressingClientHandler());
+// customHandlerChain2.add(new WSAddressingClientHandler());
bindingProvider.getBinding().setHandlerChain(customHandlerChain2);
}
Modified:
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsaddressing/StatefulEndpointImpl.java
===================================================================
---
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsaddressing/StatefulEndpointImpl.java 2009-01-14
17:25:35 UTC (rev 9034)
+++
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsaddressing/StatefulEndpointImpl.java 2009-01-14
17:27:29 UTC (rev 9035)
@@ -34,9 +34,9 @@
import javax.xml.namespace.QName;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.soap.Addressing;
import org.jboss.logging.Logger;
-import org.jboss.ws.annotation.EndpointConfig;
/**
* WS-Addressing stateful service endpoint
@@ -45,7 +45,7 @@
* @since 24-Nov-2005
*/
@WebService(name = "StatefulEndpoint", targetNamespace =
"http://org.jboss.ws/samples/wsaddressing", serviceName =
"TestService")
-@EndpointConfig(configName = "Standard WSAddressing Endpoint")
+@Addressing
@HandlerChain(file = "jaxws-handlers.xml")
@SOAPBinding(style = SOAPBinding.Style.RPC)
public class StatefulEndpointImpl implements StatefulEndpoint