You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by as...@apache.org on 2006/08/24 11:22:25 UTC

svn commit: r434353 [2/2] - in /incubator/synapse/trunk/java: ./ bin/ modules/core/ modules/core/conf/ modules/core/src/org/apache/synapse/ modules/core/src/org/apache/synapse/config/xml/ modules/core/src/org/apache/synapse/core/axis2/ modules/core/src...

Added: incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/AsyncHTTPListener.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/AsyncHTTPListener.java?rev=434353&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/AsyncHTTPListener.java (added)
+++ incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/AsyncHTTPListener.java Thu Aug 24 02:22:19 2006
@@ -0,0 +1,133 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed 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.transport.TransportListener;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.util.OptionsParser;
+import org.apache.axis2.engine.ListenerManager;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.safehaus.asyncweb.container.basic.BasicServiceContainer;
+import org.safehaus.asyncweb.container.basic.HttpServiceHandler;
+import org.safehaus.asyncweb.container.ContainerLifecycleException;
+import org.safehaus.asyncweb.container.resolver.ServiceResolver;
+import org.safehaus.asyncweb.transport.nio.NIOTransport;
+import org.safehaus.asyncweb.transport.nio.HttpIOHandler;
+import org.safehaus.asyncweb.http.HttpRequest;
+
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Iterator;
+import java.io.File;
+
+public class AsyncHTTPListener implements TransportListener {
+
+    private static final Log log = LogFactory.getLog(AsyncHTTPListener.class);
+
+    private ConfigurationContext cfgCtx = null;
+    private BasicServiceContainer svcCont = null;
+    private int port = 8080;
+    private int ioWorkerCount = 2;
+    private int maxKeepAlives = 100;
+    private int readIdleTime = 300;
+    private String hostAddress = null;
+    private String contextPath;
+
+    public AsyncHTTPListener() {
+    }
+
+    public AsyncHTTPListener(ConfigurationContext cfgCtx, int port) throws AxisFault {
+        this.cfgCtx = cfgCtx;
+        this.port = port;
+        TransportInDescription httpDescription = new TransportInDescription(
+            new QName(Constants.TRANSPORT_HTTP));
+        httpDescription.setReceiver(this);
+
+        ListenerManager listenerManager = cfgCtx.getListenerManager();
+        if (listenerManager == null) {
+            listenerManager = new ListenerManager();
+            listenerManager.init(cfgCtx);
+        }
+        cfgCtx.getListenerManager().addListener(httpDescription, true);
+    }
+
+    public void init(ConfigurationContext cfgCtx, TransportInDescription transprtIn) throws AxisFault {
+        this.cfgCtx = cfgCtx;
+        contextPath = cfgCtx.getContextPath();
+
+        try {
+            Parameter param = transprtIn.getParameter(PARAM_PORT);
+            if (param != null)
+                port = Integer.parseInt((String) param.getValue());
+
+            param = transprtIn.getParameter(HOST_ADDRESS);
+            if (param != null)
+                hostAddress = ((String) param.getValue()).trim();
+            else
+                hostAddress = java.net.InetAddress.getLocalHost().getHostName();
+
+        } catch (Exception e1) {
+            throw new AxisFault(e1);
+        }
+    }
+
+    public void start() throws AxisFault {
+        List svcHandlers = new ArrayList();
+        svcHandlers.add(
+            new org.apache.axis2.transport.nhttp.HttpServiceHandler(cfgCtx, port));
+
+        NIOTransport nioTransport = new NIOTransport();
+        nioTransport.setPort(port);
+        nioTransport.setIoWorkerCount(ioWorkerCount);
+        HttpIOHandler httpIOHandler = new HttpIOHandler();
+        httpIOHandler.setMaxKeepAlives(maxKeepAlives);
+        httpIOHandler.setReadIdleTime(readIdleTime);
+
+        nioTransport.setHttpIOHandler(httpIOHandler);
+        List transports = new ArrayList();
+        transports.add(nioTransport);
+
+        svcCont = new BasicServiceContainer();
+        svcCont.setServiceHandlers(svcHandlers);
+        svcCont.setTransports(transports);
+
+        try {
+            log.debug("Starting AsyncHTTPListener on port : " + port + "...");
+            svcCont.start();
+            log.info("Started AsyncHTTPListener on port : " + port);
+        } catch (ContainerLifecycleException e) {
+            throw new AxisFault("Error starting Async HTTP listener on port : "
+                + port + " : " + e.getMessage(), e);
+        }
+    }
+
+    public void stop() throws AxisFault {
+        svcCont.stop();
+        log.info("Async HTTP protocol listener shut down");
+    }
+
+    public EndpointReference getEPRForService(String serviceName, String ip) throws AxisFault {
+        return new EndpointReference("http://" + hostAddress + ":" + port + contextPath + "/" + serviceName);
+    }
+}

