You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by de...@apache.org on 2008/06/24 13:07:10 UTC

svn commit: r671127 [8/8] - in /webservices/axis2/trunk/java: ./ modules/addressing/ modules/clustering/ modules/clustering/test/org/apache/axis2/clustering/ modules/integration/ modules/integration/test-resources/deployment/ modules/integration/test/o...

Added: webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/local/LocalResponseTransportOutDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/local/LocalResponseTransportOutDescription.java?rev=671127&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/local/LocalResponseTransportOutDescription.java (added)
+++ webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/local/LocalResponseTransportOutDescription.java Tue Jun 24 04:07:03 2008
@@ -0,0 +1,148 @@
+/*
+ * 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.local;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.Flow;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.engine.Phase;
+import org.apache.axis2.transport.TransportSender;
+
+import java.util.ArrayList;
+
+/**
+ * This is wrapper class of TransportOutDescription class.
+ * In Using Axis2 Local Transport, you can't send SOAP Message successively.
+ */
+
+class LocalResponseTransportOutDescription extends TransportOutDescription {
+
+    private TransportSender sender = null;
+
+    private TransportOutDescription tOut = null;
+
+    public LocalResponseTransportOutDescription(
+            TransportOutDescription localTransportSenderDescription)
+            throws AxisFault {
+
+        super(localTransportSenderDescription.getName());
+
+        this.tOut = localTransportSenderDescription;
+    }
+
+    /**
+     * Method addParameter.
+     * 
+     * @param param
+     */
+    public void addParameter(Parameter param) throws AxisFault {
+        tOut.addParameter(param);
+    }
+
+    public void removeParameter(Parameter param) throws AxisFault {
+        tOut.removeParameter(param);
+    }
+
+    public void deserializeParameters(OMElement parameterElement)
+            throws AxisFault {
+        tOut.deserializeParameters(parameterElement);
+    }
+
+    public Flow getFaultFlow() {
+        return tOut.getFaultFlow();
+    }
+
+    public Phase getFaultPhase() {
+        return tOut.getFaultPhase();
+    }
+
+    /**
+     * @return Returns String.
+     */
+    public String getName() {
+        return tOut.getName();
+    }
+
+    public Flow getOutFlow() {
+        return tOut.getOutFlow();
+    }
+
+    public Phase getOutPhase() {
+        return tOut.getOutPhase();
+    }
+
+    /**
+     * Method getParameter.
+     * 
+     * @param name
+     * @return Returns Parameter.
+     */
+    public Parameter getParameter(String name) {
+        return tOut.getParameter(name);
+    }
+
+    public ArrayList getParameters() {
+        return tOut.getParameters();
+    }
+
+    /**
+     * @return Returns TransportSender.
+     */
+    public TransportSender getSender() {
+        return this.sender;
+    }
+
+    // to check whether the parameter is locked at any level
+    public boolean isParameterLocked(String parameterName) {
+        return tOut.isParameterLocked(parameterName);
+    }
+
+    public void setFaultFlow(Flow faultFlow) {
+        tOut.setFaultFlow(faultFlow);
+    }
+
+    public void setFaultPhase(Phase faultPhase) {
+        tOut.setFaultPhase(faultPhase);
+    }
+
+    /**
+     * @param name
+     */
+    public void setName(String name) {
+        tOut.setName(name);
+    }
+
+    public void setOutFlow(Flow outFlow) {
+        tOut.setOutFlow(outFlow);
+    }
+
+    public void setOutPhase(Phase outPhase) {
+        tOut.setOutPhase(outPhase);
+    }
+
+    /**
+     * @param sender
+     */
+    public void setSender(TransportSender sender) {
+        this.sender = sender;
+    }
+}

Added: webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/local/LocalTransportReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/local/LocalTransportReceiver.java?rev=671127&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/local/LocalTransportReceiver.java (added)
+++ webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/local/LocalTransportReceiver.java Tue Jun 24 04:07:03 2008
@@ -0,0 +1,103 @@
+/*
+ * 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.local;
+
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.builder.BuilderUtil;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.util.MessageContextBuilder;
+
+import javax.xml.stream.XMLStreamException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+
+public class LocalTransportReceiver {
+    public static ConfigurationContext CONFIG_CONTEXT;
+    private ConfigurationContext confContext;
+
+    public LocalTransportReceiver(ConfigurationContext configContext) {
+        confContext = configContext;
+    }
+
+    public LocalTransportReceiver(LocalTransportSender sender) {
+        this(CONFIG_CONTEXT);
+    }
+
+    public void processMessage(InputStream in, EndpointReference to, String action, OutputStream response)
+            throws AxisFault {
+        MessageContext msgCtx = confContext.createMessageContext();
+        TransportInDescription tIn = confContext.getAxisConfiguration().getTransportIn(
+                Constants.TRANSPORT_LOCAL);
+        TransportOutDescription tOut = confContext.getAxisConfiguration().getTransportOut(
+                Constants.TRANSPORT_LOCAL);
+                
+        // CAUTION : When using Local Transport of Axis2,  class LocalTransportReceiver changed the name of LocalTransportSender's class in configContext.
+        // We escaped this problem by the following code.
+        LocalResponseTransportOutDescription localTransportResOut = new LocalResponseTransportOutDescription(
+                tOut);
+        localTransportResOut.setSender(new LocalResponder(response));
+        
+        try {
+            msgCtx.setTransportIn(tIn);
+            msgCtx.setTransportOut(localTransportResOut);
+            msgCtx.setProperty(MessageContext.TRANSPORT_OUT, response);
+
+            msgCtx.setTo(to);
+            msgCtx.setWSAAction(action);
+            msgCtx.setServerSide(true);
+
+            InputStreamReader streamReader = new InputStreamReader(in);
+            OMXMLParserWrapper builder;
+            try {
+                builder = BuilderUtil.getBuilder(streamReader);
+            } catch (XMLStreamException e) {
+                throw AxisFault.makeFault(e);
+            }
+            SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
+
+            msgCtx.setEnvelope(envelope);
+
+            AxisEngine.receive(msgCtx);
+        } catch (AxisFault e) {
+            // write the fault back.
+            try {
+                MessageContext faultContext =
+                        MessageContextBuilder.createFaultMessageContext(msgCtx, e);
+                faultContext.setTransportOut(localTransportResOut);
+                faultContext.setProperty(MessageContext.TRANSPORT_OUT, response);
+
+                AxisEngine.sendFault(faultContext);
+            } catch (AxisFault axisFault) {
+                // can't handle this, so just throw it
+                throw axisFault;
+            }
+        }
+    }
+}

Added: webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/local/LocalTransportSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/local/LocalTransportSender.java?rev=671127&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/local/LocalTransportSender.java (added)
+++ webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/local/LocalTransportSender.java Tue Jun 24 04:07:03 2008
@@ -0,0 +1,114 @@
+/*
+ * 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.local;
+
+import org.apache.axis2.AxisFault;
+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.handlers.AbstractHandler;
+import org.apache.axis2.transport.TransportSender;
+import org.apache.axis2.transport.TransportUtils;
+import org.apache.axis2.transport.http.HTTPTransportUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class LocalTransportSender extends AbstractHandler implements TransportSender {
+    protected static final Log log = LogFactory.getLog(LocalTransportSender.class);
+
+    public void init(ConfigurationContext confContext, TransportOutDescription transportOut)
+            throws AxisFault {
+    }
+
+    public void stop() {
+    }
+
+    public void cleanup(MessageContext msgContext) throws AxisFault {
+    }
+
+    /**
+     * Method invoke
+     *
+     * @param msgContext the current MessageContext
+     * @throws AxisFault
+     */
+    public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
+
+        // Check for the REST behaviour, if you desire rest beahaviour
+        // put a <parameter name="doREST" value="true"/> at the axis2.xml
+        msgContext.setDoingMTOM(HTTPTransportUtils.doWriteMTOM(msgContext));
+        msgContext.setDoingSwA(HTTPTransportUtils.doWriteSwA(msgContext));
+
+        OutputStream out;
+        EndpointReference epr = msgContext.getTo();
+
+        if (log.isDebugEnabled()) {
+            ByteArrayOutputStream os = new ByteArrayOutputStream();
+            TransportUtils.writeMessage(msgContext, os);
+            log.debug("Sending - " + new String(os.toByteArray()));
+        }
+
+        if (epr != null) {
+            if (!epr.hasNoneAddress()) {
+                out = new ByteArrayOutputStream();
+                TransportUtils.writeMessage(msgContext, out);
+                finalizeSendWithToAddress(msgContext, (ByteArrayOutputStream)out);
+            }
+        } else {
+            out = (OutputStream) msgContext.getProperty(MessageContext.TRANSPORT_OUT);
+
+            if (out != null) {
+                TransportUtils.writeMessage(msgContext, out);
+            } else {
+                throw new AxisFault(
+                        "Both the TO and Property MessageContext.TRANSPORT_OUT is Null, No where to send");
+            }
+        }
+
+        TransportUtils.setResponseWritten(msgContext, true);
+        
+        return InvocationResponse.CONTINUE;
+    }
+
+    public void finalizeSendWithToAddress(MessageContext msgContext, ByteArrayOutputStream out)
+            throws AxisFault {
+        try {
+            InputStream in = new ByteArrayInputStream(out.toByteArray());
+            ByteArrayOutputStream response = new ByteArrayOutputStream();
+
+            LocalTransportReceiver localTransportReceiver = new LocalTransportReceiver(this);
+            localTransportReceiver.processMessage(in, msgContext.getTo(), msgContext.getOptions().getAction(), response);
+            in.close();
+            out.close();
+            in = new ByteArrayInputStream(response.toByteArray());
+            msgContext.setProperty(MessageContext.TRANSPORT_IN, in);
+        } catch (IOException e) {
+            throw AxisFault.makeFault(e);
+        }
+    }
+}

