You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by as...@apache.org on 2007/06/21 14:21:48 UTC
svn commit: r549457 [3/3] - in /webservices/axis2/trunk/java/modules:
kernel/ kernel/src/org/apache/axis2/transport/nhttp/
kernel/src/org/apache/axis2/transport/nhttp/util/ parent/
Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/ServerHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/ServerHandler.java?view=auto&rev=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/ServerHandler.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/ServerHandler.java Thu Jun 21 05:21:46 2007
@@ -0,0 +1,318 @@
+/*
+ * 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.nhttp;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.transport.nhttp.util.PipeImpl;
+import org.apache.axis2.transport.nhttp.util.WorkerPool;
+import org.apache.axis2.transport.nhttp.util.WorkerPoolFactory;
+import org.apache.http.*;
+import org.apache.http.entity.BasicHttpEntity;
+import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.impl.DefaultHttpResponseFactory;
+import org.apache.http.nio.ContentDecoder;
+import org.apache.http.nio.ContentEncoder;
+import org.apache.http.nio.NHttpServerConnection;
+import org.apache.http.nio.NHttpServiceHandler;
+import org.apache.http.params.HttpParams;
+import org.apache.http.protocol.*;
+import org.apache.http.util.EncodingUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.Channels;
+import java.nio.channels.WritableByteChannel;
+import java.nio.channels.ReadableByteChannel;
+
+/**
+ * The server connection handler. An instance of this class is used by each IOReactor, to
+ * process every connection. Hence this class should not store any data related to a single
+ * connection - as this is being shared.
+ */
+public class ServerHandler implements NHttpServiceHandler {
+
+ private static final Log log = LogFactory.getLog(ServerHandler.class);
+
+ /** the HTTP protocol parameters to adhere to */
+ private final HttpParams params;
+ /** the factory to create HTTP responses */
+ private final HttpResponseFactory responseFactory;
+ /** the HTTP response processor */
+ private final HttpProcessor httpProcessor;
+ /** the strategy to re-use connections */
+ private final ConnectionReuseStrategy connStrategy;
+
+ /** the Axis2 configuration context */
+ ConfigurationContext cfgCtx = null;
+ /** the nhttp configuration */
+ private NHttpConfiguration cfg = null;
+ /** is this https? */
+ private boolean isHttps = false;
+
+ /** the thread pool to process requests */
+ private WorkerPool workerPool = null;
+
+ private static final String REQUEST_SINK_CHANNEL = "request-sink-channel";
+ private static final String RESPONSE_SOURCE_CHANNEL = "response-source-channel";
+ private static final String REQUEST_BUFFER = "request-buffer";
+ private static final String RESPONSE_BUFFER = "response-buffer";
+
+ public ServerHandler(final ConfigurationContext cfgCtx, final HttpParams params,
+ final boolean isHttps) {
+ super();
+ this.cfgCtx = cfgCtx;
+ this.params = params;
+ this.isHttps = isHttps;
+ this.responseFactory = new DefaultHttpResponseFactory();
+ this.httpProcessor = getHttpProcessor();
+ this.connStrategy = new DefaultConnectionReuseStrategy();
+
+ this.cfg = NHttpConfiguration.getInstance();
+ this.workerPool = WorkerPoolFactory.getWorkerPool(
+ cfg.getServerCoreThreads(),
+ cfg.getServerMaxThreads(),
+ cfg.getServerKeepalive(),
+ cfg.getServerQueueLen(),
+ "Server Worker thread group", "HttpServerWorker");
+ }
+
+ /**
+ * Process a new incoming request
+ * @param conn the connection
+ */
+ public void requestReceived(final NHttpServerConnection conn) {
+
+ HttpContext context = conn.getContext();
+ HttpRequest request = conn.getHttpRequest();
+ context.setAttribute(HttpContext.HTTP_REQUEST, request);
+
+ // allocate temporary buffers to process this request
+ context.setAttribute(REQUEST_BUFFER, ByteBuffer.allocate(cfg.getBufferZise()));
+ context.setAttribute(RESPONSE_BUFFER, ByteBuffer.allocate(cfg.getBufferZise()));
+
+ try {
+ PipeImpl requestPipe = new PipeImpl(); // the pipe used to process the request
+ PipeImpl responsePipe = new PipeImpl(); // the pipe used to process the response
+ context.setAttribute(REQUEST_SINK_CHANNEL, requestPipe.sink());
+ context.setAttribute(RESPONSE_SOURCE_CHANNEL, responsePipe.source());
+
+ // create the default response to this request
+ HttpVersion httpVersion = request.getRequestLine().getHttpVersion();
+ HttpResponse response = responseFactory.newHttpResponse(
+ httpVersion, HttpStatus.SC_OK, context);
+ response.setParams(this.params);
+
+ // create a basic HttpEntity using the source channel of the response pipe
+ BasicHttpEntity entity = new BasicHttpEntity();
+ entity.setContent(Channels.newInputStream(responsePipe.source()));
+ if (httpVersion.greaterEquals(HttpVersion.HTTP_1_1)) {
+ entity.setChunked(true);
+ }
+ response.setEntity(entity);
+
+ // hand off processing of the request to a thread off the pool
+ workerPool.execute(
+ new ServerWorker(cfgCtx, conn, isHttps, this,
+ request, Channels.newInputStream(requestPipe.source()),
+ response, Channels.newOutputStream(responsePipe.sink())));
+
+ } catch (IOException e) {
+ handleException("Error processing request received for : " +
+ request.getRequestLine().getUri(), e, conn);
+ } catch (Exception e) {
+ handleException("Error processing request received for : " +
+ request.getRequestLine().getUri(), e, conn);
+ }
+ }
+
+ /**
+ * Process ready input by writing it into the Pipe
+ * @param conn the connection being processed
+ * @param decoder the content decoder in use
+ */
+ public void inputReady(final NHttpServerConnection conn, final ContentDecoder decoder) {
+
+ HttpContext context = conn.getContext();
+ WritableByteChannel sink = (WritableByteChannel) context.getAttribute(REQUEST_SINK_CHANNEL);
+ ByteBuffer inbuf = (ByteBuffer) context.getAttribute(REQUEST_BUFFER);
+
+ try {
+ while (decoder.read(inbuf) > 0) {
+ inbuf.flip();
+ sink.write(inbuf);
+ inbuf.compact();
+ }
+
+ if (decoder.isCompleted()) {
+ sink.close();
+ }
+
+ } catch (IOException e) {
+ handleException("I/O Error : " + e.getMessage(), e, conn);
+ }
+ }
+
+ public void responseReady(NHttpServerConnection conn) {
+ // New API method - should not require
+ }
+
+ /**
+ * Process ready output by writing into the channel
+ * @param conn the connection being processed
+ * @param encoder the content encoder in use
+ */
+ public void outputReady(final NHttpServerConnection conn, final ContentEncoder encoder) {
+
+ HttpContext context = conn.getContext();
+ HttpResponse response = conn.getHttpResponse();
+ ReadableByteChannel source = (ReadableByteChannel) context.getAttribute(RESPONSE_SOURCE_CHANNEL);
+ ByteBuffer outbuf = (ByteBuffer) context.getAttribute(RESPONSE_BUFFER);
+
+ try {
+ int bytesRead = source.read(outbuf);
+ if (bytesRead == -1) {
+ encoder.complete();
+ } else {
+ outbuf.flip();
+ encoder.write(outbuf);
+ outbuf.compact();
+ }
+
+ if (encoder.isCompleted()) {
+ source.close();
+ if (!connStrategy.keepAlive(response, context)) {
+ conn.close();
+ }
+ }
+
+ } catch (IOException e) {
+ handleException("I/O Error : " + e.getMessage(), e, conn);
+ }
+ }
+
+ /**
+ * Commit the response to the connection. Processes the response through the configured
+ * HttpProcessor and submits it to be sent out
+ * @param conn the connection being processed
+ * @param response the response to commit over the connection
+ */
+ public void commitResponse(final NHttpServerConnection conn, final HttpResponse response) {
+ try {
+ httpProcessor.process(response, conn.getContext());
+ conn.submitResponse(response);
+ } catch (HttpException e) {
+ handleException("Unexpected HTTP protocol error : " + e.getMessage(), e, conn);
+ } catch (IOException e) {
+ handleException("IO error submiting response : " + e.getMessage(), e, conn);
+ }
+ }
+
+
+ /**
+ * Handle connection timeouts by shutting down the connections
+ * @param conn the connection being processed
+ */
+ public void timeout(final NHttpServerConnection conn) {
+ HttpRequest req = (HttpRequest) conn.getContext().getAttribute(HttpContext.HTTP_REQUEST);
+ if (req != null) {
+ log.debug("Connection Timeout for request to : " + req.getRequestLine().getUri() +
+ " Probably the keepalive connection was closed");
+ } else {
+ log.warn("Connection Timeout");
+ }
+ shutdownConnection(conn);
+ }
+
+ public void connected(final NHttpServerConnection conn) {
+ log.trace("New incoming connection");
+ }
+
+ public void closed(final NHttpServerConnection conn) {
+ log.trace("Connection closed");
+ }
+
+ /**
+ * Handle HTTP Protocol violations with an error response
+ * @param conn the connection being processed
+ * @param e the exception encountered
+ */
+ public void exception(final NHttpServerConnection conn, final HttpException e) {
+ HttpContext context = conn.getContext();
+ HttpRequest request = conn.getHttpRequest();
+ HttpVersion ver = request.getRequestLine().getHttpVersion();
+ HttpResponse response = responseFactory.newHttpResponse(
+ ver, HttpStatus.SC_BAD_REQUEST, context);
+ byte[] msg = EncodingUtils.getAsciiBytes("Malformed HTTP request: " + e.getMessage());
+ ByteArrayEntity entity = new ByteArrayEntity(msg);
+ entity.setContentType("text/plain; charset=US-ASCII");
+ response.setEntity(entity);
+ commitResponse(conn, response);
+ }
+
+ /**
+ * Handle IO errors while reading or writing to underlying channels
+ * @param conn the connection being processed
+ * @param e the exception encountered
+ */
+ public void exception(NHttpServerConnection conn, IOException e) {
+ if (e instanceof ConnectionClosedException ||
+ e.getMessage().indexOf("Connection reset by peer") > 0 ||
+ e.getMessage().indexOf("forcibly closed") > 0) {
+ log.debug("I/O error (Probably the keepalive connection was closed):" + e.getMessage());
+ } else {
+ log.error("I/O error: " + e.getMessage());
+ }
+ shutdownConnection(conn);
+ }
+
+ // ----------- utility methods -----------
+
+ private void handleException(String msg, Exception e, NHttpServerConnection conn) {
+ log.error(msg, e);
+ if (conn != null) {
+ shutdownConnection(conn);
+ }
+ }
+
+ /**
+ * Shutdown the connection ignoring any IO errors during the process
+ * @param conn the connection to be shutdown
+ */
+ private void shutdownConnection(final HttpConnection conn) {
+ try {
+ conn.shutdown();
+ } catch (IOException ignore) {}
+ }
+
+ /**
+ * Return the HttpProcessor for responses
+ * @return the HttpProcessor that processes HttpResponses of this server
+ */
+ private HttpProcessor getHttpProcessor() {
+ BasicHttpProcessor httpProcessor = new BasicHttpProcessor();
+ httpProcessor.addInterceptor(new ResponseDate());
+ httpProcessor.addInterceptor(new ResponseServer());
+ httpProcessor.addInterceptor(new ResponseContent());
+ httpProcessor.addInterceptor(new ResponseConnControl());
+ return httpProcessor;
+ }
+}
Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/ServerWorker.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/ServerWorker.java?view=auto&rev=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/ServerWorker.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/ServerWorker.java Thu Jun 21 05:21:46 2007
@@ -0,0 +1,503 @@
+/*
+ * 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.nhttp;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.transport.http.HTTPTransportUtils;
+import org.apache.axis2.transport.http.HTTPTransportReceiver;
+import org.apache.axis2.transport.RequestResponseTransport;
+import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.*;
+import org.apache.http.nio.NHttpServerConnection;
+import org.apache.http.protocol.HTTP;
+import org.apache.ws.commons.schema.XmlSchema;
+
+import javax.xml.namespace.QName;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.util.*;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.net.InetAddress;
+
+/**
+ * Processes an incoming request through Axis2. An instance of this class would be created to
+ * process each unique request
+ */
+public class ServerWorker implements Runnable {
+
+ private static final Log log = LogFactory.getLog(ServerWorker.class);
+
+ /** the incoming message to be processed */
+ private MessageContext msgContext = null;
+ /** the Axis2 configuration context */
+ private ConfigurationContext cfgCtx = null;
+ /** the message handler to be used */
+ private ServerHandler serverHandler = null;
+ /** the underlying http connection */
+ private NHttpServerConnection conn = null;
+ /** is this https? */
+ private boolean isHttps = false;
+ /** the http request */
+ private HttpRequest request = null;
+ /** the http response message (which the this would be creating) */
+ private HttpResponse response = null;
+ /** the input stream to read the incoming message body */
+ private InputStream is = null;
+ /** the output stream to write the response message body */
+ private OutputStream os = null;
+ private static final String SOAPACTION = "SOAPAction";
+ private static final String LOCATION = "Location";
+ private static final String CONTENT_TYPE = "Content-Type";
+ private static final String TEXT_HTML = "text/html";
+ private static final String TEXT_XML = "text/xml";
+
+ /**
+ * Create a new server side worker to process an incoming message and optionally begin creating
+ * its output. This however does not force the processor to write a response back as the
+ * traditional servlet service() method, but creates the background required to write the
+ * response, if one would be created.
+ * @param cfgCtx the Axis2 configuration context
+ * @param conn the underlying http connection
+ * @param serverHandler the handler of the server side messages
+ * @param request the http request received (might still be in the process of being streamed)
+ * @param is the stream input stream to read the request body
+ * @param response the response to be populated if applicable
+ * @param os the output stream to write the response body if one is applicable
+ */
+ public ServerWorker(final ConfigurationContext cfgCtx, final NHttpServerConnection conn,
+ final boolean isHttps,
+ final ServerHandler serverHandler,
+ final HttpRequest request, final InputStream is,
+ final HttpResponse response, final OutputStream os) {
+
+ this.cfgCtx = cfgCtx;
+ this.conn = conn;
+ this.isHttps = isHttps;
+ this.serverHandler = serverHandler;
+ this.request = request;
+ this.response = response;
+ this.is = is;
+ this.os = os;
+ this.msgContext = createMessageContext(request);
+ }
+
+ /**
+ * Create an Axis2 message context for the given http request. The request may be in the
+ * process of being streamed
+ * @param request the http request to be used to create the corresponding Axis2 message context
+ * @return the Axis2 message context created
+ */
+ private MessageContext createMessageContext(HttpRequest request) {
+
+ MessageContext msgContext = new MessageContext();
+ msgContext.setProperty(MessageContext.TRANSPORT_NON_BLOCKING, Boolean.TRUE);
+ msgContext.setConfigurationContext(cfgCtx);
+ if (isHttps) {
+ msgContext.setTransportOut(cfgCtx.getAxisConfiguration()
+ .getTransportOut("https"));
+ msgContext.setTransportIn(cfgCtx.getAxisConfiguration()
+ .getTransportIn("https"));
+ msgContext.setIncomingTransportName("https");
+ } else {
+ msgContext.setTransportOut(cfgCtx.getAxisConfiguration()
+ .getTransportOut(Constants.TRANSPORT_HTTP));
+ msgContext.setTransportIn(cfgCtx.getAxisConfiguration()
+ .getTransportIn(Constants.TRANSPORT_HTTP));
+ msgContext.setIncomingTransportName(Constants.TRANSPORT_HTTP);
+ }
+ msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, this);
+ msgContext.setServiceGroupContextId(UUIDGenerator.getUUID());
+ msgContext.setServerSide(true);
+ msgContext.setProperty(
+ Constants.Configuration.TRANSPORT_IN_URL, request.getRequestLine().getUri());
+
+ Map headers = new HashMap();
+ Header[] headerArr = request.getAllHeaders();
+ for (int i = 0; i < headerArr.length; i++) {
+ headers.put(headerArr[i].getName(), headerArr[i].getValue());
+ }
+ msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, headers);
+ // find the remote party IP address and set it to the message context
+ if (conn instanceof HttpInetConnection) {
+ HttpInetConnection inetConn = (HttpInetConnection) conn;
+ InetAddress remoteAddr = inetConn.getRemoteAddress();
+ if (remoteAddr != null) {
+ msgContext.setProperty(MessageContext.REMOTE_ADDR, remoteAddr.getHostAddress());
+ }
+ }
+
+ // this is required to support Sandesha 2
+ msgContext.setProperty(RequestResponseTransport.TRANSPORT_CONTROL,
+ new HttpCoreRequestResponseTransport(msgContext));
+ return msgContext;
+ }
+
+ /**
+ * Process the incoming request
+ */
+ public void run() {
+
+ String method = request.getRequestLine().getMethod().toUpperCase();
+ if ("GET".equals(method)) {
+ processGet();
+ } else if ("POST".equals(method)) {
+ processPost();
+ } else {
+ handleException("Unsupported method : " + method, null);
+ }
+
+ if (msgContext != null && msgContext.getOperationContext() != null &&
+ !Constants.VALUE_TRUE.equals(
+ msgContext.getOperationContext().getProperty(Constants.RESPONSE_WRITTEN)) &&
+ !"SKIP".equals(
+ msgContext.getOperationContext().getProperty(Constants.RESPONSE_WRITTEN))) {
+
+ response.setStatusCode(HttpStatus.SC_ACCEPTED);
+ serverHandler.commitResponse(conn, response);
+
+ // make sure that the output stream is flushed and closed properly
+ try {
+ is.close();
+ } catch (IOException ignore) {}
+
+ // make sure that the output stream is flushed and closed properly
+ try {
+ os.flush();
+ os.close();
+ } catch (IOException ignore) {}
+ }
+ }
+
+ /**
+ *
+ */
+ private void processPost() {
+
+ try {
+ Header contentType = request.getFirstHeader(HTTP.CONTENT_TYPE);
+ Header soapAction = request.getFirstHeader(SOAPACTION);
+
+ HTTPTransportUtils.processHTTPPostRequest(
+ msgContext, is,
+ os,
+ (contentType != null ? contentType.getValue() : null),
+ (soapAction != null ? soapAction.getValue() : null),
+ request.getRequestLine().getUri());
+ } catch (AxisFault e) {
+ handleException("Error processing POST request ", e);
+ }
+ }
+
+ /**
+ *
+ */
+ private void processGet() {
+
+ String uri = request.getRequestLine().getUri();
+
+ String contextPath = cfgCtx.getContextRoot();
+ if (!contextPath.startsWith("/")) {
+ contextPath = "/" + contextPath;
+ }
+ if (!contextPath.endsWith("/")) {
+ contextPath = contextPath + "/";
+ }
+
+ String servicePath = cfgCtx.getServiceContextPath();
+ if (!servicePath.startsWith("/")) {
+ servicePath = "/" + servicePath;
+ }
+
+ String serviceName = null;
+ if (uri.startsWith(servicePath)) {
+ serviceName = uri.substring(servicePath.length());
+ if (serviceName.startsWith("/")) {
+ serviceName = serviceName.substring(1);
+ }
+ if (serviceName.indexOf("?") != -1) {
+ serviceName = serviceName.substring(0, serviceName.indexOf("?"));
+ }
+ }
+
+ Map parameters = new HashMap();
+ int pos = uri.indexOf("?");
+ if (pos != -1) {
+ StringTokenizer st = new StringTokenizer(uri.substring(pos+1), "&");
+ while (st.hasMoreTokens()) {
+ String param = st.nextToken();
+ pos = param.indexOf("=");
+ if (pos != -1) {
+ parameters.put(param.substring(0, pos), param.substring(pos+1));
+ } else {
+ parameters.put(param, null);
+ }
+ }
+ }
+
+ if (uri.equals("/favicon.ico")) {
+ response.setStatusCode(HttpStatus.SC_MOVED_PERMANENTLY);
+ response.addHeader(LOCATION, "http://ws.apache.org/favicon.ico");
+ serverHandler.commitResponse(conn, response);
+
+ } else if (!uri.startsWith(servicePath)) {
+ response.setStatusCode(HttpStatus.SC_MOVED_PERMANENTLY);
+ response.addHeader(LOCATION, servicePath + "/");
+ serverHandler.commitResponse(conn, response);
+
+ } else if (serviceName != null && parameters.containsKey("wsdl")) {
+ AxisService service = (AxisService) cfgCtx.getAxisConfiguration().
+ getServices().get(serviceName);
+ if (service != null) {
+ try {
+ response.addHeader(CONTENT_TYPE, TEXT_XML);
+ serverHandler.commitResponse(conn, response);
+ service.printWSDL(os, getIpAddress());
+
+ } catch (AxisFault e) {
+ handleException("Axis2 fault writing ?wsdl output", e);
+ return;
+ } catch (SocketException e) {
+ handleException("Error getting ip address for ?wsdl output", e);
+ return;
+ }
+ }
+
+ } else if (serviceName != null && parameters.containsKey("wsdl2")) {
+ AxisService service = (AxisService) cfgCtx.getAxisConfiguration().
+ getServices().get(serviceName);
+ if (service != null) {
+ try {
+ response.addHeader(CONTENT_TYPE, TEXT_XML);
+ serverHandler.commitResponse(conn, response);
+ service.printWSDL2(os);
+
+ } catch (AxisFault e) {
+ handleException("Axis2 fault writing ?wsdl2 output", e);
+ return;
+ }
+ }
+
+ } else if (serviceName != null && parameters.containsKey("xsd")) {
+ if (parameters.get("xsd") == null || "".equals(parameters.get("xsd"))) {
+ AxisService service = (AxisService) cfgCtx.getAxisConfiguration()
+ .getServices().get(serviceName);
+ if (service != null) {
+ try {
+ response.addHeader(CONTENT_TYPE, TEXT_XML);
+ serverHandler.commitResponse(conn, response);
+ service.printSchema(os);
+
+ } catch (AxisFault axisFault) {
+ handleException("Error writing ?xsd output to client", axisFault);
+ return;
+ } catch (IOException e) {
+ handleException("Error writing ?xsd output to client", e);
+ return;
+ }
+ }
+
+ } else {
+ //cater for named xsds - check for the xsd name
+ String schemaName = (String) parameters.get("xsd");
+ AxisService service = (AxisService) cfgCtx.getAxisConfiguration()
+ .getServices().get(serviceName);
+
+ if (service != null) {
+ //run the population logic just to be sure
+ service.populateSchemaMappings();
+ //write out the correct schema
+ Map schemaTable = service.getSchemaMappingTable();
+ final XmlSchema schema = (XmlSchema)schemaTable.get(schemaName);
+ //schema found - write it to the stream
+ if (schema != null) {
+ response.addHeader(CONTENT_TYPE, TEXT_XML);
+ serverHandler.commitResponse(conn, response);
+ schema.write(os);
+
+ } else {
+ // no schema available by that name - send 404
+ response.setStatusCode(HttpStatus.SC_NOT_FOUND);
+ }
+ }
+ }
+
+ } else if (serviceName == null || serviceName.length() == 0) {
+
+ try {
+ response.addHeader(CONTENT_TYPE, TEXT_HTML);
+ serverHandler.commitResponse(conn, response);
+ os.write(HTTPTransportReceiver.getServicesHTML(cfgCtx).getBytes());
+
+ } catch (IOException e) {
+ handleException("Error writing ? output to client", e);
+ }
+
+ } else {
+ if (parameters.isEmpty()) {
+ AxisService service = (AxisService) cfgCtx.getAxisConfiguration().
+ getServices().get(serviceName);
+ if (service != null) {
+ try {
+ response.addHeader(CONTENT_TYPE, TEXT_HTML);
+ serverHandler.commitResponse(conn, response);
+ os.write(HTTPTransportReceiver.printServiceHTML(serviceName, cfgCtx).getBytes());
+
+ } catch (IOException e) {
+ handleException("Error writing service HTML to client", e);
+ return;
+ }
+ } else {
+ handleException("Invalid service : " + serviceName, null);
+ return;
+ }
+
+ } else {
+ try {
+ serverHandler.commitResponse(conn, response);
+ HTTPTransportUtils.processHTTPGetRequest(
+ msgContext, os,
+ (request.getFirstHeader(SOAPACTION) != null ?
+ request.getFirstHeader(SOAPACTION).getValue() : null),
+ request.getRequestLine().getUri(),
+ cfgCtx,
+ parameters);
+
+ } catch (AxisFault axisFault) {
+ handleException("Error processing GET request for: " +
+ request.getRequestLine().getUri(), axisFault);
+ }
+ }
+ }
+
+ // make sure that the output stream is flushed and closed properly
+ try {
+ os.flush();
+ os.close();
+ } catch (IOException ignore) {}
+ }
+
+
+ private void handleException(String msg, Exception e) {
+
+ if (e == null) {
+ log.error(msg);
+ } else {
+ log.error(msg, e);
+ }
+
+ if (e == null) {
+ e = new Exception(msg);
+ }
+
+ try {
+ AxisEngine engine = new AxisEngine(cfgCtx);
+ MessageContext faultContext = engine.createFaultMessageContext(msgContext, e);
+ engine.sendFault(faultContext);
+
+ } catch (Exception ex) {
+ response.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ response.addHeader(CONTENT_TYPE, TEXT_XML);
+ serverHandler.commitResponse(conn, response);
+
+ try {
+ os.write(msg.getBytes());
+ if (ex != null) {
+ os.write(ex.getMessage().getBytes());
+ }
+ } catch (IOException ignore) {}
+
+ if (conn != null) {
+ try {
+ conn.shutdown();
+ } catch (IOException ignore) {}
+ }
+ }
+ }
+
+
+ public HttpResponse getResponse() {
+ return response;
+ }
+
+ public OutputStream getOutputStream() {
+ return os;
+ }
+
+ public InputStream getIs() {
+ return is;
+ }
+
+ public ServerHandler getServiceHandler() {
+ return serverHandler;
+ }
+
+ public NHttpServerConnection getConn() {
+ return conn;
+ }
+
+ /**
+ * Copied from transport.http of Axis2
+ *
+ * Returns the ip address to be used for the replyto epr
+ * CAUTION:
+ * This will go through all the available network interfaces and will try to return an ip address.
+ * First this will try to get the first IP which is not loopback address (127.0.0.1). If none is found
+ * then this will return this will return 127.0.0.1.
+ * This will <b>not<b> consider IPv6 addresses.
+ * <p/>
+ * TODO:
+ * - Improve this logic to genaralize it a bit more
+ * - Obtain the ip to be used here from the Call API
+ *
+ * @return Returns String.
+ * @throws java.net.SocketException
+ */
+ private static String getIpAddress() throws SocketException {
+ Enumeration e = NetworkInterface.getNetworkInterfaces();
+ String address = "127.0.0.1";
+
+ while (e.hasMoreElements()) {
+ NetworkInterface netface = (NetworkInterface) e.nextElement();
+ Enumeration addresses = netface.getInetAddresses();
+
+ while (addresses.hasMoreElements()) {
+ InetAddress ip = (InetAddress) addresses.nextElement();
+ if (!ip.isLoopbackAddress() && isIP(ip.getHostAddress())) {
+ return ip.getHostAddress();
+ }
+ }
+ }
+ return address;
+ }
+
+ private static boolean isIP(String hostAddress) {
+ return hostAddress.split("[.]").length == 4;
+ }
+}
Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/Util.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/Util.java?view=auto&rev=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/Util.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/Util.java Thu Jun 21 05:21:46 2007
@@ -0,0 +1,96 @@
+/*
+ * 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.nhttp;
+
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.Constants;
+import org.apache.axis2.transport.http.HTTPTransportUtils;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axiom.om.OMOutputFormat;
+
+public class Util {
+
+ /**
+ * Get the EPR for the message passed in
+ * @param msgContext the message context
+ * @return the destination EPR
+ */
+ public static EndpointReference getDestinationEPR(MessageContext msgContext) {
+
+ // Trasnport URL can be different from the WSA-To
+ String transportURL = (String) msgContext.getProperty(
+ Constants.Configuration.TRANSPORT_URL);
+
+ if (transportURL != null) {
+ return new EndpointReference(transportURL);
+ } else if (
+ (msgContext.getTo() != null) &&
+ !AddressingConstants.Submission.WSA_ANONYMOUS_URL.equals(
+ msgContext.getTo().getAddress()) &&
+ !AddressingConstants.Final.WSA_ANONYMOUS_URL.equals(
+ msgContext.getTo().getAddress())) {
+ return msgContext.getTo();
+ }
+ return null;
+ }
+
+ /**
+ * Retirn the OMOutputFormat to be used for the message context passed in
+ * @param msgContext the message context
+ * @return the OMOutputFormat to be used
+ */
+ public static OMOutputFormat getOMOutputFormat(MessageContext msgContext) {
+
+ OMOutputFormat format = new OMOutputFormat();
+ msgContext.setDoingMTOM(HTTPTransportUtils.doWriteMTOM(msgContext));
+ msgContext.setDoingSwA(HTTPTransportUtils.doWriteSwA(msgContext));
+ msgContext.setDoingREST(HTTPTransportUtils.isDoingREST(msgContext));
+ format.setSOAP11(msgContext.isSOAP11());
+ format.setDoOptimize(msgContext.isDoingMTOM());
+ format.setDoingSWA(msgContext.isDoingSwA());
+
+ format.setCharSetEncoding(HTTPTransportUtils.getCharSetEncoding(msgContext));
+ Object mimeBoundaryProperty = msgContext.getProperty(Constants.Configuration.MIME_BOUNDARY);
+ if (mimeBoundaryProperty != null) {
+ format.setMimeBoundary((String) mimeBoundaryProperty);
+ }
+
+ return format;
+ }
+
+ /**
+ * Get the content type for the message passed in
+ * @param msgContext the message
+ * @return content type of the message
+ */
+ public static String getContentType(MessageContext msgContext) {
+ Object contentTypeObject = msgContext.getProperty(Constants.Configuration.CONTENT_TYPE);
+ if (contentTypeObject != null) {
+ return (String) contentTypeObject;
+ } else if (msgContext.isDoingREST()) {
+ return HTTPConstants.MEDIA_TYPE_APPLICATION_XML;
+ } else {
+ return getOMOutputFormat(msgContext).getContentType();
+ }
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/util/BackportWorkerPool.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/util/BackportWorkerPool.java?view=auto&rev=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/util/BackportWorkerPool.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/util/BackportWorkerPool.java Thu Jun 21 05:21:46 2007
@@ -0,0 +1,85 @@
+/*
+ * 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.nhttp.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import edu.emory.mathcs.backport.java.util.concurrent.*;
+import edu.emory.mathcs.backport.java.util.concurrent.atomic.*;
+
+
+/**
+ * Utility class to support the backport util.concurrent in JDK 1.4 and the
+ * native concurrent package in JDK 1.5 or later
+ */
+public class BackportWorkerPool implements WorkerPool{
+
+ private static final Log log = LogFactory.getLog(BackportWorkerPool.class);
+
+ Executor executor = null;
+
+ public BackportWorkerPool(int core, int max, int keepAlive,
+ int queueLength, String threadGroupName, String threadGroupId) {
+
+ log.debug("Using backport of the util.concurrent package..");
+ executor = new ThreadPoolExecutor(
+ core, max, keepAlive,
+ TimeUnit.SECONDS,
+ queueLength == -1 ?
+ new LinkedBlockingQueue() :
+ new LinkedBlockingQueue(queueLength),
+ new BackportThreadFactory(new ThreadGroup(threadGroupName), threadGroupId));
+ }
+
+ public void execute(Runnable task) {
+ executor.execute(task);
+ }
+
+ /**
+ * This is a simple ThreadFactory implementation using java.util.concurrent
+ * Creates threads with the given name prefix
+ */
+ public class BackportThreadFactory implements
+ ThreadFactory {
+
+ final ThreadGroup group;
+ final AtomicInteger count;
+ final String namePrefix;
+
+ public BackportThreadFactory(final ThreadGroup group, final String namePrefix) {
+ super();
+ this.count = new AtomicInteger(1);
+ this.group = group;
+ this.namePrefix = namePrefix;
+ }
+
+ public Thread newThread(final Runnable runnable) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(this.namePrefix);
+ buffer.append('-');
+ buffer.append(this.count.getAndIncrement());
+ Thread t = new Thread(group, runnable, buffer.toString(), 0);
+ t.setDaemon(false);
+ t.setPriority(Thread.NORM_PRIORITY);
+ return t;
+ }
+
+ }
+}
Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/util/NativeWorkerPool.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/util/NativeWorkerPool.java?view=auto&rev=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/util/NativeWorkerPool.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/util/NativeWorkerPool.java Thu Jun 21 05:21:46 2007
@@ -0,0 +1,85 @@
+/*
+ * 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.nhttp.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+//import java.util.concurrent.*;
+//import java.util.concurrent.atomic.*;
+
+
+/**
+ * Utility class to support the backport util.concurrent in JDK 1.4 and the
+ * native concurrent package in JDK 1.5 or later
+ */
+//public class NativeWorkerPool implements WorkerPool {
+//
+// private static final Log log = LogFactory.getLog(NativeWorkerPool.class);
+//
+// Executor executor = null;
+//
+// public NativeWorkerPool(int core, int max, int keepAlive,
+// int queueLength, String threadGroupName, String threadGroupId) {
+//
+// log.debug("Using native util.concurrent package..");
+// executor = new ThreadPoolExecutor(
+// core, max, keepAlive,
+// TimeUnit.SECONDS,
+// queueLength == -1 ?
+// new LinkedBlockingQueue() :
+// new LinkedBlockingQueue(queueLength),
+// new BackportThreadFactory(new ThreadGroup(threadGroupName), threadGroupId));
+// }
+//
+// public void execute(Runnable task) {
+// executor.execute(task);
+// }
+//
+// /**
+// * This is a simple ThreadFactory implementation using java.util.concurrent
+// * Creates threads with the given name prefix
+// */
+// public class BackportThreadFactory implements
+// ThreadFactory {
+//
+// final ThreadGroup group;
+// final AtomicInteger count;
+// final String namePrefix;
+//
+// public BackportThreadFactory(final ThreadGroup group, final String namePrefix) {
+// super();
+// this.count = new AtomicInteger(1);
+// this.group = group;
+// this.namePrefix = namePrefix;
+// }
+//
+// public Thread newThread(final Runnable runnable) {
+// StringBuffer buffer = new StringBuffer();
+// buffer.append(this.namePrefix);
+// buffer.append('-');
+// buffer.append(this.count.getAndIncrement());
+// Thread t = new Thread(group, runnable, buffer.toString(), 0);
+// t.setDaemon(false);
+// t.setPriority(Thread.NORM_PRIORITY);
+// return t;
+// }
+//
+// }
+//}
Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/util/PipeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/util/PipeImpl.java?view=auto&rev=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/util/PipeImpl.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/util/PipeImpl.java Thu Jun 21 05:21:46 2007
@@ -0,0 +1,101 @@
+/*
+ * 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.nhttp.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.nio.channels.Pipe;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.WritableByteChannel;
+import java.nio.channels.spi.SelectorProvider;
+import java.nio.ByteBuffer;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.io.IOException;
+import java.io.File;
+
+/**
+ * Create a Pipe suitable for the runtime platform. The java.nio.channels.Pipe implementation
+ * on Windows uses TCP ports bound to the loopback interface to implement a Pipe. In Linux and
+ * Solaris this is passed to a native method.
+ */
+public class PipeImpl {
+
+ private static final Log log = LogFactory.getLog(PipeImpl.class);
+
+ private ReadableByteChannel source;
+ private WritableByteChannel sink;
+
+ private PipedOutputStream pipedOut;
+ protected static boolean useNative;
+
+ static {
+ // platfom default - Unix - native, Windows - Piped Streams
+ if ("/".equals(File.separator)) {
+ useNative = true;
+ }
+
+ // has this been overridden?
+ String option = System.getProperty("native_pipes");
+ if (option != null) {
+ // if an option is specified, use it
+ if ("true".equals(option)) {
+ useNative = true;
+ } else if ("false".equals(option)) {
+ useNative = false;
+ }
+ }
+
+ if (useNative) {
+ log.info("Using native OS Pipes for event-driven to stream IO bridging");
+ } else {
+ log.info("Using simulated buffered Pipes for event-driven to stream IO bridging");
+ }
+ }
+
+ public PipeImpl() throws IOException {
+ if (useNative) {
+ Pipe pipe = Pipe.open();
+ source = pipe.source();
+ sink = pipe.sink();
+
+ } else {
+ PipedInputStream pipedIn = new PipedInputStream();
+ try {
+ pipedOut = new PipedOutputStream(pipedIn);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ source = Channels.newChannel(pipedIn);
+ sink = Channels.newChannel(pipedOut);
+ }
+ }
+
+ public ReadableByteChannel source() {
+ return source;
+ }
+
+ public WritableByteChannel sink() {
+ return sink;
+ }
+}
Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/util/WorkerPool.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/util/WorkerPool.java?view=auto&rev=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/util/WorkerPool.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/util/WorkerPool.java Thu Jun 21 05:21:46 2007
@@ -0,0 +1,24 @@
+/*
+ * 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.nhttp.util;
+
+public interface WorkerPool {
+ public void execute(Runnable task);
+}
Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/util/WorkerPoolFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/util/WorkerPoolFactory.java?view=auto&rev=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/util/WorkerPoolFactory.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/util/WorkerPoolFactory.java Thu Jun 21 05:21:46 2007
@@ -0,0 +1,38 @@
+/*
+ * 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.nhttp.util;
+
+/**
+ * Dynamically select util.concurrent implemenation
+ */
+public class WorkerPoolFactory {
+
+ public static WorkerPool getWorkerPool(int core, int max, int keepAlive,
+ int queueLength, String threadGroupName, String threadGroupId) {
+// try {
+// Class.forName("java.util.concurrent.ThreadPoolExecutor");
+// return new NativeWorkerPool(
+// core, max, keepAlive, queueLength, threadGroupName, threadGroupId);
+// } catch (ClassNotFoundException e) {
+ return new BackportWorkerPool(
+ core, max, keepAlive, queueLength, threadGroupName, threadGroupId);
+ }
+// }
+}
Modified: webservices/axis2/trunk/java/modules/parent/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/parent/pom.xml?view=diff&rev=549457&r1=549456&r2=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/parent/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/parent/pom.xml Thu Jun 21 05:21:46 2007
@@ -628,6 +628,16 @@
<artifactId>jakarta-httpcore</artifactId>
<version>${jakarta.httpcore.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>jakarta-httpcore-nio</artifactId>
+ <version>${jakarta.httpcore.version}</version>
+ </dependency>
+ <!--<dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>jakarta-httpcore-niossl</artifactId>
+ <version>${jakarta.httpcore.version}</version>
+ </dependency>-->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org