Added: incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/AsyncHTTPSender.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/AsyncHTTPSender.java?rev=434353&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/AsyncHTTPSender.java (added)
+++ incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/AsyncHTTPSender.java Thu Aug 24 02:22:19 2006
@@ -0,0 +1,157 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed 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.handlers.AbstractHandler;
+import org.apache.axis2.transport.TransportSender;
+import org.apache.axis2.transport.http.CommonsHTTPTransportSender;
+import org.apache.axis2.transport.http.HTTPTransportUtils;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.om.OMElement;
+import org.safehaus.asyncweb.http.HttpRequest;
+import org.safehaus.asyncweb.http.HttpResponse;
+import org.safehaus.asyncweb.http.ResponseStatus;
+
+import java.io.OutputStream;
+
+/**
+ * If the message is being sent to an EPR, this implementation currently sends it through the
+ * commons HTTP sender
+ */
+public class AsyncHTTPSender extends AbstractHandler implements TransportSender {
+
+    public void invoke(MessageContext msgContext) throws AxisFault {
+
+        OMOutputFormat format = new OMOutputFormat();
+        String charSetEnc = (String) msgContext.getProperty(
+            Constants.Configuration.CHARACTER_SET_ENCODING);
+
+        if (charSetEnc != null) {
+            format.setCharSetEncoding(charSetEnc);
+        } else {
+            OperationContext opctx = msgContext.getOperationContext();
+            if (opctx != null) {
+                charSetEnc = (String) opctx.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
+            }
+        }
+
+        /**
+         * If the char set enc is still not found use the default
+         */
+        if (charSetEnc == null) {
+            charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
+        }
+
+        msgContext.setDoingMTOM(HTTPTransportUtils.doWriteMTOM(msgContext));
+        msgContext.setDoingREST(HTTPTransportUtils.isDoingREST(msgContext));
+        format.setSOAP11(msgContext.isSOAP11());
+        format.setDoOptimize(msgContext.isDoingMTOM());
+        format.setCharSetEncoding(charSetEnc);
+
+        // Trasnport URL can be different from the WSA-To. So processing
+        // that now.
+        EndpointReference epr = null;
+        String transportURL = (String) msgContext.getProperty(
+            Constants.Configuration.TRANSPORT_URL);
+
+        if (transportURL != null) {
+            epr = 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())) {
+            epr = msgContext.getTo();
+        }
+
+        // Check for the REST behaviour, if you desire rest beahaviour
+        // put a <parameter name="doREST" value="true"/> at the
+        // server.xml/client.xml file
+        // ######################################################
+        // Change this place to change the wsa:toepr
+        // epr = something
+        // ######################################################
+        OMElement dataOut = null;
+
+        /**
+         * Figuringout the REST properties/parameters
+         */
+        if (msgContext.isDoingREST()) {
+            dataOut = msgContext.getEnvelope().getBody().getFirstElement();
+        } else {
+            dataOut = msgContext.getEnvelope();
+        }
+
+        if (epr != null) {
+            if (!epr.getAddress().equals(AddressingConstants.Final.WSA_NONE_URI)) {
+                new CommonsHTTPTransportSender().writeMessageWithCommons(
+                    msgContext, epr, dataOut, format);
+            }
+        } else {
+            if (msgContext.getProperty(Constants.OUT_TRANSPORT_INFO) != null) {
+                sendAsyncResponse(msgContext, format, dataOut);
+            }
+            else {
+                throw new AxisFault("Both the TO and Property MessageContext.TRANSPORT_OUT is Null, No where to send");
+            }
+        }
+
+        if (msgContext.getOperationContext() != null) {
+            msgContext.getOperationContext()
+                    .setProperty(Constants.RESPONSE_WRITTEN,
+                            Constants.VALUE_TRUE);
+        }
+    }
+
+    private void sendAsyncResponse(MessageContext msgContext, OMOutputFormat format, OMElement dataOut) throws AxisFault {
+
+        HttpRequest request = (HttpRequest) msgContext.getProperty(Constants.OUT_TRANSPORT_INFO);
+        HttpResponse response = request.createHttpResponse();
+
+        response.setStatus(ResponseStatus.OK);
+        OutputStream out = response.getOutputStream();
+
+        format.setDoOptimize(msgContext.isDoingMTOM());
+        try {
+            dataOut.serializeAndConsume(out, format);
+        } catch (Exception e) {
+            throw new AxisFault(e);
+        }
+
+        request.commitResponse(response);
+    }
+
+    public void cleanup(MessageContext msgContext) throws AxisFault {
+        // do nothing
+    }
+
+    public void init(ConfigurationContext confContext, TransportOutDescription transportOut) throws AxisFault {
+        // do nothing
+    }
+
+    public void stop() {
+        // do nothing
+    }
+}

