JBossWS SVN: r10329 - stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2009-07-17 04:02:58 -0400 (Fri, 17 Jul 2009)
New Revision: 10329
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/HttpServletResponseExt.java
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/ServletControllerExt.java
Log:
[JBWS-2669] Implement missing endpoint metrics update for JBossWS-CXF
Added: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/HttpServletResponseExt.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/HttpServletResponseExt.java (rev 0)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/HttpServletResponseExt.java 2009-07-17 08:02:58 UTC (rev 10329)
@@ -0,0 +1,225 @@
+/*
+ * 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.cxf;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Locale;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * A HttpServletResponse delegate that externalizes fields.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 17-Jul-2009
+ */
+public class HttpServletResponseExt implements HttpServletResponse
+{
+ private HttpServletResponse delegate;
+ private int sc;
+
+ public HttpServletResponseExt(HttpServletResponse delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ /**
+ * Get the status currently set in the HttpServletResponse
+ *
+ * @return the http status
+ */
+ public int getStatus()
+ {
+ return this.sc;
+ }
+
+ /* HttpServletResponse API */
+
+ public void addCookie(Cookie cookie)
+ {
+ delegate.addCookie(cookie);
+ }
+
+ public void addDateHeader(String name, long date)
+ {
+ delegate.addDateHeader(name, date);
+ }
+
+ public void addHeader(String name, String value)
+ {
+ delegate.addHeader(name, value);
+ }
+
+ public void addIntHeader(String name, int value)
+ {
+ delegate.addIntHeader(name, value);
+ }
+
+ public boolean containsHeader(String name)
+ {
+ return delegate.containsHeader(name);
+ }
+
+ public String encodeRedirectURL(String url)
+ {
+ return delegate.encodeRedirectURL(url);
+ }
+
+ @Deprecated
+ public String encodeRedirectUrl(String url)
+ {
+ return delegate.encodeRedirectUrl(url);
+ }
+
+ public String encodeURL(String url)
+ {
+ return delegate.encodeURL(url);
+ }
+
+ @Deprecated
+ public String encodeUrl(String url)
+ {
+ return delegate.encodeUrl(url);
+ }
+
+ public void sendError(int sc) throws IOException
+ {
+ delegate.sendError(sc);
+ }
+
+ public void sendError(int sc, String msg) throws IOException
+ {
+ delegate.sendError(sc, msg);
+ }
+
+ public void sendRedirect(String location) throws IOException
+ {
+ delegate.sendRedirect(location);
+ }
+
+ public void setDateHeader(String name, long date)
+ {
+ delegate.setDateHeader(name, date);
+ }
+
+ public void setHeader(String name, String value)
+ {
+ delegate.setHeader(name, value);
+ }
+
+ public void setIntHeader(String name, int value)
+ {
+ delegate.setIntHeader(name, value);
+ }
+
+ public void setStatus(int sc)
+ {
+ delegate.setStatus(sc);
+ this.sc = sc;
+ }
+
+ @Deprecated
+ public void setStatus(int sc, String sm)
+ {
+ delegate.setStatus(sc, sm);
+ this.sc = sc;
+ }
+
+ public void flushBuffer() throws IOException
+ {
+ delegate.flushBuffer();
+ }
+
+ public int getBufferSize()
+ {
+ return delegate.getBufferSize();
+ }
+
+ public String getCharacterEncoding()
+ {
+ return delegate.getCharacterEncoding();
+ }
+
+ public String getContentType()
+ {
+ return delegate.getContentType();
+ }
+
+ public Locale getLocale()
+ {
+ return delegate.getLocale();
+ }
+
+ public ServletOutputStream getOutputStream() throws IOException
+ {
+ return delegate.getOutputStream();
+ }
+
+ public PrintWriter getWriter() throws IOException
+ {
+ return delegate.getWriter();
+ }
+
+ public boolean isCommitted()
+ {
+ return delegate.isCommitted();
+ }
+
+ public void reset()
+ {
+ delegate.reset();
+ }
+
+ public void resetBuffer()
+ {
+ delegate.resetBuffer();
+ }
+
+ public void setBufferSize(int size)
+ {
+ delegate.setBufferSize(size);
+ }
+
+ public void setCharacterEncoding(String charset)
+ {
+ delegate.setCharacterEncoding(charset);
+ }
+
+ public void setContentLength(int len)
+ {
+ delegate.setContentLength(len);
+ }
+
+ public void setContentType(String type)
+ {
+ delegate.setContentType(type);
+ }
+
+ public void setLocale(Locale loc)
+ {
+ delegate.setLocale(loc);
+ }
+
+}
Property changes on: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/HttpServletResponseExt.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java 2009-07-16 16:34:38 UTC (rev 10328)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java 2009-07-17 08:02:58 UTC (rev 10329)
@@ -54,11 +54,11 @@
public void handleHttpRequest(Endpoint ep, HttpServletRequest req, HttpServletResponse res, ServletContext context) throws ServletException, IOException
{
- ServletController controller = (ServletController)context.getAttribute(ServletController.class.getName());
+ ServletControllerExt controller = (ServletControllerExt)context.getAttribute(ServletController.class.getName());
if (controller == null)
throw new IllegalStateException("Cannot obtain servlet controller");
- controller.invoke(req, res);
+ controller.invoke(req, res, ep);
}
public void handleRequest(Endpoint endpoint, InputStream inStream, OutputStream outStream, InvocationContext context)
Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/ServletControllerExt.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/ServletControllerExt.java 2009-07-16 16:34:38 UTC (rev 10328)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/ServletControllerExt.java 2009-07-17 08:02:58 UTC (rev 10329)
@@ -39,6 +39,8 @@
import org.apache.cxf.transport.servlet.ServletTransportFactory;
import org.apache.cxf.transports.http.QueryHandler;
import org.apache.cxf.transports.http.QueryHandlerRegistry;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.management.EndpointMetrics;
/**
* An extension to the CXF servlet controller
@@ -150,14 +152,50 @@
return false;
}
- public void invoke(HttpServletRequest req, HttpServletResponse res) throws ServletException
+ public void invoke(HttpServletRequest req, HttpServletResponse res, Endpoint ep) throws ServletException
{
ServletDestination dest = findDestination(req);
boolean requestHandled = handleQuery(req, res, dest);
if (false == requestHandled)
{
- invokeDestination(req, res, dest);
+ Long beginTime = initRequestMetrics(ep);
+ HttpServletResponseExt response = new HttpServletResponseExt(res);
+ invokeDestination(req, response, dest);
+ if (response.getStatus() < 500)
+ {
+ processResponseMetrics(ep, beginTime);
+ }
+ else
+ {
+ processFaultMetrics(ep, beginTime);
+ }
}
}
+
+ private long initRequestMetrics(Endpoint endpoint)
+ {
+ long beginTime = 0;
+
+ EndpointMetrics metrics = endpoint.getEndpointMetrics();
+ if (metrics != null)
+ beginTime = metrics.processRequestMessage();
+
+ return beginTime;
+ }
+
+ private void processResponseMetrics(Endpoint endpoint, long beginTime)
+ {
+ EndpointMetrics metrics = endpoint.getEndpointMetrics();
+ if (metrics != null)
+ metrics.processResponseMessage(beginTime);
+ }
+
+ private void processFaultMetrics(Endpoint endpoint, long beginTime)
+ {
+ EndpointMetrics metrics = endpoint.getEndpointMetrics();
+ if (metrics != null)
+ metrics.processFaultMessage(beginTime);
+ }
+
}
15 years, 5 months
JBossWS SVN: r10328 - in stack/native/trunk/modules/core/src/main/java/org/jboss/ws: core/client and 2 other directories.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2009-07-16 12:34:38 -0400 (Thu, 16 Jul 2009)
New Revision: 10328
Added:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/feature/ChunkedEncodingFeature.java
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/StubExt.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NettyClient.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientFeatureProcessor.java
Log:
[JBWS-2694] Simpler approach to disable chunked encoding: a) adding prop in the request context or b) using the custom ChunkedEncodingFeature when getting the port
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/StubExt.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/StubExt.java 2009-07-16 13:14:53 UTC (rev 10327)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/StubExt.java 2009-07-16 16:34:38 UTC (rev 10328)
@@ -71,6 +71,8 @@
static final String PROPERTY_AUTH_TYPE_WSSE = "org.jboss.ws.authType.wsse";
/** Enable MTOM on the stub */
static final String PROPERTY_MTOM_ENABLED= "org.jboss.ws.mtom.enabled";
+ /** HTTP chunk size */
+ static final String PROPERTY_CHUNKED_ENCODING_SIZE = "http://org.jboss.ws/http#chunksize";
/**
* Get the endpoint meta data for this stub
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NettyClient.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NettyClient.java 2009-07-16 13:14:53 UTC (rev 10327)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NettyClient.java 2009-07-16 16:34:38 UTC (rev 10328)
@@ -34,6 +34,7 @@
import javax.xml.rpc.Stub;
import javax.xml.ws.BindingProvider;
+import org.jboss.logging.Logger;
import org.jboss.netty.bootstrap.ClientBootstrap;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBufferOutputStream;
@@ -73,6 +74,7 @@
{
public static final String RESPONSE_CODE = "ResponseCode";
public static final String RESPONSE_CODE_MESSAGE = "ResponseCodeMessage";
+ private static Logger log = Logger.getLogger(NettyClient.class);
private Marshaller marshaller;
private UnMarshaller unmarshaller;
@@ -181,7 +183,7 @@
request.addHeader(HttpHeaders.Names.HOST, target.getHost());
request.addHeader(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE);
setAdditionalHeaders(request, additionalHeaders);
- setActualChunkedLength(request);
+ setActualChunkedLength(request, callProps);
setAuthorization(request, callProps);
ChannelFuture writeFuture = writeRequest(channel, request, reqMessage);
@@ -326,7 +328,7 @@
*
* @param message
*/
- protected void setActualChunkedLength(HttpRequest message)
+ protected void setActualChunkedLength(HttpRequest message, Map<String, Object> callProps)
{
if (HttpMethod.POST.equals(message.getMethod()))
{
@@ -340,6 +342,20 @@
String sizeValue = config.getProperty(EndpointProperty.CHUNKED_ENCODING_SIZE);
if (sizeValue != null)
chunkSize = Integer.valueOf(sizeValue);
+
+ //override using call props
+ try
+ {
+ Object obj = callProps.get(StubExt.PROPERTY_CHUNKED_ENCODING_SIZE);
+ if (obj != null) //explicit 0 value is required to disable chunked mode
+ chunkSize = (Integer)obj;
+ }
+ catch (Exception e)
+ {
+ log.warn("Can't set chunk size from call properties, illegal value provided!");
+ }
+
+ //fastinfoset always disable chunking
if (epMetaData.isFeatureEnabled(FastInfosetFeature.class))
chunkSize = 0;
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientFeatureProcessor.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientFeatureProcessor.java 2009-07-16 13:14:53 UTC (rev 10327)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientFeatureProcessor.java 2009-07-16 16:34:38 UTC (rev 10328)
@@ -22,6 +22,7 @@
package org.jboss.ws.core.jaxws.client;
import java.util.List;
+import java.util.Map;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.RespectBindingFeature;
@@ -33,8 +34,10 @@
import javax.xml.ws.soap.SOAPBinding;
import org.jboss.logging.Logger;
+import org.jboss.ws.core.StubExt;
import org.jboss.ws.core.jaxws.binding.BindingExt;
import org.jboss.ws.extensions.addressing.jaxws.WSAddressingClientHandler;
+import org.jboss.ws.feature.ChunkedEncodingFeature;
import org.jboss.ws.feature.FastInfosetFeature;
import org.jboss.ws.feature.JsonEncodingFeature;
import org.jboss.ws.feature.SchemaValidationFeature;
@@ -70,6 +73,7 @@
supportedFeatures.addFeature(new AddressingFeature());
supportedFeatures.addFeature(new MTOMFeature());
supportedFeatures.addFeature(new RespectBindingFeature());
+ supportedFeatures.addFeature(new ChunkedEncodingFeature());
}
public static <T> void processFeature(WebServiceFeature feature, EndpointMetaData epMetaData, T stub)
@@ -81,12 +85,12 @@
processAddressingFeature(feature, epMetaData, stub);
processMTOMFeature(feature, epMetaData, stub);
processRespectBindingFeature(feature, epMetaData, stub);
+ processChunkedEncodingFeature(feature, epMetaData, stub);
epMetaData.addFeature(feature);
}
/**
- * Returns true or false depending on the provided WebServiceFeature being an AddressingFeature or not.
- * In the former case, addressing is setup.
+ * Setup addressing
*
* @param <T>
* @param feature
@@ -107,8 +111,7 @@
}
/**
- * Returns true or false depending on the provided WebServiceFeature being an MTOMFeature or not.
- * In the former case, mtom is setup.
+ * Setup http chunked encoding
*
* @param <T>
* @param feature
@@ -116,6 +119,24 @@
* @param stub
* @return
*/
+ private static <T> void processChunkedEncodingFeature(WebServiceFeature feature, EndpointMetaData epMetaData, T stub)
+ {
+ if (feature instanceof ChunkedEncodingFeature)
+ {
+ Map<String, Object> ctx = ((BindingProvider)stub).getRequestContext();
+ ctx.put(StubExt.PROPERTY_CHUNKED_ENCODING_SIZE, ((ChunkedEncodingFeature)feature).getChunkSize());
+ }
+ }
+
+ /**
+ * Setup MTOM
+ *
+ * @param <T>
+ * @param feature
+ * @param epMetaData
+ * @param stub
+ * @return
+ */
private static <T> void processMTOMFeature(WebServiceFeature feature, EndpointMetaData epMetaData, T stub)
{
if (feature instanceof MTOMFeature)
@@ -126,9 +147,9 @@
}
/**
- * Returns true or false depending on the provided WebServiceFeature being an RespectBindingFeature or not.
- * In the former case, the respect binding checks are performed.
*
+ * Perform respect binding checks
+ *
* @param <T>
* @param feature
* @param epMetaData
Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/feature/ChunkedEncodingFeature.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/feature/ChunkedEncodingFeature.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/feature/ChunkedEncodingFeature.java 2009-07-16 16:34:38 UTC (rev 10328)
@@ -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.ws.feature;
+
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.WebServiceFeature;
+
+import org.jboss.ws.Constants;
+
+/**
+ * This feature represents the use of http chunked encoding
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 16-Jul-2009
+ */
+public final class ChunkedEncodingFeature extends WebServiceFeature
+{
+ /**
+ * Constant value identifying the FastInfosetFeature
+ */
+ public static final String ID = Constants.NS_JBOSSWS_URI + "/features/chunkedencoding";
+
+ protected int chunkSize = 1024;
+
+ /**
+ * Create an <code>ChunkedEncodingFeature</code>.
+ * The instance created will be enabled.
+ */
+ public ChunkedEncodingFeature()
+ {
+ this.enabled = true;
+ }
+
+ /**
+ * Creates a <code>ChunkedEncodingFeature</code>.
+ *
+ * @param enabled specifies if this feature should be enabled or not
+ */
+ public ChunkedEncodingFeature(boolean enabled)
+ {
+ this.enabled = enabled;
+ if (!enabled)
+ {
+ this.chunkSize = 0;
+ }
+ }
+
+ /**
+ * Creates a <code>ChunkedEncodingFeature</code> and set the provided chunk size (chunkSize == 0 turns off chunked encoding).
+ *
+ * @param chunkSize the chunk size in bytes
+ */
+ public ChunkedEncodingFeature(int chunkSize)
+ {
+ if (chunkSize < 0)
+ {
+ throw new WebServiceException("ChunkedEncodingFeature.chunkSize must be >= 0, actual value: " + chunkSize);
+ }
+ this.chunkSize = chunkSize;
+ this.enabled = (chunkSize > 0);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getID()
+ {
+ return ID;
+ }
+
+ /**
+ * Gets the configured chunksize
+ *
+ * @return the current chunksize in bytes
+ */
+ public int getChunkSize()
+ {
+ return chunkSize;
+ }
+}
Property changes on: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/feature/ChunkedEncodingFeature.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
15 years, 5 months