You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ve...@apache.org on 2008/11/03 22:07:21 UTC
svn commit: r710158 [12/20] - in
/webservices/commons/trunk/modules/transport: ./ modules/base/
modules/base/src/main/java/org/apache/axis2/format/
modules/base/src/main/java/org/apache/axis2/transport/base/
modules/base/src/main/java/org/apache/axis2/...
Modified: webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/HttpFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/HttpFactory.java?rev=710158&r1=710157&r2=710158&view=diff
==============================================================================
--- webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/HttpFactory.java (original)
+++ webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/HttpFactory.java Mon Nov 3 13:07:13 2008
@@ -1,484 +1,484 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.http.server;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.engine.ListenerManager;
-import org.apache.axis2.transport.http.HTTPWorkerFactory;
-import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.HttpResponseFactory;
-import org.apache.http.impl.DefaultConnectionReuseStrategy;
-import org.apache.http.impl.DefaultHttpResponseFactory;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.params.HttpParams;
-import org.apache.http.params.HttpProtocolParams;
-import org.apache.http.protocol.BasicHttpProcessor;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.ResponseConnControl;
-import org.apache.http.protocol.ResponseContent;
-import org.apache.http.protocol.ResponseDate;
-import org.apache.http.protocol.ResponseServer;
-
-import java.io.IOException;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Factory used to configure and create the various instances required in http transports.
- * Either configure this class in axis2.xml, or in code via the setters, or subclass it and specialize some factory methods to gain more control.
- */
-public class HttpFactory {
-
- /**
- * Name of axis2.xml port parameter for SimpleHTTPServer configuration
- */
- public static final String PARAMETER_PORT = "port";
-
- /**
- * Name of axis2.xml hostname parameter for SimpleHTTPServer configuration
- */
- public static final String PARAMETER_HOST_ADDRESS = "hostname";
-
- /**
- * Name of axis2.xml originServer parameter for SimpleHTTPServer configuration
- */
- public static final String PARAMETER_ORIGIN_SERVER = "originServer";
-
- /**
- * Name of axis2.xml requestTimeout parameter for SimpleHTTPServer configuration
- */
- public static final String PARAMETER_REQUEST_SOCKET_TIMEOUT = "requestTimeout";
-
- /**
- * Name of axis2.xml requestTcpNoDelay parameter for SimpleHTTPServer configuration
- */
- public static final String PARAMETER_REQUEST_TCP_NO_DELAY = "requestTcpNoDelay";
-
- /**
- * Name of axis2.xml requestCoreThreadPoolSize parameter for SimpleHTTPServer configuration
- */
- public static final String PARAMETER_REQUEST_CORE_THREAD_POOL_SIZE =
- "requestCoreThreadPoolSize";
-
- /**
- * Name of axis2.xml requestMaxThreadPoolSize parameter for SimpleHTTPServer configuration
- */
- public static final String PARAMETER_REQUEST_MAX_THREAD_POOL_SIZE = "requestMaxThreadPoolSize";
-
- /**
- * Name of axis2.xml threadKeepAliveTime parameter for SimpleHTTPServer configuration
- */
- public static final String PARAMETER_THREAD_KEEP_ALIVE_TIME = "threadKeepAliveTime";
-
- /**
- * Name of axis2.xml threadKeepAliveTimeUnit parameter for SimpleHTTPServer configuration
- */
- public static final String PARAMETER_THREAD_KEEP_ALIVE_TIME_UNIT = "threadKeepAliveTimeUnit";
-
- private ConfigurationContext configurationContext;
- private TransportInDescription httpConfiguration;
- private int port;
- private String hostAddress;
- private String originServer;
- private int requestSocketTimeout;
- private boolean requestTcpNoDelay;
- private int requestCoreThreadPoolSize;
- private int requestMaxThreadPoolSize;
- private long threadKeepAliveTime;
- private TimeUnit threadKeepAliveTimeUnit;
-
- private WorkerFactory requestWorkerFactory = null;
-
- /**
- * Create and configure a new HttpFactory
- */
- public HttpFactory(ConfigurationContext configurationContext) throws AxisFault {
- this.configurationContext = configurationContext;
- httpConfiguration = configurationContext.getAxisConfiguration().getTransportIn(Constants.TRANSPORT_HTTP);
- port = getIntParam(PARAMETER_PORT, 6060);
- hostAddress = getStringParam(PARAMETER_HOST_ADDRESS, null);
- originServer = getStringParam(PARAMETER_ORIGIN_SERVER, "Simple-Server/1.1");
- requestSocketTimeout = getIntParam(PARAMETER_REQUEST_SOCKET_TIMEOUT, 20000);
- requestTcpNoDelay = getBooleanParam(PARAMETER_REQUEST_TCP_NO_DELAY, true);
- requestCoreThreadPoolSize = getIntParam(PARAMETER_REQUEST_CORE_THREAD_POOL_SIZE, 100);
- requestMaxThreadPoolSize = getIntParam(PARAMETER_REQUEST_MAX_THREAD_POOL_SIZE, 150);
- threadKeepAliveTime = getLongParam(PARAMETER_THREAD_KEEP_ALIVE_TIME, 180L);
- threadKeepAliveTimeUnit =
- getTimeUnitParam(PARAMETER_THREAD_KEEP_ALIVE_TIME_UNIT, TimeUnit.SECONDS);
- }
-
- /**
- * Create and configure a new HttpFactory
- */
- public HttpFactory(ConfigurationContext configurationContext, int port) throws AxisFault {
- this(configurationContext);
- this.port = port;
- }
-
- /**
- * Create and configure a new HttpFactory
- */
- public HttpFactory(ConfigurationContext configurationContext, int port,
- WorkerFactory requestWorkerFactory) throws AxisFault {
- this(configurationContext, port);
- this.requestWorkerFactory = requestWorkerFactory;
- }
-
- private int getIntParam(String name, int def) {
- String config = getStringParam(name, null);
- if (config != null) {
- return Integer.parseInt(config);
- } else {
- return def;
- }
- }
-
- private long getLongParam(String name, long def) {
- String config = getStringParam(name, null);
- if (config != null) {
- return Long.parseLong(config);
- } else {
- return def;
- }
- }
-
- private boolean getBooleanParam(String name, boolean def) throws AxisFault {
- String config = getStringParam(name, null);
- if (config != null) {
- if (config.equals("yes") || config.equals("true")) {
- return true;
- } else if (config.equals("no") || config.equals("false")) {
- return false;
- } else {
- throw new AxisFault("Boolean value must be yes, true, no or false for parameter " +
- name + ": " + config);
- }
- }
- return def;
- }
-
- private TimeUnit getTimeUnitParam(String name, TimeUnit def) throws AxisFault {
- String config = getStringParam(name, null);
- if (config != null) {
- try {
- return (TimeUnit) TimeUnit.class.getField(config).get(null);
- } catch (Exception e) {
- throw AxisFault.makeFault(e);
- }
- }
- return def;
- }
-
- private String getStringParam(String name, String def) {
- Parameter param = httpConfiguration.getParameter(name);
- if (param != null) {
-// assert param.getParameterType() == Parameter.TEXT_PARAMETER;
- String config = (String) param.getValue();
- if (config != null) {
- return config;
- }
- }
- return def;
- }
-
- /**
- * Return the configured listener manager or create and configure one with configurationContext
- */
- public ListenerManager getListenerManager() {
- ListenerManager lm = configurationContext.getListenerManager();
- if (lm == null) {
- lm = new ListenerManager();
- lm.init(configurationContext);
- }
- return lm;
- }
-
- /**
- * Create the executor used to launch the single requestConnectionListener
- */
- public ExecutorService newListenerExecutor(int port) {
- return new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS,
- new LinkedBlockingQueue(),
- new DefaultThreadFactory(
- new ThreadGroup("Listener thread group"),
- "HttpListener-" + this.port));
- }
-
- /**
- * Create the listener for request connections
- */
- public IOProcessor newRequestConnectionListener(
- int port,
- final HttpConnectionManager manager,
- final HttpParams params) throws IOException {
- return new DefaultConnectionListener(
- port,
- manager,
- new DefaultConnectionListenerFailureHandler(),
- params);
- }
-
- /**
- * Create and set the parameters applied to incoming request connections
- */
- public HttpParams newRequestConnectionParams() {
- HttpParams params = new BasicHttpParams();
- params
- .setIntParameter(HttpConnectionParams.SO_TIMEOUT, requestSocketTimeout)
- .setBooleanParameter(HttpConnectionParams.TCP_NODELAY, requestTcpNoDelay)
- .setIntParameter(HttpConnectionParams.MAX_LINE_LENGTH, 4000)
- .setIntParameter(HttpConnectionParams.MAX_HEADER_COUNT, 500)
- .setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE, 8 * 1024)
- .setParameter(HttpProtocolParams.ORIGIN_SERVER, originServer);
- return params;
- }
-
- /**
- * Create the connection manager used to launch request threads
- */
- public HttpConnectionManager newRequestConnectionManager(ExecutorService requestExecutor,
- WorkerFactory workerFactory,
- HttpParams params) {
- return new DefaultHttpConnectionManager(configurationContext, requestExecutor,
- workerFactory, params);
- }
-
- /**
- * Create the executor use the manage request processing threads
- */
- public ExecutorService newRequestExecutor(int port) {
- return new ThreadPoolExecutor(requestCoreThreadPoolSize, requestMaxThreadPoolSize,
- threadKeepAliveTime, threadKeepAliveTimeUnit,
- newRequestBlockingQueue(),
- new DefaultThreadFactory(
- new ThreadGroup("Connection thread group"),
- "HttpConnection-" + port));
- }
-
- /**
- * Create the queue used to hold incoming requests when requestCoreThreadPoolSize threads are busy.
- * Default is an unbounded queue.
- */
- public BlockingQueue newRequestBlockingQueue() {
- return new LinkedBlockingQueue();
- }
-
- /**
- * Create the factory for request workers
- */
- public WorkerFactory newRequestWorkerFactory() {
- if (requestWorkerFactory != null) {
- return requestWorkerFactory;
- } else {
- return new HTTPWorkerFactory();
- }
- }
-
- public HttpProcessor newHttpProcessor() {
- BasicHttpProcessor httpProcessor = new BasicHttpProcessor();
- httpProcessor.addInterceptor(new RequestSessionCookie());
- httpProcessor.addInterceptor(new ResponseDate());
- httpProcessor.addInterceptor(new ResponseServer());
- httpProcessor.addInterceptor(new ResponseContent());
- httpProcessor.addInterceptor(new ResponseConnControl());
- httpProcessor.addInterceptor(new ResponseSessionCookie());
- return httpProcessor;
- }
-
- public ConnectionReuseStrategy newConnStrategy() {
- return new DefaultConnectionReuseStrategy();
- }
-
- public HttpResponseFactory newResponseFactory() {
- return new DefaultHttpResponseFactory();
- }
-
- // *****
- // Getters and Setters
- // *****
-
- /**
- * Getter for configurationContext
- */
- public ConfigurationContext getConfigurationContext() {
- return configurationContext;
- }
-
- /**
- * Getter for httpConfiguration
- */
- public TransportInDescription getHttpConfiguration() {
- return httpConfiguration;
- }
-
- /**
- * Getter for port
- * return the port on which to listen for http connections (default = 6060)
- */
- public int getPort() {
- return port;
- }
-
- /**
- * Setter for port
- */
- public void setPort(int port) {
- this.port = port;
- }
-
- /**
- * Getter for hostAddress
- *
- * @return the host address (or name) to be use in reply-to endpoint references, or null if not specified (default = null)
- */
- public String getHostAddress() {
- return hostAddress;
- }
-
- /**
- * Setter for hostAddress
- */
- public void setHostAddress(String hostAddress) {
- this.hostAddress = hostAddress;
- }
-
- /**
- * Getter for originServer
- *
- * @return the Server header string for outgoing messages (default "Simple-Server/1.1")
- */
- public String getOriginServer() {
- return originServer;
- }
-
- /**
- * Setter for originServer
- */
- public void setOriginServer(String originServer) {
- this.originServer = originServer;
- }
-
- /**
- * Getter for requestSocketTimeout
- *
- * @return the maximum time in millis to wait for data on a request socket (default 20000)
- */
- public int getRequestSocketTimeout() {
- return requestSocketTimeout;
- }
-
- /**
- * Setter for requestSocketTimeout
- */
- public void setRequestSocketTimeout(int requestSocketTimeout) {
- this.requestSocketTimeout = requestSocketTimeout;
- }
-
- /**
- * Getter for requestTcpNoDelay
- * return false iff Nagle's algorithm should be used to conserve bandwidth by minimizing segments
- * at the cost of latency and performance (default true, i.e. maximize performance at
- * the cost of bandwidth)
- */
- public boolean getRequestTcpNoDelay() {
- return requestTcpNoDelay;
- }
-
- /**
- * Setter for requestTcpNoDelay
- */
- public void setRequestTcpNoDelay(boolean requestTcpNoDelay) {
- this.requestTcpNoDelay = requestTcpNoDelay;
- }
-
- /**
- * Getter for RequestCoreThreadPoolSize
- *
- * @return the size of the thread pool use to process requests assuming there is adequate queue space (default 25)
- */
- public int getRequestCoreThreadPoolSize() {
- return requestCoreThreadPoolSize;
- }
-
- /**
- * Setter for RequestCoreThreadPoolSize
- */
- public void setRequestCoreThreadPoolSize(int requestCoreThreadPoolSize) {
- this.requestCoreThreadPoolSize = requestCoreThreadPoolSize;
- }
-
- /**
- * Getter for requestMaxThreadPoolSize
- *
- * @return the maximum size of the thread pool used to process requests if the queue fills up (default 150).
- * Since the default queue is unbounded this parameter is meaningless unless you override newRequestBlockingQueue()
- */
- public int getRequestMaxThreadPoolSize() {
- return requestMaxThreadPoolSize;
- }
-
- /**
- * Setter for requestMaxThreadPoolSize
- */
- public void setRequestMaxThreadPoolSize(int requestMaxThreadPoolSize) {
- this.requestMaxThreadPoolSize = requestMaxThreadPoolSize;
- }
-
- /**
- * Getter for threadKeepAliveTime
- *
- * @return how long a request processing thread in excess of the core pool size will be kept alive it if is inactive
- * (default with threadKeepAliveTimeUnit to 180 seconds)
- */
- public long getThreadKeepAliveTime() {
- return threadKeepAliveTime;
- }
-
- /**
- * Setter for threadKeepAliveTime
- */
- public void setThreadKeepAliveTime(long threadKeepAliveTime) {
- this.threadKeepAliveTime = threadKeepAliveTime;
- }
-
- /**
- * Getter for threadKeepAliveTimeUnit
- * return the time unit for threadKeepAliveTime (default SECONDS)
- */
- public TimeUnit getThreadKeepAliveTimeUnit() {
- return threadKeepAliveTimeUnit;
- }
-
- /**
- * Setter for threadKeepAliveTimeUnit
- */
- public void setThreadKeepAliveTimeUnit(TimeUnit threadKeepAliveTimeUnit) {
- this.threadKeepAliveTimeUnit = threadKeepAliveTimeUnit;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.http.server;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.engine.ListenerManager;
+import org.apache.axis2.transport.http.HTTPWorkerFactory;
+import org.apache.http.ConnectionReuseStrategy;
+import org.apache.http.HttpResponseFactory;
+import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.impl.DefaultHttpResponseFactory;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpConnectionParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.protocol.BasicHttpProcessor;
+import org.apache.http.protocol.HttpProcessor;
+import org.apache.http.protocol.ResponseConnControl;
+import org.apache.http.protocol.ResponseContent;
+import org.apache.http.protocol.ResponseDate;
+import org.apache.http.protocol.ResponseServer;
+
+import java.io.IOException;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Factory used to configure and create the various instances required in http transports.
+ * Either configure this class in axis2.xml, or in code via the setters, or subclass it and specialize some factory methods to gain more control.
+ */
+public class HttpFactory {
+
+ /**
+ * Name of axis2.xml port parameter for SimpleHTTPServer configuration
+ */
+ public static final String PARAMETER_PORT = "port";
+
+ /**
+ * Name of axis2.xml hostname parameter for SimpleHTTPServer configuration
+ */
+ public static final String PARAMETER_HOST_ADDRESS = "hostname";
+
+ /**
+ * Name of axis2.xml originServer parameter for SimpleHTTPServer configuration
+ */
+ public static final String PARAMETER_ORIGIN_SERVER = "originServer";
+
+ /**
+ * Name of axis2.xml requestTimeout parameter for SimpleHTTPServer configuration
+ */
+ public static final String PARAMETER_REQUEST_SOCKET_TIMEOUT = "requestTimeout";
+
+ /**
+ * Name of axis2.xml requestTcpNoDelay parameter for SimpleHTTPServer configuration
+ */
+ public static final String PARAMETER_REQUEST_TCP_NO_DELAY = "requestTcpNoDelay";
+
+ /**
+ * Name of axis2.xml requestCoreThreadPoolSize parameter for SimpleHTTPServer configuration
+ */
+ public static final String PARAMETER_REQUEST_CORE_THREAD_POOL_SIZE =
+ "requestCoreThreadPoolSize";
+
+ /**
+ * Name of axis2.xml requestMaxThreadPoolSize parameter for SimpleHTTPServer configuration
+ */
+ public static final String PARAMETER_REQUEST_MAX_THREAD_POOL_SIZE = "requestMaxThreadPoolSize";
+
+ /**
+ * Name of axis2.xml threadKeepAliveTime parameter for SimpleHTTPServer configuration
+ */
+ public static final String PARAMETER_THREAD_KEEP_ALIVE_TIME = "threadKeepAliveTime";
+
+ /**
+ * Name of axis2.xml threadKeepAliveTimeUnit parameter for SimpleHTTPServer configuration
+ */
+ public static final String PARAMETER_THREAD_KEEP_ALIVE_TIME_UNIT = "threadKeepAliveTimeUnit";
+
+ private ConfigurationContext configurationContext;
+ private TransportInDescription httpConfiguration;
+ private int port;
+ private String hostAddress;
+ private String originServer;
+ private int requestSocketTimeout;
+ private boolean requestTcpNoDelay;
+ private int requestCoreThreadPoolSize;
+ private int requestMaxThreadPoolSize;
+ private long threadKeepAliveTime;
+ private TimeUnit threadKeepAliveTimeUnit;
+
+ private WorkerFactory requestWorkerFactory = null;
+
+ /**
+ * Create and configure a new HttpFactory
+ */
+ public HttpFactory(ConfigurationContext configurationContext) throws AxisFault {
+ this.configurationContext = configurationContext;
+ httpConfiguration = configurationContext.getAxisConfiguration().getTransportIn(Constants.TRANSPORT_HTTP);
+ port = getIntParam(PARAMETER_PORT, 6060);
+ hostAddress = getStringParam(PARAMETER_HOST_ADDRESS, null);
+ originServer = getStringParam(PARAMETER_ORIGIN_SERVER, "Simple-Server/1.1");
+ requestSocketTimeout = getIntParam(PARAMETER_REQUEST_SOCKET_TIMEOUT, 20000);
+ requestTcpNoDelay = getBooleanParam(PARAMETER_REQUEST_TCP_NO_DELAY, true);
+ requestCoreThreadPoolSize = getIntParam(PARAMETER_REQUEST_CORE_THREAD_POOL_SIZE, 100);
+ requestMaxThreadPoolSize = getIntParam(PARAMETER_REQUEST_MAX_THREAD_POOL_SIZE, 150);
+ threadKeepAliveTime = getLongParam(PARAMETER_THREAD_KEEP_ALIVE_TIME, 180L);
+ threadKeepAliveTimeUnit =
+ getTimeUnitParam(PARAMETER_THREAD_KEEP_ALIVE_TIME_UNIT, TimeUnit.SECONDS);
+ }
+
+ /**
+ * Create and configure a new HttpFactory
+ */
+ public HttpFactory(ConfigurationContext configurationContext, int port) throws AxisFault {
+ this(configurationContext);
+ this.port = port;
+ }
+
+ /**
+ * Create and configure a new HttpFactory
+ */
+ public HttpFactory(ConfigurationContext configurationContext, int port,
+ WorkerFactory requestWorkerFactory) throws AxisFault {
+ this(configurationContext, port);
+ this.requestWorkerFactory = requestWorkerFactory;
+ }
+
+ private int getIntParam(String name, int def) {
+ String config = getStringParam(name, null);
+ if (config != null) {
+ return Integer.parseInt(config);
+ } else {
+ return def;
+ }
+ }
+
+ private long getLongParam(String name, long def) {
+ String config = getStringParam(name, null);
+ if (config != null) {
+ return Long.parseLong(config);
+ } else {
+ return def;
+ }
+ }
+
+ private boolean getBooleanParam(String name, boolean def) throws AxisFault {
+ String config = getStringParam(name, null);
+ if (config != null) {
+ if (config.equals("yes") || config.equals("true")) {
+ return true;
+ } else if (config.equals("no") || config.equals("false")) {
+ return false;
+ } else {
+ throw new AxisFault("Boolean value must be yes, true, no or false for parameter " +
+ name + ": " + config);
+ }
+ }
+ return def;
+ }
+
+ private TimeUnit getTimeUnitParam(String name, TimeUnit def) throws AxisFault {
+ String config = getStringParam(name, null);
+ if (config != null) {
+ try {
+ return (TimeUnit) TimeUnit.class.getField(config).get(null);
+ } catch (Exception e) {
+ throw AxisFault.makeFault(e);
+ }
+ }
+ return def;
+ }
+
+ private String getStringParam(String name, String def) {
+ Parameter param = httpConfiguration.getParameter(name);
+ if (param != null) {
+// assert param.getParameterType() == Parameter.TEXT_PARAMETER;
+ String config = (String) param.getValue();
+ if (config != null) {
+ return config;
+ }
+ }
+ return def;
+ }
+
+ /**
+ * Return the configured listener manager or create and configure one with configurationContext
+ */
+ public ListenerManager getListenerManager() {
+ ListenerManager lm = configurationContext.getListenerManager();
+ if (lm == null) {
+ lm = new ListenerManager();
+ lm.init(configurationContext);
+ }
+ return lm;
+ }
+
+ /**
+ * Create the executor used to launch the single requestConnectionListener
+ */
+ public ExecutorService newListenerExecutor(int port) {
+ return new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS,
+ new LinkedBlockingQueue(),
+ new DefaultThreadFactory(
+ new ThreadGroup("Listener thread group"),
+ "HttpListener-" + this.port));
+ }
+
+ /**
+ * Create the listener for request connections
+ */
+ public IOProcessor newRequestConnectionListener(
+ int port,
+ final HttpConnectionManager manager,
+ final HttpParams params) throws IOException {
+ return new DefaultConnectionListener(
+ port,
+ manager,
+ new DefaultConnectionListenerFailureHandler(),
+ params);
+ }
+
+ /**
+ * Create and set the parameters applied to incoming request connections
+ */
+ public HttpParams newRequestConnectionParams() {
+ HttpParams params = new BasicHttpParams();
+ params
+ .setIntParameter(HttpConnectionParams.SO_TIMEOUT, requestSocketTimeout)
+ .setBooleanParameter(HttpConnectionParams.TCP_NODELAY, requestTcpNoDelay)
+ .setIntParameter(HttpConnectionParams.MAX_LINE_LENGTH, 4000)
+ .setIntParameter(HttpConnectionParams.MAX_HEADER_COUNT, 500)
+ .setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE, 8 * 1024)
+ .setParameter(HttpProtocolParams.ORIGIN_SERVER, originServer);
+ return params;
+ }
+
+ /**
+ * Create the connection manager used to launch request threads
+ */
+ public HttpConnectionManager newRequestConnectionManager(ExecutorService requestExecutor,
+ WorkerFactory workerFactory,
+ HttpParams params) {
+ return new DefaultHttpConnectionManager(configurationContext, requestExecutor,
+ workerFactory, params);
+ }
+
+ /**
+ * Create the executor use the manage request processing threads
+ */
+ public ExecutorService newRequestExecutor(int port) {
+ return new ThreadPoolExecutor(requestCoreThreadPoolSize, requestMaxThreadPoolSize,
+ threadKeepAliveTime, threadKeepAliveTimeUnit,
+ newRequestBlockingQueue(),
+ new DefaultThreadFactory(
+ new ThreadGroup("Connection thread group"),
+ "HttpConnection-" + port));
+ }
+
+ /**
+ * Create the queue used to hold incoming requests when requestCoreThreadPoolSize threads are busy.
+ * Default is an unbounded queue.
+ */
+ public BlockingQueue newRequestBlockingQueue() {
+ return new LinkedBlockingQueue();
+ }
+
+ /**
+ * Create the factory for request workers
+ */
+ public WorkerFactory newRequestWorkerFactory() {
+ if (requestWorkerFactory != null) {
+ return requestWorkerFactory;
+ } else {
+ return new HTTPWorkerFactory();
+ }
+ }
+
+ public HttpProcessor newHttpProcessor() {
+ BasicHttpProcessor httpProcessor = new BasicHttpProcessor();
+ httpProcessor.addInterceptor(new RequestSessionCookie());
+ httpProcessor.addInterceptor(new ResponseDate());
+ httpProcessor.addInterceptor(new ResponseServer());
+ httpProcessor.addInterceptor(new ResponseContent());
+ httpProcessor.addInterceptor(new ResponseConnControl());
+ httpProcessor.addInterceptor(new ResponseSessionCookie());
+ return httpProcessor;
+ }
+
+ public ConnectionReuseStrategy newConnStrategy() {
+ return new DefaultConnectionReuseStrategy();
+ }
+
+ public HttpResponseFactory newResponseFactory() {
+ return new DefaultHttpResponseFactory();
+ }
+
+ // *****
+ // Getters and Setters
+ // *****
+
+ /**
+ * Getter for configurationContext
+ */
+ public ConfigurationContext getConfigurationContext() {
+ return configurationContext;
+ }
+
+ /**
+ * Getter for httpConfiguration
+ */
+ public TransportInDescription getHttpConfiguration() {
+ return httpConfiguration;
+ }
+
+ /**
+ * Getter for port
+ * return the port on which to listen for http connections (default = 6060)
+ */
+ public int getPort() {
+ return port;
+ }
+
+ /**
+ * Setter for port
+ */
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ /**
+ * Getter for hostAddress
+ *
+ * @return the host address (or name) to be use in reply-to endpoint references, or null if not specified (default = null)
+ */
+ public String getHostAddress() {
+ return hostAddress;
+ }
+
+ /**
+ * Setter for hostAddress
+ */
+ public void setHostAddress(String hostAddress) {
+ this.hostAddress = hostAddress;
+ }
+
+ /**
+ * Getter for originServer
+ *
+ * @return the Server header string for outgoing messages (default "Simple-Server/1.1")
+ */
+ public String getOriginServer() {
+ return originServer;
+ }
+
+ /**
+ * Setter for originServer
+ */
+ public void setOriginServer(String originServer) {
+ this.originServer = originServer;
+ }
+
+ /**
+ * Getter for requestSocketTimeout
+ *
+ * @return the maximum time in millis to wait for data on a request socket (default 20000)
+ */
+ public int getRequestSocketTimeout() {
+ return requestSocketTimeout;
+ }
+
+ /**
+ * Setter for requestSocketTimeout
+ */
+ public void setRequestSocketTimeout(int requestSocketTimeout) {
+ this.requestSocketTimeout = requestSocketTimeout;
+ }
+
+ /**
+ * Getter for requestTcpNoDelay
+ * return false iff Nagle's algorithm should be used to conserve bandwidth by minimizing segments
+ * at the cost of latency and performance (default true, i.e. maximize performance at
+ * the cost of bandwidth)
+ */
+ public boolean getRequestTcpNoDelay() {
+ return requestTcpNoDelay;
+ }
+
+ /**
+ * Setter for requestTcpNoDelay
+ */
+ public void setRequestTcpNoDelay(boolean requestTcpNoDelay) {
+ this.requestTcpNoDelay = requestTcpNoDelay;
+ }
+
+ /**
+ * Getter for RequestCoreThreadPoolSize
+ *
+ * @return the size of the thread pool use to process requests assuming there is adequate queue space (default 25)
+ */
+ public int getRequestCoreThreadPoolSize() {
+ return requestCoreThreadPoolSize;
+ }
+
+ /**
+ * Setter for RequestCoreThreadPoolSize
+ */
+ public void setRequestCoreThreadPoolSize(int requestCoreThreadPoolSize) {
+ this.requestCoreThreadPoolSize = requestCoreThreadPoolSize;
+ }
+
+ /**
+ * Getter for requestMaxThreadPoolSize
+ *
+ * @return the maximum size of the thread pool used to process requests if the queue fills up (default 150).
+ * Since the default queue is unbounded this parameter is meaningless unless you override newRequestBlockingQueue()
+ */
+ public int getRequestMaxThreadPoolSize() {
+ return requestMaxThreadPoolSize;
+ }
+
+ /**
+ * Setter for requestMaxThreadPoolSize
+ */
+ public void setRequestMaxThreadPoolSize(int requestMaxThreadPoolSize) {
+ this.requestMaxThreadPoolSize = requestMaxThreadPoolSize;
+ }
+
+ /**
+ * Getter for threadKeepAliveTime
+ *
+ * @return how long a request processing thread in excess of the core pool size will be kept alive it if is inactive
+ * (default with threadKeepAliveTimeUnit to 180 seconds)
+ */
+ public long getThreadKeepAliveTime() {
+ return threadKeepAliveTime;
+ }
+
+ /**
+ * Setter for threadKeepAliveTime
+ */
+ public void setThreadKeepAliveTime(long threadKeepAliveTime) {
+ this.threadKeepAliveTime = threadKeepAliveTime;
+ }
+
+ /**
+ * Getter for threadKeepAliveTimeUnit
+ * return the time unit for threadKeepAliveTime (default SECONDS)
+ */
+ public TimeUnit getThreadKeepAliveTimeUnit() {
+ return threadKeepAliveTimeUnit;
+ }
+
+ /**
+ * Setter for threadKeepAliveTimeUnit
+ */
+ public void setThreadKeepAliveTimeUnit(TimeUnit threadKeepAliveTimeUnit) {
+ this.threadKeepAliveTimeUnit = threadKeepAliveTimeUnit;
+ }
+
+}
Propchange: webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/HttpFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/HttpServiceProcessor.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/HttpServiceProcessor.java?rev=710158&r1=710157&r2=710158&view=diff
==============================================================================
--- webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/HttpServiceProcessor.java (original)
+++ webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/HttpServiceProcessor.java Mon Nov 3 13:07:13 2008
@@ -1,164 +1,164 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.http.server;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.ConnectionClosedException;
-import org.apache.http.HttpException;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
-
-import java.io.IOException;
-import java.net.SocketException;
-import java.net.SocketTimeoutException;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * I/O processor intended to process requests and fill in responses.
- */
-public class HttpServiceProcessor implements IOProcessor {
-
- private static final Log LOG = LogFactory.getLog(HttpServiceProcessor.class);
-
- /** Counter used to create unique IDs. */
- private static AtomicLong counter = new AtomicLong(0L);
-
- private AtomicBoolean terminated;
-
- private final AxisHttpService httpservice;
-
- private final AxisHttpConnection conn;
-
- private final IOProcessorCallback callback;
-
- /**
- * Unique identifier used by {@linkplain #equals(Object)} and
- * {@linkplain #hashCode()}.
- * <p>
- * This field is needed to allow the equals method to work properly when this
- * HttpServiceProcessor has to be removed from the list of processors.
- *
- * @see DefaultHttpConnectionManager
- */
- private final long id;
-
-
- public HttpServiceProcessor(final AxisHttpService httpservice,
- final AxisHttpConnection conn, final IOProcessorCallback callback) {
- super();
- this.httpservice = httpservice;
- this.conn = conn;
- this.callback = callback;
- this.terminated = new AtomicBoolean(false);
-
- id = counter.incrementAndGet();
- }
-
-
- public void run() {
- LOG.debug("New connection thread");
- HttpContext context = new BasicHttpContext(null);
- try {
- while (! Thread.interrupted() && ! isDestroyed() && this.conn.isOpen()) {
- this.httpservice.handleRequest(this.conn, context);
- }
- } catch (ConnectionClosedException ex) {
- LOG.debug("Client closed connection");
- } catch (IOException ex) {
- if (ex instanceof SocketTimeoutException) {
- LOG.debug(ex.getMessage());
- } else if (ex instanceof SocketException) {
- LOG.debug(ex.getMessage());
- } else {
- LOG.warn(ex.getMessage(), ex);
- }
- } catch (HttpException ex) {
- if (LOG.isWarnEnabled()) {
- LOG.warn("HTTP protocol error: " + ex.getMessage());
- }
- } finally {
- destroy();
- if (this.callback == null) {
- throw new NullPointerException("The callback object can't be null");
- }
- this.callback.completed(this);
- }
- }
-
-
- public void close() throws IOException {
- this.conn.close();
- }
-
-
- public void destroy() {
- if (this.terminated.compareAndSet(false, true)) {
- try {
-// this.conn.shutdown();
- close();
- } catch (IOException ex) {
- LOG.debug("I/O error shutting down connection");
- }
- }
- }
-
-
- public boolean isDestroyed() {
- return this.terminated.get();
- }
-
-
- // -------------------------------------------------- Methods from Object
-
- /**
- * Returns the unique ID of this HttpServiceProcessor.
- *
- * @return The unique ID of this HttpServiceProcessor.
- */
- public int hashCode() {
- final int PRIME = 31;
- int result = 1;
- result = PRIME * result + (int) (id ^ (id >>> 32));
- return result;
- }
-
-
- /**
- * Indicates whether some other object is "equal to" this one.
- *
- * @return <code>true</code> if this HttpServiceProcessor refere to the same
- * object as obj or they have the same {@linkplain #id}, <code>false</code> otherwise.
- */
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final HttpServiceProcessor other = (HttpServiceProcessor) obj;
- if (id != other.id)
- return false;
- return true;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.http.server;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.ConnectionClosedException;
+import org.apache.http.HttpException;
+import org.apache.http.protocol.BasicHttpContext;
+import org.apache.http.protocol.HttpContext;
+
+import java.io.IOException;
+import java.net.SocketException;
+import java.net.SocketTimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * I/O processor intended to process requests and fill in responses.
+ */
+public class HttpServiceProcessor implements IOProcessor {
+
+ private static final Log LOG = LogFactory.getLog(HttpServiceProcessor.class);
+
+ /** Counter used to create unique IDs. */
+ private static AtomicLong counter = new AtomicLong(0L);
+
+ private AtomicBoolean terminated;
+
+ private final AxisHttpService httpservice;
+
+ private final AxisHttpConnection conn;
+
+ private final IOProcessorCallback callback;
+
+ /**
+ * Unique identifier used by {@linkplain #equals(Object)} and
+ * {@linkplain #hashCode()}.
+ * <p>
+ * This field is needed to allow the equals method to work properly when this
+ * HttpServiceProcessor has to be removed from the list of processors.
+ *
+ * @see DefaultHttpConnectionManager
+ */
+ private final long id;
+
+
+ public HttpServiceProcessor(final AxisHttpService httpservice,
+ final AxisHttpConnection conn, final IOProcessorCallback callback) {
+ super();
+ this.httpservice = httpservice;
+ this.conn = conn;
+ this.callback = callback;
+ this.terminated = new AtomicBoolean(false);
+
+ id = counter.incrementAndGet();
+ }
+
+
+ public void run() {
+ LOG.debug("New connection thread");
+ HttpContext context = new BasicHttpContext(null);
+ try {
+ while (! Thread.interrupted() && ! isDestroyed() && this.conn.isOpen()) {
+ this.httpservice.handleRequest(this.conn, context);
+ }
+ } catch (ConnectionClosedException ex) {
+ LOG.debug("Client closed connection");
+ } catch (IOException ex) {
+ if (ex instanceof SocketTimeoutException) {
+ LOG.debug(ex.getMessage());
+ } else if (ex instanceof SocketException) {
+ LOG.debug(ex.getMessage());
+ } else {
+ LOG.warn(ex.getMessage(), ex);
+ }
+ } catch (HttpException ex) {
+ if (LOG.isWarnEnabled()) {
+ LOG.warn("HTTP protocol error: " + ex.getMessage());
+ }
+ } finally {
+ destroy();
+ if (this.callback == null) {
+ throw new NullPointerException("The callback object can't be null");
+ }
+ this.callback.completed(this);
+ }
+ }
+
+
+ public void close() throws IOException {
+ this.conn.close();
+ }
+
+
+ public void destroy() {
+ if (this.terminated.compareAndSet(false, true)) {
+ try {
+// this.conn.shutdown();
+ close();
+ } catch (IOException ex) {
+ LOG.debug("I/O error shutting down connection");
+ }
+ }
+ }
+
+
+ public boolean isDestroyed() {
+ return this.terminated.get();
+ }
+
+
+ // -------------------------------------------------- Methods from Object
+
+ /**
+ * Returns the unique ID of this HttpServiceProcessor.
+ *
+ * @return The unique ID of this HttpServiceProcessor.
+ */
+ public int hashCode() {
+ final int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + (int) (id ^ (id >>> 32));
+ return result;
+ }
+
+
+ /**
+ * Indicates whether some other object is "equal to" this one.
+ *
+ * @return <code>true</code> if this HttpServiceProcessor refere to the same
+ * object as obj or they have the same {@linkplain #id}, <code>false</code> otherwise.
+ */
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final HttpServiceProcessor other = (HttpServiceProcessor) obj;
+ if (id != other.id)
+ return false;
+ return true;
+ }
+
+}
Propchange: webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/HttpServiceProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/HttpUtils.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/HttpUtils.java?rev=710158&r1=710157&r2=710158&view=diff
==============================================================================
--- webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/HttpUtils.java (original)
+++ webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/HttpUtils.java Mon Nov 3 13:07:13 2008
@@ -1,50 +1,50 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.http.server;
-
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.transport.TransportListener;
-import org.apache.axis2.transport.http.HTTPConstants;
-import org.apache.http.Header;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.util.Enumeration;
-
-public class HttpUtils {
-
- private HttpUtils() {
- }
-
- public static String getSoapAction(final AxisHttpRequest request) {
- if (request == null) {
- return null;
- }
- Header header = request.getFirstHeader(HTTPConstants.HEADER_SOAP_ACTION);
- if (header != null) {
- return header.getValue();
- } else {
- return null;
- }
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.http.server;
+
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.transport.TransportListener;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.http.Header;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.util.Enumeration;
+
+public class HttpUtils {
+
+ private HttpUtils() {
+ }
+
+ public static String getSoapAction(final AxisHttpRequest request) {
+ if (request == null) {
+ return null;
+ }
+ Header header = request.getFirstHeader(HTTPConstants.HEADER_SOAP_ACTION);
+ if (header != null) {
+ return header.getValue();
+ } else {
+ return null;
+ }
+ }
+
+}
Propchange: webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/HttpUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/IOProcessor.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/IOProcessor.java?rev=710158&r1=710157&r2=710158&view=diff
==============================================================================
--- webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/IOProcessor.java (original)
+++ webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/IOProcessor.java Mon Nov 3 13:07:13 2008
@@ -1,32 +1,32 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.http.server;
-
-import java.io.IOException;
-
-public interface IOProcessor extends Runnable {
-
- void close() throws IOException;
-
- boolean isDestroyed();
-
- void destroy();
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.http.server;
+
+import java.io.IOException;
+
+public interface IOProcessor extends Runnable {
+
+ void close() throws IOException;
+
+ boolean isDestroyed();
+
+ void destroy();
+
+}
Propchange: webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/IOProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/IOProcessorCallback.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/IOProcessorCallback.java?rev=710158&r1=710157&r2=710158&view=diff
==============================================================================
--- webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/IOProcessorCallback.java (original)
+++ webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/IOProcessorCallback.java Mon Nov 3 13:07:13 2008
@@ -1,26 +1,26 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.http.server;
-
-public interface IOProcessorCallback {
-
- void completed(IOProcessor processor);
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.http.server;
+
+public interface IOProcessorCallback {
+
+ void completed(IOProcessor processor);
+
+}
Propchange: webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/IOProcessorCallback.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/RequestSessionCookie.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/RequestSessionCookie.java?rev=710158&r1=710157&r2=710158&view=diff
==============================================================================
--- webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/RequestSessionCookie.java (original)
+++ webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/RequestSessionCookie.java Mon Nov 3 13:07:13 2008
@@ -1,59 +1,59 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.http.server;
-
-import org.apache.axis2.Constants;
-import org.apache.axis2.transport.http.HTTPConstants;
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.protocol.HttpContext;
-
-import java.io.IOException;
-
-public class RequestSessionCookie implements HttpRequestInterceptor {
-
- public void process(final HttpRequest request, final HttpContext context)
- throws HttpException, IOException {
- if (request == null) {
- throw new IllegalArgumentException("HTTP request may not be null");
- }
- if (context == null) {
- throw new IllegalArgumentException("HTTP context may not be null");
- }
-
- String sessionCookie = null;
- Header[] headers = request.getHeaders(HTTPConstants.HEADER_COOKIE);
- for (int i = 0; i < headers.length; i++) {
- HeaderElement[] elements = headers[i].getElements();
- for (int e = 0; e < elements.length; e++) {
- HeaderElement element = elements[e];
- if (Constants.SESSION_COOKIE.equalsIgnoreCase(element.getName()) ||
- Constants.SESSION_COOKIE_JSESSIONID.equalsIgnoreCase(element.getName())) {
- sessionCookie = element.getValue();
- }
- }
- }
- context.setAttribute(HTTPConstants.COOKIE_STRING, sessionCookie);
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.http.server;
+
+import org.apache.axis2.Constants;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.http.Header;
+import org.apache.http.HeaderElement;
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpRequestInterceptor;
+import org.apache.http.protocol.HttpContext;
+
+import java.io.IOException;
+
+public class RequestSessionCookie implements HttpRequestInterceptor {
+
+ public void process(final HttpRequest request, final HttpContext context)
+ throws HttpException, IOException {
+ if (request == null) {
+ throw new IllegalArgumentException("HTTP request may not be null");
+ }
+ if (context == null) {
+ throw new IllegalArgumentException("HTTP context may not be null");
+ }
+
+ String sessionCookie = null;
+ Header[] headers = request.getHeaders(HTTPConstants.HEADER_COOKIE);
+ for (int i = 0; i < headers.length; i++) {
+ HeaderElement[] elements = headers[i].getElements();
+ for (int e = 0; e < elements.length; e++) {
+ HeaderElement element = elements[e];
+ if (Constants.SESSION_COOKIE.equalsIgnoreCase(element.getName()) ||
+ Constants.SESSION_COOKIE_JSESSIONID.equalsIgnoreCase(element.getName())) {
+ sessionCookie = element.getValue();
+ }
+ }
+ }
+ context.setAttribute(HTTPConstants.COOKIE_STRING, sessionCookie);
+ }
+
+}
Propchange: webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/RequestSessionCookie.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/ResponseSessionCookie.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/ResponseSessionCookie.java?rev=710158&r1=710157&r2=710158&view=diff
==============================================================================
--- webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/ResponseSessionCookie.java (original)
+++ webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/ResponseSessionCookie.java Mon Nov 3 13:07:13 2008
@@ -1,82 +1,82 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.http.server;
-
-import org.apache.axis2.Constants;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.transport.http.HTTPConstants;
-import org.apache.http.HttpException;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.message.BufferedHeader;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.CharArrayBuffer;
-
-import java.io.IOException;
-
-public class ResponseSessionCookie implements HttpResponseInterceptor {
-
- public void process(final HttpResponse response, final HttpContext context)
- throws HttpException, IOException {
- if (response == null) {
- throw new IllegalArgumentException("HTTP response may not be null");
- }
- if (context == null) {
- throw new IllegalArgumentException("HTTP context may not be null");
- }
-
- String sessionCookie = null;
- MessageContext msgctx = (MessageContext) context.getAttribute(AxisParams.MESSAGE_CONTEXT);
- if (msgctx != null) {
- sessionCookie = (String) msgctx.getProperty(HTTPConstants.COOKIE_STRING);
- }
- if (sessionCookie == null) {
- sessionCookie = (String) context.getAttribute(HTTPConstants.COOKIE_STRING);
- }
- if (sessionCookie != null) {
- // Generate Netscape style cookie header
- CharArrayBuffer buffer1 = new CharArrayBuffer(sessionCookie.length() + 40);
- buffer1.append(HTTPConstants.HEADER_SET_COOKIE);
- buffer1.append(": ");
- buffer1.append(Constants.SESSION_COOKIE_JSESSIONID);
- buffer1.append("=");
- buffer1.append(sessionCookie);
- response.addHeader(new BufferedHeader(buffer1));
-
- // Generate RFC2965 cookie2 header
- CharArrayBuffer buffer2 = new CharArrayBuffer(sessionCookie.length() + 50);
- buffer2.append(HTTPConstants.HEADER_SET_COOKIE2);
- buffer2.append(": ");
- buffer2.append(Constants.SESSION_COOKIE_JSESSIONID);
- buffer2.append("=");
- buffer2.append(sessionCookie);
- buffer2.append("; ");
- int port = response.getParams().getIntParameter(AxisParams.LISTENER_PORT, 0);
- if (port > 0) {
- buffer2.append("Port=\"");
- buffer2.append(Integer.toString(port));
- buffer2.append("\"; ");
- }
- buffer2.append("Version=1");
- response.addHeader(new BufferedHeader(buffer2));
- }
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.http.server;
+
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.http.HttpException;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpResponseInterceptor;
+import org.apache.http.message.BufferedHeader;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.CharArrayBuffer;
+
+import java.io.IOException;
+
+public class ResponseSessionCookie implements HttpResponseInterceptor {
+
+ public void process(final HttpResponse response, final HttpContext context)
+ throws HttpException, IOException {
+ if (response == null) {
+ throw new IllegalArgumentException("HTTP response may not be null");
+ }
+ if (context == null) {
+ throw new IllegalArgumentException("HTTP context may not be null");
+ }
+
+ String sessionCookie = null;
+ MessageContext msgctx = (MessageContext) context.getAttribute(AxisParams.MESSAGE_CONTEXT);
+ if (msgctx != null) {
+ sessionCookie = (String) msgctx.getProperty(HTTPConstants.COOKIE_STRING);
+ }
+ if (sessionCookie == null) {
+ sessionCookie = (String) context.getAttribute(HTTPConstants.COOKIE_STRING);
+ }
+ if (sessionCookie != null) {
+ // Generate Netscape style cookie header
+ CharArrayBuffer buffer1 = new CharArrayBuffer(sessionCookie.length() + 40);
+ buffer1.append(HTTPConstants.HEADER_SET_COOKIE);
+ buffer1.append(": ");
+ buffer1.append(Constants.SESSION_COOKIE_JSESSIONID);
+ buffer1.append("=");
+ buffer1.append(sessionCookie);
+ response.addHeader(new BufferedHeader(buffer1));
+
+ // Generate RFC2965 cookie2 header
+ CharArrayBuffer buffer2 = new CharArrayBuffer(sessionCookie.length() + 50);
+ buffer2.append(HTTPConstants.HEADER_SET_COOKIE2);
+ buffer2.append(": ");
+ buffer2.append(Constants.SESSION_COOKIE_JSESSIONID);
+ buffer2.append("=");
+ buffer2.append(sessionCookie);
+ buffer2.append("; ");
+ int port = response.getParams().getIntParameter(AxisParams.LISTENER_PORT, 0);
+ if (port > 0) {
+ buffer2.append("Port=\"");
+ buffer2.append(Integer.toString(port));
+ buffer2.append("\"; ");
+ }
+ buffer2.append("Version=1");
+ response.addHeader(new BufferedHeader(buffer2));
+ }
+ }
+
+}
Propchange: webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/ResponseSessionCookie.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/SessionManager.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/SessionManager.java?rev=710158&r1=710157&r2=710158&view=diff
==============================================================================
--- webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/SessionManager.java (original)
+++ webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/SessionManager.java Mon Nov 3 13:07:13 2008
@@ -1,84 +1,84 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.http.server;
-
-import org.apache.axiom.om.util.UUIDGenerator;
-import org.apache.axis2.context.ServiceContext;
-import org.apache.axis2.context.ServiceGroupContext;
-import org.apache.axis2.context.SessionContext;
-import org.apache.axis2.engine.DependencyManager;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-public class SessionManager {
-
- private final Map sessionmap;
-
- public SessionManager() {
- super();
- this.sessionmap = new HashMap();
- }
-
- public synchronized SessionContext getSessionContext(String sessionKey) {
- SessionContext sessionContext = null;
- if (sessionKey != null && sessionKey.length() != 0) {
- sessionContext = (SessionContext) this.sessionmap.get(sessionKey);
- }
- if (sessionContext == null) {
- sessionKey = UUIDGenerator.getUUID();
- sessionContext = new SessionContext(null);
- sessionContext.setCookieID(sessionKey);
- this.sessionmap.put(sessionKey, sessionContext);
- }
- sessionContext.touch();
- cleanupServiceGroupContexts();
- return sessionContext;
- }
-
- private void cleanupServiceGroupContexts() {
- long currentTime = System.currentTimeMillis();
- for (Iterator it = this.sessionmap.keySet().iterator(); it.hasNext();) {
- String cookieID = (String) it.next();
- SessionContext sessionContext = (SessionContext) this.sessionmap.get(cookieID);
- if ((currentTime - sessionContext.getLastTouchedTime()) >
- sessionContext.sessionContextTimeoutInterval) {
- it.remove();
- Iterator serviceGroupContext = sessionContext.getServiceGroupContext();
- if (serviceGroupContext != null) {
- while (serviceGroupContext.hasNext()) {
- ServiceGroupContext groupContext =
- (ServiceGroupContext) serviceGroupContext.next();
- cleanupServiceContexts(groupContext);
- }
- }
- }
- }
- }
-
- private void cleanupServiceContexts(final ServiceGroupContext serviceGroupContext) {
- for (Iterator it = serviceGroupContext.getServiceContexts(); it.hasNext();) {
- ServiceContext serviceContext = (ServiceContext) it.next();
- DependencyManager.destroyServiceObject(serviceContext);
- }
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.http.server;
+
+import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.axis2.context.SessionContext;
+import org.apache.axis2.engine.DependencyManager;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+public class SessionManager {
+
+ private final Map sessionmap;
+
+ public SessionManager() {
+ super();
+ this.sessionmap = new HashMap();
+ }
+
+ public synchronized SessionContext getSessionContext(String sessionKey) {
+ SessionContext sessionContext = null;
+ if (sessionKey != null && sessionKey.length() != 0) {
+ sessionContext = (SessionContext) this.sessionmap.get(sessionKey);
+ }
+ if (sessionContext == null) {
+ sessionKey = UUIDGenerator.getUUID();
+ sessionContext = new SessionContext(null);
+ sessionContext.setCookieID(sessionKey);
+ this.sessionmap.put(sessionKey, sessionContext);
+ }
+ sessionContext.touch();
+ cleanupServiceGroupContexts();
+ return sessionContext;
+ }
+
+ private void cleanupServiceGroupContexts() {
+ long currentTime = System.currentTimeMillis();
+ for (Iterator it = this.sessionmap.keySet().iterator(); it.hasNext();) {
+ String cookieID = (String) it.next();
+ SessionContext sessionContext = (SessionContext) this.sessionmap.get(cookieID);
+ if ((currentTime - sessionContext.getLastTouchedTime()) >
+ sessionContext.sessionContextTimeoutInterval) {
+ it.remove();
+ Iterator serviceGroupContext = sessionContext.getServiceGroupContext();
+ if (serviceGroupContext != null) {
+ while (serviceGroupContext.hasNext()) {
+ ServiceGroupContext groupContext =
+ (ServiceGroupContext) serviceGroupContext.next();
+ cleanupServiceContexts(groupContext);
+ }
+ }
+ }
+ }
+ }
+
+ private void cleanupServiceContexts(final ServiceGroupContext serviceGroupContext) {
+ for (Iterator it = serviceGroupContext.getServiceContexts(); it.hasNext();) {
+ ServiceContext serviceContext = (ServiceContext) it.next();
+ DependencyManager.destroyServiceObject(serviceContext);
+ }
+ }
+
+}
Propchange: webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/SessionManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/SimpleHttpServer.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/SimpleHttpServer.java?rev=710158&r1=710157&r2=710158&view=diff
==============================================================================
--- webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/SimpleHttpServer.java (original)
+++ webservices/commons/trunk/modules/transport/modules/http/src/org/apache/axis2/transport/http/server/SimpleHttpServer.java Mon Nov 3 13:07:13 2008
@@ -1,110 +1,110 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.http.server;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.params.HttpParams;
-
-import java.io.IOException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.TimeUnit;
-
-/**
- * A simple, but configurable and extensible HTTP server.
- */
-public class SimpleHttpServer {
-
- private static Log LOG = LogFactory.getLog(SimpleHttpServer.class);
-
- private static final int SHUTDOWN_GRACE_PERIOD = 3000; // ms
-
- private HttpFactory httpFactory;
- private final int port;
- private final HttpParams params;
- private final WorkerFactory workerFactory;
-
- private IOProcessor listener = null;
- private ExecutorService listenerExecutor = null;
- private HttpConnectionManager connmanager = null;
- private ExecutorService requestExecutor = null;
-
- public SimpleHttpServer(ConfigurationContext configurationContext, WorkerFactory workerFactory,
- int port) throws IOException {
- this(new HttpFactory(configurationContext, port, workerFactory), port);
- }
-
- public SimpleHttpServer(HttpFactory httpFactory, int port) throws IOException {
- this.httpFactory = httpFactory;
- this.port = port;
- this.workerFactory = httpFactory.newRequestWorkerFactory();
- this.params = httpFactory.newRequestConnectionParams();
- this.params.setIntParameter(AxisParams.LISTENER_PORT, port);
- }
-
- public void init() throws IOException {
- requestExecutor = httpFactory.newRequestExecutor(port);
- connmanager =
- httpFactory.newRequestConnectionManager(requestExecutor, workerFactory, params);
- listenerExecutor = httpFactory.newListenerExecutor(port);
- listener = httpFactory.newRequestConnectionListener(port, connmanager, params);
- }
-
- public void destroy() throws IOException, InterruptedException {
- // Attempt to terminate the listener nicely
- LOG.info("Shut down connection listener");
- this.listenerExecutor.shutdownNow();
- this.listener.destroy();
- this.listenerExecutor.awaitTermination(SHUTDOWN_GRACE_PERIOD, TimeUnit.MILLISECONDS);
- if (!this.listenerExecutor.isTerminated()) {
- // Terminate the listener forcibly
- LOG.info("Force shut down connection listener");
- this.listener.destroy();
- // Leave it up to the garbage collector to clean up the mess
- this.listener = null;
- }
- // Attempt to terminate the active processors nicely
- LOG.info("Shut down HTTP processors");
- this.requestExecutor.shutdownNow();
- this.requestExecutor.awaitTermination(SHUTDOWN_GRACE_PERIOD, TimeUnit.MILLISECONDS);
- if (!this.requestExecutor.isTerminated()) {
- // Terminate the active processors forcibly
- LOG.info("Force shut down HTTP processors");
- this.connmanager.shutdown();
- // Leave it up to the garbage collector to clean up the mess
- this.connmanager = null;
- }
- LOG.info("HTTP protocol handler shut down");
- }
-
- public void start() {
- this.listenerExecutor.execute(this.listener);
- }
-
- public boolean isRunning() {
- return this.listenerExecutor != null && !this.listenerExecutor.isShutdown();
- }
-
- public int getPort() {
- return this.port;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.transport.http.server;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.params.HttpParams;
+
+import java.io.IOException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * A simple, but configurable and extensible HTTP server.
+ */
+public class SimpleHttpServer {
+
+ private static Log LOG = LogFactory.getLog(SimpleHttpServer.class);
+
+ private static final int SHUTDOWN_GRACE_PERIOD = 3000; // ms
+
+ private HttpFactory httpFactory;
+ private final int port;
+ private final HttpParams params;
+ private final WorkerFactory workerFactory;
+
+ private IOProcessor listener = null;
+ private ExecutorService listenerExecutor = null;
+ private HttpConnectionManager connmanager = null;
+ private ExecutorService requestExecutor = null;
+
+ public SimpleHttpServer(ConfigurationContext configurationContext, WorkerFactory workerFactory,
+ int port) throws IOException {
+ this(new HttpFactory(configurationContext, port, workerFactory), port);
+ }
+
+ public SimpleHttpServer(HttpFactory httpFactory, int port) throws IOException {
+ this.httpFactory = httpFactory;
+ this.port = port;
+ this.workerFactory = httpFactory.newRequestWorkerFactory();
+ this.params = httpFactory.newRequestConnectionParams();
+ this.params.setIntParameter(AxisParams.LISTENER_PORT, port);
+ }
+
+ public void init() throws IOException {
+ requestExecutor = httpFactory.newRequestExecutor(port);
+ connmanager =
+ httpFactory.newRequestConnectionManager(requestExecutor, workerFactory, params);
+ listenerExecutor = httpFactory.newListenerExecutor(port);
+ listener = httpFactory.newRequestConnectionListener(port, connmanager, params);
+ }
+
+ public void destroy() throws IOException, InterruptedException {
+ // Attempt to terminate the listener nicely
+ LOG.info("Shut down connection listener");
+ this.listenerExecutor.shutdownNow();
+ this.listener.destroy();
+ this.listenerExecutor.awaitTermination(SHUTDOWN_GRACE_PERIOD, TimeUnit.MILLISECONDS);
+ if (!this.listenerExecutor.isTerminated()) {
+ // Terminate the listener forcibly
+ LOG.info("Force shut down connection listener");
+ this.listener.destroy();
+ // Leave it up to the garbage collector to clean up the mess
+ this.listener = null;
+ }
+ // Attempt to terminate the active processors nicely
+ LOG.info("Shut down HTTP processors");
+ this.requestExecutor.shutdownNow();
+ this.requestExecutor.awaitTermination(SHUTDOWN_GRACE_PERIOD, TimeUnit.MILLISECONDS);
+ if (!this.requestExecutor.isTerminated()) {
+ // Terminate the active processors forcibly
+ LOG.info("Force shut down HTTP processors");
+ this.connmanager.shutdown();
+ // Leave it up to the garbage collector to clean up the mess
+ this.connmanager = null;
+ }
+ LOG.info("HTTP protocol handler shut down");
+ }
+
+ public void start() {
+ this.listenerExecutor.execute(this.listener);
+ }
+
+ public boolean isRunning() {
+ return this.listenerExecutor != null && !this.listenerExecutor.isShutdown();
+ }
+
+ public int getPort() {
+ return this.port;
+ }
+
+}