Added: incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/Axis2AsyncWebProcessor.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/Axis2AsyncWebProcessor.java?rev=434353&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/Axis2AsyncWebProcessor.java (added)
+++ incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/Axis2AsyncWebProcessor.java Thu Aug 24 02:22:19 2006
@@ -0,0 +1,439 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed 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.safehaus.asyncweb.http.*;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.context.SessionContext;
+import org.apache.axis2.Constants;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.transport.njms.DefaultThreadFactory;
+import org.apache.axis2.transport.http.HTTPTransportUtils;
+import org.apache.axis2.transport.http.HTTPTransportReceiver;
+import org.apache.axis2.transport.http.server.SessionManager;
+import org.apache.axis2.util.UUIDGenerator;
+import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.description.AxisService;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.QName;
+import java.io.OutputStreamWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.*;
+import java.net.SocketException;
+import java.net.NetworkInterface;
+import java.net.InetAddress;
+
+import edu.emory.mathcs.backport.java.util.concurrent.*;
+
+public class Axis2AsyncWebProcessor implements HttpService {
+
+    private static final Log log = LogFactory.getLog(Axis2AsyncWebProcessor.class);
+
+    private static final String TEXT_PLAIN = "text/plain";
+    private static final String CONTENT_TYPE = "ContentType";
+
+    private static final int WORKERS_MAX_THREADS = 40;
+    private static final long WORKER_KEEP_ALIVE = 100L;
+    private static final TimeUnit TIME_UNIT = TimeUnit.SECONDS;
+    private Executor workerPool = null;
+    private SessionManager sessionManager = new SessionManager();
+    private int port = 8080;
+
+    private ConfigurationContext configurationContext = null;
+
+    Axis2AsyncWebProcessor(int port) {
+        this.port = port;
+        // create thread pool of workers
+        workerPool = new ThreadPoolExecutor(
+            1,
+            WORKERS_MAX_THREADS, WORKER_KEEP_ALIVE, TIME_UNIT,
+            new LinkedBlockingQueue(),
+            new DefaultThreadFactory(
+                    new ThreadGroup("HTTP Worker thread group"),
+                    "HTTPWorker"));
+    }
+
+    public void setConfigurationContext(ConfigurationContext configurationContext) {
+        this.configurationContext = configurationContext;
+    }
+
+    public void handleRequest(HttpRequest request) {
+
+        log.debug("@@@@ Got new Async HTTP request for: " +
+            request.getRequestURI() + " on port : " + port);
+
+        MessageContext msgContext = new MessageContext();
+        msgContext.setIncomingTransportName(Constants.TRANSPORT_HTTP);
+        try {
+            TransportOutDescription transportOut = configurationContext.getAxisConfiguration()
+                .getTransportOut(new QName(Constants.TRANSPORT_HTTP));
+            TransportInDescription transportIn = configurationContext.getAxisConfiguration()
+                .getTransportIn(new QName(Constants.TRANSPORT_HTTP));
+
+            msgContext.setConfigurationContext(configurationContext);
+
+            String sessionKey = request.getSession(true).getId();
+            if (configurationContext.getAxisConfiguration().isManageTransportSession()) {
+                SessionContext sessionContext = sessionManager.getSessionContext(sessionKey);
+                msgContext.setSessionContext(sessionContext);
+            }
+
+            msgContext.setTransportIn(transportIn);
+            msgContext.setTransportOut(transportOut);
+            msgContext.setServiceGroupContextId(UUIDGenerator.getUUID());
+            msgContext.setServerSide(true);
+            msgContext.setProperty(Constants.Configuration.TRANSPORT_IN_URL, request.getRequestURI());
+
+            // set the transport Headers
+            Map headerMap = new HashMap();
+            for (Iterator it = request.getHeaderNames(); it.hasNext(); ) {
+                String headerName = (String) it.next();
+                headerMap.put(headerName, request.getHeader(headerName));
+            }
+            msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, headerMap);
+            msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, request);
+
+            workerPool.execute(new Worker(msgContext, request));
+
+        } catch (AxisFault e) {
+            HttpResponse response = request.createHttpResponse();
+
+            try {
+                AxisEngine engine = new AxisEngine(configurationContext);
+                msgContext.setProperty(MessageContext.TRANSPORT_OUT, response.getOutputStream());
+                msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, response.getOutputStream());
+
+                MessageContext faultContext = engine.createFaultMessageContext(msgContext, e);
+                engine.sendFault(faultContext);
+
+                response.setStatus(ResponseStatus.INTERNAL_SERVER_ERROR);
+
+            } catch (Exception ex) {
+                response.setStatus(ResponseStatus.INTERNAL_SERVER_ERROR);
+                response.setHeader(CONTENT_TYPE, TEXT_PLAIN);
+                OutputStreamWriter out = new OutputStreamWriter(
+                    response.getOutputStream());
+                try {
+                    out.write(ex.getMessage());
+                    out.close();
+                } catch (IOException ee) {}
+            }
+            request.commitResponse(response);
+            return;
+        }
+    }
+
+    public void start() {
+    }
+
+    public void stop() {
+    }
+
+    class Worker implements Runnable {
+
+        private MessageContext msgContext = null;
+        private HttpRequest request = null;
+        private String contextPath = null;
+        private String servicePath = null;
+        private static final String SOAPACTION = "SOAPAction";
+        private static final String TEXT_HTML = "text/html";
+        private static final String CONTENT_TYPE = Axis2AsyncWebProcessor.CONTENT_TYPE;
+        private static final String TRANSFER_ENCODING = "Transfer-Encoding";
+        private static final String CHUNKED = "chunked";
+        private static final String LOCATION = "Location";
+
+        Worker(MessageContext msgContext, HttpRequest request) {
+            this.msgContext = msgContext;
+            this.request = request;
+            contextPath = configurationContext.getContextPath() + "/";
+            servicePath = configurationContext.getServicePath();
+        }
+
+        public void run() {
+
+            // TODO handle chunking and correct http versions
+            HttpResponse response = request.createHttpResponse();
+
+            if (HttpMethod.GET.equals(request.getMethod())) {
+                processGet(response);
+
+            } else if (HttpMethod.POST.equals(request.getMethod())) {
+                processPost(response);
+
+                // Finalize response
+                OperationContext operationContext = msgContext.getOperationContext();
+                Object contextWritten = null;
+                if (operationContext != null) {
+                    contextWritten = operationContext.getProperty(Constants.RESPONSE_WRITTEN);
+                }
+
+                if (!(contextWritten != null && "SKIP".equals(contextWritten))) {
+
+                    if ((contextWritten != null) && Constants.VALUE_TRUE.equals(contextWritten)) {
+                        response.setStatus(ResponseStatus.OK);
+                    } else {
+                        response.setStatus(ResponseStatus.ACCEPTED);
+                    }
+                    request.commitResponse(response);
+                }
+
+            } else {
+                handleException("Unsupported method : " + request.getMethod(), null, response);
+            }
+        }
+
+        private void processGet(HttpResponse response) {
+
+            String uri = request.getRequestURI();
+            String serviceName = uri.substring(uri.lastIndexOf("/") + 1);
+
+            Map parameters = new HashMap();
+            Iterator iter = request.getParameterNames();
+            while (iter.hasNext()) {
+                String name = (String) iter.next();
+                parameters.put(name, request.getParameter(name));
+            }
+
+            if (uri.equals("/favicon.ico")) {
+                response.setStatus(ResponseStatus.MOVED_PERMANENTLY);
+                response.addHeader(LOCATION, "http://ws.apache.org/favicon.ico");
+
+            } else if (!uri.startsWith(contextPath)) {
+                response.setStatus(ResponseStatus.MOVED_PERMANENTLY);
+                response.addHeader(LOCATION, contextPath);
+
+            } else if (parameters.containsKey("wsdl")) {
+                AxisService service = (AxisService) configurationContext.getAxisConfiguration().
+                    getServices().get(serviceName);
+                if (service != null) {
+                    try {
+                        service.printWSDL(response.getOutputStream(),
+                            getIpAddress(), servicePath);
+                        response.setHeader(CONTENT_TYPE, TEXT_HTML);
+                        response.setStatus(ResponseStatus.OK);
+
+                    } catch (AxisFault e) {
+                        handleException("Axis2 fault writing ?wsdl output", e, response);
+                        return;
+                    } catch (SocketException e) {
+                        handleException("Error getting ip address for ?wsdl output", e, response);
+                        return;
+                    }
+                }
+
+            } else if (parameters.containsKey("wsdl2")) {
+                AxisService service = (AxisService) configurationContext.getAxisConfiguration().
+                    getServices().get(serviceName);
+                if (service != null) {
+                    try {
+                        service.printWSDL2(response.getOutputStream(),
+                            getIpAddress(), servicePath);
+                        response.setHeader(CONTENT_TYPE, TEXT_HTML);
+                        response.setStatus(ResponseStatus.OK);
+
+                    } catch (AxisFault e) {
+                        handleException("Axis2 fault writing ?wsdl2 output", e, response);
+                        return;
+                    } catch (SocketException e) {
+                        handleException("Error getting ip address for ?wsdl2 output", e, response);
+                        return;
+                    }
+                }
+
+            } else if (parameters.containsKey("xsd")) {
+                if (parameters.get("xsd") == null || "".equals(parameters.get("xsd"))) {
+                    AxisService service = (AxisService) configurationContext.getAxisConfiguration()
+                        .getServices().get(serviceName);
+                    if (service != null) {
+                        try {
+                            service.printSchema(response.getOutputStream());
+                            response.setHeader(CONTENT_TYPE, TEXT_HTML);
+                            response.setStatus(ResponseStatus.OK);
+
+                        } catch (AxisFault axisFault) {
+                            handleException("Error writing ?xsd output to client", axisFault, response);
+                            return;
+                        }
+                    }
+
+                } else {
+                    //cater for named xsds - check for the xsd name
+                    String schemaName = (String) parameters.get("xsd");
+                    AxisService service = (AxisService) configurationContext.getAxisConfiguration()
+                        .getServices().get(serviceName);
+
+                    if (service != null) {
+                        //run the population logic just to be sure
+                        service.populateSchemaMappings();
+                        //write out the correct schema
+                        Hashtable schemaTable = service.getSchemaMappingTable();
+                        final XmlSchema schema = (XmlSchema)schemaTable.get(schemaName);
+                        //schema found - write it to the stream
+                        if (schema != null) {
+                            schema.write(response.getOutputStream());
+                            response.setHeader(CONTENT_TYPE, TEXT_HTML);
+                            response.setStatus(ResponseStatus.OK);
+                        } else {
+                            // no schema available by that name  - send 404
+                            response.setStatus(ResponseStatus.NOT_FOUND, "Schema Not Found");
+                        }
+                    }
+                }
+
+            } else if (parameters.isEmpty()) {
+
+                // request is for a service over GET without params, send service HTML
+                if (!(uri.endsWith(contextPath) || uri.endsWith(contextPath+"/"))) {
+
+                    OutputStreamWriter out = new OutputStreamWriter(
+                        response.getOutputStream());
+                    try {
+                        out.write(
+                            HTTPTransportReceiver.printServiceHTML(
+                                serviceName, configurationContext));
+                        out.close();
+                        response.setHeader(CONTENT_TYPE, TEXT_HTML);
+                        response.setStatus(ResponseStatus.OK);
+
+                    } catch (IOException e) {
+                        handleException("Error writing service HTML to client", e, response);
+                        return;
+                    }
+                } else {
+                    processAxisGet(response, parameters);
+                }
+            }
+
+            request.commitResponse(response);
+        }
+
+        public void processPost(HttpResponse response) {
+
+            try {
+                HTTPTransportUtils.processHTTPPostRequest(
+                    msgContext,
+                    request.getInputStream(),
+                    response.getOutputStream(),
+                    request.getHeader(CONTENT_TYPE),
+                    request.getHeader(SOAPACTION),
+                    request.getRequestURI());
+            } catch (AxisFault e) {
+                handleException("Error processing POST request ", e, response);
+            }
+        }
+
+        private void processAxisGet(HttpResponse response, Map parameters) {
+            try {
+                // deal with GET request
+                boolean processed = HTTPTransportUtils.processHTTPGetRequest(
+                    msgContext,
+                    response.getOutputStream(),
+                    request.getHeader(SOAPACTION),
+                    request.getRequestURI(),
+                    configurationContext,
+                    parameters);
+
+                if (!processed) {
+                    OutputStreamWriter out = new OutputStreamWriter(
+                        response.getOutputStream());
+                    try {
+                        out.write(HTTPTransportReceiver.getServicesHTML(configurationContext));
+                        out.flush();
+                        response.setHeader(CONTENT_TYPE, TEXT_HTML);
+                        response.setStatus(ResponseStatus.OK);
+
+                    } catch (IOException e) {
+                        handleException("Error writing ? output to client", e, response);
+                    }
+                }
+            } catch (AxisFault e) {
+                handleException("Axis fault while serving GET request", e, response);
+            }
+        }
+
+        private void handleException(String msg, Exception e, HttpResponse response) {
+            log.error(msg, e);
+
+            try {
+                AxisEngine engine = new AxisEngine(configurationContext);
+                msgContext.setProperty(MessageContext.TRANSPORT_OUT, response.getOutputStream());
+                msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, response.getOutputStream());
+                MessageContext faultContext = engine.createFaultMessageContext(msgContext, e);
+                engine.sendFault(faultContext);
+
+            } catch (Exception ex) {
+                response.setHeader(CONTENT_TYPE, TEXT_PLAIN);
+                OutputStreamWriter out = new OutputStreamWriter(
+                    response.getOutputStream());
+                try {
+                    out.write(ex.getMessage());
+                    out.close();
+                } catch (IOException ee) {}
+
+            } finally {
+                response.setStatus(ResponseStatus.INTERNAL_SERVER_ERROR);
+                request.commitResponse(response);
+            }
+        }
+    }
+
+    /**
+     * 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 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: incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpServiceHandler.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpServiceHandler.java?rev=434353&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpServiceHandler.java (added)
+++ incubator/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpServiceHandler.java Thu Aug 24 02:22:19 2006
@@ -0,0 +1,48 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed 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.safehaus.asyncweb.container.ServiceHandler;
+import org.safehaus.asyncweb.request.AsyncWebRequest;
+import org.safehaus.asyncweb.request.AsyncWebResponse;
+import org.safehaus.asyncweb.util.InvocationChain;
+import org.apache.axis2.context.ConfigurationContext;
+
+public class HttpServiceHandler implements ServiceHandler {
+
+    private Axis2AsyncWebProcessor service = null;
+
+    public HttpServiceHandler(ConfigurationContext cc, int port) {
+        service = new Axis2AsyncWebProcessor(port);
+        service.setConfigurationContext(cc);
+    }
+
+    public void handleRequest(AsyncWebRequest request, InvocationChain handlerChain) {
+        service.handleRequest(request);
+        handlerChain.invokeNext();
+    }
+
+    public void start() {
+    }
+
+    public void stop() {
+    }
+
+    public void handleResponse(AsyncWebRequest asyncWebRequest,
+        AsyncWebResponse asyncWebResponse, InvocationChain responseChain) {
+        responseChain.invokeNext();
+    }
+}

Modified: incubator/synapse/trunk/java/modules/samples/src/samples/userguide/ProxyStockQuoteClient.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/samples/src/samples/userguide/ProxyStockQuoteClient.java?rev=434353&r1=434352&r2=434353&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/src/samples/userguide/ProxyStockQuoteClient.java (original)
+++ incubator/synapse/trunk/java/modules/samples/src/samples/userguide/ProxyStockQuoteClient.java Thu Aug 24 02:22:19 2006
@@ -26,7 +26,7 @@
 
         String symbol = "IBM";
         String xurl   = "http://localhost:9000/axis2/services/SimpleStockQuoteService";
-        String purl   = "http://localhost:8080";
+        String purl   = "http://localhost:8081";
         String sAction= "urn:getQuote";
 
         if (args.length > 0) symbol = args[0];

Modified: incubator/synapse/trunk/java/project.properties
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/project.properties?rev=434353&r1=434352&r2=434353&view=diff
==============================================================================
--- incubator/synapse/trunk/java/project.properties (original)
+++ incubator/synapse/trunk/java/project.properties Thu Aug 24 02:22:19 2006
@@ -8,7 +8,8 @@
 http://www.openejb.org/maven,\
 http://dist.codehaus.org/,\
 http://mirrors.sunsite.dk/maven/,\
-http://jibx.sourceforge.net/maven/
+http://jibx.sourceforge.net/maven/,\
+http://people.apache.org/~asankha/maven/
 
 # -------------------------------------------------------------------
 #                xdoc
@@ -26,7 +27,8 @@
 # -------------------------------------------------------------------
 # explicit setting of Sax parser as below is a hack to avoid Junit from loading its own parsers ignoring maven.test.excludeXmlApis
 # explicit setting of the SchemaFactory class as the default one in Java 5 does not support schema-full-checking and honour-all-schemaLocations features
-maven.junit.jvmargs=-Djava.awt.headless=true -Dorg.xml.sax.driver=org.apache.xerces.parsers.SAXParser -Djavax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema=org.apache.xerces.jaxp.validation.XMLSchemaFactory
+#maven.junit.jvmargs=-Djava.awt.headless=true -Dorg.xml.sax.driver=org.apache.xerces.parsers.SAXParser -Djavax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema=org.apache.xerces.jaxp.validation.XMLSchemaFactory -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_shmem,server=y,suspend=y,address=javadebug
+maven.junit.jvmargs=-Djava.awt.headless=true -Dorg.xml.sax.driver=org.apache.xerces.parsers.SAXParser -Djavax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema=org.apache.xerces.jaxp.validation.XMLSchemaFactory 
 maven.junit.fork=yes 
 maven.test.excludeXmlApis=yes
 #maven.junit.dir=${basedir}/modules/core
@@ -69,8 +71,8 @@
 opensaml.version=1.0.1
 stax.impl.groupid=woodstox
 stax.impl.artifactid=wstx
-stax.impl.version=asl-2.9.3
-stax.api.version=1.0
+stax.impl.version=asl-3.0.0
+stax.api.version=1.0.1
 xalan.version=2.7.0
 xerces.version=2.8.0
 xmlunit.version=1.0
@@ -83,12 +85,18 @@
 js.version=1.6R2
 xbean.version=2.1.0
 
+mina.version=0.8.0
+slf4j.version=1.0
+asyncWeb.version=0.8.2
+concurrent.version=1.3.4
+
 # -------------------------------------------------------------------
 #                Multiproject includes and excludes
 # -------------------------------------------------------------------
 
 optional.includes=
 maven.multiproject.includes=\
+modules/nhttp/project.xml,\
 modules/core/project.xml,\
 modules/mediators/project.xml,\
 modules/samples/project.xml,\

Modified: incubator/synapse/trunk/java/project.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/project.xml?rev=434353&r1=434352&r2=434353&view=diff
==============================================================================
--- incubator/synapse/trunk/java/project.xml (original)
+++ incubator/synapse/trunk/java/project.xml Thu Aug 24 02:22:19 2006
@@ -291,7 +291,58 @@
             <properties>
                 <module>true</module>
             </properties>
-        </dependency> 
+        </dependency>
+        
+        <!-- For nhttp --> 
+        <dependency>
+            <groupId>directory-network</groupId>
+            <artifactId>mina</artifactId>
+            <version>${mina.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+			      <groupId>concurrent</groupId>
+	    		  <artifactId>concurrent</artifactId>
+      			<version>1.3.4</version>
+            <properties>
+                <module>true</module>
+            </properties>
+    		</dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <version>${slf4j.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>asyncweb</groupId>
+            <artifactId>asyncWeb</artifactId>
+            <version>${asyncWeb.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>asyncweb</groupId>
+            <artifactId>asyncWeb_API</artifactId>
+            <version>${asyncWeb.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>asyncweb</groupId>
+            <artifactId>asyncWeb_CommonCodecs</artifactId>
+            <version>${asyncWeb.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+
 
     </dependencies>
 

Modified: incubator/synapse/trunk/java/repository/conf/axis2.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/repository/conf/axis2.xml?rev=434353&r1=434352&r2=434353&view=diff
==============================================================================
--- incubator/synapse/trunk/java/repository/conf/axis2.xml (original)
+++ incubator/synapse/trunk/java/repository/conf/axis2.xml Thu Aug 24 02:22:19 2006
@@ -26,7 +26,6 @@
     <!-- ==================================================== -->
     <parameter name="Sandesha2StorageManager" locked="false">inmemory</parameter>
     <module ref="addressing"/>
-    <module ref="rampart"/>
     <module ref="synapse"/>
 
     <!-- ==================================================== -->
@@ -47,9 +46,10 @@
     <!-- ================================================= -->
     <!-- Transport Ins -->
     <!-- ================================================= -->
-    <transportReceiver name="http"
+    <transportReceiver name="http" class="org.apache.axis2.transport.nhttp.AsyncHTTPListener"/>
+    <!--<transportReceiver name="http"
                        class="org.apache.axis2.transport.http.SimpleHTTPServer">
-        <parameter name="port" locked="false">6060</parameter>
+        <parameter name="port" locked="false">6060</parameter>-->
     <!-- Here is the complete list of supported parameters (see example settings further below):
         port: the port to listen on (default 6060)
         hostname:  if non-null, url prefix used in reply-to endpoint references                                 (default null)
@@ -72,7 +72,7 @@
         <!-- <parameter name="RequestMaxThreadPoolSize"  locked="false">100</parameter>                     -->
         <!-- <parameter name="threadKeepAliveTime"       locked="false">240000</parameter>                  -->
         <!-- <parameter name="threadKeepAliveTimeUnit"   locked="false">MILLISECONDS</parameter>            -->
-    </transportReceiver>
+    <!--</transportReceiver>-->
 
     <transportReceiver name="tcp"
                        class="org.apache.axis2.transport.tcp.TCPServer">
@@ -81,6 +81,27 @@
         <!--uncommet following paramter , and set as you required.-->
         <!--<parameter name="hostname" locked="false">tcp://myApp.com/ws</parameter>-->
     </transportReceiver>
+    
+    <!--Uncomment this for JMS after setting up your JMS environment (e.g. ActiveMQ)
+    <transportReceiver name="jms" class="org.apache.axis2.transport.njms.JMSListener">
+        <parameter name="myTopicConnectionFactory" locked="false">        	        	
+        	<parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+        	<parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>        	
+        	<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">TopicConnectionFactory</parameter>
+        </parameter>
+
+        <parameter name="myQueueConnectionFactory" locked="false">        	        	
+        	<parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+        	<parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>        	
+        	<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
+        </parameter>
+
+        <parameter name="default" locked="false">        	        	
+        	<parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+        	<parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>        	
+        	<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
+        </parameter>
+    </transportReceiver>-->
 
     <!-- ================================================= -->
     <!-- Transport Outs -->
@@ -91,9 +112,11 @@
     <transportSender name="local"
                      class="org.apache.axis2.transport.local.LocalTransportSender"/>
     <transportSender name="jms"
-                     class="org.apache.axis2.transport.jms.JMSSender"/>
+                     class="org.apache.axis2.transport.njms.JMSSender"/>
+    <!--<transportSender name="http"
+                     class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">-->
     <transportSender name="http"
-                     class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+                     class="org.apache.axis2.transport.nhttp.AsyncHTTPSender">
         <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
         <!--<parameter name="Transfer-Encoding" locked="false">chunked</parameter>-->
     </transportSender>



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