axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asan...@apache.org
Subject svn commit: r549457 [2/3] - in /webservices/axis2/trunk/java/modules: kernel/ kernel/src/org/apache/axis2/transport/nhttp/ kernel/src/org/apache/axis2/transport/nhttp/util/ parent/
Date Thu, 21 Jun 2007 12:21:48 GMT
Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSSLSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSSLSender.java?view=auto&rev=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSSLSender.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSSLSender.java Thu Jun 21 05:21:46 2007
@@ -0,0 +1,176 @@
+///*
+// *  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.commons.logging.LogFactory;
+//import org.apache.commons.logging.Log;
+//import org.apache.http.nio.reactor.IOEventDispatch;
+//import org.apache.http.nio.NHttpClientHandler;
+//import org.apache.http.impl.nio.reactor.SSLIOSessionHandler;
+//import org.apache.http.params.HttpParams;
+//import org.apache.axis2.AxisFault;
+//import org.apache.axis2.description.Parameter;
+//import org.apache.axis2.description.TransportOutDescription;
+//import org.apache.axiom.om.OMElement;
+//
+//import javax.net.ssl.*;
+//import javax.xml.namespace.QName;
+//import java.security.GeneralSecurityException;
+//import java.security.KeyStore;
+//import java.net.URL;
+//import java.net.SocketAddress;
+//import java.net.InetSocketAddress;
+//import java.io.IOException;
+//
+//public class HttpCoreNIOSSLSender extends HttpCoreNIOSender{
+//
+//    private static final Log log = LogFactory.getLog(HttpCoreNIOSSLSender.class);
+//
+//    protected IOEventDispatch getEventDispatch(
+//        NHttpClientHandler handler, SSLContext sslContext,
+//        SSLIOSessionHandler sslIOSessionHandler, HttpParams params) {
+//        return new SSLClientIOEventDispatch(handler, sslContext, sslIOSessionHandler, params);
+//    }
+//
+//    /**
+//     * Create the SSLContext to be used by this listener
+//     * @param transportOut the Axis2 transport configuration
+//     * @return the SSLContext to be used
+//     */
+//    protected SSLContext getSSLContext(TransportOutDescription transportOut) throws AxisFault {
+//
+//        KeyManager[] keymanagers  = null;
+//        TrustManager[] trustManagers = null;
+//
+//        Parameter keyParam    = transportOut.getParameter("keystore");
+//        Parameter trustParam  = transportOut.getParameter("truststore");
+//
+//        if (keyParam != null) {
+//            OMElement ksEle      = keyParam.getParameterElement().getFirstElement();
+//            String location      = ksEle.getFirstChildWithName(new QName("Location")).getText();
+//            String type          = ksEle.getFirstChildWithName(new QName("Type")).getText();
+//            String storePassword = ksEle.getFirstChildWithName(new QName("Password")).getText();
+//            String keyPassword   = ksEle.getFirstChildWithName(new QName("KeyPassword")).getText();
+//
+//            try {
+//                KeyStore keyStore = KeyStore.getInstance(type);
+//                URL url = getClass().getClassLoader().getResource(location);
+//                log.debug("Loading Key Store from URL : " + url);
+//
+//                keyStore.load(url.openStream(), storePassword.toCharArray());
+//                KeyManagerFactory kmfactory = KeyManagerFactory.getInstance(
+//                    KeyManagerFactory.getDefaultAlgorithm());
+//                kmfactory.init(keyStore, keyPassword.toCharArray());
+//                keymanagers = kmfactory.getKeyManagers();
+//
+//            } catch (GeneralSecurityException gse) {
+//                log.error("Error loading Key store : " + location, gse);
+//                throw new AxisFault("Error loading Key store : " + location, gse);
+//            } catch (IOException ioe) {
+//                log.error("Error opening Key store : " + location, ioe);
+//                throw new AxisFault("Error opening Key store : " + location, ioe);
+//            }
+//        }
+//
+//        if (trustParam != null) {
+//            OMElement tsEle      = trustParam.getParameterElement().getFirstElement();
+//            String location      = tsEle.getFirstChildWithName(new QName("Location")).getText();
+//            String type          = tsEle.getFirstChildWithName(new QName("Type")).getText();
+//            String storePassword = tsEle.getFirstChildWithName(new QName("Password")).getText();
+//
+//            try {
+//                KeyStore trustStore = KeyStore.getInstance(type);
+//                URL url = getClass().getClassLoader().getResource(location);
+//                log.debug("Loading Trust Key Store from URL : " + url);
+//
+//                trustStore.load(url.openStream(), storePassword.toCharArray());
+//                TrustManagerFactory trustManagerfactory = TrustManagerFactory.getInstance(
+//                    TrustManagerFactory.getDefaultAlgorithm());
+//                trustManagerfactory.init(trustStore);
+//                trustManagers = trustManagerfactory.getTrustManagers();
+//
+//            } catch (GeneralSecurityException gse) {
+//                log.error("Error loading Key store : " + location, gse);
+//                throw new AxisFault("Error loading Key store : " + location, gse);
+//            } catch (IOException ioe) {
+//                log.error("Error opening Key store : " + location, ioe);
+//                throw new AxisFault("Error opening Key store : " + location, ioe);
+//            }
+//        }
+//
+//        try {
+//            SSLContext sslcontext = SSLContext.getInstance("TLS");
+//            sslcontext.init(keymanagers, trustManagers, null);
+//            return sslcontext;
+//
+//        } catch (GeneralSecurityException gse) {
+//            log.error("Unable to create SSL context with the given configuration", gse);
+//            throw new AxisFault("Unable to create SSL context with the given configuration", gse);
+//        }
+//    }
+//
+//    /**
+//     * Create the SSLIOSessionHandler to initialize the host name verification at the following
+//     * levels, through an Axis2 transport configuration parameter as follows:
+//     * HostnameVerifier - Default, DefaultAndLocalhost, Strict, AllowAll
+//     *
+//     * @param transportOut the Axis2 transport configuration
+//     * @return the SSLIOSessionHandler to be used
+//     * @throws AxisFault if a configuration error occurs
+//     */
+//    protected SSLIOSessionHandler getSSLIOSessionHandler(TransportOutDescription transportOut) throws AxisFault {
+//
+//        final Parameter hostnameVerifier = transportOut.getParameter("HostnameVerifier");
+//
+//        return new SSLIOSessionHandler() {
+//
+//            public void initalize(SSLEngine sslengine, HttpParams params) {
+//            }
+//
+//            public void verify(SocketAddress remoteAddress, SSLSession session)
+//                throws SSLException {
+//
+//                String address = null;
+//                if (remoteAddress instanceof InetSocketAddress) {
+//                    address = ((InetSocketAddress) remoteAddress).getHostName();
+//                } else {
+//                    address = remoteAddress.toString();
+//                }
+//
+//                boolean valid = false;
+//                if (hostnameVerifier != null) {
+//                    if ("Strict".equals(hostnameVerifier.getValue())) {
+//                        valid = HostnameVerifier.STRICT.verify(address, session);
+//                    } else if ("AllowAll".equals(hostnameVerifier.getValue())) {
+//                        valid = HostnameVerifier.ALLOW_ALL.verify(address, session);
+//                    } else if ("DefaultAndLocalhost".equals(hostnameVerifier.getValue())) {
+//                        valid = HostnameVerifier.DEFAULT_AND_LOCALHOST.verify(address, session);
+//                    }
+//                } else {
+//                    valid = HostnameVerifier.DEFAULT.verify(address, session);
+//                }
+//
+//                if (!valid) {
+//                    throw new SSLException("Host name verification failed for host : " + address);
+//                }
+//            }
+//        };
+//    }
+//}

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSender.java?view=auto&rev=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSender.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSender.java Thu Jun 21 05:21:46 2007
@@ -0,0 +1,465 @@
+/*
+ *  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 java.io.IOException;
+import java.io.InterruptedIOException;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.net.ssl.SSLContext;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.util.MessageContextBuilder;
+import org.apache.axis2.util.Utils;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.axis2.transport.OutTransportInfo;
+import org.apache.axis2.transport.TransportSender;
+import org.apache.axis2.transport.TransportUtils;
+import org.apache.axis2.transport.MessageFormatter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
+//import org.apache.http.impl.nio.reactor.SSLIOSessionHandler;
+import org.apache.http.nio.NHttpClientConnection;
+import org.apache.http.nio.NHttpClientHandler;
+import org.apache.http.nio.reactor.ConnectingIOReactor;
+import org.apache.http.nio.reactor.IOEventDispatch;
+import org.apache.http.nio.reactor.SessionRequest;
+import org.apache.http.nio.reactor.SessionRequestCallback;
+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.HTTP;
+
+/**
+ * NIO transport sender for Axis2 based on HttpCore and NIO extensions
+ */
+public class HttpCoreNIOSender extends AbstractHandler implements TransportSender {
+
+    private static final Log log = LogFactory.getLog(HttpCoreNIOSender.class);
+
+    /** The Axis2 configuration context */
+    private ConfigurationContext cfgCtx;
+    /** The IOReactor */
+    private ConnectingIOReactor ioReactor = null;
+    /** The client handler */
+    private NHttpClientHandler handler = null;
+    /** The session request callback that calls back to the message receiver with errors */
+    private final SessionRequestCallback sessionRequestCallback = getSessionRequestCallback();
+    /** The SSL Context to be used */
+    private SSLContext sslContext = null;
+    /** The SSL session handler that manages hostname verification etc */
+//    private SSLIOSessionHandler sslIOSessionHandler = null;
+
+    /**
+     * Initialize the transport sender, and execute reactor in new seperate thread
+     * @param cfgCtx the Axis2 configuration context
+     * @param transportOut the description of the http/s transport from Axis2 configuration
+     * @throws AxisFault thrown on an error
+     */
+    public void init(ConfigurationContext cfgCtx, TransportOutDescription transportOut) throws AxisFault {
+        this.cfgCtx = cfgCtx;
+
+        // is this an SSL Sender?
+        sslContext = getSSLContext(transportOut);
+        //sslIOSessionHandler = getSSLIOSessionHandler(transportOut);
+
+        // start the Sender in a new seperate thread
+        Thread t = new Thread(new Runnable() {
+            public void run() {
+                executeClientEngine();
+            }
+        }, "HttpCoreNIOSender");
+        t.start();
+        log.info((sslContext == null ? "HTTP" : "HTTPS") + " Sender starting");
+    }
+
+    /**
+     * Configure and start the IOReactor
+     */
+    private void executeClientEngine() {
+
+        HttpParams params = getClientParameters();
+        try {
+            ioReactor = new DefaultConnectingIOReactor(
+                NHttpConfiguration.getInstance().getClientIOWorkers(), params);
+        } catch (IOException e) {
+            log.error("Error starting the IOReactor", e);
+        }
+
+        handler = new ClientHandler(cfgCtx, params);
+        IOEventDispatch ioEventDispatch = getEventDispatch(
+            handler, sslContext, /*sslIOSessionHandler,*/ params);
+
+        try {
+            ioReactor.execute(ioEventDispatch);
+        } catch (InterruptedIOException ex) {
+            log.fatal("Reactor Interrupted");
+        } catch (IOException e) {
+            log.fatal("Encountered an I/O error: " + e.getMessage(), e);
+        }
+        log.info("Sender Shutdown");
+    }
+
+    /**
+     * Return the IOEventDispatch implementation to be used. This is overridden by the
+     * SSL sender
+     * @param handler
+     * @param sslContext
+     * @param params
+     * @return
+     */
+    protected IOEventDispatch getEventDispatch(
+        NHttpClientHandler handler, SSLContext sslContext,
+        /*SSLIOSessionHandler sslIOSessionHandler,*/ HttpParams params) {
+        return new PlainClientIOEventDispatch(handler, params);
+    }
+
+    /**
+     * Always return null, as this implementation does not support outgoing SSL
+     * @param transportOut
+     * @return null
+     * @throws AxisFault
+     */
+    protected SSLContext getSSLContext(TransportOutDescription transportOut) throws AxisFault {
+        return null;
+    }
+
+    /**
+     * Create the SSL IO Session handler to be used by this listener
+     * @param transportOut
+     * @return always null
+     */
+//    protected SSLIOSessionHandler getSSLIOSessionHandler(TransportOutDescription transportOut)
+//        throws AxisFault {
+//        return null;
+//    }
+
+    /**
+     * get HTTP protocol parameters to which the sender must adhere to
+     * @return the applicable HTTP protocol parameters
+     */
+    private HttpParams getClientParameters() {
+        NHttpConfiguration cfg = NHttpConfiguration.getInstance();
+        HttpParams params = new BasicHttpParams();
+        params
+            .setIntParameter(HttpConnectionParams.SO_TIMEOUT,
+                cfg.getProperty(HttpConnectionParams.SO_TIMEOUT, 60000))
+            .setIntParameter(HttpConnectionParams.CONNECTION_TIMEOUT,
+                cfg.getProperty(HttpConnectionParams.CONNECTION_TIMEOUT, 10000))
+            .setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE,
+                cfg.getProperty(HttpConnectionParams.SOCKET_BUFFER_SIZE, 8 * 1024))
+            .setBooleanParameter(HttpConnectionParams.STALE_CONNECTION_CHECK,
+                cfg.getProperty(HttpConnectionParams.STALE_CONNECTION_CHECK, 0) == 1)
+            .setBooleanParameter(HttpConnectionParams.TCP_NODELAY,
+                cfg.getProperty(HttpConnectionParams.TCP_NODELAY, 1) == 1)
+            .setParameter(HttpProtocolParams.USER_AGENT, "Synapse-HttpComponents-NIO");
+        return params;
+    }
+
+    /**
+     * transport sender invocation from Axis2 core
+     * @param msgContext message to be sent
+     * @return the invocation response (always InvocationResponse.CONTINUE)
+     * @throws AxisFault on error
+     */
+    public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
+
+        // remove unwanted HTTP headers (if any from the current message)
+        removeUnwantedHeaders(msgContext);
+
+        EndpointReference epr = Util.getDestinationEPR(msgContext);
+        if (epr != null) {
+            if (!AddressingConstants.Final.WSA_NONE_URI.equals(epr.getAddress())) {
+                sendAsyncRequest(epr, msgContext);
+            } else {
+                handleException("Cannot send message to " + AddressingConstants.Final.WSA_NONE_URI);
+            }
+        } else {
+            if (msgContext.getProperty(Constants.OUT_TRANSPORT_INFO) != null) {
+                if (msgContext.getProperty(Constants.OUT_TRANSPORT_INFO) instanceof ServerWorker) {
+                    sendAsyncResponse(msgContext);
+                } else {
+                    sendUsingOutputStream(msgContext);
+                }
+            } else {
+                handleException("No valid destination EPR or OutputStream to send message");
+            }
+        }
+
+        if (msgContext.getOperationContext() != null) {
+            msgContext.getOperationContext().setProperty(
+                Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE);
+        }
+
+        return InvocationResponse.CONTINUE;
+    }
+
+    /**
+     * Remove unwanted headers from the http response of outgoing request. These are headers which
+     * should be dictated by the transport and not the user. We remove these as these may get
+     * copied from the request messages
+     * @param msgContext the Axis2 Message context from which these headers should be removed
+     */
+    private void removeUnwantedHeaders(MessageContext msgContext) {
+        Map headers = (Map) msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
+        if (headers != null && !headers.isEmpty()) {
+            headers.remove(HTTP.CONN_DIRECTIVE);
+            headers.remove(HTTP.TRANSFER_ENCODING);
+            headers.remove(HTTP.DATE_DIRECTIVE);
+            headers.remove(HTTP.SERVER_DIRECTIVE);
+            headers.remove(HTTP.CONTENT_TYPE);
+            headers.remove(HTTP.CONTENT_LEN);
+            headers.remove(HTTP.USER_AGENT);
+        }
+    }
+
+    /**
+     * Send the request message asynchronously to the given EPR
+     * @param epr the destination EPR for the message
+     * @param msgContext the message being sent
+     * @throws AxisFault on error
+     */
+    private void sendAsyncRequest(EndpointReference epr, MessageContext msgContext) throws AxisFault {
+        try {
+            URL url = new URL(epr.getAddress());
+            int port = url.getPort();
+            if (port == -1) {
+                // use default
+                if ("http".equals(url.getProtocol())) {
+                    port = 80;
+                } else if ("https".equals(url.getProtocol())) {
+                    port = 443;
+                }
+            }
+            HttpHost httpHost = new HttpHost(url.getHost(), port, url.getProtocol());
+
+            Axis2HttpRequest axis2Req = new Axis2HttpRequest(epr, httpHost, msgContext);
+
+            NHttpClientConnection conn = ConnectionPool.getConnection(url.getHost(), port);
+
+            if (conn == null) {
+                ioReactor.connect(new InetSocketAddress(url.getHost(), port),
+                    null, axis2Req, sessionRequestCallback);
+                log.debug("A new connection established");
+            } else {
+                ((ClientHandler) handler).submitRequest(conn, axis2Req);
+                log.debug("An existing connection reused");
+            }
+
+            axis2Req.streamMessageContents();
+
+        } catch (MalformedURLException e) {
+            handleException("Malformed destination EPR : " + epr.getAddress(), e);
+        } catch (IOException e) {
+            handleException("IO Error while submiting request message for sending", e);
+        }
+    }
+
+    /**
+     * Send the passed in response message, asynchronously
+     * @param msgContext the message context to be sent
+     * @throws AxisFault on error
+     */
+    private void sendAsyncResponse(MessageContext msgContext) throws AxisFault {
+
+        // remove unwanted HTTP headers (if any from the current message)
+        removeUnwantedHeaders(msgContext);
+        
+        ServerWorker worker = (ServerWorker) msgContext.getProperty(Constants.OUT_TRANSPORT_INFO);
+        HttpResponse response = worker.getResponse();
+
+        OMOutputFormat format = Util.getOMOutputFormat(msgContext);
+        MessageFormatter messageFormatter = TransportUtils.getMessageFormatter(msgContext);
+        response.setHeader(
+            HTTP.CONTENT_TYPE,
+            messageFormatter.getContentType(msgContext, format, msgContext.getSoapAction()));
+
+        // return http 500 when a SOAP fault is returned
+        if (msgContext.getEnvelope().getBody().hasFault()) {
+            response.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+        }
+
+        // if this is a dummy message to handle http 202 case with non-blocking IO
+        // set the status code to 202 and the message body to an empty byte array (see below)
+        if (Utils.isExplicitlyTrue(msgContext, NhttpConstants.SC_ACCEPTED) &&
+                msgContext.getProperty(
+                    //org.apache.sandesha2.Sandesha2Constants.MessageContextProperties.SEQUENCE_ID
+                    "WSRMSequenceId") == null) {
+            response.setStatusCode(HttpStatus.SC_ACCEPTED);
+        }
+
+        // set any transport headers
+        Map transportHeaders = (Map) msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
+        if (transportHeaders != null && !transportHeaders.values().isEmpty()) {
+            Iterator iter = transportHeaders.keySet().iterator();
+            while (iter.hasNext()) {
+                Object header = iter.next();
+                Object value = transportHeaders.get(header);
+                if (value != null && header instanceof String && value instanceof String) {
+                    response.setHeader((String) header, (String) value);
+                }
+            }
+        }
+        worker.getServiceHandler().commitResponse(worker.getConn(), response);
+
+        OutputStream out = worker.getOutputStream();
+        try {
+            if (Utils.isExplicitlyTrue(msgContext, NhttpConstants.SC_ACCEPTED) &&
+                msgContext.getProperty(
+                    //Sandesha2Constants.MessageContextProperties.SEQUENCE_ID
+                    "WSRMSequenceId") == null) {
+                // see comment above on the reasoning
+                out.write(new byte[0]);
+            } else {
+                messageFormatter.writeTo(msgContext, format, out, true);
+            }
+            out.close();
+        } catch (IOException e) {
+            handleException("IO Error sending response message", e);
+        }
+
+        try {
+            worker.getIs().close();
+        } catch (IOException ignore) {}        
+    }
+
+    private void sendUsingOutputStream(MessageContext msgContext) throws AxisFault {
+        OMOutputFormat format = Util.getOMOutputFormat(msgContext);
+        MessageFormatter messageFormatter = TransportUtils.getMessageFormatter(msgContext);
+        OutputStream out = (OutputStream) msgContext.getProperty(MessageContext.TRANSPORT_OUT);
+
+        if (msgContext.isServerSide()) {
+            OutTransportInfo transportInfo =
+                (OutTransportInfo) msgContext.getProperty(Constants.OUT_TRANSPORT_INFO);
+
+            if (transportInfo != null) {
+                transportInfo.setContentType(
+                messageFormatter.getContentType(msgContext, format, msgContext.getSoapAction()));
+            } else {
+                throw new AxisFault(Constants.OUT_TRANSPORT_INFO + " has not been set");
+            }
+        }
+
+        try {
+            messageFormatter.writeTo(msgContext, format, out, true);
+            out.close();
+        } catch (IOException e) {
+            handleException("IO Error sending response message", e);
+        }
+    }
+
+
+    public void cleanup(MessageContext msgContext) throws AxisFault {
+        // do nothing
+    }
+
+    public void stop() {
+        try {
+            ioReactor.shutdown();
+            log.info("Sender shut down");
+        } catch (IOException e) {
+            log.warn("Error shutting down IOReactor", e);
+        }
+    }
+
+    /**
+     * Return a SessionRequestCallback which gets notified of a connection failure
+     * or an error during a send operation. This method finds the corresponding
+     * Axis2 message context for the outgoing request, and find the message receiver
+     * and sends a fault message back to the message receiver that is marked as
+     * related to the outgoing request
+     * @return a Session request callback
+     */
+    private static SessionRequestCallback getSessionRequestCallback() {
+        return new SessionRequestCallback() {
+            public void completed(SessionRequest request) {
+            }
+
+            public void failed(SessionRequest request) {
+                handleError(request);
+            }
+
+            public void timeout(SessionRequest request) {
+                handleError(request);
+            }
+
+            public void cancelled(SessionRequest sessionRequest) {
+
+            }
+
+            private void handleError(SessionRequest request) {
+                if (request.getAttachment() != null &&
+                    request.getAttachment() instanceof Axis2HttpRequest) {
+
+                    Axis2HttpRequest axis2Request = (Axis2HttpRequest) request.getAttachment();
+                    MessageContext mc = axis2Request.getMsgContext();
+                    MessageReceiver mr = mc.getAxisOperation().getMessageReceiver();
+
+                    try {
+                        // this fault is NOT caused by the endpoint while processing. so we have to
+                        // inform that this is a sending error (e.g. endpoint failure) and handle it
+                        // differently at the message receiver.
+
+                        Exception exception = request.getException();
+                        MessageContext nioFaultMessageContext =
+                            MessageContextBuilder.createFaultMessageContext(
+                                /** this is not a mistake I do NOT want getMessage()*/
+                                mc, new AxisFault(exception.toString(), exception));
+                        nioFaultMessageContext.setProperty(NhttpConstants.SENDING_FAULT, Boolean.TRUE);
+                        mr.receive(nioFaultMessageContext);
+                        
+                    } catch (AxisFault af) {
+                        log.error("Unable to report back failure to the message receiver", af);
+                    }
+                }
+            }
+        };
+    }
+
+    // -------------- utility methods -------------
+    private void handleException(String msg, Exception e) throws AxisFault {
+        log.error(msg, e);
+        throw new AxisFault(msg, e);
+    }
+
+    private void handleException(String msg) throws AxisFault {
+        log.error(msg);
+        throw new AxisFault(msg);
+    }
+}

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreRequestResponseTransport.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreRequestResponseTransport.java?view=auto&rev=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreRequestResponseTransport.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreRequestResponseTransport.java Thu Jun 21 05:21:46 2007
@@ -0,0 +1,69 @@
+/*
+ *  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.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.transport.RequestResponseTransport;
+
+/**
+ * This interface is a point of control for Axis2 (and Sandesha2 in particular) to control
+ * the behaviour of a Request-Response transport such as HTTP/s
+ *
+ * For nhttp, this does not make much of a difference, as we are capable of keeping a socket open
+ * and writing to it from a different thread, while letting the initial thread that read the request
+ * go free. However, it seems like Sandesha2 is looking for this interface, and it is not going to
+ * create much of an issue anyway
+ */
+public class HttpCoreRequestResponseTransport implements RequestResponseTransport {
+
+    private static final Log log = LogFactory.getLog(HttpCoreRequestResponseTransport.class);
+    private RequestResponseTransportStatus status = RequestResponseTransportStatus.INITIAL;
+    private MessageContext msgContext = null;
+
+    HttpCoreRequestResponseTransport(MessageContext msgContext) {
+        this.msgContext = msgContext;
+    }
+
+    public void acknowledgeMessage(MessageContext msgContext) throws AxisFault {
+        log.debug("Acking one-way request");
+    }
+
+    public void awaitResponse() throws InterruptedException, AxisFault {
+        log.debug("Returning thread but keeping socket open -- awaiting response");
+        status = RequestResponseTransportStatus.WAITING;
+        msgContext.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN, "SKIP");
+    }
+
+    public void signalResponseReady() {
+        log.debug("Signal response available");
+        status = RequestResponseTransportStatus.SIGNALLED;
+    }
+
+    public RequestResponseTransportStatus getStatus() {
+        return status;
+    }
+
+    public void signalFaultReady(AxisFault fault) {
+    }
+}

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/LoggingIOSession.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/LoggingIOSession.java?view=auto&rev=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/LoggingIOSession.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/LoggingIOSession.java Thu Jun 21 05:21:46 2007
@@ -0,0 +1,181 @@
+/*
+ *  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 java.io.IOException;
+import java.net.SocketAddress;
+import java.nio.ByteBuffer;
+import java.nio.channels.ByteChannel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.nio.reactor.IOSession;
+import org.apache.http.nio.reactor.SessionBufferStatus;
+
+/**
+ * Decorator class intended to transparently extend an {@link IOSession} 
+ * with basic event logging capabilities using Commons Logging. 
+ */
+public class LoggingIOSession implements IOSession {
+
+    private static int COUNT = 0;
+    
+    private final Log log;
+    private final IOSession session;
+    private final ByteChannel channel;
+    private final int id;
+    
+    public LoggingIOSession(final IOSession session) {
+        super();
+        if (session == null) {
+            throw new IllegalArgumentException("I/O session may not be null");
+        }
+        this.session = session;
+        this.channel = new LoggingByteChannel();
+        this.id = ++COUNT;
+        this.log = LogFactory.getLog(session.getClass());
+    }
+
+    public ByteChannel channel() {
+        return this.channel;
+    }
+
+    public SocketAddress getLocalAddress() {
+        return this.session.getLocalAddress();
+    }
+
+    public SocketAddress getRemoteAddress() {
+        return this.session.getRemoteAddress();
+    }
+
+    public int getEventMask() {
+        return this.session.getEventMask();
+    }
+
+    public void setEventMask(int ops) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("I/O session " + this.id + " " + this.session + ": Set event mask " 
+                    + ops);
+        }
+        this.session.setEventMask(ops);
+    }
+
+    public void setEvent(int op) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("I/O session " + this.id + " " + this.session + ": Set event " 
+                    + op);
+        }
+        this.session.setEvent(op);
+    }
+
+    public void clearEvent(int op) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("I/O session " + this.id + " " + this.session + ": Clear event " 
+                    + op);
+        }
+        this.session.clearEvent(op);
+    }
+
+    public void close() {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("I/O session " + this.id + " " + this.session + ": Close");
+        }
+        this.session.close();
+    }
+
+    public boolean isClosed() {
+        return this.session.isClosed();
+    }
+
+    public int getSocketTimeout() {
+        return this.session.getSocketTimeout();
+    }
+
+    public void setSocketTimeout(int timeout) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("I/O session " + this.id + " " + this.session + ": Set timeout " 
+                    + timeout);
+        }
+        this.session.setSocketTimeout(timeout);
+    }
+
+    public void setBufferStatus(final SessionBufferStatus status) {
+        this.session.setBufferStatus(status);
+    }
+
+    public boolean hasBufferedInput() {
+        return this.session.hasBufferedInput();
+    }
+
+    public boolean hasBufferedOutput() {
+        return this.session.hasBufferedOutput();
+    }
+
+    public Object getAttribute(final String name) {
+        return this.session.getAttribute(name);
+    }
+
+    public void setAttribute(final String name, final Object obj) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("I/O session " + this.id + " " + this.session + ": Set attribute " 
+                    + name);
+        }
+        this.session.setAttribute(name, obj);
+    }
+
+    public Object removeAttribute(final String name) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("I/O session " + this.id + " " + this.session + ": Remove attribute " 
+                    + name);
+        }
+        return this.session.removeAttribute(name);
+    }
+
+    class LoggingByteChannel implements ByteChannel {
+
+        public int read(final ByteBuffer dst) throws IOException {
+            int bytesRead = session.channel().read(dst);
+            if (log.isDebugEnabled()) {
+                log.debug("I/O session " + id + " " + session + ": " + bytesRead + " bytes read");
+            }
+            return bytesRead;
+        }
+
+        public int write(final ByteBuffer src) throws IOException {
+            int byteWritten = session.channel().write(src);
+            if (log.isDebugEnabled()) {
+                log.debug("I/O session " + id + " " + session + ": " + byteWritten + " bytes written");
+            }
+            return byteWritten;
+        }
+
+        public void close() throws IOException {
+            if (log.isDebugEnabled()) {
+                log.debug("I/O session " + id + " " + session + ": Channel close");
+            }
+            session.channel().close();
+        }
+
+        public boolean isOpen() {
+            return session.channel().isOpen();
+        }
+        
+    }    
+    
+}
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/LoggingNHttpClientHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/LoggingNHttpClientHandler.java?view=auto&rev=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/LoggingNHttpClientHandler.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/LoggingNHttpClientHandler.java Thu Jun 21 05:21:46 2007
@@ -0,0 +1,116 @@
+/*
+ *  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 java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.HttpException;
+import org.apache.http.HttpResponse;
+import org.apache.http.nio.ContentDecoder;
+import org.apache.http.nio.ContentEncoder;
+import org.apache.http.nio.NHttpClientConnection;
+import org.apache.http.nio.NHttpClientHandler;
+
+/**
+ * Decorator class intended to transparently extend an {@link NHttpClientHandler} 
+ * with basic event logging capabilities using Commons Logging. 
+ */
+public class LoggingNHttpClientHandler implements NHttpClientHandler {
+
+    private final Log log;
+    private final NHttpClientHandler handler;
+    
+    public LoggingNHttpClientHandler(final NHttpClientHandler handler) {
+        super();
+        if (handler == null) {
+            throw new IllegalArgumentException("HTTP client handler may not be null");
+        }
+        this.handler = handler;
+        this.log = LogFactory.getLog(handler.getClass());
+    }
+    
+    public void connected(final NHttpClientConnection conn, final Object attachment) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Connected (" + attachment + ")");
+        }
+        this.handler.connected(conn, attachment);
+    }
+
+    public void closed(final NHttpClientConnection conn) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Closed");
+        }
+        this.handler.closed(conn);
+    }
+
+    public void exception(final NHttpClientConnection conn, final IOException ex) {
+        this.log.error("HTTP connection " + conn + ": " + ex.getMessage(), ex);
+        this.handler.exception(conn, ex);
+    }
+
+    public void exception(final NHttpClientConnection conn, final HttpException ex) {
+        this.log.error("HTTP connection " + conn + ": " + ex.getMessage(), ex);
+        this.handler.exception(conn, ex);
+    }
+
+    public void requestReady(final NHttpClientConnection conn) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Request ready");
+        }
+        this.handler.requestReady(conn);
+    }
+
+    public void outputReady(final NHttpClientConnection conn, final ContentEncoder encoder) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Output ready");
+        }
+        this.handler.outputReady(conn, encoder);
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Content encoder " + encoder);
+        }
+    }
+
+    public void responseReceived(final NHttpClientConnection conn) {
+        if (this.log.isDebugEnabled()) {
+            HttpResponse response = conn.getHttpResponse();
+            this.log.debug("HTTP connection " + conn + ": " + response.getStatusLine());
+        }
+        this.handler.responseReceived(conn);
+    }
+
+    public void inputReady(final NHttpClientConnection conn, final ContentDecoder decoder) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Input ready");
+        }
+        this.handler.inputReady(conn, decoder);
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Content decoder " + decoder);
+        }
+    }
+
+    public void timeout(final NHttpClientConnection conn) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Timeout");
+        }
+        this.handler.timeout(conn);
+    }
+
+}
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/LoggingNHttpServiceHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/LoggingNHttpServiceHandler.java?view=auto&rev=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/LoggingNHttpServiceHandler.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/LoggingNHttpServiceHandler.java Thu Jun 21 05:21:46 2007
@@ -0,0 +1,126 @@
+/*
+ *  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 java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.nio.ContentDecoder;
+import org.apache.http.nio.ContentEncoder;
+import org.apache.http.nio.NHttpServerConnection;
+import org.apache.http.nio.NHttpServiceHandler;
+
+/**
+ * Decorator class intended to transparently extend an {@link NHttpServiceHandler} 
+ * with basic event logging capabilities using Commons Logging. 
+ */
+public class LoggingNHttpServiceHandler implements NHttpServiceHandler {
+
+    private final Log log;
+    private final NHttpServiceHandler handler;
+    
+    public LoggingNHttpServiceHandler(final NHttpServiceHandler handler) {
+        super();
+        if (handler == null) {
+            throw new IllegalArgumentException("HTTP service handler may not be null");
+        }
+        this.handler = handler;
+        this.log = LogFactory.getLog(handler.getClass());
+    }
+    
+    public void connected(final NHttpServerConnection conn) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Connected");
+        }
+        this.handler.connected(conn);
+    }
+
+    public void closed(final NHttpServerConnection conn) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Closed");
+        }
+        this.handler.closed(conn);
+    }
+
+    public void exception(final NHttpServerConnection conn, final IOException ex) {
+        if (ex.getMessage().indexOf("Connection reset") != -1 ||
+            ex.getMessage().indexOf("forcibly closed")  != -1) {
+            this.log.warn("HTTP connection " + conn + ": " + ex.getMessage());
+        } else {
+            this.log.error("HTTP connection " + conn + ": " + ex.getMessage(), ex);
+        }
+        this.handler.exception(conn, ex);
+    }
+
+    public void exception(final NHttpServerConnection conn, final HttpException ex) {
+        if (ex.getMessage().indexOf("Connection reset") > 0 ||
+            ex.getMessage().indexOf("forcibly closed") > 0) {
+            this.log.warn("HTTP connection " + conn + ": " + ex.getMessage());
+        } else {
+            this.log.error("HTTP connection " + conn + ": " + ex.getMessage(), ex);
+        }
+        this.handler.exception(conn, ex);
+    }
+
+    public void requestReceived(final NHttpServerConnection conn) {
+        if (this.log.isDebugEnabled()) {
+            HttpRequest request = conn.getHttpRequest();
+            this.log.debug("HTTP connection " + conn + ": " + request.getRequestLine());
+        }
+        this.handler.requestReceived(conn);
+    }
+
+    public void outputReady(final NHttpServerConnection conn, final ContentEncoder encoder) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Output ready");
+        }
+        this.handler.outputReady(conn, encoder);
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Content encoder " + encoder);
+        }
+    }
+
+    public void responseReady(final NHttpServerConnection conn) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Response ready");
+        }
+        this.handler.responseReady(conn);
+    }
+
+    public void inputReady(final NHttpServerConnection conn, final ContentDecoder decoder) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Input ready");
+        }
+        this.handler.inputReady(conn, decoder);
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Content decoder " + decoder);
+        }
+    }
+
+    public void timeout(final NHttpServerConnection conn) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Timeout");
+        }
+        this.handler.timeout(conn);
+    }
+
+}
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/NHttpConfiguration.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/NHttpConfiguration.java?view=auto&rev=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/NHttpConfiguration.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/NHttpConfiguration.java Thu Jun 21 05:21:46 2007
@@ -0,0 +1,138 @@
+/*
+ *  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.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
+import org.apache.http.params.HttpConnectionParams;
+
+import java.util.Properties;
+import java.io.IOException;
+import java.net.URL;
+
+/**
+ * Store and manage properties that tune the nhttp transport
+ */
+public class NHttpConfiguration {
+
+    // defaults
+    private static final int WORKERS_CORE_THREADS  = 20;
+    private static final int WORKERS_MAX_THREADS   = 100;
+    private static final int WORKER_KEEP_ALIVE     = 5;
+    private static final int BLOCKING_QUEUE_LENGTH = -1;
+    private static final int IO_WORKER_COUNT = 2;
+    private static final int BUFFER_SIZE           = 2048;
+
+    // server listener
+    private static final String S_T_CORE     = "snd_t_core";
+    private static final String S_T_MAX      = "snd_t_max";
+    private static final String S_T_ALIVE    = "snd_alive_sec";
+    private static final String S_T_QLEN     = "snd_qlen";
+    private static final String S_IO_WORKERS = "snd_io_threads";
+
+    // client sender
+    private static final String C_T_CORE     = "lst_t_core";
+    private static final String C_T_MAX      = "lst_t_max";
+    private static final String C_T_ALIVE    = "lst_alive_sec";
+    private static final String C_T_QLEN     = "lst_qlen";
+    private static final String C_IO_WORKERS = "lst_io_threads";
+
+    // general
+    private static final String G_BUFFER_SIZE  = "nhttp_buffer_size";
+
+    private static final Log log = LogFactory.getLog(NHttpConfiguration.class);
+    private static NHttpConfiguration _instance = new NHttpConfiguration();
+    private Properties props = new Properties();
+
+    private NHttpConfiguration() {
+        try {
+            props.load(getClass().getClassLoader().getResourceAsStream("nhttp.properties"));
+        } catch (Exception ignore) {}
+    }
+
+    public static NHttpConfiguration getInstance() {
+        return _instance;
+    }
+
+    public int getServerCoreThreads() {
+        return getProperty(S_T_CORE, WORKERS_CORE_THREADS);
+    }
+
+    public int getServerMaxThreads() {
+        return getProperty(S_T_MAX, WORKERS_MAX_THREADS);
+    }
+
+    public int getServerKeepalive() {
+        return getProperty(S_T_ALIVE, WORKER_KEEP_ALIVE);
+    }
+
+    public int getServerQueueLen() {
+        return getProperty(S_T_QLEN, BLOCKING_QUEUE_LENGTH);
+    }
+
+    public int getServerIOWorkers() {
+        return getProperty(S_IO_WORKERS, IO_WORKER_COUNT);
+    }
+
+
+    public int getClientCoreThreads() {
+        return getProperty(C_T_CORE, WORKERS_CORE_THREADS);
+    }
+
+    public int getClientMaxThreads() {
+        return getProperty(C_T_MAX, WORKERS_MAX_THREADS);
+    }
+
+    public int getClientKeepalive() {
+        return getProperty(C_T_ALIVE, WORKER_KEEP_ALIVE);
+    }
+
+    public int getClientQueueLen() {
+        return getProperty(C_T_QLEN, BLOCKING_QUEUE_LENGTH);
+    }
+
+    public int getClientIOWorkers() {
+        return getProperty(C_IO_WORKERS, IO_WORKER_COUNT);
+    }
+
+    public int getBufferZise() {
+        return getProperty(G_BUFFER_SIZE, BUFFER_SIZE);
+    }
+
+    /**
+     * Get properties that tune nhttp transport. Preference to system properties
+     * @param name name of the system/config property
+     * @param def default value to return if the property is not set
+     * @return the value of the property to be used
+     */
+    public int getProperty(String name, int def) {
+        String val = System.getProperty(name);
+        if (val == null) {
+            val = props.getProperty(name);
+        }
+
+        if (val != null && Integer.valueOf(val).intValue() > 0) {
+            log.debug("Using nhttp tuning parameter : " + name + " = " + val);
+            return Integer.valueOf(val).intValue();
+        }        
+        return def;
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/NhttpConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/NhttpConstants.java?view=auto&rev=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/NhttpConstants.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/NhttpConstants.java Thu Jun 21 05:21:46 2007
@@ -0,0 +1,25 @@
+/*
+ *  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;
+
+public class NhttpConstants {
+    public static final String SC_ACCEPTED = "SC_ACCEPTED";
+    public static final String SENDING_FAULT = "sending_fault";
+}

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/PlainClientIOEventDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/PlainClientIOEventDispatch.java?view=auto&rev=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/PlainClientIOEventDispatch.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/PlainClientIOEventDispatch.java Thu Jun 21 05:21:46 2007
@@ -0,0 +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.nhttp;
+
+import org.apache.http.impl.DefaultHttpResponseFactory;
+import org.apache.http.impl.nio.DefaultNHttpClientConnection;
+import org.apache.http.nio.NHttpClientHandler;
+import org.apache.http.nio.reactor.IOEventDispatch;
+import org.apache.http.nio.reactor.IOSession;
+import org.apache.http.params.HttpParams;
+
+public class PlainClientIOEventDispatch implements IOEventDispatch {
+
+    private static final String NHTTP_CONN = "SYNAPSE.NHTTP_CONN";
+    
+    private final NHttpClientHandler handler;
+    private final HttpParams params;
+    
+    public PlainClientIOEventDispatch(final NHttpClientHandler handler, final HttpParams params) {
+        super();
+        if (handler == null) {
+            throw new IllegalArgumentException("HTTP client handler may not be null");
+        }
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        // Decorate client handler with logging capabilities
+        this.handler = new LoggingNHttpClientHandler(handler);
+        this.params = params;
+    }
+    
+    public void connected(final IOSession session) {
+        // Decorate I/O session with logging capabilities
+        DefaultNHttpClientConnection conn = new DefaultNHttpClientConnection(
+                new LoggingIOSession(session), 
+                new DefaultHttpResponseFactory(),
+                this.params); 
+        session.setAttribute(NHTTP_CONN, conn);
+        
+        Object attachment = session.getAttribute(IOSession.ATTACHMENT_KEY);
+        this.handler.connected(conn, attachment);
+    }
+
+    public void disconnected(final IOSession session) {
+        DefaultNHttpClientConnection conn = (DefaultNHttpClientConnection) session.getAttribute(
+                NHTTP_CONN);
+        this.handler.closed(conn);
+    }
+
+    public void inputReady(final IOSession session) {
+        DefaultNHttpClientConnection conn = (DefaultNHttpClientConnection) session.getAttribute(
+                NHTTP_CONN);
+        conn.consumeInput(this.handler);
+    }
+
+    public void outputReady(final IOSession session) {
+        DefaultNHttpClientConnection conn = (DefaultNHttpClientConnection) session.getAttribute(
+                NHTTP_CONN);
+        conn.produceOutput(this.handler);
+    }
+
+    public void timeout(final IOSession session) {
+        DefaultNHttpClientConnection conn = (DefaultNHttpClientConnection) session.getAttribute(
+                NHTTP_CONN);
+        this.handler.timeout(conn);
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/PlainServerIOEventDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/PlainServerIOEventDispatch.java?view=auto&rev=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/PlainServerIOEventDispatch.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/PlainServerIOEventDispatch.java Thu Jun 21 05:21:46 2007
@@ -0,0 +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.nhttp;
+
+import org.apache.http.impl.DefaultHttpRequestFactory;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
+import org.apache.http.nio.NHttpServiceHandler;
+import org.apache.http.nio.reactor.IOEventDispatch;
+import org.apache.http.nio.reactor.IOSession;
+import org.apache.http.params.HttpParams;
+
+public class PlainServerIOEventDispatch implements IOEventDispatch {
+
+    private static final String NHTTP_CONN = "SYNAPSE.NHTTP_CONN";
+    
+    private final NHttpServiceHandler handler;
+    private final HttpParams params;
+    
+    public PlainServerIOEventDispatch(final NHttpServiceHandler handler, final HttpParams params) {
+        super();
+        if (handler == null) {
+            throw new IllegalArgumentException("HTTP service handler may not be null");
+        }
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        // Decorate service handler with logging capabilities
+        this.handler = new LoggingNHttpServiceHandler(handler);
+        this.params = params;
+    }
+    
+    public void connected(final IOSession session) {
+        // Decorate I/O session with logging capabilities
+        DefaultNHttpServerConnection conn = new DefaultNHttpServerConnection(
+                new LoggingIOSession(session), 
+                new DefaultHttpRequestFactory(),
+                this.params); 
+        session.setAttribute(NHTTP_CONN, conn);
+        this.handler.connected(conn);
+    }
+
+    public void disconnected(final IOSession session) {
+        DefaultNHttpServerConnection conn = (DefaultNHttpServerConnection) session.getAttribute(
+                NHTTP_CONN);
+        this.handler.closed(conn);
+    }
+
+    public void inputReady(final IOSession session) {
+        DefaultNHttpServerConnection conn = (DefaultNHttpServerConnection) session.getAttribute(
+                NHTTP_CONN);
+        conn.consumeInput(this.handler);
+    }
+
+    public void outputReady(final IOSession session) {
+        DefaultNHttpServerConnection conn = (DefaultNHttpServerConnection) session.getAttribute(
+                NHTTP_CONN);
+        conn.produceOutput(this.handler);
+    }
+
+    public void timeout(final IOSession session) {
+        DefaultNHttpServerConnection conn = (DefaultNHttpServerConnection) session.getAttribute(
+                NHTTP_CONN);
+        this.handler.timeout(conn);
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/SSLClientIOEventDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/SSLClientIOEventDispatch.java?view=auto&rev=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/SSLClientIOEventDispatch.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/SSLClientIOEventDispatch.java Thu Jun 21 05:21:46 2007
@@ -0,0 +1,157 @@
+///*
+// *  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 java.io.IOException;
+//
+//import javax.net.ssl.SSLContext;
+//import javax.net.ssl.SSLException;
+//
+//import org.apache.http.impl.DefaultHttpResponseFactory;
+//import org.apache.http.impl.nio.DefaultNHttpClientConnection;
+//import org.apache.http.impl.nio.reactor.SSLIOSession;
+//import org.apache.http.impl.nio.reactor.SSLIOSessionHandler;
+//import org.apache.http.impl.nio.reactor.SSLMode;
+//import org.apache.http.nio.NHttpClientHandler;
+//import org.apache.http.nio.reactor.IOEventDispatch;
+//import org.apache.http.nio.reactor.IOSession;
+//import org.apache.http.params.HttpParams;
+//
+//public class SSLClientIOEventDispatch implements IOEventDispatch {
+//
+//    private static final String NHTTP_CONN = "SYNAPSE.NHTTP_CONN";
+//    private static final String SSL_SESSION = "SYNAPSE.SSL_SESSION";
+//
+//    private final NHttpClientHandler handler;
+//    private final HttpParams params;
+//    private final SSLContext sslcontext;
+//    private final SSLIOSessionHandler sslHandler;
+//
+//    public SSLClientIOEventDispatch(
+//            final NHttpClientHandler handler,
+//            final SSLContext sslcontext,
+//            final SSLIOSessionHandler sslHandler,
+//            final HttpParams params) {
+//        super();
+//        if (handler == null) {
+//            throw new IllegalArgumentException("HTTP client handler may not be null");
+//        }
+//        if (sslcontext == null) {
+//            throw new IllegalArgumentException("SSL context may not be null");
+//        }
+//        if (params == null) {
+//            throw new IllegalArgumentException("HTTP parameters may not be null");
+//        }
+//        this.handler = new LoggingNHttpClientHandler(handler);
+//        this.params = params;
+//        this.sslcontext = sslcontext;
+//        this.sslHandler = sslHandler;
+//    }
+//
+//    public SSLClientIOEventDispatch(
+//            final NHttpClientHandler handler,
+//            final SSLContext sslcontext,
+//            final HttpParams params) {
+//        this(handler, sslcontext, null, params);
+//    }
+//
+//    public void connected(final IOSession session) {
+//
+//        SSLIOSession sslSession = new SSLIOSession(
+//                session,
+//                this.sslcontext,
+//                this.sslHandler);
+//
+//        DefaultNHttpClientConnection conn = new DefaultNHttpClientConnection(
+//                new LoggingIOSession(sslSession),
+//                new DefaultHttpResponseFactory(),
+//                this.params);
+//
+//        session.setAttribute(NHTTP_CONN, conn);
+//        session.setAttribute(SSL_SESSION, sslSession);
+//
+//        Object attachment = session.getAttribute(IOSession.ATTACHMENT_KEY);
+//        this.handler.connected(conn, attachment);
+//
+//        try {
+//            sslSession.initialize(SSLMode.CLIENT, this.params);
+//        } catch (SSLException ex) {
+//            this.handler.exception(conn, ex);
+//            sslSession.shutdown();
+//        }
+//    }
+//
+//    public void disconnected(final IOSession session) {
+//        DefaultNHttpClientConnection conn = (DefaultNHttpClientConnection) session.getAttribute(
+//                NHTTP_CONN);
+//
+//        this.handler.closed(conn);
+//    }
+//
+//    public void inputReady(final IOSession session) {
+//        DefaultNHttpClientConnection conn = (DefaultNHttpClientConnection) session.getAttribute(
+//                NHTTP_CONN);
+//        SSLIOSession sslSession = (SSLIOSession) session.getAttribute(
+//                SSL_SESSION);
+//        try {
+//            synchronized (sslSession) {
+//                while (sslSession.isAppInputReady()) {
+//                    conn.consumeInput(this.handler);
+//                }
+//                sslSession.inboundTransport();
+//            }
+//        } catch (IOException ex) {
+//            this.handler.exception(conn, ex);
+//            sslSession.shutdown();
+//        }
+//    }
+//
+//    public void outputReady(final IOSession session) {
+//        DefaultNHttpClientConnection conn = (DefaultNHttpClientConnection) session.getAttribute(
+//                NHTTP_CONN);
+//        SSLIOSession sslSession = (SSLIOSession) session.getAttribute(
+//                SSL_SESSION);
+//        try {
+//            synchronized (sslSession) {
+//                if (sslSession.isAppOutputReady()) {
+//                    conn.produceOutput(this.handler);
+//                }
+//                sslSession.outboundTransport();
+//            }
+//        } catch (IOException ex) {
+//            this.handler.exception(conn, ex);
+//            sslSession.shutdown();
+//        }
+//    }
+//
+//    public void timeout(final IOSession session) {
+//        DefaultNHttpClientConnection conn = (DefaultNHttpClientConnection) session.getAttribute(
+//                NHTTP_CONN);
+//        SSLIOSession sslSession = (SSLIOSession) session.getAttribute(
+//                SSL_SESSION);
+//        this.handler.timeout(conn);
+//        synchronized (sslSession) {
+//            if (sslSession.isOutboundDone() && !sslSession.isInboundDone()) {
+//                // The session failed to terminate cleanly
+//                sslSession.shutdown();
+//            }
+//        }
+//    }
+//
+//}

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/SSLServerIOEventDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/SSLServerIOEventDispatch.java?view=auto&rev=549457
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/SSLServerIOEventDispatch.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/SSLServerIOEventDispatch.java Thu Jun 21 05:21:46 2007
@@ -0,0 +1,155 @@
+///*
+// *  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 java.io.IOException;
+//
+//import javax.net.ssl.SSLContext;
+//import javax.net.ssl.SSLException;
+//
+//import org.apache.http.impl.DefaultHttpRequestFactory;
+//import org.apache.http.impl.nio.DefaultNHttpServerConnection;
+//import org.apache.http.impl.nio.reactor.SSLIOSession;
+//import org.apache.http.impl.nio.reactor.SSLIOSessionHandler;
+//import org.apache.http.impl.nio.reactor.SSLMode;
+//import org.apache.http.nio.NHttpServiceHandler;
+//import org.apache.http.nio.reactor.IOEventDispatch;
+//import org.apache.http.nio.reactor.IOSession;
+//import org.apache.http.params.HttpParams;
+//
+//public class SSLServerIOEventDispatch implements IOEventDispatch {
+//
+//    private static final String NHTTP_CONN = "SYNAPSE.NHTTP_CONN";
+//    private static final String SSL_SESSION = "SYNAPSE.SSL_SESSION";
+//
+//    private final NHttpServiceHandler handler;
+//    private final SSLContext sslcontext;
+//    private final SSLIOSessionHandler sslHandler;
+//    private final HttpParams params;
+//
+//    public SSLServerIOEventDispatch(
+//            final NHttpServiceHandler handler,
+//            final SSLContext sslcontext,
+//            final SSLIOSessionHandler sslHandler,
+//            final HttpParams params) {
+//        super();
+//        if (handler == null) {
+//            throw new IllegalArgumentException("HTTP service handler may not be null");
+//        }
+//        if (sslcontext == null) {
+//            throw new IllegalArgumentException("SSL context may not be null");
+//        }
+//        if (params == null) {
+//            throw new IllegalArgumentException("HTTP parameters may not be null");
+//        }
+//        this.handler = new LoggingNHttpServiceHandler(handler);
+//        this.params = params;
+//        this.sslcontext = sslcontext;
+//        this.sslHandler = sslHandler;
+//    }
+//
+//    public SSLServerIOEventDispatch(
+//            final NHttpServiceHandler handler,
+//            final SSLContext sslcontext,
+//            final HttpParams params) {
+//        this(handler, sslcontext, null, params);
+//    }
+//
+//    public void connected(final IOSession session) {
+//
+//        SSLIOSession sslSession = new SSLIOSession(
+//                session,
+//                this.sslcontext,
+//                this.sslHandler);
+//
+//        DefaultNHttpServerConnection conn = new DefaultNHttpServerConnection(
+//                new LoggingIOSession(sslSession),
+//                new DefaultHttpRequestFactory(),
+//                this.params);
+//
+//        session.setAttribute(NHTTP_CONN, conn);
+//        session.setAttribute(SSL_SESSION, sslSession);
+//
+//        this.handler.connected(conn);
+//
+//        try {
+//            sslSession.initialize(SSLMode.SERVER, this.params);
+//        } catch (SSLException ex) {
+//            this.handler.exception(conn, ex);
+//            sslSession.shutdown();
+//        }
+//    }
+//
+//    public void disconnected(final IOSession session) {
+//        DefaultNHttpServerConnection conn = (DefaultNHttpServerConnection) session.getAttribute(
+//                NHTTP_CONN);
+//        this.handler.closed(conn);
+//    }
+//
+//    public void inputReady(final IOSession session) {
+//        DefaultNHttpServerConnection conn = (DefaultNHttpServerConnection) session.getAttribute(
+//                NHTTP_CONN);
+//        SSLIOSession sslSession = (SSLIOSession) session.getAttribute(
+//                SSL_SESSION);
+//        try {
+//            synchronized (sslSession) {
+//                if (sslSession.isAppInputReady()) {
+//                    conn.consumeInput(this.handler);
+//                }
+//                sslSession.inboundTransport();
+//            }
+//        } catch (IOException ex) {
+//            this.handler.exception(conn, ex);
+//            sslSession.shutdown();
+//        }
+//    }
+//
+//    public void outputReady(final IOSession session) {
+//        DefaultNHttpServerConnection conn = (DefaultNHttpServerConnection) session.getAttribute(
+//                NHTTP_CONN);
+//        SSLIOSession sslSession = (SSLIOSession) session.getAttribute(
+//                SSL_SESSION);
+//        try {
+//            synchronized (sslSession) {
+//                if (sslSession.isAppOutputReady()) {
+//                    conn.produceOutput(this.handler);
+//                }
+//                sslSession.outboundTransport();
+//            }
+//        } catch (IOException ex) {
+//            this.handler.exception(conn, ex);
+//            sslSession.shutdown();
+//        }
+//    }
+//
+//    public void timeout(final IOSession session) {
+//        DefaultNHttpServerConnection conn = (DefaultNHttpServerConnection) session.getAttribute(
+//                NHTTP_CONN);
+//        SSLIOSession sslSession = (SSLIOSession) session.getAttribute(
+//                SSL_SESSION);
+//        this.handler.timeout(conn);
+//        synchronized (sslSession) {
+//            if (sslSession.isOutboundDone() && !sslSession.isInboundDone()) {
+//                // The session failed to terminate cleanly
+//                sslSession.shutdown();
+//            }
+//        }
+//    }
+//
+//}



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message