Author: richard.opalka(a)jboss.com
Date: 2009-10-15 10:38:02 -0400 (Thu, 15 Oct 2009)
New Revision: 10915
Added:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/AbstractNettyMessage.java
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyHttp11Message.java
Removed:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/server/NettyHeaderSource.java
Modified:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyCallbackHandlerImpl.java
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyHttpServerAdapter.java
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyRequestHandlerImpl.java
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
Log:
[JBWS-2674][JBWS-2754] fixing output stream issue - we're streaming now, but we
don't support HTTP 1.0 ATM
Added:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/AbstractNettyMessage.java
===================================================================
---
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/AbstractNettyMessage.java
(rev 0)
+++
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/AbstractNettyMessage.java 2009-10-15
14:38:02 UTC (rev 10915)
@@ -0,0 +1,248 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.spi.http;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.soap.MimeHeader;
+import javax.xml.soap.MimeHeaders;
+
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.handler.codec.http.Cookie;
+import org.jboss.netty.handler.codec.http.CookieDecoder;
+import org.jboss.netty.handler.codec.http.CookieEncoder;
+import org.jboss.netty.handler.codec.http.DefaultHttpMessage;
+import org.jboss.netty.handler.codec.http.HttpHeaders;
+import org.jboss.netty.handler.codec.http.HttpRequest;
+import org.jboss.netty.handler.codec.http.HttpResponse;
+import org.jboss.netty.handler.codec.http.HttpResponseStatus;
+import org.jboss.netty.handler.codec.http.HttpVersion;
+import org.jboss.ws.core.server.MimeHeaderSource;
+
+/**
+ * HTTP 1.1 response implementation.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public abstract class AbstractNettyMessage extends DefaultHttpMessage implements
MimeHeaderSource, HttpResponse
+{
+
+ /** HTTP response status code. */
+ private HttpResponseStatus status;
+
+ /** HTTP request this reponse relates to. */
+ private HttpRequest request;
+
+ /** HTTP channel. */
+ private Channel channel;
+
+ /**
+ * Constructor.
+ *
+ * @param version HTTP protocol version
+ * @param channel Netty channel
+ * @param request original request
+ */
+ protected AbstractNettyMessage(final HttpVersion version, final Channel channel, final
HttpRequest request)
+ {
+ super(version);
+
+ this.channel = channel;
+ this.request = request;
+ }
+
+ /**
+ * Gets request input stream.
+ *
+ * @return request input stream
+ */
+ public abstract InputStream getInputStream();
+
+ /**
+ * Gets response output stream.
+ *
+ * @return response output stream.
+ */
+ public abstract OutputStream getOutputStream();
+
+ /**
+ * Returns HTTP request.
+ *
+ * @return HTTP request
+ */
+ protected final HttpRequest getRequest()
+ {
+ return this.request;
+ }
+
+ /**
+ * Returns Netty channel.
+ *
+ * @return Netty channel
+ */
+ protected final Channel getChannel()
+ {
+ return this.channel;
+ }
+
+ /**
+ * Returns response status code.
+ *
+ * @return message status code
+ */
+ public final HttpResponseStatus getStatus()
+ {
+ return this.status;
+ }
+
+ /**
+ * Sets response status code.
+ * @param sc response status code
+ */
+ public final void setStatus(final int sc)
+ {
+ this.status = HttpResponseStatus.valueOf(sc);
+ }
+
+ /**
+ * Sets cookis to response.
+ */
+ public final void setCookies()
+ {
+ final String cookieString = this.getRequest().getHeader(HttpHeaders.Names.COOKIE);
+ if (cookieString != null)
+ {
+ final CookieDecoder cookieDecoder = new CookieDecoder();
+ final Set<Cookie> cookies = cookieDecoder.decode(cookieString);
+ if (!cookies.isEmpty())
+ {
+ // Reset the cookies if necessary.
+ final CookieEncoder cookieEncoder = new CookieEncoder(true);
+ for (Cookie cookie : cookies)
+ {
+ cookieEncoder.addCookie(cookie);
+ }
+ this.addHeader(HttpHeaders.Names.SET_COOKIE, cookieEncoder.encode());
+ }
+ }
+ }
+
+ /**
+ * String representation of the instance.
+ *
+ * @return string
+ */
+ @Override
+ public final String toString()
+ {
+ return this.getProtocolVersion().getText() + ' ' + this.getStatus();
+ }
+
+ /**
+ * @see MimeHeaderSource#getMimeHeaders()
+ *
+ * @return mime headers
+ */
+ public final MimeHeaders getMimeHeaders()
+ {
+ if (this.request.getHeaderNames().size() == 0)
+ {
+ return null;
+ }
+
+ final MimeHeaders headers = new MimeHeaders();
+
+ final Iterator<String> e = this.request.getHeaderNames().iterator();
+ String key = null;
+ String value = null;
+ while (e.hasNext())
+ {
+ key = e.next();
+ value = this.request.getHeader(key);
+
+ headers.addHeader(key, value);
+ }
+
+ return headers;
+ }
+
+ /**
+ * @see MimeHeaderSource#setMimeHeaders(MimeHeaders)
+ *
+ * @param headers mime headers
+ */
+ public final void setMimeHeaders(final MimeHeaders headers)
+ {
+ final Iterator<?> i = headers.getAllHeaders();
+ String key = null;
+ while (i.hasNext())
+ {
+ final MimeHeader header = (MimeHeader) i.next();
+ key = header.getName();
+ List<String> values = new LinkedList<String>();
+ values.add(header.getValue());
+ values = this.removeProhibitedCharacters(values);
+ this.setHeader(key, values);
+ }
+ }
+
+ // TODO:
https://jira.jboss.org/jira/browse/NETTY-237
+ /**
+ * Removes prohibited header value characters.
+ *
+ * @param values header values before optimization
+ * @return optimized header values
+ */
+ private List<String> removeProhibitedCharacters(final List<String>
values)
+ {
+ final List<String> retVal = new LinkedList<String>();
+ for (int i = 0; i < values.size(); i++)
+ {
+ retVal.add(i, this.removeProhibitedCharacters(values.get(i)));
+ }
+
+ return retVal;
+ }
+
+ // TODO:
https://jira.jboss.org/jira/browse/NETTY-237
+ /**
+ * Removes prohibited header value characters.
+ *
+ * @param value header value before optimization
+ * @return optimized header value
+ */
+ private String removeProhibitedCharacters(final String value)
+ {
+ String retVal = value;
+
+ retVal = retVal.replace('\r', ' ');
+ retVal = retVal.replace('\n', ' ');
+
+ return retVal;
+ }
+
+}
Modified:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyCallbackHandlerImpl.java
===================================================================
---
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyCallbackHandlerImpl.java 2009-10-15
14:33:24 UTC (rev 10914)
+++
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyCallbackHandlerImpl.java 2009-10-15
14:38:02 UTC (rev 10915)
@@ -30,7 +30,6 @@
import javax.xml.ws.WebServiceException;
import org.jboss.logging.Logger;
-import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
import org.jboss.ws.core.server.netty.NettyCallbackHandler;
import org.jboss.ws.extensions.wsrm.transport.backchannel.RMCallbackHandlerImpl;
@@ -55,12 +54,6 @@
final class NettyCallbackHandlerImpl implements NettyCallbackHandler
{
- /** 200 HTTP status code. */
- public static final int SC_OK = 200;
-
- /** 500 HTTP status code. */
- public static final int SC_INTERNAL_SERVER_ERROR = 500;
-
/** Logger. */
private static final Logger LOGGER = Logger.getLogger(RMCallbackHandlerImpl.class);
@@ -118,13 +111,11 @@
* @param is input stream
* @param os output stream
* @param invCtx invocation context
- * @return HTTP status code
* @throws IOException if some I/O error occurs
*/
- public int handle(final String method, final InputStream is, final OutputStream os,
final InvocationContext invCtx)
- throws IOException
+ public void handle(final String method, final InputStream is, final OutputStream os,
final InvocationContext invCtx)
+ throws IOException
{
- Integer statusCode = null;
try
{
EndpointAssociation.setEndpoint(this.endpoint);
@@ -133,7 +124,6 @@
if (method.equals("POST"))
{
requestHandler.handleRequest(this.endpoint, is, os, invCtx);
- statusCode = (Integer) invCtx.getProperty(Constants.NETTY_STATUS_CODE);
}
else if (method.equals("GET"))
{
@@ -147,15 +137,28 @@
catch (final Exception e)
{
NettyCallbackHandlerImpl.LOGGER.error(e.getMessage(), e);
- statusCode = NettyCallbackHandlerImpl.SC_INTERNAL_SERVER_ERROR;
}
finally
{
+ try
+ {
+ is.close();
+ }
+ catch (IOException e)
+ {
+ NettyCallbackHandlerImpl.LOGGER.error(e.getMessage(), e);
+ }
+ try
+ {
+ os.close();
+ }
+ catch (IOException e)
+ {
+ NettyCallbackHandlerImpl.LOGGER.error(e.getMessage(), e);
+ }
this.registerForPreDestroy(this.endpoint);
EndpointAssociation.removeEndpoint();
}
-
- return statusCode == null ? NettyCallbackHandlerImpl.SC_OK : statusCode;
}
/**
Added:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyHttp11Message.java
===================================================================
---
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyHttp11Message.java
(rev 0)
+++
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyHttp11Message.java 2009-10-15
14:38:02 UTC (rev 10915)
@@ -0,0 +1,200 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.spi.http;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.jboss.netty.buffer.ChannelBufferInputStream;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.handler.codec.http.HttpHeaders;
+import org.jboss.netty.handler.codec.http.HttpRequest;
+import org.jboss.netty.handler.codec.http.HttpResponseStatus;
+import org.jboss.netty.handler.codec.http.HttpVersion;
+import org.jboss.ws.core.client.transport.NettyTransportOutputStream;
+
+/**
+ * HTTP 1.1 message.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public final class NettyHttp11Message extends AbstractNettyMessage
+{
+
+ /** Chunks size. */
+ private static final int CHUNK_SIZE = 1024;
+ /** Flag indicating HTTP headers have been written to the stream. */
+ private boolean headersWritten;
+
+ /**
+ * Constructor.
+ *
+ * @param channel Netty channel
+ * @param request original request
+ */
+ public NettyHttp11Message(final Channel channel, final HttpRequest request)
+ {
+ super(HttpVersion.HTTP_1_1, channel, request);
+ }
+
+ /**
+ * @see AbstractNettyMessage#getInputStream()
+ *
+ * @return request input stream
+ */
+ public InputStream getInputStream()
+ {
+ return new ChannelBufferInputStream(this.getRequest().getContent());
+ }
+
+ /**
+ * @see AbstractNettyMessage#getOutputStream()
+ *
+ * @return response output stream
+ */
+ public OutputStream getOutputStream()
+ {
+ return new ChunkingOutputStream(this, new
NettyTransportOutputStream(this.getChannel(), NettyHttp11Message.CHUNK_SIZE));
+ }
+
+ /**
+ * Ensures HTTP message headers are written before message body.
+ */
+ private void flushHeaders()
+ {
+ if (this.headersWritten)
+ {
+ return;
+ }
+
+ this.headersWritten = true;
+
+ if (this.getStatus() == null)
+ {
+ this.setStatus(HttpResponseStatus.OK.getCode());
+ }
+ if (this.getHeader(HttpHeaders.Names.CONTENT_TYPE) == null)
+ {
+ this.setHeader(HttpHeaders.Names.CONTENT_TYPE, "text/xml;
charset=UTF-8");
+ }
+ this.setHeader(HttpHeaders.Names.TRANSFER_ENCODING, "chunked");
+ this.setCookies();
+
+ // Write the response headers
+ this.getChannel().write(this);
+ }
+
+ /**
+ * Chunking output stream.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard
Opalka</a>
+ */
+ private static final class ChunkingOutputStream extends OutputStream
+ {
+
+ /** Netty output stream. */
+ private final NettyTransportOutputStream delegee;
+ /** Netty message. */
+ private final NettyHttp11Message message;
+
+ /**
+ * Constructor.
+ *
+ * @param message wrapped netty message
+ * @param os wrapped output stream
+ */
+ public ChunkingOutputStream(final NettyHttp11Message message, final
NettyTransportOutputStream os)
+ {
+ super();
+
+ this.message = message;
+ this.delegee = os;
+ }
+
+ /**
+ * @see OutputStream#write(int)
+ *
+ * @param b byte
+ * @throws IOException if some I/O error occurs
+ */
+ @Override
+ public void write(final int b) throws IOException
+ {
+ this.message.flushHeaders();
+ this.delegee.write(b);
+ }
+
+ /**
+ * @see OutputStream#write(byte[], int, int)
+ *
+ * @param b byte array
+ * @param off offset
+ * @param len length
+ * @throws IOException if some I/O error occurs
+ */
+ @Override
+ public void write(final byte[] b, final int off, final int len) throws IOException
+ {
+ this.message.flushHeaders();
+ this.delegee.write(b, off, len);
+ }
+
+ /**
+ * @see OutputStream#write(byte[])
+ *
+ * @param b byte array
+ * @throws IOException if some I/O error occurs
+ */
+ @Override
+ public void write(final byte[] b) throws IOException
+ {
+ this.message.flushHeaders();
+ this.delegee.write(b);
+ }
+
+ /**
+ * @see OutputStream#flush()
+ *
+ * @throws IOException if some I/O error occurs
+ */
+ @Override
+ public void flush() throws IOException
+ {
+ this.delegee.flush();
+ }
+
+ /**
+ * @see OutputStream#close()
+ *
+ * @throws IOException if some I/O error occurs
+ */
+ @Override
+ public void close() throws IOException
+ {
+ this.delegee.close();
+ this.delegee.getChannelFuture().awaitUninterruptibly();
+ }
+
+ }
+
+}
Modified:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyHttpServerAdapter.java
===================================================================
---
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyHttpServerAdapter.java 2009-10-15
14:33:24 UTC (rev 10914)
+++
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyHttpServerAdapter.java 2009-10-15
14:38:02 UTC (rev 10915)
@@ -44,9 +44,9 @@
import org.jboss.wsf.spi.SPIProviderResolver;
import org.jboss.wsf.spi.deployment.ArchiveDeployment;
import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
import org.jboss.wsf.spi.deployment.DeploymentAspect;
import org.jboss.wsf.spi.deployment.DeploymentModelFactory;
-import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
import org.jboss.wsf.spi.http.HttpContext;
import org.jboss.wsf.spi.http.HttpContextFactory;
import org.jboss.wsf.spi.http.HttpServer;
@@ -56,11 +56,10 @@
import org.jboss.wsf.stack.jbws.UnifiedMetaDataDeploymentAspect;
/**
- * TODO: javadoc
+ * Netty HTTP server adapter.
*
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
*/
-// TODO: review thread safety
final class NettyHttpServerAdapter implements HttpServer
{
@@ -75,7 +74,9 @@
private static final DeploymentModelFactory DEPLOYMENT_FACTORY =
NettyHttpServerAdapter.SPI_PROVIDER
.getSPI(DeploymentModelFactory.class);
- private static final NettyRequestHandlerFactory requestHandlerFactory =
NettyRequestHandlerFactoryImpl.getInstance();
+ /** Request handler factory. */
+ private static final NettyRequestHandlerFactory<NettyRequestHandlerImpl>
REQUEST_HANDLER_FACTORY = NettyRequestHandlerFactoryImpl
+ .getInstance();
/**
* Constructor.
@@ -85,54 +86,84 @@
super();
}
- public HttpContext createContext(final String contextRoot)
+ /**
+ * @see HttpServer#createContext(String)
+ *
+ * @param ctx context root
+ * @return http context
+ */
+ public HttpContext createContext(final String ctx)
{
- // TODO: check context is not already registered, throw exception otherwise
- return NettyHttpServerAdapter.HTTP_CONTEXT_FACTORY.newHttpContext(this,
contextRoot);
+ return NettyHttpServerAdapter.HTTP_CONTEXT_FACTORY.newHttpContext(this, ctx);
}
- public void destroy(HttpContext context, Endpoint endpoint)
+ /**
+ * @see HttpServer#publish(HttpContext, Endpoint)
+ *
+ * @param ctx server context
+ * @param endpoint web service endpoint
+ */
+ public void publish(final HttpContext ctx, final Endpoint endpoint)
{
- EndpointImpl epImpl = (EndpointImpl) endpoint;
- NettyHttpServer server =
NettyHttpServerFactory.getNettyHttpServer(epImpl.getPort(), this.requestHandlerFactory);
- NettyCallbackHandler callback = server.getCallback(epImpl.getPath());
- server.unregisterCallback(callback);
+ final EndpointImpl epImpl = (EndpointImpl) endpoint;
+ final String contextRoot = ctx.getContextRoot();
+ final Deployment dep = this.newDeployment(epImpl, contextRoot);
- DeploymentAspectManagerImpl daManager = new DeploymentAspectManagerImpl();
- daManager.setDeploymentAspects(getDeploymentAspects());
- daManager.undeploy(epImpl.getDeployment());
- }
-
- public void publish(HttpContext context, Endpoint ep)
- {
- EndpointImpl epImpl = (EndpointImpl) ep;
- String contextRoot = context.getContextRoot();
- Deployment dep = this.newDeployment(epImpl, contextRoot);
-
- DeploymentAspectManagerImpl daManager = new DeploymentAspectManagerImpl();
- daManager.setDeploymentAspects(getDeploymentAspects());
+ final DeploymentAspectManagerImpl daManager = new DeploymentAspectManagerImpl();
+ daManager.setDeploymentAspects(this.getDeploymentAspects());
daManager.deploy(dep);
epImpl.setDeployment(dep);
- NettyHttpServer server =
NettyHttpServerFactory.getNettyHttpServer(epImpl.getPort(), requestHandlerFactory);
- NettyCallbackHandler callback = new NettyCallbackHandlerImpl(epImpl.getPath(),
contextRoot, this
+ final NettyHttpServer server =
NettyHttpServerFactory.getNettyHttpServer(epImpl.getPort(),
NettyHttpServerAdapter.REQUEST_HANDLER_FACTORY);
+ final NettyCallbackHandler callback = new
NettyCallbackHandlerImpl(epImpl.getPath(), contextRoot, this
.getEndpointRegistryPath(epImpl));
server.registerCallback(callback);
}
- private String getEndpointRegistryPath(EndpointImpl endpoint)
+ /**
+ * @see HttpServer#destroy(HttpContext, Endpoint)
+ *
+ * @param ctx server context
+ * @param endpoint web service endpoint
+ */
+ public void destroy(final HttpContext ctx, final Endpoint endpoint)
{
+ final EndpointImpl epImpl = (EndpointImpl) endpoint;
+ final NettyHttpServer server =
NettyHttpServerFactory.getNettyHttpServer(epImpl.getPort(),
NettyHttpServerAdapter.REQUEST_HANDLER_FACTORY);
+ final NettyCallbackHandler callback = server.getCallback(epImpl.getPath());
+ server.unregisterCallback(callback);
+
+ final DeploymentAspectManagerImpl daManager = new DeploymentAspectManagerImpl();
+ daManager.setDeploymentAspects(this.getDeploymentAspects());
+ daManager.undeploy(epImpl.getDeployment());
+ }
+
+ /**
+ * Returns endpoint registry path. This path includes also port endpoint is running
on.
+ *
+ * @param endpoint endpoint
+ * @return endpoint registry path
+ */
+ private String getEndpointRegistryPath(final EndpointImpl endpoint)
+ {
// we need to distinguish ports in endpoints registry in JSE environment
return endpoint.getPath() + "-port-" + endpoint.getPort();
}
- private Deployment newDeployment(EndpointImpl epImpl, String contextRoot)
+ /**
+ * Creates new deployment.
+ *
+ * @param epImpl endpoint implementation
+ * @param contextRoot context root
+ * @return deployment model
+ */
+ private Deployment newDeployment(final EndpointImpl epImpl, final String contextRoot)
{
- Class<?> endpointClass = this.getEndpointClass(epImpl);
- ClassLoader loader = endpointClass.getClassLoader();
+ final Class<?> endpointClass = this.getEndpointClass(epImpl);
+ final ClassLoader loader = endpointClass.getClassLoader();
- final ArchiveDeployment dep = (ArchiveDeployment)
DEPLOYMENT_FACTORY.newDeployment(contextRoot, loader);
- final org.jboss.wsf.spi.deployment.Endpoint endpoint =
DEPLOYMENT_FACTORY.newEndpoint(endpointClass.getName());
+ final ArchiveDeployment dep = (ArchiveDeployment)
NettyHttpServerAdapter.DEPLOYMENT_FACTORY.newDeployment(contextRoot, loader);
+ final org.jboss.wsf.spi.deployment.Endpoint endpoint =
NettyHttpServerAdapter.DEPLOYMENT_FACTORY.newEndpoint(endpointClass.getName());
endpoint.setShortName(this.getEndpointRegistryPath(epImpl));
endpoint.setURLPattern(epImpl.getPathWithoutContext());
dep.getService().addEndpoint(endpoint);
@@ -149,22 +180,27 @@
return dep;
}
+ /**
+ * Returns deployment aspects needed to create deployment model.
+ *
+ * @return deployment aspects
+ */
private List<DeploymentAspect> getDeploymentAspects()
{
- List<DeploymentAspect> retVal = new LinkedList<DeploymentAspect>();
+ final List<DeploymentAspect> retVal = new
LinkedList<DeploymentAspect>();
// TODO: native stack can't use framework classes directly
- retVal.add(new EndpointHandlerDeploymentAspect()); // 13
- retVal.add(new BackwardCompatibleContextRootDeploymentAspect()); // 14
- retVal.add(new URLPatternDeploymentAspect()); // 15
- retVal.add(new EndpointAddressDeploymentAspect()); // 16
- retVal.add(new EndpointNameDeploymentAspect()); // 17
- retVal.add(new UnifiedMetaDataDeploymentAspect()); // 22
- retVal.add(new ServiceEndpointInvokerDeploymentAspect()); // 23
- retVal.add(new PublishContractDeploymentAspect()); // 24
- retVal.add(new EagerInitializeDeploymentAspect()); // 25
- retVal.add(new EndpointRegistryDeploymentAspect()); // 35
- retVal.add(new EndpointLifecycleDeploymentAspect()); // 37
+ retVal.add(new EndpointHandlerDeploymentAspect());
+ retVal.add(new BackwardCompatibleContextRootDeploymentAspect());
+ retVal.add(new URLPatternDeploymentAspect());
+ retVal.add(new EndpointAddressDeploymentAspect());
+ retVal.add(new EndpointNameDeploymentAspect());
+ retVal.add(new UnifiedMetaDataDeploymentAspect());
+ retVal.add(new ServiceEndpointInvokerDeploymentAspect());
+ retVal.add(new PublishContractDeploymentAspect());
+ retVal.add(new EagerInitializeDeploymentAspect());
+ retVal.add(new EndpointRegistryDeploymentAspect());
+ retVal.add(new EndpointLifecycleDeploymentAspect());
return retVal;
}
Modified:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyRequestHandlerImpl.java
===================================================================
---
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyRequestHandlerImpl.java 2009-10-15
14:33:24 UTC (rev 10914)
+++
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/http/NettyRequestHandlerImpl.java 2009-10-15
14:38:02 UTC (rev 10915)
@@ -21,36 +21,15 @@
*/
package org.jboss.ws.core.jaxws.spi.http;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
import org.jboss.logging.Logger;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBufferInputStream;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.ChannelStateEvent;
-import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent;
-import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
-import org.jboss.netty.handler.codec.http.Cookie;
-import org.jboss.netty.handler.codec.http.CookieDecoder;
-import org.jboss.netty.handler.codec.http.CookieEncoder;
import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
import org.jboss.netty.handler.codec.http.HttpHeaders;
import org.jboss.netty.handler.codec.http.HttpRequest;
@@ -58,8 +37,6 @@
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
import org.jboss.netty.handler.codec.http.HttpVersion;
import org.jboss.ws.Constants;
-import org.jboss.ws.core.client.transport.NettyTransportOutputStream;
-import org.jboss.ws.core.server.netty.NettyCallbackHandler;
import org.jboss.ws.core.server.netty.AbstractNettyRequestHandler;
import org.jboss.wsf.spi.invocation.InvocationContext;
@@ -70,180 +47,133 @@
*/
final class NettyRequestHandlerImpl extends AbstractNettyRequestHandler
{
+ /** Logger. */
private static final Logger LOG = Logger.getLogger(NettyRequestHandlerImpl.class);
+ /**
+ * Constructor.
+ */
public NettyRequestHandlerImpl()
{
super();
}
+ /**
+ * Callback method called by Netty HTTP server.
+ *
+ * @param ctx channel handler context
+ * @param event message event
+ * @throws Exception
+ */
@Override
- public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws
Exception
+ public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent
event)
{
- HttpRequest request = (HttpRequest) e.getMessage();
- ChannelBuffer content = request.getContent();
- OutputStream baos = new ByteArrayOutputStream();
- OutputStream outputStream = new BufferedOutputStream(baos);
- Integer statusCode = null;
-
- InvocationContext invCtx = new InvocationContext();
- Map<String, List<String>> requestHeaders = new HashMap<String,
List<String>>();
- Map<String, List<String>> responseHeaders = new HashMap<String,
List<String>>();
- invCtx.setProperty(Constants.NETTY_REQUEST_HEADERS, requestHeaders);
- invCtx.setProperty(Constants.NETTY_RESPONSE_HEADERS, responseHeaders);
- for (String headerName : request.getHeaderNames())
+ // TODO: create custom HttpNettyRequest and don't use Netty provided default
impl.
+ final HttpRequest request = (HttpRequest) event.getMessage();
+ if (HttpVersion.HTTP_1_1.equals(request.getProtocolVersion()))
{
- requestHeaders.put(headerName, request.getHeaders(headerName));
- }
- try
- {
- String requestPath = request.getUri();
- int paramIndex = requestPath.indexOf('?');
- if (paramIndex != -1)
+ final AbstractNettyMessage message = new NettyHttp11Message(ctx.getChannel(),
request);
+
+ final InvocationContext invCtx = new InvocationContext();
+ invCtx.setProperty(Constants.NETTY_MESSAGE, message);
+ try
{
- requestPath = requestPath.substring(0, paramIndex);
+ final String requestPath = this.getRequestPath(request.getUri());
+ final String httpMethod = request.getMethod().getName();
+ this.handle(requestPath, httpMethod, message.getInputStream(),
message.getOutputStream(), invCtx);
}
- requestPath = this.getRequestPath(requestPath);
- String httpMethod = request.getMethod().getName();
- statusCode = handle(requestPath, httpMethod, getInputStream(content),
outputStream, invCtx);
+ catch (Exception e)
+ {
+ NettyRequestHandlerImpl.LOG.error(e);
+ this.sendError(event, HttpResponseStatus.INTERNAL_SERVER_ERROR);
+ }
}
- catch (Throwable t)
+ else
{
- statusCode = 500;
- LOG.error(t);
+ NettyRequestHandlerImpl.LOG.fatal("HTTP 1.0 not supported");
+ this.sendError(event, HttpResponseStatus.NOT_IMPLEMENTED);
}
- finally
- {
- writeResponse(e, request, baos.toString(), statusCode, responseHeaders,
ctx.getChannel());
- }
}
- private InputStream getInputStream(ChannelBuffer content)
+ /**
+ * Calls Netty callback handler associated with request path.
+ *
+ * @param requestPath to handle
+ * @param httpMethod http method (GET or POST)
+ * @param is input stream
+ * @param os output stream
+ * @param invCtx invocation context
+ * @throws IOException if some I/O error occurs
+ */
+ private void handle(final String requestPath, final String httpMethod, final
InputStream is,
+ final OutputStream os, final InvocationContext invCtx) throws IOException
{
- return new ChannelBufferInputStream(content);
- }
-
- private int handle(final String requestPath, final String httpMethod, final
InputStream inputStream, final OutputStream outputStream,
- final InvocationContext invCtx) throws IOException
- {
final NettyCallbackHandlerImpl handler = (NettyCallbackHandlerImpl)
this.getCallback(requestPath);
if (handler != null)
{
- NettyRequestHandlerImpl.LOG.debug("Handling " + httpMethod + "
request for " + requestPath);
-
- return handler.handle(httpMethod, inputStream, outputStream, invCtx);
+ handler.handle(httpMethod, is, os, invCtx);
}
else
{
- NettyRequestHandlerImpl.LOG.warn("No callback handler registered for path:
" + requestPath);
-
- return 501;
+ final String errorMessage = "No callback handler registered for path:
" + requestPath;
+ NettyRequestHandlerImpl.LOG.warn(errorMessage);
+ throw new IllegalArgumentException(errorMessage);
}
}
- private void writeResponse(MessageEvent e, HttpRequest request, String content, int
statusCode,
- Map<String, List<String>> responseHeaders, Channel channel) throws
IOException
+ /**
+ * Sends error to HTTP client.
+ *
+ * @param event message event
+ * @param statusCode HTTP status code
+ */
+ private void sendError(final MessageEvent event, final HttpResponseStatus statusCode)
{
// Build the response object.
- HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1,
HttpResponseStatus.valueOf(statusCode));
+ final HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1,
statusCode);
+ response.setHeader(HttpHeaders.Names.CONTENT_TYPE, "text/plain;
charset=UTF-8");
- Iterator<String> iterator = responseHeaders.keySet().iterator();
- String key = null;
- List<String> values = null;
- while (iterator.hasNext())
- {
- key = iterator.next();
- values = responseHeaders.get(key);
- values = removeProhibitedCharacters(values);
- response.setHeader(key, values);
- }
- if (!responseHeaders.containsKey(HttpHeaders.Names.CONTENT_TYPE))
- {
- response.setHeader(HttpHeaders.Names.CONTENT_TYPE, "text/xml;
charset=UTF-8");
- response.setHeader(HttpHeaders.Names.CONTENT_LENGTH,
String.valueOf(content.length()));
- response.setContent(ChannelBuffers.copiedBuffer(content, "UTF-8"));
- }
- else
- {
- response.setHeader(HttpHeaders.Names.TRANSFER_ENCODING, "chunked");
- }
-
- String cookieString = request.getHeader(HttpHeaders.Names.COOKIE);
- if (cookieString != null)
- {
- CookieDecoder cookieDecoder = new CookieDecoder();
- Set<Cookie> cookies = cookieDecoder.decode(cookieString);
- if (!cookies.isEmpty())
- {
- // Reset the cookies if necessary.
- CookieEncoder cookieEncoder = new CookieEncoder(true);
- for (Cookie cookie : cookies)
- {
- cookieEncoder.addCookie(cookie);
- }
- response.addHeader(HttpHeaders.Names.SET_COOKIE, cookieEncoder.encode());
- }
- }
-
// Write the response.
- ChannelFuture cf = e.getChannel().write(response);
- if (responseHeaders.containsKey(HttpHeaders.Names.CONTENT_TYPE))
- {
- NettyTransportOutputStream out = new NettyTransportOutputStream(channel, 1024);
- out.write(content.getBytes("UTF-8"));
- out.close();
- out.getChannelFuture().awaitUninterruptibly();
- }
- else
- {
- cf.awaitUninterruptibly();
- }
+ event.getChannel().write(response).awaitUninterruptibly();
}
- // TODO:
https://jira.jboss.org/jira/browse/NETTY-239
- private String getRequestPath(String s)
+ /**
+ * Returns request path without query string.
+ *
+ * @param requestPath to parse
+ * @return request path without query string
+ */
+ private String getRequestPath(final String requestPath)
{
- String retVal = s;
- if (s.startsWith("http"))
+ String retVal = requestPath;
+
+ // remove query string if available
+ final int paramIndex = retVal.indexOf('?');
+ if (paramIndex != -1)
{
+ retVal = retVal.substring(0, paramIndex);
+ }
+
+ // remove protocol, host and port if available
+ if (retVal.startsWith("http"))
+ {
try
{
- retVal = new URL(s).getPath();
+ retVal = new URL(retVal).getPath();
}
catch (MalformedURLException mue)
{
- LOG.error(mue.getMessage(), mue);
+ NettyRequestHandlerImpl.LOG.error(mue.getMessage(), mue);
}
}
-
+
+ // remove '/' characters at the end
while (retVal.endsWith("/"))
{
retVal = retVal.substring(0, retVal.length() - 1);
}
- return retVal;
- }
- // TODO:
https://jira.jboss.org/jira/browse/NETTY-237
- private List<String> removeProhibitedCharacters(List<String> values)
- {
- List<String> retVal = new LinkedList<String>();
- for (int i = 0; i < values.size(); i++)
- {
- retVal.add(i, removeProhibitedCharacters(values.get(i)));
- }
-
return retVal;
}
- // TODO:
https://jira.jboss.org/jira/browse/NETTY-237
- private String removeProhibitedCharacters(String s)
- {
- String retVal = s;
-
- retVal = retVal.replace('\r', ' ');
- retVal = retVal.replace('\n', ' ');
-
- return retVal;
- }
-
}
Deleted:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/server/NettyHeaderSource.java
===================================================================
---
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/server/NettyHeaderSource.java 2009-10-15
14:33:24 UTC (rev 10914)
+++
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/ws/core/server/NettyHeaderSource.java 2009-10-15
14:38:02 UTC (rev 10915)
@@ -1,119 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.server;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.soap.MimeHeader;
-import javax.xml.soap.MimeHeaders;
-
-/**
- * Netty headers abstraction.
- *
- * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
- */
-public class NettyHeaderSource implements MimeHeaderSource
-{
-
- private final Map<String, List<String>> req;
- private final Map<String, List<String>> res;
-
- public NettyHeaderSource(final Map<String, List<String>> req, final
Map<String, List<String>> res)
- {
- super();
-
- this.req = req;
- this.res = res;
- }
-
- public MimeHeaders getMimeHeaders()
- {
- if (req.size() == 0) return null;
-
- MimeHeaders headers = new MimeHeaders();
-
- Iterator<String> e = req.keySet().iterator();
- String key = null;
- String value = null;
- while (e.hasNext())
- {
- key = e.next();
- value = req.get(key).get(0);
-
- headers.addHeader(key, value);
- }
-
- return headers;
- }
-
- public void setMimeHeaders(final MimeHeaders headers)
- {
- Iterator i = headers.getAllHeaders();
- String key = null;
- while (i.hasNext())
- {
- MimeHeader header = (MimeHeader)i.next();
- key = header.getName();
- List<String> values = new LinkedList<String>();
- values.add(header.getValue());
- res.put(key, values);
- }
- }
-
- public Map<String, List<String>> getHeaderMap()
- {
- Map<String, List<String>> headerMap = new HashMap<String,
List<String>>();
-
- Iterator<String> e = req.keySet().iterator();
- if (e != null)
- {
- String key = null;
- List<String> value = null;
- while (e.hasNext())
- {
- key = e.next();
- value = req.get(key);
- headerMap.put(key, value);
- }
- }
-
- return headerMap;
- }
-
- public void setHeaderMap(Map<String, List<String>> headers)
- {
- Iterator<String> it = headers.keySet().iterator();
- String key = null;
- List<String> value = null;
- while (it.hasNext())
- {
- key = it.next();
- value = headers.get(key);
- res.put(key, value);
- }
- }
-
-}
Modified:
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
===================================================================
---
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2009-10-15
14:33:24 UTC (rev 10914)
+++
stack/native/branches/ropalka/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2009-10-15
14:38:02 UTC (rev 10915)
@@ -51,6 +51,8 @@
import javax.xml.ws.http.HTTPBinding;
import org.jboss.logging.Logger;
+import org.jboss.netty.handler.codec.http.HttpMessage;
+import org.jboss.netty.handler.codec.http.HttpRequest;
import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
import org.jboss.ws.core.CommonBinding;
@@ -65,8 +67,8 @@
import org.jboss.ws.core.jaxrpc.handler.SOAPMessageContextJAXRPC;
import org.jboss.ws.core.jaxws.handler.MessageContextJAXWS;
import org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS;
+import org.jboss.ws.core.jaxws.spi.http.AbstractNettyMessage;
import org.jboss.ws.core.server.MimeHeaderSource;
-import org.jboss.ws.core.server.NettyHeaderSource;
import org.jboss.ws.core.server.ServiceEndpointInvoker;
import org.jboss.ws.core.server.ServletHeaderSource;
import org.jboss.ws.core.server.ServletRequestContext;
@@ -261,7 +263,7 @@
// Set servlet specific properties
HttpServletResponse httpResponse = null;
ServletHeaderSource headerSource = null;
- NettyHeaderSource nettyHeaderSource = this.getNettyHeadersSource(invContext);
+ AbstractNettyMessage nettyMessage = this.getNettyHeadersSource(invContext);
if (invContext instanceof ServletRequestContext)
{
ServletRequestContext reqContext = (ServletRequestContext)invContext;
@@ -295,7 +297,7 @@
try
{
msgContext.setEndpointMetaData(sepMetaData);
- MessageAbstraction resMessage = processRequest(endpoint, nettyHeaderSource ==
null ? headerSource : nettyHeaderSource, invContext, inStream);
+ MessageAbstraction resMessage = processRequest(endpoint, nettyMessage == null ?
headerSource : nettyMessage, invContext, inStream);
// Replace the message context with the response context
msgContext = MessageContextAssociation.peekMessageContext();
@@ -307,10 +309,6 @@
{
headerSource.setHeaderMap(headers);
}
- else if (nettyHeaderSource != null)
- {
- nettyHeaderSource.setHeaderMap(headers);
- }
}
Integer code = (Integer)msgContext.get(MessageContextJAXWS.HTTP_RESPONSE_CODE);
@@ -320,12 +318,9 @@
{
httpResponse.setStatus(code.intValue());
}
- else
+ else if (nettyMessage != null)
{
- if (nettyHeaderSource != null)
- {
- invContext.setProperty(Constants.NETTY_STATUS_CODE, code.intValue());
- }
+ nettyMessage.setStatus(code.intValue());
}
}
@@ -349,12 +344,9 @@
{
httpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
- else
+ else if (nettyMessage != null)
{
- if (nettyHeaderSource != null)
- {
- invContext.setProperty(Constants.NETTY_STATUS_CODE,
HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- }
+ nettyMessage.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
}
@@ -382,17 +374,9 @@
}
}
- private NettyHeaderSource getNettyHeadersSource(final InvocationContext invContext)
+ private AbstractNettyMessage getNettyHeadersSource(final InvocationContext
invContext)
{
- Map<String, List<String>> nettyRequestHeaders = (Map<String,
List<String>>)invContext.getProperty(Constants.NETTY_REQUEST_HEADERS);
- Map<String, List<String>> nettyResponseHeaders = (Map<String,
List<String>>)invContext.getProperty(Constants.NETTY_RESPONSE_HEADERS);
-
- if (nettyRequestHeaders != null && nettyResponseHeaders != null)
- {
- return new NettyHeaderSource(nettyRequestHeaders, nettyResponseHeaders);
- }
-
- return null;
+ return (AbstractNettyMessage)invContext.getProperty(Constants.NETTY_MESSAGE);
}
private void sendResponse(Endpoint endpoint, OutputStream output, boolean isFault)
throws SOAPException, IOException
@@ -664,7 +648,7 @@
HttpServletRequest req = reqContext.getHttpServletRequest();
requestURL = new URL(req.getRequestURL().toString());
}
- else if (context.getProperty(Constants.NETTY_REQUEST_HEADERS) != null)
+ else if (context.getProperty(Constants.NETTY_MESSAGE) != null)
{
requestURL = new URL(endpoint.getAddress());
}
@@ -682,10 +666,10 @@
HttpServletRequest req = reqContext.getHttpServletRequest();
resourcePath = (String)req.getParameter("resource");
}
- else if (context.getProperty(Constants.NETTY_REQUEST_HEADERS) != null)
+ else if (context.getProperty(Constants.NETTY_MESSAGE) != null)
{
- Map<String, Object> requestHeaders = (Map<String,
Object>)context.getProperty(Constants.NETTY_REQUEST_HEADERS);
- resourcePath = (String)requestHeaders.get("resource");
+ return null;
+ // TODO: implement resourcePath = getResourcePath(nettyMessage.getUri()); //
i.e. parse it from query string
}
return resourcePath;
@@ -697,7 +681,7 @@
return false;
final boolean servletInvocationContext = context instanceof ServletRequestContext;
- final boolean nettyInvocationContext =
context.getProperty(Constants.NETTY_REQUEST_HEADERS) != null;
+ final boolean nettyInvocationContext = context.getProperty(Constants.NETTY_MESSAGE)
!= null;
return servletInvocationContext || nettyInvocationContext;
}