Added: webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/tcp/TCPServer.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/tcp/TCPServer.java?rev=671127&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/tcp/TCPServer.java (added)
+++ webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/tcp/TCPServer.java Tue Jun 24 04:07:03 2008
@@ -0,0 +1,232 @@
+/*
+ * 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.tcp;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.util.Utils;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.SessionContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.engine.ListenerManager;
+import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.transport.TransportListener;
+import org.apache.axis2.transport.http.server.HttpUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketException;
+
+/**
+ * Class TCPServer
+ */
+public class TCPServer implements Runnable, TransportListener {
+    private int port = 8000;
+    private boolean started = false;
+    private static final Log log = LogFactory.getLog(TCPServer.class);
+    private ConfigurationContext configContext;
+    private ServerSocket serversocket;
+    private String hostAddress = null;
+    private String contextPath;
+
+    public TCPServer() {
+    }
+
+    public TCPServer(int port, ConfigurationContext configContext) throws AxisFault {
+        try {
+            this.configContext = configContext;
+            serversocket = new ServerSocket(port);
+
+            ListenerManager listenerManager = configContext.getListenerManager();
+            TransportInDescription trsIn = new TransportInDescription(Constants.TRANSPORT_TCP);
+            trsIn.setReceiver(this);
+            if (listenerManager == null) {
+                listenerManager = new ListenerManager();
+                listenerManager.init(configContext);
+            }
+            listenerManager.addListener(trsIn, true);
+            contextPath = configContext.getServiceContextPath();
+
+        } catch (IOException e1) {
+            throw AxisFault.makeFault(e1);
+        }
+    }
+
+    public TCPServer(int port, String dir) throws AxisFault {
+        this(port, ConfigurationContextFactory.createConfigurationContextFromFileSystem(dir, null));
+    }
+
+    public void init(ConfigurationContext axisConf, TransportInDescription transprtIn)
+            throws AxisFault {
+        this.configContext = axisConf;
+
+        Parameter param = transprtIn.getParameter(PARAM_PORT);
+
+        if (param != null) {
+            this.port = Integer.parseInt((String) param.getValue());
+        }
+        param = transprtIn.getParameter(HOST_ADDRESS);
+        if (param != null) {
+            hostAddress = ((String) param.getValue()).trim();
+        }
+        contextPath = configContext.getServiceContextPath();
+    }
+
+    public static void main(String[] args) throws AxisFault, NumberFormatException {
+        if (args.length != 2) {
+            System.out.println("TCPServer repositoryLocation port");
+        } else {
+            File repository = new File(args[0]);
+
+            if (!repository.exists()) {
+                System.out.print("Repository file does not exists .. initializing repository");
+            }
+
+            TCPServer tcpServer = new TCPServer(Integer.parseInt(args[1]),
+                                                repository.getAbsolutePath());
+
+            System.out.println("[Axis2] Using the Repository " + repository.getAbsolutePath());
+            System.out.println("[Axis2] Starting the TCP Server on port " + args[1]);
+            tcpServer.start();
+            Runtime.getRuntime().addShutdownHook(new Thread(tcpServer));
+        }
+    }
+
+    public void run() {
+        while (started) {
+            Socket socket = null;
+
+            try {
+                socket = serversocket.accept();
+            } catch (java.io.InterruptedIOException iie) {
+            }
+            catch (Exception e) {
+                log.debug(e);
+
+                break;
+            }
+
+            if (socket != null) {
+                configContext.getThreadPool().execute(new TCPWorker(configContext, socket));
+            }
+        }
+    }
+
+    public synchronized void start() throws AxisFault {
+        if (serversocket == null) {
+            serversocket = openSocket(port);
+        }
+        started = true;
+        this.configContext.getThreadPool().execute(this);
+    }
+
+
+    /**
+     * Controls the number of server sockets kept open.
+     */
+    public ServerSocket openSocket(int port) throws AxisFault {
+        for (int i = 0; i < 5; i++) {
+            try {
+                return new ServerSocket(port + i);
+            } catch (IOException e) {
+                // What I'm gonna do here. Try again.
+            }
+        }
+
+        throw new AxisFault(Messages.getMessage("failedToOpenSocket"));
+    }
+
+
+    /*
+    *  (non-Javadoc)
+    * @see org.apache.axis2.transport.TransportListener#stop()
+    */
+    public void stop() throws AxisFault {
+        try {
+            this.serversocket.close();
+            started = false;
+        } catch (IOException e) {
+            throw AxisFault.makeFault(e);
+        }
+    }
+
+    public ConfigurationContext getConfigurationContext() {
+        return this.configContext;
+    }
+
+    /**
+     * I fthe hostAddress parameter is present in axis2.xml then the EPR will be
+     * created by taking the hostAddres into account
+     * (non-Javadoc)
+     *
+     * @see org.apache.axis2.transport.TransportListener#getEPRForService(String, String)
+     */
+    public EndpointReference getEPRForService(String serviceName, String ip) throws AxisFault {
+        EndpointReference[] epRsForService = getEPRsForService(serviceName, ip);
+        return epRsForService != null ? epRsForService[0] : null;
+    }
+
+    public EndpointReference[] getEPRsForService(String serviceName, String ip) throws AxisFault {
+        //if host address is present
+        if (hostAddress != null) {
+            if (serversocket != null) {
+                // todo this has to fix
+                return new EndpointReference[]{
+                        new EndpointReference(hostAddress + "/" + contextPath + serviceName)};
+            } else {
+                log.debug("Unable to generate EPR for the transport tcp");
+                return null;
+            }
+        }
+        if (ip == null) {
+            try {
+                ip = Utils.getIpAddress(configContext.getAxisConfiguration());
+            } catch (SocketException e) {
+                throw AxisFault.makeFault(e);
+            }
+        }
+        if (serversocket != null) {
+            // todo this has to fix
+            return new EndpointReference[]{
+                    new EndpointReference("tcp://" + ip + ":" + (serversocket.getLocalPort())
+                                          + "/" + contextPath + "/" + serviceName)};
+        } else {
+            log.debug("Unable to generate EPR for the transport tcp");
+            return null;
+        }
+    }
+
+    public SessionContext getSessionContext(MessageContext messageContext) {
+        return null;
+    }
+
+    public void destroy() {
+        this.configContext = null;
+    }
+}

