Author: heiko.braun(a)jboss.com
Date: 2008-02-28 14:01:39 -0500 (Thu, 28 Feb 2008)
New Revision: 5852
Added:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/MessageStreamAdapter.java
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/MessageStreamConnectionImpl.java
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/MessageStreamContext.java
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/DelegationServlet.java
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/JBWS1869Endpoint.java
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/JBWS1869EndpointImpl.java
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/JBWS1869TestCase.java
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/jaxws/
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/jaxws/Echo.java
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/jaxws/EchoResponse.java
stack/metro/trunk/src/test/resources/jaxws/jbws1869/
stack/metro/trunk/src/test/resources/jaxws/jbws1869/WEB-INF/
stack/metro/trunk/src/test/resources/jaxws/jbws1869/WEB-INF/web.xml
Modified:
stack/metro/trunk/ant-import-tests/build-jars-jaxws.xml
stack/metro/trunk/metro-trunk.iml
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/RequestHandlerImpl.java
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/metadata/RuntimeModelDeploymentAspect.java
Log:
Fix JBWS-1869: Support stream based invocations through RequestHandler
Modified: stack/metro/trunk/ant-import-tests/build-jars-jaxws.xml
===================================================================
--- stack/metro/trunk/ant-import-tests/build-jars-jaxws.xml 2008-02-28 16:32:23 UTC (rev
5851)
+++ stack/metro/trunk/ant-import-tests/build-jars-jaxws.xml 2008-02-28 19:01:39 UTC (rev
5852)
@@ -9,43 +9,54 @@
<!-- $Id$ -->
<project>
-
- <description>JBossWS test archive builder</description>
-
- <!-- ================================================================== -->
- <!-- Building -->
- <!-- ================================================================== -->
-
- <target name="build-jars-jaxws" description="Build the
deployments.">
-
- <mkdir dir="${tests.output.dir}/libs"/>
- <!-- jbws1871 -->
- <war warfile="${tests.output.dir}/libs/jaxws-jbws1871.war"
-
webxml="${tests.output.dir}/resources/jaxws/jbws1871/WEB-INF/web.xml">
- <classes dir="${tests.output.dir}/classes">
- <include name="org/jboss/test/ws/jaxws/jbws1871/**/*"/>
- </classes>
- <webinf
dir="${tests.output.dir}/resources/jaxws/jbws1871/WEB-INF">
- <include name="**/*"/>
- </webinf>
- </war>
+ <description>JBossWS test archive builder</description>
- <!-- wsit-rm -->
- <war warfile="${tests.output.dir}/libs/wsit-rm.war"
webxml="${tests.output.dir}/resources/wsit/rm/WEB-INF/web.xml">
- <classes dir="${tests.output.dir}/classes">
- <include
name="org/jboss/test/ws/wsit/rm/CalculatorWSImpl.class"/>
- <include name="org/jboss/test/ws/wsit/rm/CalculatorWS.class"/>
- <include name="org/jboss/test/ws/wsit/rm/Add.class"/>
- <include name="org/jboss/test/ws/wsit/rm/AddResponse.class"/>
- </classes>
- <webinf dir="${tests.output.dir}/resources/wsit/rm/WEB-INF">
- <include name="sun-web.xml"/>
- <include name="web.xml"/>
- <include
name="wsit-org.jboss.test.ws.wsit.rm.CalculatorWSImpl.xml"/>
- </webinf>
- </war>
+ <!-- ================================================================== -->
+ <!-- Building -->
+ <!-- ================================================================== -->
- </target>
-
+ <target name="build-jars-jaxws" description="Build the
deployments.">
+
+ <mkdir dir="${tests.output.dir}/libs"/>
+
+ <!-- jbws1869 -->
+ <war warfile="${tests.output.dir}/libs/jaxws-jbws1869.war"
+
webxml="${tests.output.dir}/resources/jaxws/jbws1869/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/classes">
+ <include name="org/jboss/test/ws/jaxws/jbws1869/**/*"/>
+ </classes>
+ <webinf
dir="${tests.output.dir}/resources/jaxws/jbws1869/WEB-INF">
+ <include name="**/*"/>
+ </webinf>
+ </war>
+
+ <!-- jbws1871 -->
+ <war warfile="${tests.output.dir}/libs/jaxws-jbws1871.war"
+
webxml="${tests.output.dir}/resources/jaxws/jbws1871/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/classes">
+ <include name="org/jboss/test/ws/jaxws/jbws1871/**/*"/>
+ </classes>
+ <webinf
dir="${tests.output.dir}/resources/jaxws/jbws1871/WEB-INF">
+ <include name="**/*"/>
+ </webinf>
+ </war>
+
+ <!-- wsit-rm -->
+ <war warfile="${tests.output.dir}/libs/wsit-rm.war"
webxml="${tests.output.dir}/resources/wsit/rm/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/classes">
+ <include
name="org/jboss/test/ws/wsit/rm/CalculatorWSImpl.class"/>
+ <include
name="org/jboss/test/ws/wsit/rm/CalculatorWS.class"/>
+ <include name="org/jboss/test/ws/wsit/rm/Add.class"/>
+ <include
name="org/jboss/test/ws/wsit/rm/AddResponse.class"/>
+ </classes>
+ <webinf dir="${tests.output.dir}/resources/wsit/rm/WEB-INF">
+ <include name="sun-web.xml"/>
+ <include name="web.xml"/>
+ <include
name="wsit-org.jboss.test.ws.wsit.rm.CalculatorWSImpl.xml"/>
+ </webinf>
+ </war>
+
+ </target>
+
</project>
Modified: stack/metro/trunk/metro-trunk.iml
===================================================================
--- stack/metro/trunk/metro-trunk.iml 2008-02-28 16:32:23 UTC (rev 5851)
+++ stack/metro/trunk/metro-trunk.iml 2008-02-28 19:01:39 UTC (rev 5852)
@@ -184,15 +184,6 @@
<orderEntry type="module-library">
<library>
<CLASSES>
- <root url="jar://$MODULE_DIR$/thirdparty/jaxws-rt.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES />
- </library>
- </orderEntry>
- <orderEntry type="module-library">
- <library>
- <CLASSES>
<root url="jar://$MODULE_DIR$/thirdparty/jaxws-api.jar!/" />
</CLASSES>
<JAVADOC />
@@ -388,6 +379,7 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="module" module-name="jaxws-2.1.3-src" />
<orderEntryProperties />
</component>
</module>
Added:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/MessageStreamAdapter.java
===================================================================
--- stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/MessageStreamAdapter.java
(rev 0)
+++
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/MessageStreamAdapter.java 2008-02-28
19:01:39 UTC (rev 5852)
@@ -0,0 +1,124 @@
+/*
+ * 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.wsf.stack.metro;
+
+import com.sun.xml.ws.api.message.Packet;
+import com.sun.xml.ws.api.server.Adapter;
+import com.sun.xml.ws.api.server.TransportBackChannel;
+import com.sun.xml.ws.api.server.WSEndpoint;
+import com.sun.xml.ws.transport.http.DeploymentDescriptorParser.AdapterFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Heiko Braun
+ */
+public class MessageStreamAdapter extends
Adapter<MessageStreamAdapter.StreamToolkit> {
+
+ final String name;
+
+ public MessageStreamAdapter(String name, WSEndpoint endpoint)
+ {
+ super(endpoint);
+ this.name = name;
+ }
+
+ public void handle(MessageStreamContext context, InputStream in, OutputStream out)
throws IOException
+ {
+ MessageStreamConnectionImpl connection = new MessageStreamConnectionImpl(context,
in, out);
+
+ StreamToolkit tk = pool.take();
+ try {
+ tk.handle(connection);
+ connection.flush();
+ } finally {
+ pool.recycle(tk);
+ connection.close();
+ }
+ }
+
+ protected StreamToolkit createToolkit() {
+ return new StreamToolkit();
+ }
+
+ class StreamToolkit extends Adapter.Toolkit implements TransportBackChannel {
+
+ private MessageStreamConnectionImpl connection;
+
+ private void handle(MessageStreamConnectionImpl connection) throws IOException {
+ this.connection = connection;
+
+ String contentTypeStr =
connection.getRequestHeader(MessageStreamContext.CONTENT_TYPE);
+ InputStream in = connection.getInputStream();
+ Packet packet = new Packet();
+
+ codec.decode(in, contentTypeStr, packet);
+
+ try
+ {
+ packet = head.process(packet, connection, this);
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ writeInternalServerError(connection);
+ return;
+ }
+
+ contentTypeStr = codec.getStaticContentType(packet).getContentType();
+ if (contentTypeStr == null)
+ {
+ throw new UnsupportedOperationException();
+ }
+ else
+ {
+ Map<String, String> headers = new HashMap();
+ headers.put(MessageStreamContext.CONTENT_TYPE, contentTypeStr);
+ connection.setResponseHeaders(headers);
+
+ codec.encode(packet, connection.getOutputStream());
+ }
+
+ }
+
+ private void writeInternalServerError(MessageStreamConnectionImpl connection) {
+ connection.setStatus(MessageStreamContext.STATUS_INTERNAL_SERVER_ERROR);
+ }
+
+ public void close() {
+ connection.close();
+ }
+
+ }
+
+ public static final AdapterFactory<MessageStreamAdapter> FACTORY = new
AdapterFactory<MessageStreamAdapter>()
+ {
+ public MessageStreamAdapter createAdapter(String name, String urlPattern,
WSEndpoint<?> endpoint)
+ {
+ return new MessageStreamAdapter(name, endpoint);
+ }
+ };
+}
Property changes on:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/MessageStreamAdapter.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/MessageStreamConnectionImpl.java
===================================================================
---
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/MessageStreamConnectionImpl.java
(rev 0)
+++
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/MessageStreamConnectionImpl.java 2008-02-28
19:01:39 UTC (rev 5852)
@@ -0,0 +1,164 @@
+/*
+ * 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.wsf.stack.metro;
+
+import com.sun.istack.NotNull;
+import com.sun.xml.ws.api.message.Packet;
+import com.sun.xml.ws.api.server.WSEndpoint;
+import com.sun.xml.ws.api.server.WebServiceContextDelegate;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.Principal;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Heiko Braun
+ */
+public class MessageStreamConnectionImpl implements WebServiceContextDelegate {
+
+ private MessageStreamContext messageContext;
+ private InputStream inputStream;
+ private OutputStream outputStream;
+
+ private int status;
+
+ private boolean isClosed;
+
+ private Map<String, String> requestHeaders;
+ private Map<String, String> responseHeaders;
+
+ public MessageStreamConnectionImpl(MessageStreamContext context, InputStream in,
OutputStream out)
+ {
+ outputStream = out;
+ inputStream = in;
+ messageContext = context;
+
+ populateRequestHeaders();
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void setStatus(int statusCode) {
+ this.status = statusCode;
+ }
+
+ public Map<String, String> getRequestHeaders() {
+ return requestHeaders;
+ }
+
+ public void setRequestHeaders(Map<String, String> requestHeaders) {
+ this.requestHeaders = requestHeaders;
+ }
+
+ public String getRequestHeader(String name) {
+ return requestHeaders.get(name);
+ }
+
+ public Map<String, String> getResponseHeaders() {
+ return responseHeaders;
+ }
+
+ public void setResponseHeaders(Map<String, String> responseHeaders) {
+ this.responseHeaders = responseHeaders;
+ }
+
+ public InputStream getInputStream() {
+ return inputStream;
+ }
+
+ public OutputStream getOutputStream() {
+ return outputStream;
+ }
+
+ public void closeInput() {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException ex) {
+ }
+
+ inputStream = null;
+ }
+ }
+
+ public void closeOutput() {
+ if (outputStream != null) {
+ try {
+ outputStream.close();
+ } catch (IOException ex) {
+ }
+
+ outputStream = null;
+ }
+ }
+
+ public void close() {
+ if (!isClosed) {
+ synchronized (this) {
+ if (!isClosed) {
+ isClosed = true;
+
+ closeInput();
+ closeOutput();
+ }
+ }
+ }
+ }
+
+ // Not supported
+ public Principal getUserPrincipal(Packet request) {
+ return null;
+ }
+
+ // Not supported
+ public boolean isUserInRole(Packet request, String role) {
+ return false;
+ }
+
+ public @NotNull String getEPRAddress(@NotNull Packet request, @NotNull WSEndpoint
endpoint) {
+ return null;
+ }
+
+ public String getWSDLAddress(@NotNull Packet request, @NotNull WSEndpoint endpoint) {
+ return null;
+ }
+
+ public void flush() throws IOException {
+ if (outputStream != null) {
+ outputStream.flush();
+ }
+ }
+
+ private void populateRequestHeaders() {
+ requestHeaders = new HashMap();
+
+ for(String s : messageContext.getRequestContext().keySet())
+ {
+ requestHeaders.put(s, messageContext.getRequestContext().get(s));
+ }
+ }
+}
Property changes on:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/MessageStreamConnectionImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/MessageStreamContext.java
===================================================================
--- stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/MessageStreamContext.java
(rev 0)
+++
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/MessageStreamContext.java 2008-02-28
19:01:39 UTC (rev 5852)
@@ -0,0 +1,58 @@
+/*
+ * 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.wsf.stack.metro;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author Heiko Braun
+ */
+public class MessageStreamContext
+{
+
+ public static final int STATUS_INTERNAL_SERVER_ERROR = 500;
+ public final static String CONTENT_TYPE = "Content-Type";
+
+ private Map<String, String> requestContext = new HashMap<String,
String>();
+ private Map<String, String> responseContext = new HashMap<String,
String>();
+
+ public Map<String, String> getRequestContext()
+ {
+ return requestContext;
+ }
+
+ public void setRequestContext(Map<String, String> requestContext)
+ {
+ this.requestContext = requestContext;
+ }
+
+ public Map<String, String> getResponseContext()
+ {
+ return responseContext;
+ }
+
+ public void setResponseContext(Map<String, String> responseContext)
+ {
+ this.responseContext = responseContext;
+ }
+}
Property changes on:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/MessageStreamContext.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/RequestHandlerImpl.java
===================================================================
---
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/RequestHandlerImpl.java 2008-02-28
16:32:23 UTC (rev 5851)
+++
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/RequestHandlerImpl.java 2008-02-28
19:01:39 UTC (rev 5852)
@@ -28,6 +28,7 @@
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.invocation.InvocationContext;
import org.jboss.wsf.spi.invocation.RequestHandler;
+import org.jboss.wsf.spi.invocation.EndpointAssociation;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
@@ -38,6 +39,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Writer;
+import java.util.Properties;
/**
* A request handler
@@ -59,7 +61,7 @@
ServletAdapter target = endpoint.getAttachment(ServletAdapter.class);
if(null == target)
throw new IllegalArgumentException("Cannot obtain ServletAdapter");
-
+
String method = req.getMethod();
if (method.equals("POST"))
{
@@ -128,11 +130,59 @@
}
}
+ /**
+ * The InvocationContext accepts a {@link Properties} attachment that can carry
request properies.<br/>
+ * Property keys are derived from {@link
org.jboss.wsf.stack.metro.MessageStreamContext}
+ * <p/>
+ * Required propeties are:
+ *
+ * <ul>
+ * <li><tt>Content-Type</tt> ({@link
org.jboss.wsf.stack.metro.MessageStreamContext#CONTENT_TYPE})
+ * </ul>
+ * @param endpoint
+ * @param inStream
+ * @param outStream
+ * @param context
+ */
+ public void handleRequest(Endpoint endpoint, InputStream inStream, OutputStream
outStream, InvocationContext context)
+ {
+ MessageStreamAdapter adapter = endpoint.getAttachment(MessageStreamAdapter.class);
+ if(null == adapter)
+ throw new IllegalArgumentException("Cannot obtain
MessageStreamAdapter");
+ try
+ {
+ MessageStreamContext streamContext = new MessageStreamContext();
- public void handleRequest(Endpoint endpoint, InputStream inStream, OutputStream
outStream, InvocationContext context)
- {
- throw new IllegalArgumentException("JBWS-1869: Not implemented");
+ if(context!=null && context.getAttachment(Properties.class)!=null)
+ {
+ Properties props = context.getAttachment(Properties.class);
+ for(Object o : props.keySet())
+ {
+ String key = (String)o;
+ streamContext.getRequestContext().put(key, props.getProperty(key));
+ }
+ }
+
+ // Hacky, but the InvokerJSE requires it.
+ // However it's bette to do it here then outside the RequestHandler...
+ EndpointAssociation.setEndpoint(endpoint);
+ try
+ {
+ adapter.handle(streamContext, inStream, outStream );
+ }
+ finally
+ {
+ EndpointAssociation.setEndpoint(null);
+ }
+
+ }
+ catch (IOException e)
+ {
+ throw new WebServiceException("Failed to process request: " +
e.getMessage(), e);
+
+ }
+
}
public void handleWSDLRequest(Endpoint endpoint, OutputStream outStream,
InvocationContext context)
Modified:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/metadata/RuntimeModelDeploymentAspect.java
===================================================================
---
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/metadata/RuntimeModelDeploymentAspect.java 2008-02-28
16:32:23 UTC (rev 5851)
+++
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/metadata/RuntimeModelDeploymentAspect.java 2008-02-28
19:01:39 UTC (rev 5852)
@@ -37,6 +37,7 @@
import org.jboss.wsf.stack.metro.DeploymentDescriptorParserExt;
import org.jboss.wsf.stack.metro.DeploymentDescriptorParserJBWS;
import org.jboss.wsf.stack.metro.FakeServletContext;
+import org.jboss.wsf.stack.metro.MessageStreamAdapter;
import org.jboss.wsf.stack.metro.log.MessageLogPipelineHook;
import javax.xml.ws.WebServiceException;
@@ -110,7 +111,7 @@
List<ServletAdapter> adapters = parser.parse(sunJaxWsXml.toExternalForm(),
sunJaxWsXml.openStream());
for(ServletAdapter adapter : adapters)
- {
+ {
for(Endpoint ep : deployment.getService().getEndpoints() )
{
// TODO matching need to be improved
@@ -118,6 +119,12 @@
ep.getTargetBeanClass().equals(adapter.getEndpoint().getImplementationClass()))
{
ep.addAttachment(ServletAdapter.class, adapter);
+
+ // JBWS-1869: Support stream based RequestHandler API
+ ep.addAttachment(
+ MessageStreamAdapter.class,
+ MessageStreamAdapter.FACTORY.createAdapter(adapter.getName(), null,
adapter.getEndpoint())
+ );
break;
}
}
Added:
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/DelegationServlet.java
===================================================================
---
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/DelegationServlet.java
(rev 0)
+++
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/DelegationServlet.java 2008-02-28
19:01:39 UTC (rev 5852)
@@ -0,0 +1,87 @@
+/*
+ * 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.test.ws.jaxws.jbws1869;
+
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.invocation.InvocationContext;
+import org.jboss.wsf.spi.management.EndpointRegistry;
+import org.jboss.wsf.spi.management.EndpointRegistryFactory;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Properties;
+
+/**
+ * Reads a SOAP message from HTTP body and invokes an
+ * Endpoint through {@link
org.jboss.wsf.spi.invocation.RequestHandler#handleRequest(org.jboss.wsf.spi.deployment.Endpoint,
java.io.InputStream, java.io.OutputStream,
org.jboss.wsf.spi.invocation.InvocationContext)}
+ */
+public class DelegationServlet extends HttpServlet
+{
+
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
+ {
+ ObjectName EP_NAME = null;
+ try
+ {
+ EP_NAME = new
ObjectName("jboss.ws:context=jaxws-jbws1869,endpoint=Endpoint");
+ }
+ catch (MalformedObjectNameException e) {}
+
+ // EndpointRegistry access
+ SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+ EndpointRegistryFactory registryFactory =
spiProvider.getSPI(EndpointRegistryFactory.class);
+ EndpointRegistry reg = registryFactory.getEndpointRegistry();
+
+ Endpoint endpoint = reg.getEndpoint(EP_NAME);
+ ServletInputStream inputStream = request.getInputStream();
+ OutputStream outputStream = response.getOutputStream();
+
+ try
+ {
+ InvocationContext invocationContext = new InvocationContext();
+ Properties props = new Properties();
+ props.put("Content-Type", request.getContentType());
+ invocationContext.addAttachment(Properties.class, props);
+
+ endpoint.getRequestHandler().handleRequest(endpoint, inputStream, outputStream,
invocationContext);
+ }
+ catch(Exception e)
+ {
+ throw new ServletException("Failed to invoke endpoint", e);
+ }
+ finally
+ {
+ if(inputStream!=null) inputStream.close();
+ if(outputStream!=null) outputStream.close();
+ }
+
+ }
+}
Property changes on:
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/DelegationServlet.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/JBWS1869Endpoint.java
===================================================================
---
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/JBWS1869Endpoint.java
(rev 0)
+++
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/JBWS1869Endpoint.java 2008-02-28
19:01:39 UTC (rev 5852)
@@ -0,0 +1,30 @@
+/*
+ * 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.test.ws.jaxws.jbws1869;
+
+import javax.jws.WebService;
+
+@WebService
+public interface JBWS1869Endpoint
+{
+ public String echo(String msg);
+}
Property changes on:
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/JBWS1869Endpoint.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/JBWS1869EndpointImpl.java
===================================================================
---
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/JBWS1869EndpointImpl.java
(rev 0)
+++
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/JBWS1869EndpointImpl.java 2008-02-28
19:01:39 UTC (rev 5852)
@@ -0,0 +1,35 @@
+/*
+ * 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.test.ws.jaxws.jbws1869;
+
+import javax.jws.WebService;
+
+@WebService
+public class JBWS1869EndpointImpl implements JBWS1869Endpoint
+{
+
+ public String echo(String msg)
+ {
+ System.out.println(msg);
+ return msg;
+ }
+}
Property changes on:
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/JBWS1869EndpointImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/JBWS1869TestCase.java
===================================================================
---
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/JBWS1869TestCase.java
(rev 0)
+++
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/JBWS1869TestCase.java 2008-02-28
19:01:39 UTC (rev 5852)
@@ -0,0 +1,100 @@
+/*
+ * 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.test.ws.jaxws.jbws1869;
+
+import junit.framework.Test;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.HttpURLConnection;
+import java.io.OutputStreamWriter;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+/**
+ * Support stream based RequestHandler API
+ */
+public class JBWS1869TestCase extends JBossWSTest
+{
+ private final static String TNS =
"http://jbws1869.jaxws.ws.test.jboss.org/";
+ private final static QName portName = new QName(TNS,
"JBWS1869EndpointImplPort");
+ private final static QName serviceName = new QName(TNS,
"JBWS1869EndpointImplService");
+
+ private final static String REQUEST = "<?xml version=\"1.0\"
?><S:Envelope
xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"><S:...
xmlns:ns2=\"http://jbws1869.jaxws.ws.test.jboss.org/\"><a...;
+ private final static String RESPONSE = "<?xml version=\"1.0\"
?><S:Envelope
xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"><S:...
xmlns:ns2=\"http://jbws1869.jaxws.ws.test.jboss.org/\"><r...;
+
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(JBWS1869TestCase.class,
"jaxws-jbws1869.war");
+ }
+
+ /**
+ * Go through {@link
org.jboss.wsf.spi.invocation.RequestHandler#handleHttpRequest(org.jboss.wsf.spi.deployment.Endpoint,
javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
javax.servlet.ServletContext)}
+ * @throws Exception
+ */
+ public void testServletInvocation() throws Exception
+ {
+ Service service = Service.create(
+ new
URL("http://"+getServerHost()+":8080/jaxws-jbws1869?wsdl"),
serviceName
+ );
+ JBWS1869Endpoint port = service.getPort(portName, JBWS1869Endpoint .class);
+
+ String res = port.echo("ServletInvocation");
+ assertEquals(res, "ServletInvocation");
+ }
+
+ /**
+ * Go through {@link
org.jboss.wsf.spi.invocation.RequestHandler#handleRequest(org.jboss.wsf.spi.deployment.Endpoint,
java.io.InputStream, java.io.OutputStream,
org.jboss.wsf.spi.invocation.InvocationContext)}
+ * @throws Exception
+ */
+ public void testStreamBasedInvocation() throws Exception
+ {
+ // Send data
+ URL url = new
URL("http://"+getServerHost()+":8080/jaxws-jbws1869/delegate");
+ HttpURLConnection conn = (HttpURLConnection)url.openConnection();
+ conn.setDoOutput(true);
+ conn.setRequestProperty("Content-Type", "text/xml");
+
+
+ OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
+ wr.write(REQUEST);
+ wr.flush();
+
+ // Get the response
+ StringBuffer sb = new StringBuffer();
+ BufferedReader rd = new BufferedReader(new
InputStreamReader(conn.getInputStream()));
+ String line;
+ while ((line = rd.readLine()) != null)
+ {
+ sb.append(line);
+ }
+ wr.close();
+ rd.close();
+
+ // response assertion
+ assertEquals(RESPONSE, sb.toString());
+ }
+}
Property changes on:
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/JBWS1869TestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/jaxws/Echo.java
===================================================================
--- stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/jaxws/Echo.java
(rev 0)
+++
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/jaxws/Echo.java 2008-02-28
19:01:39 UTC (rev 5852)
@@ -0,0 +1,53 @@
+/*
+ * 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.test.ws.jaxws.jbws1869.jaxws;
+
+import javax.xml.bind.annotation.*;
+
+@XmlRootElement(name = "echo", namespace =
"http://jbws1869.jaxws.ws.test.jboss.org/")
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "echo", namespace =
"http://jbws1869.jaxws.ws.test.jboss.org/")
+public class Echo
+{
+
+ @XmlElement(name = "arg0", namespace = "")
+ private String arg0;
+
+ /**
+ *
+ * @return
+ * returns String
+ */
+ public String getArg0() {
+ return this.arg0;
+ }
+
+ /**
+ *
+ * @param arg0
+ * the value for the arg0 property
+ */
+ public void setArg0(String arg0) {
+ this.arg0 = arg0;
+ }
+
+}
Property changes on:
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/jaxws/Echo.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/jaxws/EchoResponse.java
===================================================================
---
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/jaxws/EchoResponse.java
(rev 0)
+++
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/jaxws/EchoResponse.java 2008-02-28
19:01:39 UTC (rev 5852)
@@ -0,0 +1,53 @@
+/*
+ * 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.test.ws.jaxws.jbws1869.jaxws;
+
+import javax.xml.bind.annotation.*;
+
+@XmlRootElement(name = "echoResponse", namespace =
"http://jbws1869.jaxws.ws.test.jboss.org/")
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "echoResponse", namespace =
"http://jbws1869.jaxws.ws.test.jboss.org/")
+public class EchoResponse
+{
+
+ @XmlElement(name = "return", namespace = "")
+ private String _return;
+
+ /**
+ *
+ * @return
+ * returns String
+ */
+ public String getReturn() {
+ return this._return;
+ }
+
+ /**
+ *
+ * @param _return
+ * the value for the _return property
+ */
+ public void setReturn(String _return) {
+ this._return = _return;
+ }
+
+}
Property changes on:
stack/metro/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1869/jaxws/EchoResponse.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/metro/trunk/src/test/resources/jaxws/jbws1869/WEB-INF/web.xml
===================================================================
--- stack/metro/trunk/src/test/resources/jaxws/jbws1869/WEB-INF/web.xml
(rev 0)
+++ stack/metro/trunk/src/test/resources/jaxws/jbws1869/WEB-INF/web.xml 2008-02-28
19:01:39 UTC (rev 5852)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <servlet>
+ <servlet-name>Endpoint</servlet-name>
+
<servlet-class>org.jboss.test.ws.jaxws.jbws1869.JBWS1869EndpointImpl</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Endpoint</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet>
+ <servlet-name>Delegate</servlet-name>
+
<servlet-class>org.jboss.test.ws.jaxws.jbws1869.DelegationServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Delegate</servlet-name>
+ <url-pattern>/delegate</url-pattern>
+ </servlet-mapping>
+</web-app>
Property changes on: stack/metro/trunk/src/test/resources/jaxws/jbws1869/WEB-INF/web.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF