[jboss-svn-commits] JBossWS SVN: r735 - in branches/tdiesler/trunk/src: main/java/org/jboss/ws/jaxws/handler test/java/org/jboss/test/ws/jaxws test/java/org/jboss/test/ws/jaxws/handlerscope
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Aug 13 07:11:31 EDT 2006
Author: thomas.diesler at jboss.com
Date: 2006-08-13 07:11:25 -0400 (Sun, 13 Aug 2006)
New Revision: 735
Added:
branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/handler/GenericHandler.java
branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/handler/GenericSOAPHandler.java
branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/handlerscope/
branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/handlerscope/ClientHandler.java
branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/handlerscope/HandlerScopeTestCase.java
branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/handlerscope/SOAPEndpoint.java
branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/handlerscope/SOAPEndpointBean.java
Log:
handler scoping
Added: branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/handler/GenericHandler.java
===================================================================
--- branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/handler/GenericHandler.java 2006-08-13 11:10:17 UTC (rev 734)
+++ branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/handler/GenericHandler.java 2006-08-13 11:11:25 UTC (rev 735)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jaxws.handler;
+
+// $Id: $
+
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.PortInfo;
+
+/**
+ * A generic jaxws handler
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 13-Aug-2006
+ */
+public abstract class GenericHandler implements Handler
+{
+ private PortInfo portInfo;
+
+ public GenericHandler()
+ {
+ }
+
+ public GenericHandler(PortInfo portInfo)
+ {
+ this.portInfo = portInfo;
+ }
+
+ public PortInfo getPortInfo()
+ {
+ return portInfo;
+ }
+
+ public void setPortInfo(PortInfo portInfo)
+ {
+ this.portInfo = portInfo;
+ }
+
+ public boolean handleMessage(MessageContext msgContext)
+ {
+ Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+ if (outbound == null)
+ throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+
+ return outbound ? handleOutbound(msgContext) : handleInbound(msgContext);
+ }
+
+ protected boolean handleOutbound(MessageContext msgContext)
+ {
+ return true;
+ }
+
+ protected boolean handleInbound(MessageContext msgContext)
+ {
+ return true;
+ }
+
+ public boolean handleFault(MessageContext messagecontext)
+ {
+ return true;
+ }
+
+ public void close(MessageContext messagecontext)
+ {
+ }
+}
Added: branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/handler/GenericSOAPHandler.java
===================================================================
--- branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/handler/GenericSOAPHandler.java 2006-08-13 11:10:17 UTC (rev 734)
+++ branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/handler/GenericSOAPHandler.java 2006-08-13 11:11:25 UTC (rev 735)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jaxws.handler;
+
+// $Id: $
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.handler.PortInfo;
+import javax.xml.ws.handler.soap.SOAPHandler;
+
+/**
+ * A generic jaxws soap handler
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 13-Aug-2006
+ */
+public abstract class GenericSOAPHandler extends GenericHandler implements SOAPHandler
+{
+ // The header blocks that can be processed by this Handler instance
+ private Set<QName> headers = new HashSet<QName>();
+
+ public GenericSOAPHandler()
+ {
+ }
+
+ public GenericSOAPHandler(PortInfo portInfo)
+ {
+ super(portInfo);
+ }
+
+ /** Gets the header blocks that can be processed by this Handler instance.
+ */
+ public Set<QName> getHeaders()
+ {
+ return headers;
+ }
+
+ /** Sets the header blocks that can be processed by this Handler instance.
+ */
+ public void setHeaders(Set<QName> headers)
+ {
+ this.headers = headers;
+ }
+}
Added: branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/handlerscope/ClientHandler.java
===================================================================
--- branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/handlerscope/ClientHandler.java 2006-08-13 11:10:17 UTC (rev 734)
+++ branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/handlerscope/ClientHandler.java 2006-08-13 11:11:25 UTC (rev 735)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.test.ws.jaxws.handlerscope;
+
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.PortInfo;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.jboss.ws.jaxws.handler.GenericSOAPHandler;
+import org.jboss.ws.jaxws.handler.PortInfoImpl;
+
+/**
+ * A client side handler for the ws-addressing
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 24-Nov-2005
+ */
+public class ClientHandler extends GenericSOAPHandler
+{
+ public ClientHandler(PortInfoImpl portInfo)
+ {
+ super(portInfo);
+ }
+
+ public boolean handleOutbound(MessageContext msgContext)
+ {
+ try
+ {
+ SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
+ SOAPElement soapElement = (SOAPElement)soapMessage.getSOAPBody().getChildElements().next();
+ String value = soapElement.getValue();
+
+ PortInfo portInfo = getPortInfo();
+ soapElement.setValue(value + ":" + portInfo);
+
+ return true;
+ }
+ catch (SOAPException ex)
+ {
+ throw new WebServiceException(ex);
+ }
+ }
+
+ public boolean handleInbound(MessageContext msgContext)
+ {
+ try
+ {
+ SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
+ SOAPElement soapElement = (SOAPElement)soapMessage.getSOAPBody().getChildElements().next();
+ soapElement = (SOAPElement)soapElement.getChildElements().next();
+ String value = soapElement.getValue();
+
+ PortInfo portInfo = getPortInfo();
+ soapElement.setValue(value + ":" + portInfo);
+
+ return true;
+ }
+ catch (SOAPException ex)
+ {
+ throw new WebServiceException(ex);
+ }
+ }
+}
Added: branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/handlerscope/HandlerScopeTestCase.java
===================================================================
--- branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/handlerscope/HandlerScopeTestCase.java 2006-08-13 11:10:17 UTC (rev 734)
+++ branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/handlerscope/HandlerScopeTestCase.java 2006-08-13 11:11:25 UTC (rev 735)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.test.ws.jaxws.handlerscope;
+
+// $Id: $
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+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 junit.framework.Test;
+
+import org.jboss.test.ws.JBossWSTest;
+import org.jboss.test.ws.JBossWSTestSetup;
+
+/**
+ * Test SOAP12 binding type
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 12-Aug-2006
+ */
+public class HandlerScopeTestCase extends JBossWSTest
+{
+ public static Test suite()
+ {
+ return JBossWSTestSetup.newTestSetup(HandlerScopeTestCase.class, "jbossws-jaxws-handlerscope.war");
+ }
+
+ public void testClientAccess() throws Exception
+ {
+ URL wsdlURL = new URL("http://" + getServerHost() + ":8080/jbossws-jaxws-handlerscope?wsdl");
+ QName serviceName = new QName("http://org.jboss.ws/jaxws/handlerscope", "SOAPEndpointService");
+ QName portName = new QName("http://org.jboss.ws/jaxws/handlerscope", "SOAPEndpointPort");
+ Service service = Service.create(wsdlURL, serviceName);
+ SOAPEndpoint port = (SOAPEndpoint)service.getPort(SOAPEndpoint.class);
+
+ HandlerResolver handlerResolver = new HandlerResolver()
+ {
+ public List<Handler> getHandlerChain(PortInfo info)
+ {
+ List<Handler> handlerChain = new ArrayList<Handler>();
+
+ QName sname = info.getServiceName();
+ QName pname = info.getPortName();
+ String bid = info.getBindingID();
+
+ return handlerChain;
+ }
+ };
+ service.setHandlerResolver(handlerResolver);
+
+
+ String retStr = port.echo("hello");
+ assertEquals("hello", retStr);
+ }
+}
Added: branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/handlerscope/SOAPEndpoint.java
===================================================================
--- branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/handlerscope/SOAPEndpoint.java 2006-08-13 11:10:17 UTC (rev 734)
+++ branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/handlerscope/SOAPEndpoint.java 2006-08-13 11:11:25 UTC (rev 735)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.test.ws.jaxws.handlerscope;
+
+// $Id: $
+
+public interface SOAPEndpoint
+{
+ public String echo(String msg);
+}
Added: branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/handlerscope/SOAPEndpointBean.java
===================================================================
--- branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/handlerscope/SOAPEndpointBean.java 2006-08-13 11:10:17 UTC (rev 734)
+++ branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/handlerscope/SOAPEndpointBean.java 2006-08-13 11:11:25 UTC (rev 735)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.test.ws.jaxws.handlerscope;
+
+// $Id: $
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.Style;
+import javax.xml.ws.BindingType;
+
+import org.jboss.logging.Logger;
+
+ at WebService(name = "SOAPEndpoint", targetNamespace = "http://org.jboss.ws/jaxws/handlerscope")
+ at BindingType(value = "http://www.w3.org/2003/05/soap/bindings/HTTP/") // SOAP-1.2
+ at SOAPBinding(style = Style.RPC)
+public class SOAPEndpointBean implements SOAPEndpoint
+{
+ private static Logger log = Logger.getLogger(SOAPEndpointBean.class);
+
+ @WebMethod
+ public String echo(String msg)
+ {
+ log.info("echo: " + msg);
+ return msg + ":endpoint";
+ }
+}
More information about the jboss-svn-commits
mailing list