Added: webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/tcp/TCPTransportSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/tcp/TCPTransportSender.java?rev=671127&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/tcp/TCPTransportSender.java (added)
+++ webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/tcp/TCPTransportSender.java Tue Jun 24 04:07:03 2008
@@ -0,0 +1,134 @@
+/*
+ * 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.tcp;
+
+import org.apache.axis2.AxisFault;
+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.handlers.AbstractHandler;
+import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.transport.TransportSender;
+import org.apache.axis2.transport.TransportUtils;
+import org.apache.axis2.transport.http.HTTPTransportUtils;
+import org.apache.axis2.util.URL;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
+import java.net.Socket;
+import java.net.SocketAddress;
+
+public class TCPTransportSender extends AbstractHandler implements TransportSender {
+    protected Writer out;
+    private Socket socket;
+
+    public void init(ConfigurationContext confContext, TransportOutDescription transportOut)
+            throws AxisFault {
+    }
+
+    public void stop() {
+    }
+
+    public void cleanup(MessageContext msgContext) throws AxisFault {
+        try {
+            if (socket != null) {
+                socket.close();
+                socket = null;
+            }
+        } catch (IOException e) {
+            // TODO: Log this?
+        }
+    }
+
+    /**
+     * Method invoke
+     *
+     * @param msgContext
+     * @throws AxisFault
+     */
+    public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
+
+        // Check for the REST behaviour, if you desire rest beahaviour
+        // put a <parameter name="doREST" value="true"/> at the axis2.xml
+        msgContext.setDoingMTOM(HTTPTransportUtils.doWriteMTOM(msgContext));
+        msgContext.setDoingSwA(HTTPTransportUtils.doWriteSwA(msgContext));
+
+        OutputStream out;
+        EndpointReference epr = null;
+
+        if (msgContext.getTo() != null && !msgContext.getTo().hasAnonymousAddress()) {
+            epr = msgContext.getTo();
+        }
+
+        if (epr != null) {
+            if (!epr.hasNoneAddress()) {
+                out = openTheConnection(epr, msgContext);
+                TransportUtils.writeMessage(msgContext, out);
+                try {
+                    socket.shutdownOutput();
+                    msgContext.setProperty(MessageContext.TRANSPORT_IN, socket.getInputStream());
+                } catch (IOException e) {
+                    throw AxisFault.makeFault(e);
+                }
+            }
+        } else {
+            out = (OutputStream) msgContext.getProperty(MessageContext.TRANSPORT_OUT);
+
+            if (out != null) {
+                TransportUtils.writeMessage(msgContext, out);
+            } else {
+                throw new AxisFault(
+                        "Both the TO and Property MessageContext.TRANSPORT_OUT is Null, No where to send");
+            }
+        }
+
+        TransportUtils.setResponseWritten(msgContext, true);
+        
+        return InvocationResponse.CONTINUE;
+    }
+
+    protected OutputStream openTheConnection(EndpointReference toURL, MessageContext msgContext)
+            throws AxisFault {
+        if (toURL != null) {
+            try {
+                URL url = new URL(toURL.getAddress());
+                SocketAddress add = new InetSocketAddress(url.getHost(), (url.getPort() == -1)
+                        ? 80
+                        : url.getPort());
+
+                socket = new Socket();
+                socket.connect(add);
+
+                return socket.getOutputStream();
+            } catch (MalformedURLException e) {
+                throw AxisFault.makeFault(e);
+            } catch (IOException e) {
+                throw AxisFault.makeFault(e);
+            }
+        } else {
+            throw new AxisFault(Messages.getMessage("canNotBeNull", "End point reference"));
+        }
+    }
+}

Added: webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/tcp/TCPWorker.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/tcp/TCPWorker.java?rev=671127&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/tcp/TCPWorker.java (added)
+++ webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/tcp/TCPWorker.java Tue Jun 24 04:07:03 2008
@@ -0,0 +1,117 @@
+/*
+ * 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.tcp;
+
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.builder.BuilderUtil;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.util.MessageContextBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.net.Socket;
+
+/**
+ * This Class is the work hoarse of the TCP request, this process the incomming SOAP Message.
+ */
+public class TCPWorker implements Runnable {
+    private static final Log log = LogFactory.getLog(TCPWorker.class);
+    private ConfigurationContext configurationContext;
+    private Socket socket;
+
+    public TCPWorker(ConfigurationContext configurationContext, Socket socket) {
+        this.configurationContext = configurationContext;
+        this.socket = socket;
+    }
+
+    public void run() {
+        MessageContext msgContext = null;
+
+        try {
+            AxisConfiguration axisConf = configurationContext.getAxisConfiguration();
+            TransportOutDescription transportOut =
+                    axisConf.getTransportOut(Constants.TRANSPORT_TCP);
+            TransportInDescription transportIn =
+                    axisConf.getTransportIn(Constants.TRANSPORT_TCP);
+
+            if ((transportOut != null) && (transportIn != null)) {
+
+                // create the Message Context and fill in the values
+                msgContext = configurationContext.createMessageContext();
+                msgContext.setIncomingTransportName(Constants.TRANSPORT_TCP);
+                msgContext.setTransportIn(transportIn);
+                msgContext.setTransportOut(transportOut);
+                msgContext.setServerSide(true);
+
+                OutputStream out = socket.getOutputStream();
+
+                msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);
+
+                // create the SOAP Envelope
+                Reader in = new InputStreamReader(socket.getInputStream());
+                OMXMLParserWrapper builder = BuilderUtil.getBuilder(in);
+                SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
+
+                msgContext.setEnvelope(envelope);
+                AxisEngine.receive(msgContext);
+            } else {
+                throw new AxisFault(Messages.getMessage("unknownTransport",
+                                                        Constants.TRANSPORT_TCP));
+            }
+        } catch (Throwable e) {
+            log.error(e.getMessage(), e);
+            try {
+
+                if (msgContext != null) {
+                    msgContext.setProperty(MessageContext.TRANSPORT_OUT, socket.getOutputStream());
+
+                    MessageContext faultContext =
+                            MessageContextBuilder.createFaultMessageContext(msgContext, e);
+
+                    AxisEngine.sendFault(faultContext);
+                }
+            } catch (Exception e1) {
+                log.error(e1.getMessage(), e1);
+            }
+        } finally {
+            if (socket != null) {
+                try {
+                    this.socket.close();
+                } catch (IOException e1) {
+                    // Do nothing
+                }
+            }
+        }
+    }
+}

Added: webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/XMPPListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/XMPPListener.java?rev=671127&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/XMPPListener.java (added)
+++ webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/XMPPListener.java Tue Jun 24 04:07:03 2008
@@ -0,0 +1,196 @@
+/*
+ * 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.xmpp;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.SessionContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.ParameterIncludeImpl;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.transport.TransportListener;
+import org.apache.axis2.transport.xmpp.util.XMPPConnectionFactory;
+import org.apache.axis2.transport.xmpp.util.XMPPConstants;
+import org.apache.axis2.transport.xmpp.util.XMPPPacketListener;
+import org.apache.axis2.transport.xmpp.util.XMPPServerCredentials;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jivesoftware.smack.XMPPConnection;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+
+public class XMPPListener implements TransportListener {
+    private static Log log = LogFactory.getLog(XMPPListener.class);
+    private ConfigurationContext configurationContext = null;
+    private String replyTo = "";
+
+    /**
+     * A Map containing the connection factories managed by this, 
+     * keyed by userName-at-jabberServerURL
+     */
+    private Map connectionFactories = new HashMap();
+    private ExecutorService workerPool;
+    private static final int WORKERS_MAX_THREADS = 5;
+    private static final long WORKER_KEEP_ALIVE = 60L;
+    private static final TimeUnit TIME_UNIT = TimeUnit.SECONDS;
+    private XMPPConnection xmppConnection = null;
+
+
+    
+    public XMPPListener() {
+	}
+
+	/**
+     * Initializing the XMPPListener. Retrieve connection details provided in
+     * xmpp transport receiver, connect to those servers & start listening in
+     * for messages.
+     */
+    public void init(ConfigurationContext configurationCtx, TransportInDescription transportIn)
+            throws AxisFault {
+    	log.info("Initializing XMPPListener...");
+        configurationContext = configurationCtx;
+        initializeConnectionFactories(configurationContext,transportIn);
+        if (connectionFactories.isEmpty()) {
+            log.warn("No XMPP connection factories defined." +
+                     "Will not listen for any XMPP messages");
+            return;
+        }
+    }    
+   
+    /**
+     * Extract connection details & connect to those xmpp servers.
+     * @see init(ConfigurationContext configurationCtx, TransportInDescription transportIn)
+     * @param configurationContext
+     * @param transportIn
+     */
+    private void initializeConnectionFactories(
+			ConfigurationContext configurationContext,
+			TransportInDescription transportIn) throws AxisFault{
+    	
+        Iterator serversToListenOn = transportIn.getParameters().iterator();
+        while (serversToListenOn.hasNext()) {
+            Parameter connection = (Parameter) serversToListenOn.next();
+            log.info("Trying to establish connection for : "+connection.getName());
+            ParameterIncludeImpl pi = new ParameterIncludeImpl();
+            try {
+                pi.deserializeParameters((OMElement) connection.getValue());
+            } catch (AxisFault axisFault) {
+                log.error("Error reading parameters");
+            }
+
+            Iterator params = pi.getParameters().iterator();
+            XMPPServerCredentials serverCredentials = 
+            	new XMPPServerCredentials();
+            
+            while (params.hasNext()) {
+                Parameter param = (Parameter) params.next();
+                if(XMPPConstants.XMPP_SERVER_URL.equals(param.getName())){
+        			serverCredentials.setServerUrl((String)param.getValue());                	
+                }else if(XMPPConstants.XMPP_SERVER_USERNAME.equals(param.getName())){
+        			serverCredentials.setAccountName((String)param.getValue());                	
+                }else if(XMPPConstants.XMPP_SERVER_PASSWORD.equals(param.getName())){
+        			serverCredentials.setPassword((String)param.getValue());                	
+                }else if(XMPPConstants.XMPP_SERVER_TYPE.equals(param.getName())){
+        			serverCredentials.setServerType((String)param.getValue());                	
+                }
+            }
+    		XMPPConnectionFactory xmppConnectionFactory = new XMPPConnectionFactory();
+    		xmppConnectionFactory.connect(serverCredentials);
+    		
+    		connectionFactories.put(serverCredentials.getAccountName() + "@"
+    				+ serverCredentials.getServerUrl(), xmppConnectionFactory);           
+        }
+	}
+
+    /**
+     * Stop XMPP listener & disconnect from all XMPP Servers
+     */
+    public void stop() {
+        if (!workerPool.isShutdown()) {
+            workerPool.shutdown();
+        }
+        //TODO : Iterate through all connections in connectionFactories & call disconnect()
+    }
+
+    /**
+     * Returns Default EPR for a given Service name & IP
+     * @param serviceName
+     * @param ip
+     */
+    public EndpointReference getEPRForService(String serviceName, String ip) throws AxisFault {
+        return getEPRsForService(serviceName, ip)[0];
+    }
+
+    /**
+     * Returns all EPRs for a given Service name & IP
+     * @param serviceName
+     * @param ip
+     */    
+    public EndpointReference[] getEPRsForService(String serviceName, String ip) throws AxisFault {
+        return new EndpointReference[]{new EndpointReference(XMPPConstants.XMPP_PREFIX +
+                replyTo + "?" + configurationContext
+                .getServiceContextPath() + "/" + serviceName)};
+    }
+
+
+    public SessionContext getSessionContext(MessageContext messageContext) {
+        return null;
+    }
+
+	public void destroy() {
+		if(xmppConnection != null && xmppConnection.isConnected()){
+			xmppConnection.disconnect();
+		}
+	}
+
+	/**
+	 * Start a pool of Workers. For each connection in connectionFactories,
+	 * assign a packer listener. This packet listener will trigger when a 
+	 * message arrives.
+	 */
+	public void start() throws AxisFault {
+        // create thread pool of workers
+       ExecutorService workerPool = new ThreadPoolExecutor(
+                1,
+                WORKERS_MAX_THREADS, WORKER_KEEP_ALIVE, TIME_UNIT,
+                new LinkedBlockingQueue(),
+                new org.apache.axis2.util.threadpool.DefaultThreadFactory(
+                        new ThreadGroup("XMPP Worker thread group"),
+                        "XMPPWorker"));
+
+        Iterator iter = connectionFactories.values().iterator();
+        while (iter.hasNext()) {
+            XMPPConnectionFactory connectionFactory = (XMPPConnectionFactory) iter.next(); 
+            XMPPPacketListener xmppPacketListener =
+                    new XMPPPacketListener(connectionFactory,this.configurationContext,workerPool);
+            connectionFactory.listen(xmppPacketListener);
+        }	
+	}
+}

Added: webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/XMPPSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/XMPPSender.java?rev=671127&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/XMPPSender.java (added)
+++ webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/XMPPSender.java Tue Jun 24 04:07:03 2008
@@ -0,0 +1,279 @@
+/*
+ * 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.xmpp;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.axis2.transport.OutTransportInfo;
+import org.apache.axis2.transport.TransportSender;
+import org.apache.axis2.transport.xmpp.util.XMPPClientSidePacketListener;
+import org.apache.axis2.transport.xmpp.util.XMPPConnectionFactory;
+import org.apache.axis2.transport.xmpp.util.XMPPConstants;
+import org.apache.axis2.transport.xmpp.util.XMPPOutTransportInfo;
+import org.apache.axis2.transport.xmpp.util.XMPPServerCredentials;
+import org.apache.axis2.transport.xmpp.util.XMPPUtils;
+import org.apache.axis2.util.Utils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jivesoftware.smack.Chat;
+import org.jivesoftware.smack.ChatManager;
+import org.jivesoftware.smack.XMPPConnection;
+import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.filter.PacketFilter;
+import org.jivesoftware.smack.filter.PacketTypeFilter;
+import org.jivesoftware.smack.packet.Message;
+
+public class XMPPSender extends AbstractHandler implements TransportSender {
+	Log log = null;
+    XMPPConnectionFactory connectionFactory;
+	
+    public XMPPSender() {
+        log = LogFactory.getLog(XMPPSender.class);
+    }
+    
+	public void cleanup(MessageContext msgContext) throws AxisFault {	
+	}
+
+    /**
+     * Initialize the transport sender by reading pre-defined connection factories for
+     * outgoing messages. These will create sessions (one per each destination dealt with)
+     * to be used when messages are being sent.
+     * @param confContext the configuration context
+     * @param transportOut the transport sender definition from axis2.xml
+     * @throws AxisFault on error
+     */	
+	public void init(ConfigurationContext confContext,
+			TransportOutDescription transportOut) throws AxisFault {
+		//if connection details are available from axis configuration
+		//use those & connect to jabber server(s)
+		XMPPServerCredentials serverCredentials = new XMPPServerCredentials();
+		getConnectionDetailsFromAxisConfiguration(serverCredentials,transportOut);
+		connectionFactory = new XMPPConnectionFactory();
+		connectionFactory.connect(serverCredentials);		
+	}
+
+	/**
+	 * Extract connection details from Client options
+	 * @param msgCtx
+	 */
+	private void connectUsingClientOptions(MessageContext msgCtx) throws AxisFault{		
+		XMPPServerCredentials serverCredentials = new XMPPServerCredentials();
+		getConnectionDetailsFromClientOptions(serverCredentials,msgCtx);
+		connectionFactory = new XMPPConnectionFactory();
+		connectionFactory.connect(serverCredentials);
+	}
+	
+	public void stop() {}
+
+	public InvocationResponse invoke(MessageContext msgContext)
+			throws AxisFault {
+        String targetAddress = (String) msgContext.getProperty(
+                Constants.Configuration.TRANSPORT_URL);
+            if (targetAddress != null) {
+                sendMessage(msgContext, targetAddress, null);
+            } else if (msgContext.getTo() != null && !msgContext.getTo().hasAnonymousAddress()) {
+                targetAddress = msgContext.getTo().getAddress();
+
+                if (!msgContext.getTo().hasNoneAddress()) {
+                    sendMessage(msgContext, targetAddress, null);
+                } else {
+                    //Don't send the message.
+                    return InvocationResponse.CONTINUE;
+                }
+            } else if (msgContext.isServerSide()) {
+                // get the out transport info for server side when target EPR is unknown
+                sendMessage(msgContext, null,
+                    (OutTransportInfo) msgContext.getProperty(Constants.OUT_TRANSPORT_INFO));
+            }
+            return InvocationResponse.CONTINUE;
+	}
+
+    /**
+     * Send the given message over XMPP transport
+     *
+     * @param msgCtx the axis2 message context
+     * @throws AxisFault on error
+     */
+    public void sendMessage(MessageContext msgCtx, String targetAddress,
+        OutTransportInfo outTransportInfo) throws AxisFault {
+		XMPPConnection xmppConnection = null;
+		XMPPOutTransportInfo xmppOutTransportInfo = null;
+		
+		//if on client side,create connection to xmpp server
+		if(!msgCtx.isServerSide()){
+			connectUsingClientOptions(msgCtx);
+		}
+		
+		Message message = new Message();
+		Options options = msgCtx.getOptions();    	
+    	String serviceName = XMPPUtils.getServiceName(targetAddress);    	
+    	
+		if (targetAddress != null) {
+			xmppOutTransportInfo = new XMPPOutTransportInfo(targetAddress);
+			xmppOutTransportInfo.setConnectionFactory(connectionFactory);
+		} else if (msgCtx.getTo() != null &&
+				!msgCtx.getTo().hasAnonymousAddress()) {
+			//TODO 
+		} else if (msgCtx.isServerSide()) {
+			xmppOutTransportInfo = (XMPPOutTransportInfo)
+			msgCtx.getProperty(Constants.OUT_TRANSPORT_INFO);
+		}
+    	
+    	
+		if(msgCtx.isServerSide()){
+			xmppConnection = xmppOutTransportInfo.getConnectionFactory().getXmppConnection();
+			message.setProperty(XMPPConstants.IS_SERVER_SIDE, new Boolean(false));
+			message.setProperty(XMPPConstants.IN_REPLY_TO, xmppOutTransportInfo.getInReplyTo());
+		}else{
+			xmppConnection = xmppOutTransportInfo.getConnectionFactory().getXmppConnection();
+			message.setProperty(XMPPConstants.IS_SERVER_SIDE, new Boolean(true));
+			message.setProperty(XMPPConstants.SERVICE_NAME, serviceName);
+			message.setProperty(XMPPConstants.ACTION, options.getAction());
+		}
+		
+    	if(xmppConnection == null){
+    		handleException("Connection to XMPP Server is not established.");    		
+    	}
+		
+		//initialize the chat manager using connection
+		ChatManager chatManager = xmppConnection.getChatManager();
+		Chat chat = chatManager.createChat(xmppOutTransportInfo.getDestinationAccount(), null);		
+		
+		try 
+		{
+			OMElement msgElement = msgCtx.getEnvelope();
+			if (msgCtx.isDoingREST()) {
+				msgElement = msgCtx.getEnvelope().getBody().getFirstElement();
+			}
+			boolean waitForResponse =
+				msgCtx.getOperationContext() != null &&
+				WSDL2Constants.MEP_URI_OUT_IN.equals(
+						msgCtx.getOperationContext().getAxisOperation().getMessageExchangePattern());
+			
+			
+			String soapMessage = msgElement.toString();
+			//int endOfXMLDeclaration = soapMessage.indexOf("?>");
+			//String modifiedSOAPMessage = soapMessage.substring(endOfXMLDeclaration+2);
+			message.setBody(soapMessage);	
+			
+			XMPPClientSidePacketListener xmppClientSidePacketListener = null;
+			if(waitForResponse && !msgCtx.isServerSide()){
+				PacketFilter filter = new PacketTypeFilter(message.getClass());				
+				xmppClientSidePacketListener = new XMPPClientSidePacketListener(msgCtx);
+				xmppConnection.addPacketListener(xmppClientSidePacketListener,filter);
+			}			
+
+			chat.sendMessage(message);
+			log.debug("Sent message :"+message.toXML());
+
+			//If this is on client side, wait for the response from server.
+			//Is this the best way to do this?
+			if(waitForResponse && !msgCtx.isServerSide()){
+				while(! xmppClientSidePacketListener.isResponseReceived()){
+					try {
+						Thread.sleep(1000);
+					} catch (InterruptedException e) {
+						log.debug("Sleep interrupted",e);
+					}		
+				}
+				xmppConnection.disconnect();
+			}
+
+		} catch (XMPPException e) {
+			log.error("Error occurred while sending the message : "+message.toXML(),e);
+			handleException("Error occurred while sending the message : "+message.toXML(),e);
+		}finally{
+			if(!msgCtx.isServerSide()){
+				xmppConnection.disconnect();
+			}
+		}
+    }	
+    
+    
+    /**
+     * Extract connection details from axis2.xml's transportsender section
+     * @param serverCredentials
+     * @param transportOut
+     */
+	private void getConnectionDetailsFromAxisConfiguration(XMPPServerCredentials serverCredentials,
+			TransportOutDescription transportOut){
+		if(transportOut != null){
+			Parameter serverUrl = transportOut.getParameter(XMPPConstants.XMPP_SERVER_URL);
+			if (serverUrl != null) {
+				serverCredentials.setServerUrl(Utils.getParameterValue(serverUrl));
+			}
+			
+			Parameter userName = transportOut.getParameter(XMPPConstants.XMPP_SERVER_USERNAME);
+			if (userName != null) {
+				serverCredentials.setAccountName(Utils.getParameterValue(userName));
+			}
+		
+			Parameter password = transportOut.getParameter(XMPPConstants.XMPP_SERVER_PASSWORD);
+			if (password != null) {
+				serverCredentials.setPassword(Utils.getParameterValue(password));
+			}
+
+			Parameter serverType = transportOut.getParameter(XMPPConstants.XMPP_SERVER_TYPE);			
+			if (serverType != null) {
+				serverCredentials.setServerType(Utils.getParameterValue(serverType));
+			}			
+		}
+	}
+	
+	/**
+	 * Extract connection details from client options
+	 * @param serverCredentials
+	 * @param msgContext
+	 */
+	private void getConnectionDetailsFromClientOptions(XMPPServerCredentials serverCredentials,
+			MessageContext msgContext){
+		Options clientOptions = msgContext.getOptions();
+
+		if (clientOptions.getProperty(XMPPConstants.XMPP_SERVER_USERNAME) != null){
+			serverCredentials.setAccountName((String)clientOptions.getProperty(XMPPConstants.XMPP_SERVER_USERNAME));
+		}
+		if (clientOptions.getProperty(XMPPConstants.XMPP_SERVER_PASSWORD) != null){
+			serverCredentials.setPassword((String)clientOptions.getProperty(XMPPConstants.XMPP_SERVER_PASSWORD));
+		}
+		if (clientOptions.getProperty(XMPPConstants.XMPP_SERVER_URL) != null){
+			serverCredentials.setServerUrl((String)clientOptions.getProperty(XMPPConstants.XMPP_SERVER_URL));
+		}
+		if (clientOptions.getProperty(XMPPConstants.XMPP_SERVER_TYPE) != null){
+			serverCredentials.setServerType((String)clientOptions.getProperty(XMPPConstants.XMPP_SERVER_TYPE));
+		}		
+	}  
+	
+    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);
+    }
+}
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPClientSidePacketListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPClientSidePacketListener.java?rev=671127&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPClientSidePacketListener.java (added)
+++ webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPClientSidePacketListener.java Tue Jun 24 04:07:03 2008
@@ -0,0 +1,63 @@
+/*
+ * 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.xmpp.util;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jivesoftware.smack.PacketListener;
+import org.jivesoftware.smack.packet.Message;
+import org.jivesoftware.smack.packet.Packet;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+public class XMPPClientSidePacketListener implements PacketListener {
+	private static Log log = LogFactory.getLog(XMPPClientSidePacketListener.class);
+	private MessageContext messageContext = null;
+	private boolean responseReceived;
+
+	public XMPPClientSidePacketListener(MessageContext messageContext){
+		this.messageContext = messageContext;
+	}
+
+	/**
+	 * This method will be triggered, when a message is arrived at client side
+	 */
+	public void processPacket(Packet packet) {		
+		Message message = (Message)packet;
+		String xml = StringEscapeUtils.unescapeXml(message.getBody());
+		log.info("Client received message : "+xml);
+		this.responseReceived = true;
+		InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
+		messageContext.setProperty(MessageContext.TRANSPORT_IN, inputStream);
+	}
+
+	/**
+	 * Indicates response message is received at client side.
+	 * @see processPacket(Packet packet)
+	 * @return
+	 */
+	public boolean isResponseReceived() {
+		return responseReceived;
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPConnectionFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPConnectionFactory.java?rev=671127&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPConnectionFactory.java (added)
+++ webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPConnectionFactory.java Tue Jun 24 04:07:03 2008
@@ -0,0 +1,179 @@
+/*
+ * 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.xmpp.util;
+
+import org.apache.axis2.AxisFault;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jivesoftware.smack.ConnectionConfiguration;
+import org.jivesoftware.smack.ConnectionListener;
+import org.jivesoftware.smack.XMPPConnection;
+import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.filter.FromContainsFilter;
+import org.jivesoftware.smack.filter.PacketFilter;
+import org.jivesoftware.smack.filter.ToContainsFilter;
+
+import java.util.HashMap;
+
+public class XMPPConnectionFactory {
+	private static Log log = LogFactory.getLog(XMPPConnectionFactory.class);
+	private XMPPConnection xmppConnection = null;
+	private PacketFilter packetFilter = null;
+	private HashMap xmppConnections = new HashMap();
+
+	public XMPPConnectionFactory(){}
+
+	/**
+	 * Connects to a XMPP server based on the details available in serverCredentials object
+	 * @param serverCredentials
+	 * @throws XMPPException 
+	 */
+	public void connect(final XMPPServerCredentials serverCredentials) throws AxisFault {
+		if(XMPPConstants.XMPP_SERVER_TYPE_JABBER.equals(serverCredentials.getServerType())){
+			ConnectionListener connectionListener = null;
+			try 
+			{
+				//XMPPConnection.DEBUG_ENABLED = true;
+				xmppConnection = new XMPPConnection(serverCredentials.getServerUrl());
+				xmppConnection.connect();
+				connectionListener = new ConnectionListener(){
+
+					public void connectionClosed() {
+						log.debug("Connection closed normally");
+					}
+
+					public void connectionClosedOnError(
+							Exception e1) {
+						log.debug("Connection to "+serverCredentials.getServerUrl()
+								+ " closed with error.",e1);
+						log.debug("Retrying to connect in 2 secs");
+						try
+						{
+							Thread.sleep(2000);
+							xmppConnection = new XMPPConnection(serverCredentials.getServerUrl());
+							log.debug("connected to "+serverCredentials.getServerUrl());
+						} catch (InterruptedException e2) {
+							log.debug("Sleep interrupted.",e2);
+						}
+					}
+
+					public void reconnectingIn(int seconds) {			
+					}
+
+					public void reconnectionFailed(Exception e) {
+					}
+
+					public void reconnectionSuccessful() {
+					}
+				};
+				xmppConnection.addConnectionListener(connectionListener);
+			}
+			catch(XMPPException e){
+				log.error("Failed to connect to server :"+serverCredentials.getServerUrl(), e);
+				throw new AxisFault("Failed to connect to server :"+serverCredentials.getServerUrl());
+			}
+
+			//Pause for a small time before trying to login.
+			//This prevents random ssl exception from Smack API
+			try {
+				Thread.sleep(100);
+			} catch (InterruptedException e5) {
+				log.debug("Sleep interrupted ",e5);
+			}
+
+			if(xmppConnection.isConnected()){
+				if(! xmppConnection.isAuthenticated()){
+					try {
+						xmppConnection.login(serverCredentials.getAccountName()+"@"+
+								serverCredentials.getServerUrl(), 
+								serverCredentials.getPassword(),
+								serverCredentials.getResource(),
+								true);
+					} catch (XMPPException e) {
+						try {
+							log.error("Login failed for "
+									+serverCredentials.getAccountName()
+									+"@"+serverCredentials.getServerUrl() 
+									+".Retrying in 2 secs",e); 
+							Thread.sleep(2000);
+							xmppConnection.login(serverCredentials.getAccountName()+"@"+
+									serverCredentials.getServerUrl(), 
+									serverCredentials.getPassword(),
+									serverCredentials.getResource(),
+									true);
+						} catch (InterruptedException e1) {
+							log.error("Sleep interrupted.",e1);
+						} catch (XMPPException e2) {
+							log.error("Login failed for : "+serverCredentials.getAccountName()
+									+"@"+serverCredentials.getServerUrl(),e2);
+							throw new AxisFault("Login failed for : "+serverCredentials.getAccountName()
+									+"@"+serverCredentials.getServerUrl());
+						}
+					}
+					//Listen for Message type packets from specified server url
+					//packetFilter = new AndFilter(new PacketTypeFilter(Message.class), 
+					//		new FromContainsFilter(serverCredentials.getServerUrl()));
+					packetFilter = new FromContainsFilter(serverCredentials.getServerUrl());					
+				}
+			}
+		}else if(XMPPConstants.XMPP_SERVER_TYPE_GOOGLETALK.equals(serverCredentials.getServerType())){
+			try {
+				ConnectionConfiguration connectionConfiguration = 
+					new ConnectionConfiguration(XMPPConstants.GOOGLETALK_URL
+						,XMPPConstants.GOOGLETALK_PORT
+						,XMPPConstants.GOOGLETALK_SERVICE_NAME);				
+				xmppConnection = new XMPPConnection(connectionConfiguration);
+				xmppConnection.connect();
+
+				xmppConnection.login(serverCredentials.getAccountName()
+						, serverCredentials.getPassword()
+						,serverCredentials.getResource(),
+						true);
+				//packetFilter = new AndFilter(new PacketTypeFilter(Message.class), 
+				//		new FromContainsFilter(XMPPConstants.GOOGLETALK_FROM));
+				//packetFilter = new FromContainsFilter(XMPPConstants.GOOGLETALK_FROM);
+				packetFilter = new ToContainsFilter("@gmail.com");
+				
+			} catch (XMPPException e1) {
+				log.error("Error occured while connecting to Googletalk server.",e1);
+				throw new AxisFault("Error occured while connecting to Googletalk server.");
+			}
+		}
+	} 
+
+	public XMPPConnection getConnection(String connectionIdentifier){
+		return (XMPPConnection)xmppConnections.get(connectionIdentifier);
+	}
+
+
+	public XMPPConnection getXmppConnection() {
+		return xmppConnection;
+	}
+
+	public void setXmppConnection(XMPPConnection xmppConnection) {
+		this.xmppConnection = xmppConnection;
+	}
+
+	public void listen(XMPPPacketListener packetListener){
+		xmppConnection.addPacketListener(packetListener,packetFilter);
+	}
+
+	public void stop() {}
+}
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPConstants.java?rev=671127&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPConstants.java (added)
+++ webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPConstants.java Tue Jun 24 04:07:03 2008
@@ -0,0 +1,49 @@
+/*
+ * 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.xmpp.util;
+
+
+public class XMPPConstants {	
+	public static final String XMPP = "xmpp";
+    //The prefix indicating an Axis XMPP URL
+    public static final String XMPP_PREFIX = "xmpp://";
+
+    //properties related to XMPP server connection
+    public static final String XMPP_SERVER_USERNAME = "transport.xmpp.ServerAccountUserName";
+    public static final String XMPP_SERVER_PASSWORD = "transport.xmpp.ServerAccountPassword";    
+    public static final String XMPP_SERVER_URL = "transport.xmpp.ServerUrl";
+    
+    //Google talk attributes
+    public static final String GOOGLETALK_URL = "talk.google.com";
+    public static final int GOOGLETALK_PORT = 5222;
+    public static final String GOOGLETALK_SERVICE_NAME = "gmail.com";
+    public static final String GOOGLETALK_FROM = "gmail.com";
+    
+    
+    //XMPP Server Types
+    public static final String XMPP_SERVER_TYPE = "transport.xmpp.ServerType";
+    public static final String XMPP_SERVER_TYPE_JABBER = "transport.xmpp.ServerType.Jabber";
+    public static final String XMPP_SERVER_TYPE_GOOGLETALK = "transport.xmpp.ServerType.GoogleTalk";   
+    
+    public static final String IS_SERVER_SIDE = "isServerSide";
+    public static final String IN_REPLY_TO = "inReplyTo";
+    public static final String SERVICE_NAME = "ServiceName";
+    public static final String ACTION = "Action";
+}

Added: webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPOutTransportInfo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPOutTransportInfo.java?rev=671127&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPOutTransportInfo.java (added)
+++ webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPOutTransportInfo.java Tue Jun 24 04:07:03 2008
@@ -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.xmpp.util;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.transport.OutTransportInfo;
+
+/**
+ * 
+ * Holds XMPP transport out details
+ *
+ */
+public class XMPPOutTransportInfo implements OutTransportInfo{
+	private String contentType = null;
+	private String destinationAccount = null;
+	private String inReplyTo;
+	private EndpointReference from;
+	private XMPPConnectionFactory connectionFactory = null;
+	
+	public XMPPOutTransportInfo(){
+		
+	}
+	
+	public XMPPOutTransportInfo(String transportUrl) throws AxisFault {
+        this.destinationAccount = XMPPUtils.getAccountName(transportUrl);
+	}
+	public void setContentType(String contentType) {
+		this.contentType = contentType;
+	}		
+		
+    public XMPPConnectionFactory getConnectionFactory() {
+		return connectionFactory;
+	}
+
+    public void setConnectionFactory(XMPPConnectionFactory connectionFactory) {
+		this.connectionFactory = connectionFactory;
+	}
+	
+	public String getDestinationAccount() {
+		return destinationAccount;
+	}
+
+	public EndpointReference getFrom() {
+		return from;
+	}
+
+	public void setFrom(EndpointReference from) {
+		this.from = from;
+	}
+
+	public String getInReplyTo() {
+		return inReplyTo;
+	}
+
+	public void setInReplyTo(String inReplyTo) {
+		this.inReplyTo = inReplyTo;
+	}
+
+	public void setDestinationAccount(String destinationAccount) {
+		this.destinationAccount = destinationAccount;
+	}
+
+	public String getContentType() {
+		return contentType;
+	}	
+}

Added: webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPPacketListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPPacketListener.java?rev=671127&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPPacketListener.java (added)
+++ webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPPacketListener.java Tue Jun 24 04:07:03 2008
@@ -0,0 +1,225 @@
+/*
+ * 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.xmpp.util;
+
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.transport.TransportUtils;
+import org.apache.axis2.util.MessageContextBuilder;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jivesoftware.smack.PacketListener;
+import org.jivesoftware.smack.packet.Message;
+import org.jivesoftware.smack.packet.Packet;
+
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.concurrent.Executor;
+
+public class XMPPPacketListener implements PacketListener {
+	private static final Log log = LogFactory.getLog(XMPPPacketListener.class);
+	private XMPPConnectionFactory xmppConnectionFactory = null;
+	private ConfigurationContext configurationContext = null;
+	private Executor workerPool = null;
+    
+    public final static String CONTENT_TYPE = "mail.contenttype";
+
+    public XMPPPacketListener(XMPPConnectionFactory xmppConnectionFactory, ConfigurationContext configurationContext, Executor workerPool) {
+		this.xmppConnectionFactory = xmppConnectionFactory;
+		this.configurationContext = configurationContext;
+		this.workerPool = workerPool;
+	}
+
+	/**
+	 * This method gets triggered when server side gets a message
+	 */
+	public void processPacket(Packet packet) {
+		log.info("Received : "+packet.toXML());
+		if(packet instanceof Message){
+			workerPool.execute(new Worker(packet));			
+		}
+	}
+
+	/**
+	 * Creates message context using values received in XMPP packet
+	 * @param packet
+	 * @return MessageContext
+	 * @throws AxisFault
+	 */
+	private MessageContext createMessageContext(Packet packet) throws AxisFault {
+		Message message = (Message) packet;
+
+		Boolean isServerSide = (Boolean) message
+				.getProperty(XMPPConstants.IS_SERVER_SIDE);
+		String serviceName = (String) message
+				.getProperty(XMPPConstants.SERVICE_NAME);
+		String action = (String) message.getProperty(XMPPConstants.ACTION);
+		MessageContext msgContext = null;
+
+		TransportInDescription transportIn = configurationContext
+				.getAxisConfiguration().getTransportIn("xmpp");
+		TransportOutDescription transportOut = configurationContext
+				.getAxisConfiguration().getTransportOut("xmpp");
+		if ((transportIn != null) && (transportOut != null)) {
+			msgContext = configurationContext.createMessageContext();
+			msgContext.setTransportIn(transportIn);
+			msgContext.setTransportOut(transportOut);
+			if (isServerSide != null) {
+				msgContext.setServerSide(isServerSide.booleanValue());
+			}
+			msgContext.setProperty(
+					CONTENT_TYPE,
+					"text/xml");
+			msgContext.setProperty(
+					Constants.Configuration.CHARACTER_SET_ENCODING, "UTF-8");
+			msgContext.setIncomingTransportName("xmpp");
+
+			HashMap services = configurationContext.getAxisConfiguration()
+					.getServices();
+
+			AxisService axisService = (AxisService) services.get(serviceName);
+			msgContext.setAxisService(axisService);
+			msgContext.setSoapAction(action);
+
+			// pass the configurationFactory to transport sender
+			msgContext.setProperty("XMPPConfigurationFactory",
+					this.xmppConnectionFactory);
+
+			if (packet.getFrom() != null) {
+				msgContext.setFrom(new EndpointReference(packet.getFrom()));
+			}
+			if (packet.getTo() != null) {
+				msgContext.setTo(new EndpointReference(packet.getTo()));
+			}
+
+			XMPPOutTransportInfo xmppOutTransportInfo = new XMPPOutTransportInfo();
+			xmppOutTransportInfo
+					.setConnectionFactory(this.xmppConnectionFactory);
+
+			String packetFrom = packet.getFrom();
+			if (packetFrom != null) {
+				EndpointReference fromEPR = new EndpointReference(packetFrom);
+				xmppOutTransportInfo.setFrom(fromEPR);
+				xmppOutTransportInfo.setDestinationAccount(packetFrom);
+			}
+
+			// Save Message-Id to set as In-Reply-To on reply
+			String xmppMessageId = packet.getPacketID();
+			if (xmppMessageId != null) {
+				xmppOutTransportInfo.setInReplyTo(xmppMessageId);
+			}
+			msgContext.setProperty(
+					org.apache.axis2.Constants.OUT_TRANSPORT_INFO,
+					xmppOutTransportInfo);
+			buildSOAPEnvelope(packet, msgContext);
+		} else {
+			throw new AxisFault("Either transport in or transport out is null");
+		}
+		return msgContext;
+	}
+
+    /**
+     * builds SOAP envelop using message contained in packet
+     * @param packet
+     * @param msgContext
+     * @throws AxisFault
+     */
+	private void buildSOAPEnvelope(Packet packet, MessageContext msgContext) throws AxisFault{
+		Message message = (Message)packet;
+		String xml = StringEscapeUtils.unescapeXml(message.getBody());
+		InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
+		SOAPEnvelope envelope;
+		try {
+			envelope = TransportUtils.createSOAPMessage(msgContext, inputStream, "text/xml");
+			if(msgContext.isServerSide()){
+				log.info("Received Envelope : "+xml);
+			}
+			msgContext.setEnvelope(envelope);
+		}catch (OMException e) {
+			log.error("Error occured while trying to create " +
+					"message content using XMPP message received :"+packet.toXML(), e);
+			throw new AxisFault("Error occured while trying to create " +
+					"message content using XMPP message received :"+packet.toXML());
+		}catch (XMLStreamException e) {
+			log.error("Error occured while trying to create " +
+					"message content using XMPP message received :"+packet.toXML(), e);
+			throw new AxisFault("Error occured while trying to create " +
+					"message content using XMPP message received :"+packet.toXML());
+		}catch (FactoryConfigurationError e) {
+			log.error("Error occured while trying to create " +
+					"message content using XMPP message received :"+packet.toXML(), e);
+			throw new AxisFault("Error occured while trying to create " +
+					"message content using XMPP message received :"+packet.toXML());
+		}catch (AxisFault e){
+			log.error("Error occured while trying to create " +
+					"message content using XMPP message received :"+packet.toXML(), e);
+			throw new AxisFault("Error occured while trying to create " +
+					"message content using XMPP message received :"+packet.toXML());
+		}
+	}
+
+
+	/**
+	 * The actual Runnable Worker implementation which will process the
+	 * received XMPP messages in the worker thread pool
+	 */
+	class Worker implements Runnable {
+		private Packet packet = null;
+		Worker(Packet packet) {
+			this.packet = packet;
+		}
+
+		public void run() {
+			MessageContext msgCtx = null;
+			try {
+				msgCtx = createMessageContext(packet);
+				if(msgCtx.isProcessingFault() && msgCtx.isServerSide()){
+					AxisEngine.sendFault(msgCtx);
+				}else{
+					AxisEngine.receive(msgCtx);	
+				}
+			} catch (AxisFault e) {
+				log.error("Error occurred while sending message"+e);
+   				if (msgCtx != null && msgCtx.isServerSide()) {
+    				MessageContext faultContext;
+					try {
+						faultContext = MessageContextBuilder.createFaultMessageContext(msgCtx, e);
+	    				AxisEngine.sendFault(faultContext);
+					} catch (AxisFault e1) {
+						log.error("Error occurred while creating SOAPFault message"+e1);
+					}
+   				}
+			}
+		}
+	}
+}

Added: webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPServerCredentials.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPServerCredentials.java?rev=671127&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPServerCredentials.java (added)
+++ webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPServerCredentials.java Tue Jun 24 04:07:03 2008
@@ -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.xmpp.util;
+
+/**
+ * Holds connection details to a XMPP Server 
+ * 
+ */
+public class XMPPServerCredentials {
+	private String accountName;
+	private String serverUrl;
+	private String password;		
+	private String serverType;
+	private String resource; 
+	
+	public String getAccountName() {
+		return accountName;
+	}
+	public void setAccountName(String accountName) {
+		this.accountName = accountName;
+	}
+	public String getServerUrl() {
+		return serverUrl;
+	}
+	public void setServerUrl(String serverUrl) {
+		this.serverUrl = serverUrl;
+	}
+	public String getPassword() {
+		return password;
+	}
+	public void setPassword(String password) {
+		this.password = password;
+	}
+	public String getServerType() {
+		return serverType;
+	}
+	public void setServerType(String serverType) {
+		this.serverType = serverType;
+	}
+	public String getResource() {
+		return resource;
+	}
+	public void setResource(String resource) {
+		this.resource = resource;
+	}
+	
+	public XMPPServerCredentials() {
+		super();
+		this.accountName = "";
+		this.serverUrl = "";
+		this.password = "";
+		this.serverType = "";
+		this.resource = "soapserver"; //Default value
+	}
+	
+	public XMPPServerCredentials(String accountName, String serverUrl,
+			String password, String serverType, String resource) {
+		super();
+		this.accountName = accountName;
+		this.serverUrl = serverUrl;
+		this.password = password;
+		this.serverType = serverType;
+		this.resource = resource;
+	}
+	
+
+}

Added: webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPUtils.java?rev=671127&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPUtils.java (added)
+++ webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/xmpp/util/XMPPUtils.java Tue Jun 24 04:07:03 2008
@@ -0,0 +1,79 @@
+/*
+ * 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.xmpp.util;
+
+import org.apache.axis2.AxisFault;
+
+
+public class XMPPUtils {
+    
+	/**
+	 * Extract XMPP server accountName section from transport URL passed in.  
+	 * @param transportUrl
+	 * @return String 
+	 * @throws AxisFault
+	 */
+    public static String getAccountName(String transportUrl) throws AxisFault{
+    	String accountName = "";
+    	if(transportUrl == null){
+    		return null;
+    	}
+    	
+        if (!transportUrl.startsWith(XMPPConstants.XMPP)) {
+            throw new AxisFault ("Invalid XMPP URL : " + transportUrl +
+                    " Must begin with the prefix xmpp");
+        }
+        //eg: transportUrl is similar to xmpp://axisserver@sumedha/Version
+        int start = transportUrl.indexOf("://") + 3;
+        int end = transportUrl.lastIndexOf("/"); //first index
+        if(start != -1 && end != -1){
+        	accountName = transportUrl.substring(start, end);
+        }else{
+        	accountName = transportUrl;
+        }
+        return accountName;
+    }
+
+    /**
+     * Extract Service name from transport URL passed in
+     * @param transportUrl
+     * @return
+     * @throws AxisFault
+     */
+    public static String getServiceName(String transportUrl) throws AxisFault{
+    	String serviceName = "";
+    	if(transportUrl == null){
+    		return null;
+    	}
+        if (!transportUrl.startsWith(XMPPConstants.XMPP)) {
+            throw new AxisFault ("Invalid XMPP URL : " + transportUrl +
+                    " Must begin with the prefix xmpp");
+        }
+        //eg: transportUrl is similar to xmpp://axisserver@sumedha/Version
+        int start = transportUrl.lastIndexOf("/") + 1;
+        int end = transportUrl.length();
+        if(start != -1 && end != -1){
+        	serviceName = transportUrl.substring(start, end);
+        }
+        return serviceName;
+    }
+    
+}
+

Modified: webservices/axis2/trunk/java/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/pom.xml?rev=671127&r1=671126&r2=671127&view=diff
==============================================================================
--- webservices/axis2/trunk/java/pom.xml (original)
+++ webservices/axis2/trunk/java/pom.xml Tue Jun 24 04:07:03 2008
@@ -44,6 +44,7 @@
         <module>modules/jibx</module>
         <module>modules/json</module>
         <module>modules/kernel</module>
+        <module>modules/transports</module>
         <module>modules/mex</module>
         <module>modules/mtompolicy</module>
         <module>modules/parent</module>