[jboss-svn-commits] JBL Code SVN: r24761 - in labs/jbossesb/workspace/dbevenius/nettygateway/product: etc/schemas/xml and 21 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Jan 18 12:04:05 EST 2009


Author: beve
Date: 2009-01-18 12:04:04 -0500 (Sun, 18 Jan 2009)
New Revision: 24761

Added:
   labs/jbossesb/workspace/dbevenius/nettygateway/product/lib/ext/netty-3.1.0.ALPHA3-SNAPSHOT.jar
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/NettyListenerMapper.java
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/EsbServiceHandler.java
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/NettyGatewayConfig.java
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/NettyGatewayListener.java
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/PipelineFactory.java
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/ResponseHandler.java
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/codec/
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/codec/EsbMessageDecoder.java
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/codec/EsbMessageEncoder.java
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/EsbServiceHandlerUnitTest.java
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/EsbServicePipelineFactoryUnitTest.java
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/MockChannelHandler.java
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/NettyGatewayListenerUnitTest.java
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/TestUtil.java
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/codec/
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/codec/EsbMessageEncoderUnitTest.java
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/decoders/
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/encoders/
   labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/
   labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/build.xml
   labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/deployment.xml
   labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/jboss-esb.xml
   labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/jbossesb-properties.xml
   labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/jndi.properties
   labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/juddi.properties
   labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/log4j.xml
   labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/readme.txt
   labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/src/
   labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/src/org/
   labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/src/org/jboss/
   labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/src/org/jboss/soa/
   labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/src/org/jboss/soa/esb/
   labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/src/org/jboss/soa/esb/samples/
   labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/src/org/jboss/soa/esb/samples/quickstart/
   labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/src/org/jboss/soa/esb/samples/quickstart/nettygateway/
   labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/src/org/jboss/soa/esb/samples/quickstart/nettygateway/test/
   labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/src/org/jboss/soa/esb/samples/quickstart/nettygateway/test/NettyClient.java
Modified:
   labs/jbossesb/workspace/dbevenius/nettygateway/product/build-distr.xml
   labs/jbossesb/workspace/dbevenius/nettygateway/product/etc/schemas/xml/jbossesb-1.0.1.xsd
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/config/GatewayGenerator.java
   labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourier.java
Log:
Adding NettyGateway.


Modified: labs/jbossesb/workspace/dbevenius/nettygateway/product/build-distr.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/build-distr.xml	2009-01-18 15:10:39 UTC (rev 24760)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/build-distr.xml	2009-01-18 17:04:04 UTC (rev 24761)
@@ -134,6 +134,8 @@
             <fileset dir="${lib.ext.dir}" includes="commons-ssl-*.jar"/>
             <!-- groovy -->
             <fileset dir="${lib.dir}" includes="groovy-*.jar"/>
+            <!-- Netty -->
+            <fileset dir="${lib.ext.dir}" includes="netty-*.jar"/>
         </copy>
     	<copy todir="${build.dir}/jbossesb.sar">
     		<fileset dir="${installation.files.dir}/jUDDI-registry" includes="juddi.war"/>

Modified: labs/jbossesb/workspace/dbevenius/nettygateway/product/etc/schemas/xml/jbossesb-1.0.1.xsd
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/etc/schemas/xml/jbossesb-1.0.1.xsd	2009-01-18 15:10:39 UTC (rev 24760)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/etc/schemas/xml/jbossesb-1.0.1.xsd	2009-01-18 17:04:04 UTC (rev 24761)
@@ -1700,5 +1700,106 @@
 			</xsd:complexContent>
 		</xsd:complexType>
 	</xsd:element>
+	
+	<!-- 88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
+        Netty Gateway Type Implementations.
+        88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888-->
+    <xsd:element name="netty-listener" substitutionGroup="jesb:listener">
+        <xsd:annotation>
+            <xsd:documentation xml:lang="en">
+                Netty Listener.
+            </xsd:documentation>
+        </xsd:annotation>
+        <xsd:complexType>
+            <xsd:complexContent>
+                <xsd:extension base="jesb:listener">
+                    <xsd:sequence>
+                        <xsd:element maxOccurs="1" minOccurs="0" ref="jesb:netty-options" />
+                        <xsd:element maxOccurs="1" minOccurs="0" ref="jesb:netty-handlers" />
+                    </xsd:sequence>
+                    <xsd:attribute name="host" type="xsd:string" use="required">
+                        <xsd:annotation>
+                            <xsd:documentation xml:lang="en">
+                                The host that this listener will listen to.
+                            </xsd:documentation>
+                        </xsd:annotation>
+                    </xsd:attribute>
+                    <xsd:attribute name="port" type="xsd:integer" use="required">
+                        <xsd:annotation>
+                            <xsd:documentation xml:lang="en">
+                                The port that this listener will listen to.
+                            </xsd:documentation>
+                        </xsd:annotation>
+                    </xsd:attribute>
+                    <xsd:attribute name="timeout" type="xsd:integer" use="optional" default="-1">
+                        <xsd:annotation>
+                            <xsd:documentation xml:lang="en">
+                                A timeout value if the netty gateway is synchonous. Default is '-1' meaning that the
+                                gateway is asynchronous and no return is excepted from it.
+                            </xsd:documentation>
+                        </xsd:annotation>
+                    </xsd:attribute>
+                </xsd:extension>
+            </xsd:complexContent>
+        </xsd:complexType>
+    </xsd:element>
+    
+    <xsd:element name="netty-options">
+        <xsd:annotation>
+            <xsd:documentation xml:lang="en">
+                Zero or more options that will be passed to Netty ServerBootstrap.
+            </xsd:documentation>
+        </xsd:annotation>
+        <xsd:complexType>
+            <xsd:sequence>
+                <xsd:element maxOccurs="unbounded" minOccurs="0" ref="jesb:netty-option" />
+            </xsd:sequence>
+        </xsd:complexType>
+    </xsd:element>
+    
+    <xsd:element name="netty-handlers">
+        <xsd:annotation>
+            <xsd:documentation xml:lang="en">
+               One or more ChannelHandler that will be added to the Netty ChannelPipeline. 
+            </xsd:documentation>
+        </xsd:annotation>
+        <xsd:complexType>
+            <xsd:sequence>
+                <xsd:element maxOccurs="unbounded" minOccurs="1" ref="jesb:netty-handler" />
+            </xsd:sequence>
+        </xsd:complexType>
+    </xsd:element>
+    
+    <xsd:element name="netty-option">
+        <xsd:annotation>
+            <xsd:documentation xml:lang="en">
+                Netty ServerBootstrap options.
+            </xsd:documentation>
+        </xsd:annotation>
+        <xsd:complexType>
+            <xsd:complexContent>
+                <xsd:extension base="xsd:anyType">
+                    <xsd:attribute name="name" type="xsd:string" use="required" />
+                    <xsd:attribute name="value" type="xsd:string" use="required" />
+                </xsd:extension>
+            </xsd:complexContent>
+        </xsd:complexType>
+    </xsd:element>
+    
+    <xsd:element name="netty-handler">
+        <xsd:annotation>
+            <xsd:documentation xml:lang="en">
+                Netty ChannelHandlers. 'name' will be the name of the handler.
+            </xsd:documentation>
+        </xsd:annotation>
+        <xsd:complexType>
+            <xsd:complexContent>
+                <xsd:extension base="xsd:anyType">
+                    <xsd:attribute name="name" type="xsd:string" use="required" />
+                    <xsd:attribute name="class" type="xsd:string" use="required" />
+                </xsd:extension>
+            </xsd:complexContent>
+        </xsd:complexType>
+    </xsd:element>
 
 </xsd:schema>

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/lib/ext/netty-3.1.0.ALPHA3-SNAPSHOT.jar
===================================================================
(Binary files differ)


Property changes on: labs/jbossesb/workspace/dbevenius/nettygateway/product/lib/ext/netty-3.1.0.ALPHA3-SNAPSHOT.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/config/GatewayGenerator.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/config/GatewayGenerator.java	2009-01-18 15:10:39 UTC (rev 24760)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/config/GatewayGenerator.java	2009-01-18 17:04:04 UTC (rev 24761)
@@ -39,7 +39,9 @@
 import org.jboss.soa.esb.listeners.config.xbeanmodel.Listener;
 import org.jboss.soa.esb.listeners.config.xbeanmodel.JcaGatewayDocument;
 import org.jboss.soa.esb.listeners.config.xbeanmodel.AbstractScheduledListener;
+import org.jboss.soa.esb.listeners.config.xbeanmodel.NettyListenerDocument;
 import org.jboss.soa.esb.listeners.config.mappers.*;
+import org.jboss.soa.esb.listeners.gateway.netty.NettyGatewayListener;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
@@ -138,6 +140,8 @@
             listenerConfig = GroovyListenerMapper.map(root, (GroovyListener) gateway, model);
         } else if (gateway instanceof HibernateListener) {
             listenerConfig = HibernateListenerMapper.map(root, (HibernateListener) gateway, model);
+        } else if (gateway instanceof NettyListenerDocument.NettyListener) {
+            listenerConfig = NettyListenerMapper.map(root, (NettyListenerDocument.NettyListener)gateway, model);
         } else {
             listenerConfig = UntypedListenerMapper.map(root, gateway, model);
         }

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/NettyListenerMapper.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/NettyListenerMapper.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/NettyListenerMapper.java	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.listeners.config.mappers;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.dom.YADOMUtil;
+import org.jboss.soa.esb.listeners.config.Generator;
+import org.jboss.soa.esb.listeners.config.xbeanmodel.NettyListenerDocument;
+import org.jboss.soa.esb.listeners.gateway.netty.NettyGatewayConfig;
+import org.jboss.soa.esb.listeners.gateway.netty.NettyGatewayListener;
+import org.w3c.dom.Element;
+
+/**
+ * Config mapper class for the Netty Listener.
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class NettyListenerMapper {
+
+    public static Element map(final Element root, final NettyListenerDocument.NettyListener listener, final Generator.XMLBeansModel model) throws ConfigurationException 
+    {
+        final Element listenerNode = YADOMUtil.addElement(root, "listener");
+
+        listenerNode.setAttribute("name", listener.getName());
+
+        // Map the standard listener attributes - common across all listener types...
+        MapperUtil.mapDefaultAttributes(listener, listenerNode, model);
+        
+        // Map the <property> elements targeted at the listener - from the listener itself.
+        MapperUtil.mapProperties(listener.getPropertyList(), listenerNode);
+
+        listenerNode.setAttribute("gatewayClass", NettyGatewayListener.class.getName());
+
+        // Map the host and port
+        listenerNode.setAttribute(NettyGatewayConfig.HOST_ATTR, listener.getHost());
+        listenerNode.setAttribute(NettyGatewayConfig.PORT_ATTR, listener.getPort().toString());
+        listenerNode.setAttribute(NettyGatewayConfig.TIMEOUT_ATTR, listener.getTimeout().toString());
+        
+        // Map the handlers.
+        Element handlers = YADOMUtil.addElement(listenerNode, NettyGatewayConfig.HANDLERS_ELEMENT_NAME);
+        MapperUtil.serialize(listener.getNettyHandlers(), handlers);
+        
+        // Map the server bootstrap options.
+        Element options = YADOMUtil.addElement(listenerNode, NettyGatewayConfig.OPTIONS_ELEMENT_NAME);
+        MapperUtil.serialize(listener.getNettyOptions(), options);
+        
+        return listenerNode;
+    }
+}

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/EsbServiceHandler.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/EsbServiceHandler.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/EsbServiceHandler.java	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,146 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.gateway.netty;
+
+import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelPipelineCoverage;
+import org.jboss.netty.channel.ExceptionEvent;
+import org.jboss.netty.channel.MessageEvent;
+import org.jboss.netty.channel.SimpleChannelHandler;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.listeners.gateway.netty.codec.EsbMessageDecoder;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+
+/**
+ * Extends Netty's SimpleChannelHandler and upon recieving a MessageEvent
+ * will invoke the ESB service that this handler was created with.
+ * <p/> 
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+ at ChannelPipelineCoverage ("one")
+public class EsbServiceHandler extends SimpleChannelHandler
+{
+    /**
+     * Logger.
+     */
+    private Logger log = Logger.getLogger(EsbServiceHandler.class);
+    
+    /**
+     * {@link ServiceInvoker} that will delegate to the ESB.
+     */
+    private ServiceInvoker serviceInvoker;
+    
+    /**
+     * The timeout what will be used if the call to the ESB should block
+     * and return something to the calling client.
+     */
+    private long timeout;
+    
+    /**
+     * Constructs a EsbServiceHandler intended for asynchronous calls.
+     * 
+     * @param invoker The {@link ServiceInvoker} that this handler will use.
+     */
+    public EsbServiceHandler(final ServiceInvoker invoker)
+    {
+        this(invoker, -1);
+    }
+    
+    /**
+     * Constructs a EsbServiceHandler intended for synchronous calls.
+     * 
+     * @param invoker   The {@link ServiceInvoker} that this handler will use.
+     * @param timout    The time to wait before timing out when invoking the ESB target service.
+     */
+    public EsbServiceHandler(final ServiceInvoker invoker, final long timeout)
+    {
+        AssertArgument.isNotNull(invoker, "invoker");
+        this.serviceInvoker = invoker;
+        this.timeout = timeout;
+    }
+    
+    /**
+     * Takes the MessageEvent message that should be an {@link Message} object instance. This task 
+     * is performed by the {@link EsbMessageDecoder}.
+     * </p>
+     * 
+     * 
+     * @param ctx   The Netty ChannelHandlerContext.
+     * @param event The Netty MessageEvent. This events getMessage() method must return a {@link Message} object.
+     */
+    @Override
+    public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent event)
+    {
+        log.info("MessageEvent '" + event.getClass().getName() + "'");
+        
+        final Message esbMessage = (Message) event.getMessage();
+        final Channel channel = event.getChannel();
+        if (isSync())
+        {
+            try
+            {
+                final Message responseMsg = serviceInvoker.deliverSync(esbMessage, timeout);
+                channel.write(responseMsg);
+            } 
+            catch (final Exception e)
+            {
+                final Message errorMsg = MessageFactory.getInstance().getMessage();
+                errorMsg.getBody().add(e);
+                channel.write(errorMsg);
+            }
+        }
+        else
+        {
+            try
+            {
+                serviceInvoker.deliverAsync(esbMessage);
+                channel.close();
+            }
+            catch (final MessageDeliverException e)
+            {
+                log.error("Caught MessageDeliveryException :", e);
+            }
+        }
+    }
+    
+    /**
+     * Handle exceptions while processing.
+     */
+    @Override
+    public void exceptionCaught(final ChannelHandlerContext ctx, final ExceptionEvent e) throws Exception
+    {
+        log.error(e.getCause().getMessage(), e.getCause());
+        e.getChannel().close();
+    }
+    
+    private boolean isSync()
+    {
+        return timeout > 0L;
+    }
+    
+    
+}

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/NettyGatewayConfig.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/NettyGatewayConfig.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/NettyGatewayConfig.java	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,276 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.gateway.netty;
+
+import java.net.InetSocketAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.netty.channel.ChannelHandler;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.ListenerTagNames;
+import org.jboss.soa.esb.util.ClassUtil;
+
+/**
+ * Deals with Netty configuration properties and parsing.
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class NettyGatewayConfig
+{
+    /**
+     * Host name configuration attribute name.
+     */
+    public static final String HOST_ATTR  = "host";
+    
+    /**
+     * Port configuration attribute name.
+     */
+    public static final String PORT_ATTR  = "port";
+    
+    /**
+     * Options configuration element name.
+     */
+    public static final String OPTIONS_ELEMENT_NAME = "options";
+    
+    /**
+     * Option configuration element name.
+     */
+    public static final String OPTION_ELEMENT_NAME = "netty-option";
+    
+    /**
+     * Handlers configuration element name.
+     */
+    public static final String HANDLERS_ELEMENT_NAME  = "handlers";
+    
+    /**
+     * Handler configuration element name.
+     */
+    public static final String HANDLER_ELEMENT_NAME  = "netty-handler";
+    
+    /**
+     * Handler class configuration attribute name.
+     */
+    public static final String HANDLER_CLASS_ATTR  = "class";
+    
+    /**
+     * Timeout configuration attribute name.
+     */
+    public static final String TIMEOUT_ATTR  = "timeout";
+    
+    /**
+     * Name configuration attribute name.
+     */
+    public static final String NAME_ATTR  = "name";
+    
+    /**
+     * Value configuration attribute name.
+     */
+    public static final String VALUE_ATTR  = "value";
+    
+    /**
+     * ConfigTree with contains the elements and attributes
+     * from the configuration file.
+     */
+    private final ConfigTree config;
+    
+    
+    /**
+     * Sole constructor.
+     * 
+     * @param   config The {@link ConfigTree} that contains the configuration information.
+     */
+    public NettyGatewayConfig(final ConfigTree config)
+    {
+        this.config = config;
+    }
+    
+    /**
+     * Gets the port from the configuration.
+     * 
+     * @return  {@code int} the port that the gateway should listen to.
+     * 
+     * @throws  ConfigurationException 
+     *          If the port was missing from the configuration or it could not be parse as an int.
+     */
+    public int getPort() throws ConfigurationException
+    {
+        return parsePort(config.getRequiredAttribute(PORT_ATTR));
+    }
+    
+    /**
+     * Gets the {@link InetSocketAddress} that this gateway should listen to.
+     * 
+     * @return  {@code InetSocketAddress} the {@link InetSocketAddress} that the gateway should listen to.
+     * 
+     * @throws  ConfigurationException
+     *          If the host or port was missing from the configuration or if the port could not be parsed.
+     */
+    public InetSocketAddress getSocketAddress() throws ConfigurationException
+    {
+        return new InetSocketAddress(config.getRequiredAttribute(HOST_ATTR), getPort());
+    }
+    
+    /**
+     * Gets the timeout.
+     * 
+     * @return  {@code long} the timeout if the call to the esb should be synchonous. -1 if no timeout as specified.
+     * 
+     */
+    public long getTimeout()
+    {
+       return config.getLongAttribute(TIMEOUT_ATTR, -1l);
+    }
+    
+    /**
+     * Gets the target service category from the configuration.
+     * 
+     * @return  {@code String}   The target service category
+     * 
+     * @throws  ConfigurationException
+     *          If service category attribute is missing from the configuration.
+     */
+    public String getServiceCategory() throws ConfigurationException
+    {
+        return config.getRequiredAttribute(ListenerTagNames.TARGET_SERVICE_CATEGORY_TAG);
+    }
+    
+    /**
+     * Gets the target service name from the configuration.
+     * 
+     * @return  {@code String}   The target service name
+     * 
+     * @throws  ConfigurationException
+     *          If service name attribute is missing from the configuration.
+     */
+    public String getServiceName() throws ConfigurationException
+    {
+        return config.getRequiredAttribute(ListenerTagNames.TARGET_SERVICE_NAME_TAG);
+    }
+    
+    /**
+     * Gets the {@link ChannelHandler}s from the configuration.
+     * 
+     * @return  {@code Map<String, ChannelHandler} Map of channelhandler names and {@link ChannelHandler}s.
+     * 
+     * @throws  ConfigurationException
+     *          If one of the specified channelhandler classes could not be loaded.
+     */
+    public Map<String, ChannelHandler> getChannelHandlers() throws ConfigurationException
+    {
+        HashMap<String, ChannelHandler> handlerMap = new HashMap<String, ChannelHandler>();
+        for (final ConfigTree handlers : config.getChildren(HANDLERS_ELEMENT_NAME))
+        {
+            for (final ConfigTree handler : handlers.getChildren(HANDLER_ELEMENT_NAME))
+            {
+                final String name = handler.getRequiredAttribute(NAME_ATTR);
+                final String className = handler.getRequiredAttribute(HANDLER_CLASS_ATTR);
+                final ChannelHandler channelHandler = loadChannelHandler(className);
+                handlerMap.put(name, channelHandler);
+            }
+        }
+        return handlerMap;
+    }
+    
+    /**
+     * Gets the Netty server bootstrap options form the configuration. 
+     * 
+     * @return  {@code Map<String, String} Map of Netty server bootstrap options.
+     * 
+     * @throws  ConfigurationException
+     *          If one of the specified option element does not contains the required 
+     *          attributes 'name' and 'value'.
+     */
+    public Map<String, String> getOptions() throws ConfigurationException
+    {
+        HashMap<String, String> optionsMap = new HashMap<String, String>();
+        for (final ConfigTree options : config.getChildren(OPTIONS_ELEMENT_NAME))
+        {
+            for (final ConfigTree option : options.getChildren(OPTION_ELEMENT_NAME))
+            {
+                final String name = option.getRequiredAttribute(NAME_ATTR);
+                final String value = option.getRequiredAttribute(VALUE_ATTR);
+                optionsMap.put(name, value);
+            }
+        }
+        return optionsMap;
+    }
+    
+    private ChannelHandler loadChannelHandler(final String handlerClass) throws ConfigurationException
+    {
+        return newInstance(loadClass(handlerClass));
+    }
+    
+    private Class<?> loadClass(final String className) throws ConfigurationException
+    {
+        try
+        {
+            return ClassUtil.forName(className, getClass());
+        } 
+        catch (final ClassNotFoundException e)
+        {
+            throw new ConfigurationException("Could not load class '" + className + "'", e);
+        } 
+    }
+
+    private ChannelHandler newInstance(final Class<?> handlerClass) throws ConfigurationException
+    {
+        try
+        {
+            final Object handler = handlerClass.newInstance();
+            if (!(handler instanceof ChannelHandler))
+            {
+                throw new ConfigurationException("Handler class '" + handlerClass.getName() + "' does not implement ChannelHandler");
+            }
+            return (ChannelHandler) handler;
+        }
+        catch (InstantiationException e)
+        {
+            throw new ConfigurationException("Could not instantiate class '" + handlerClass.getName() + "'", e);
+        } 
+        catch (IllegalAccessException e)
+        {
+            throw new ConfigurationException("IllegalAccess while trying to instantiate '" + handlerClass.getName() + "'", e);
+        }
+    }
+    
+    public static int parsePort(String portString) throws ConfigurationException
+    {
+        int parseInt;
+        try
+        {
+            parseInt = Integer.parseInt(portString);
+        }
+        catch (final NumberFormatException e)
+        {
+            throw new ConfigurationException("port must be a postive integer. It was '" + portString +"'");
+        }
+        
+        if (parseInt <= 0)
+        {
+            throw new ConfigurationException("port must be a postive integer. It was '" + portString +"'");
+        }
+        return parseInt;
+    }
+    
+}

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/NettyGatewayListener.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/NettyGatewayListener.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/NettyGatewayListener.java	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,202 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.listeners.gateway.netty;
+
+import java.net.InetSocketAddress;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.Executors;
+
+import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelFactory;
+import org.jboss.netty.channel.ChannelHandler;
+import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.lifecycle.AbstractManagedLifecycle;
+import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+
+/**
+ * Netty gateway listener implementation for receiving ESB unaware messages.
+ * <p/>
+ * This gateway will set up a netty server and listen for incoming connection request. The 
+ * requests will be passed to the Netty channel pipeline configured and the last handler will
+ * invoke the target ESB service.
+ * 
+ * Example configuration:
+ * <pre>{@code
+ * <netty-listener name="netty-listener" host="localhost" port="9999" is-gateway="true" timeout="5000">
+ *  <netty-options>
+ *     <netty-option name="child.tcpNoDelay" value="true"/>
+ *     <netty-option name="child.keepAlive" value="true"/>
+ *  </netty-options>
+ *  <netty-handlers>
+ *      <netty-handler name="esbMessageDecoder" class="org.jboss.soa.esb.listeners.gateway.netty.decoders.EsbMessageDecoder"/>
+ *      <netty-handler name="esbMessageEncoder" class="org.jboss.soa.esb.listeners.gateway.netty.encoders.EsbMessageEncoder"/>
+ *  </netty-handlers>
+ * </netty-listener>
+ * }</pre>
+ * <lu>
+ * <li>{@code host} the host to listen to.</li>
+ * <li>{@code port} the port to listen on.</li>
+ * <li>{@code is-gateway} is always true as netty cannot be used as a bus transport at the moment..</li>
+ * <li>{@code timeout} if not -1 then this indicated that this gateways is synchonrous and will block calling the ESB target service.
+ *                     this is the amount of time that before the call will timeout.</li>
+ * <li>{@code netty-options} options to the server bootstrap. These will passed to netty as is.</li>
+ * <li>{@code netty-handlers} Netty ChannelHandlers that should be added to this gateways channel pipeline.</li>
+ * </lu>
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class NettyGatewayListener extends AbstractManagedLifecycle
+{
+    /**
+     * Serial version unique identifier.
+     */
+    private static final long serialVersionUID = 1L;
+    
+    /**
+     * Class Logger instance.
+     */
+    private Logger log = Logger.getLogger(NettyGatewayListener.class);
+    
+    /**
+     * The local address this gateway listeners to.
+     */
+    private InetSocketAddress socketAddress;
+    
+    /**
+     * The target service category that this gateway should dispatch to.
+     */
+    private String serviceCategory;
+
+    /**
+     * The target service name that this gateway should dispatch to.
+     */
+    private String serviceName;
+    
+    /**
+     * Timeout for synchronous service invocations.
+     */
+    private long timeout;
+
+    /**
+     * Custom ChannelHandlers specified in the configuration.
+     * These can be endoders, decoders or what ever is required.
+     */
+    private Map<String, ChannelHandler> handlersMap = new HashMap<String, ChannelHandler>();
+    
+    /**
+     * Netty server bootstap options.
+     */
+    private Map<String, String> bootstrapOptions = new HashMap<String, String>();
+
+    /**
+     * The {@link Channel} that this gateway is bound to.
+     */
+    private Channel serverChannel;
+
+    /**
+     *
+     * @param config The configuration associated with this instance. Must not be null.
+     * @throws ConfigurationException if a configuration errors during initialisation.
+     */
+    public NettyGatewayListener(final ConfigTree config) throws ConfigurationException 
+    {
+        super(config);
+        final NettyGatewayConfig nettyConfig = new NettyGatewayConfig(config);
+        socketAddress = nettyConfig.getSocketAddress();
+        timeout = nettyConfig.getTimeout();
+        serviceCategory = nettyConfig.getServiceCategory();
+        serviceName = nettyConfig.getServiceName();
+        handlersMap = nettyConfig.getChannelHandlers();
+        bootstrapOptions = nettyConfig.getOptions();
+    }
+
+    @Override
+    protected void doInitialise() throws ManagedLifecycleException 
+    {
+        final ChannelFactory channelFactory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool());
+        final ServerBootstrap serverBootstrap = new ServerBootstrap(channelFactory);
+        
+        for (Entry<String, String> entry : bootstrapOptions.entrySet())
+        {
+            serverBootstrap.setOption(entry.getKey(), entry.getValue());
+        }
+        
+        final ServiceInvoker serviceInvoker = createServiceInvoker(serviceCategory, serviceName);
+        PipelineFactory pipelineFactory = new PipelineFactory(new EsbServiceHandler(serviceInvoker, timeout), handlersMap);
+        serverBootstrap.setPipelineFactory(pipelineFactory);
+        serverChannel = serverBootstrap.bind(socketAddress);
+        
+        log.info("Started " + toString());
+    }
+
+    @Override
+    protected void doStart() throws ManagedLifecycleException
+    {
+        // NoOp
+    }
+    
+    @Override
+    protected void doStop() throws ManagedLifecycleException 
+    {
+        serverChannel.getFactory().releaseExternalResources();
+        log.info("Stopped " + toString());
+    }
+
+    @Override
+    protected void doDestroy() throws ManagedLifecycleException 
+    {
+        // NoOp
+    }
+
+    private ServiceInvoker createServiceInvoker(final String serviceCategory, final String serviceName) throws ManagedLifecycleException
+    {
+        AssertArgument.isNotNull(serviceCategory, "serviceCategory");
+        AssertArgument.isNotNull(serviceName, "serviceName");
+        try
+        {
+            return new ServiceInvoker(serviceCategory, serviceName);
+        } 
+        catch (MessageDeliverException e)
+        {
+            throw new ManagedLifecycleException(e.getMessage(), e);
+        }
+    }
+
+    Map<String, ChannelHandler> getHandlers()
+    {
+        return Collections.unmodifiableMap(handlersMap);
+    }
+    
+    @Override
+    public String toString()
+    {
+        return "NettyGatewayListener [address=" + socketAddress + ", targetService=" + serviceCategory + ":" + serviceName + ", timeout=" + timeout + ", handlers=" + handlersMap + ", options=" + bootstrapOptions + "]";
+    }
+}

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/PipelineFactory.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/PipelineFactory.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/PipelineFactory.java	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.gateway.netty;
+
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.netty.channel.ChannelHandler;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.channel.ChannelPipelineFactory;
+import org.jboss.netty.channel.Channels;
+
+/**
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class PipelineFactory implements ChannelPipelineFactory 
+{
+    private static final String DEFAULT_HANDLER = "DefaultHandler";
+    
+    private final ChannelHandler defaultHandler;
+    
+    private Map<String, ChannelHandler> handlers;
+
+    public PipelineFactory(final ChannelHandler defaultHandler, final Map<String, ChannelHandler> handlers) 
+    {
+        AssertArgument.isNotNull(defaultHandler, "handler");
+        AssertArgument.isNotNull(handlers, "handlers");
+        this.defaultHandler = defaultHandler;
+        this.handlers = handlers;
+    }
+
+    public ChannelPipeline getPipeline() throws Exception 
+    {
+        final ChannelPipeline pipeline = Channels.pipeline();
+        addHandlers(pipeline).addLast(DEFAULT_HANDLER, defaultHandler);
+        return pipeline;
+    }
+    
+    private ChannelPipeline addHandlers(final ChannelPipeline pipeline)
+    {
+        for (Entry<String, ChannelHandler> entry : handlers.entrySet())
+        {
+            pipeline.addLast(entry.getKey(), entry.getValue());
+        }
+        return pipeline;
+    }
+}

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/ResponseHandler.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/ResponseHandler.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/ResponseHandler.java	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.gateway.netty;
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import org.jboss.netty.channel.ChannelFuture;
+import org.jboss.netty.channel.ChannelFutureListener;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelPipelineCoverage;
+import org.jboss.netty.channel.ExceptionEvent;
+import org.jboss.netty.channel.MessageEvent;
+import org.jboss.netty.channel.SimpleChannelHandler;
+
+/**
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ * @param <T>
+ */
+ at ChannelPipelineCoverage("one")
+public class ResponseHandler<T extends Object> extends SimpleChannelHandler
+{
+    final BlockingQueue<T> response = new LinkedBlockingQueue<T>();
+
+    @Override
+    public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent e)
+    {
+        e.getChannel().close().addListener(new ChannelFutureListener()
+        {
+            @SuppressWarnings("unchecked")
+            public void operationComplete(ChannelFuture future)
+            {
+                response.offer((T) e.getMessage());
+            }
+        });
+    }
+
+    public Object getPayload()
+    {
+        for (;;)
+        {
+            try
+            {
+                return response.take();
+            } 
+            catch (final InterruptedException ignored)
+            {
+            }
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public void exceptionCaught(final ChannelHandlerContext ctx, final ExceptionEvent e)
+    {
+        response.offer((T) e.getCause());
+        e.getChannel().close();
+    }
+}

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/codec/EsbMessageDecoder.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/codec/EsbMessageDecoder.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/codec/EsbMessageDecoder.java	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.gateway.netty.codec;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelPipelineCoverage;
+import org.jboss.netty.handler.codec.oneone.OneToOneDecoder;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+
+/**
+ * A simple decoder that will add a String to ESB Messages default body location. 
+ * Other locations and types can be returned by creating new decoders.
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+ at ChannelPipelineCoverage("all")
+public class EsbMessageDecoder extends OneToOneDecoder
+{
+    @Override
+    protected Object decode(final ChannelHandlerContext ctx, final Channel channel, final Object msg) throws Exception
+    {
+        if (!(msg instanceof ChannelBuffer)) 
+        {
+            return msg;
+        }
+        
+        final String payload = ((ChannelBuffer) msg).toString("UTF-8");
+        
+        final Message esbMessage = MessageFactory.getInstance().getMessage();
+        esbMessage.getBody().add(payload);
+        return esbMessage;
+    }
+}

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/codec/EsbMessageEncoder.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/codec/EsbMessageEncoder.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/netty/codec/EsbMessageEncoder.java	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.gateway.netty.codec;
+
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelPipelineCoverage;
+import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
+import org.jboss.soa.esb.message.Message;
+
+/**
+ * A simple encoder that will extract the ESB Message payload from the 
+ * default body location. 
+ * 
+ * Other locations can be returned by creating new decoders.
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+ at ChannelPipelineCoverage("all")
+public class EsbMessageEncoder extends OneToOneEncoder
+{
+    @Override
+    protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception
+    {
+        if (msg instanceof Message)
+        {
+            final Message esbMessage = (Message) msg;
+            final Object payload = esbMessage.getBody().get();
+            if (payload instanceof String)
+            {
+                return ChannelBuffers.copiedBuffer((String) payload, "UTF-8");
+            }
+            else if (payload instanceof Exception)
+            {
+                final Exception exception = (Exception) payload;
+                return ChannelBuffers.copiedBuffer(exception.getMessage(), "UTF-8");
+            }
+        }
+        
+        return msg;
+    }
+}

Modified: labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourier.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourier.java	2009-01-18 15:10:39 UTC (rev 24760)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourier.java	2009-01-18 17:04:04 UTC (rev 24761)
@@ -38,10 +38,17 @@
     public boolean deliveryAttempted = false;
     public CourierException courierException;
     public MalformedEPRException malformedEPRException;
+    private boolean setPickupMessage;
 
     public MockCourier(boolean deliveryResult) {
         this.deliveryResult = deliveryResult;
     }
+    
+    public MockCourier(boolean deliveryResult, boolean setPickupMessage) {
+        this.deliveryResult = deliveryResult;
+        this.setPickupMessage = setPickupMessage;
+        
+    }
 
     public MockCourier(CourierException courierException) {
         this.courierException = courierException;
@@ -65,6 +72,11 @@
             this.message = message;
         }
         
+        if (setPickupMessage)
+        {
+            pickupMessage = message;
+        }
+        
         return deliveryResult;
     }
 

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/EsbServiceHandlerUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/EsbServiceHandlerUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/EsbServiceHandlerUnitTest.java	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.gateway.netty;
+
+import static org.junit.Assert.assertEquals;
+import junit.framework.JUnit4TestAdapter;
+
+import org.jboss.internal.soa.esb.couriers.MockCourier;
+import org.jboss.internal.soa.esb.couriers.MockCourierFactory;
+import org.jboss.internal.soa.esb.services.registry.MockRegistry;
+import org.jboss.netty.channel.Channel;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.eprs.InVMEpr;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Unit test for {@link EsbServiceHandler}.
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class EsbServiceHandlerUnitTest
+{
+    private static final String SERVICE_CATEGORY = "TestCategory";
+    private static final String SERVICE_NAME = "TestService";
+    
+    private static final String HOST = "localhost";
+    private static final int PORT = 8988;
+    
+    private MockCourier mockCourier;
+    private ServiceInvoker serviceInvoker;
+    
+    @Test
+    public void sendAsync() throws Exception
+    {
+        final String payload = "Sample text payload";
+        final Channel serverChannel = TestUtil.startSocketServer(HOST, PORT, serviceInvoker, 0l);
+        final Channel clientChannel = TestUtil.startClientAndWrite(HOST, PORT, payload);
+        
+        Thread.sleep(100l);
+        assertEquals(mockCourier.message.getBody().get(), payload);
+        
+        clientChannel.getFactory().releaseExternalResources();
+        serverChannel.getFactory().releaseExternalResources();
+    }
+    
+    @SuppressWarnings("unchecked")
+    @Test
+    public void sendSync() throws Exception
+    {
+        final String payload = "Sample text payload";
+        final Channel serverChannel = TestUtil.startSocketServer(HOST, PORT, serviceInvoker, 5000l);
+        final Channel clientChannel = TestUtil.startClientAndWrite(HOST, PORT, payload);
+        
+        final ResponseHandler<String> handler = (ResponseHandler<String>) clientChannel.getPipeline().getLast();
+        assertEquals(payload, handler.getPayload());
+        
+        clientChannel.getFactory().releaseExternalResources();
+        serverChannel.getFactory().releaseExternalResources();
+    }
+    
+    @Before
+    public void setUp() throws Exception 
+    {
+        MockCourierFactory.install();
+        MockRegistry.install();
+        mockCourier = new MockCourier(true, true);
+        MockRegistry.register(SERVICE_CATEGORY, SERVICE_NAME, new InVMEpr(new EPR()), mockCourier);
+        serviceInvoker = new ServiceInvoker(SERVICE_CATEGORY, SERVICE_NAME);
+    }
+    
+    @After
+    public void tearDown() throws Exception 
+    {
+        MockRegistry.uninstall();
+        MockCourierFactory.uninstall();
+    }
+
+    public static junit.framework.Test suite()
+    {
+        return new JUnit4TestAdapter(EsbServiceHandlerUnitTest.class);
+    }
+
+}

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/EsbServicePipelineFactoryUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/EsbServicePipelineFactoryUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/EsbServicePipelineFactoryUnitTest.java	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.gateway.netty;
+
+import static org.junit.Assert.*;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.netty.channel.ChannelHandler;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.junit.Test;
+
+import junit.framework.JUnit4TestAdapter;
+
+/**
+ * Unit test for {@link PipelineFactory}.
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class EsbServicePipelineFactoryUnitTest
+{
+    @SuppressWarnings("unchecked")
+    @Test (expected = IllegalArgumentException.class)
+    public void constructorNullHandler()
+    {
+        new PipelineFactory(null, Collections.EMPTY_MAP);
+    }
+    
+    @Test
+    public void constructor() throws Exception
+    {
+        ResponseHandler<String> handler = new ResponseHandler<String>();
+        Map<String, ChannelHandler> handlers = new HashMap<String, ChannelHandler>();
+        handlers.put("decoder", new StringDecoder());
+        handlers.put("encoder", new StringEncoder());
+        
+        final PipelineFactory factory = new PipelineFactory(handler, handlers);
+        ChannelPipeline pipeline = factory.getPipeline();
+        
+        assertEquals(handler, pipeline.getLast());
+        assertNotNull(pipeline.get("decoder"));
+        assertNotNull(pipeline.get("encoder"));
+    }
+    
+    public static junit.framework.Test suite()
+    {
+        return new JUnit4TestAdapter(EsbServicePipelineFactoryUnitTest.class);
+    }
+
+}

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/MockChannelHandler.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/MockChannelHandler.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/MockChannelHandler.java	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.gateway.netty;
+
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelPipelineCoverage;
+import org.jboss.netty.channel.ExceptionEvent;
+import org.jboss.netty.channel.MessageEvent;
+import org.jboss.netty.channel.SimpleChannelHandler;
+
+/**
+ * Mock handler used for testing. 
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+ at ChannelPipelineCoverage ("one")
+public class MockChannelHandler extends SimpleChannelHandler
+{
+    private boolean invoked;
+
+    @Override
+    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception
+    {
+        invoked = true;
+        Object message = e.getMessage();
+        System.out.println(message);
+        if (e.getChannel().getParent() != null) 
+        {
+            e.getChannel().write(message);
+        }
+    }
+    
+    @Override
+    public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception
+    {
+        e.getCause().printStackTrace();
+        e.getChannel().close();
+    }
+
+    public boolean isInvoked()
+    {
+        return invoked;
+    }
+    
+}

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/NettyGatewayListenerUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/NettyGatewayListenerUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/NettyGatewayListenerUnitTest.java	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,210 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.gateway.netty;
+
+import static org.jboss.soa.esb.listeners.gateway.netty.NettyGatewayConfig.HANDLERS_ELEMENT_NAME;
+import static org.jboss.soa.esb.listeners.gateway.netty.NettyGatewayConfig.HANDLER_CLASS_ATTR;
+import static org.jboss.soa.esb.listeners.gateway.netty.NettyGatewayConfig.HANDLER_ELEMENT_NAME;
+import static org.jboss.soa.esb.listeners.gateway.netty.NettyGatewayConfig.HOST_ATTR;
+import static org.jboss.soa.esb.listeners.gateway.netty.NettyGatewayConfig.NAME_ATTR;
+import static org.jboss.soa.esb.listeners.gateway.netty.NettyGatewayConfig.OPTIONS_ELEMENT_NAME;
+import static org.jboss.soa.esb.listeners.gateway.netty.NettyGatewayConfig.OPTION_ELEMENT_NAME;
+import static org.jboss.soa.esb.listeners.gateway.netty.NettyGatewayConfig.PORT_ATTR;
+import static org.jboss.soa.esb.listeners.gateway.netty.NettyGatewayConfig.VALUE_ATTR;
+import static org.junit.Assert.assertEquals;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.jboss.internal.soa.esb.couriers.MockCourier;
+import org.jboss.internal.soa.esb.couriers.MockCourierFactory;
+import org.jboss.internal.soa.esb.services.registry.MockRegistry;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelHandler;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.ListenerTagNames;
+import org.jboss.soa.esb.listeners.gateway.netty.codec.EsbMessageDecoder;
+import org.jboss.soa.esb.listeners.gateway.netty.codec.EsbMessageEncoder;
+import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Unit test for {@link NettyGatewayListener}.
+ * </p>
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class NettyGatewayListenerUnitTest
+{
+    private static final String SERVICE_CATEGORY = "TestCategory";
+    private static final String SERVICE_NAME = "TestService";
+    private static final String HOST = "localhost";
+    private static final int PORT = 9688;
+    
+    private MockCourier mockCourier;
+    private MockCourier mockCourier2;
+    
+    @Test
+    public void parseChannelHandlersFromConfig() throws ConfigurationException, ManagedLifecycleException
+    {
+        final Map<String, ChannelHandler> handlers = createHandlers();
+        final Map<String, String> options = createOptions();
+        final ConfigTree config = createConfig(HOST, "9588", options, handlers, SERVICE_CATEGORY, SERVICE_NAME);
+        final NettyGatewayListener gateway = new NettyGatewayListener(config);
+        
+        gateway.initialise();
+        Map<String, ChannelHandler> actualHandlers = gateway.getHandlers();
+        assertEquals(handlers.keySet(), actualHandlers.keySet());
+        gateway.doStop();
+    }
+    
+    @Test
+    public void lifecycle() throws ConfigurationException, ManagedLifecycleException, InterruptedException, URISyntaxException
+    {
+        Map<String, ChannelHandler> handlers = createHandlers();
+        final Map<String, String> options = createOptions();
+        final ConfigTree config = createConfig(HOST, String.valueOf(PORT), options, handlers, SERVICE_CATEGORY, SERVICE_NAME);
+        NettyGatewayListener gateway = new NettyGatewayListener(config);
+        gateway.initialise();
+        gateway.doStart();
+        
+        final String payload = "Some content";
+        final Channel clientChannel = TestUtil.startClientAndWrite(HOST, PORT, payload);
+        
+        Thread.sleep(1000l);
+        assertEquals(payload, mockCourier.message.getBody().get());
+        
+        clientChannel.getFactory().releaseExternalResources();
+        gateway.doStop();
+    }
+    
+    @Before
+    public void setUp() throws Exception 
+    {
+        MockCourierFactory.install();
+        MockRegistry.install();
+        mockCourier = new MockCourier(true, true);
+        mockCourier2 = new MockCourier(true, true);
+        MockRegistry.register(SERVICE_CATEGORY, SERVICE_NAME, new EPR(new URI("jms://localhost:8080/queue1")), mockCourier);
+        MockRegistry.register(SERVICE_CATEGORY, SERVICE_NAME+1, new EPR(new URI("jms://localhost:8080/queue2")), mockCourier2);
+     }
+    
+    @After
+    public void tearDown() throws Exception 
+    {
+        MockRegistry.uninstall();
+        MockCourierFactory.uninstall();
+    }
+    
+    public static junit.framework.Test suite()
+    {
+        return new JUnit4TestAdapter(NettyGatewayListenerUnitTest.class);
+    }
+
+    private Map<String, String> createOptions()
+    {
+        HashMap<String, String> options = new HashMap<String, String>();
+        options.put("child.tcpNoDelay", "true");
+        options.put("child.keepAlive", "true");
+        return options;
+    }
+
+    private Map<String, ChannelHandler> createHandlers()
+    {
+        Map<String, ChannelHandler> handlers = new HashMap<String, ChannelHandler>();
+        handlers.put("esbMsgDecoder", new EsbMessageDecoder());
+        handlers.put("esbMsgEncoder", new EsbMessageEncoder());
+        return handlers;
+    }
+
+    /**
+     * <pre>{@code
+     * <listener gatewayClass="org.jboss.soa.esb.listeners.gateway.netty.NettyGatewayListener" 
+     *      host="localhost" 
+     *      maxThreads="1" 
+     *      name="netty-listener" 
+     *      port="9999" 
+     *      service-description="EPR Description" 
+     *      target-service-category="NettyTargetService" 
+     *      target-service-name="Service">
+     *  <handlers>
+     *      <netty-handler class="org.jboss.soa.esb.listeners.gateway.netty.decoders.EsbMessageDecoder" name="esbMessageDecoder"/>
+     *      <netty-handler class="org.jboss.soa.esb.listeners.gateway.netty.encoders.EsbMessageEncoder" name="esbMessageEncoder"/>
+     *  </handlers>
+     *  <options>
+     *      <netty-option name="child.tcpNoDelay" value="true"/>
+     *      <netty-option name="child.keepAlive" value="true"/>
+     *  </options>
+     * </listener>
+     * }
+     * </pre>
+     * @return
+     */
+    private ConfigTree createConfig(
+            final String host, 
+            final String port,
+            final Map<String, String> options,
+            final Map<String, ChannelHandler> handlers,
+            final String categoryName,
+            final String serviceName)
+    {
+        final ConfigTree config = new ConfigTree("NettyGatewayListenerUnitTest");
+        config.setAttribute(ListenerTagNames.TARGET_SERVICE_CATEGORY_TAG, categoryName);
+        config.setAttribute(ListenerTagNames.TARGET_SERVICE_NAME_TAG, serviceName);
+        config.setAttribute(HOST_ATTR, host);
+        config.setAttribute(PORT_ATTR, port);
+        
+        if (options != null)
+        {
+            final ConfigTree serverOptions = new ConfigTree(OPTIONS_ELEMENT_NAME, config);
+            for (Entry<String, String> entry : options.entrySet())
+            {
+                final ConfigTree option = new ConfigTree(OPTION_ELEMENT_NAME, serverOptions);
+                option.setAttribute(NAME_ATTR, entry.getKey());
+                option.setAttribute(VALUE_ATTR, entry.getValue());
+            }
+        }
+        
+        if (handlers != null)
+        {
+            
+            final ConfigTree handlerConfig = new ConfigTree(HANDLERS_ELEMENT_NAME, config);
+            for (Entry<String, ChannelHandler> entry : handlers.entrySet())
+            {
+                final ConfigTree handler = new ConfigTree(HANDLER_ELEMENT_NAME, handlerConfig);
+                handler.setAttribute(NAME_ATTR, entry.getKey());
+                handler.setAttribute(HANDLER_CLASS_ATTR, ((ChannelHandler)entry.getValue()).getClass().getName());
+            }
+        }
+        return config;
+    }
+
+}

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/TestUtil.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/TestUtil.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/TestUtil.java	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.gateway.netty;
+
+import java.net.InetSocketAddress;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Executors;
+
+import org.jboss.netty.bootstrap.ClientBootstrap;
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelFactory;
+import org.jboss.netty.channel.ChannelFuture;
+import org.jboss.netty.channel.ChannelHandler;
+import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
+import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.listeners.gateway.netty.codec.EsbMessageDecoder;
+import org.jboss.soa.esb.listeners.gateway.netty.codec.EsbMessageEncoder;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+
+/**
+ * Util methods for testing Netty related classes.
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class TestUtil
+{
+    private TestUtil()
+    {
+    }
+    
+    public static Channel startSocketServer(final String host, final int port, final ServiceInvoker serviceInvoker, final long timeout) throws MessageDeliverException
+    {
+        final InetSocketAddress inetAddress = new InetSocketAddress(host, port);
+        final EsbServiceHandler serviceHandler = timeout > 0l ? new EsbServiceHandler(serviceInvoker, timeout): new EsbServiceHandler(serviceInvoker);
+            
+        Map<String, ChannelHandler> handlers = new HashMap<String, ChannelHandler>();
+        handlers.put("esbMsgDecoder", new EsbMessageDecoder());
+        handlers.put("esbMsgEncoder", new EsbMessageEncoder());
+        PipelineFactory servicePipelineFactory = new PipelineFactory(serviceHandler, handlers);
+        
+        final ChannelFactory serverFactory = new NioServerSocketChannelFactory( Executors.newCachedThreadPool(), Executors.newCachedThreadPool());
+        final ServerBootstrap bootstrap = new ServerBootstrap(serverFactory);
+        bootstrap.setPipelineFactory(servicePipelineFactory);
+        bootstrap.setOption("child.tcpNoDelay", true);
+        bootstrap.setOption("child.keepAlive", true);
+        Channel channel = bootstrap.bind(inetAddress);
+        return channel;
+    }
+    
+    public static Channel startClientAndWrite(final String host, final int port, final String payload)
+    {
+        final ChannelFactory clientFactory = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool());
+        final ClientBootstrap clientBootstrap = new ClientBootstrap(clientFactory);
+        Map<String, ChannelHandler> handlers = new HashMap<String, ChannelHandler>();
+        // Client only sends and receives Strings.
+        handlers.put("decoder", new StringDecoder());
+        handlers.put("encoder", new StringEncoder());
+        clientBootstrap.setPipelineFactory(new PipelineFactory(new ResponseHandler<String>(), handlers));
+        clientBootstrap.setOption("tcpNoDelay", true);
+        clientBootstrap.setOption("keepAlive", true);
+        
+        final ChannelFuture future = clientBootstrap.connect(new InetSocketAddress(host, port));
+        final Channel channel = future.awaitUninterruptibly().getChannel();
+        
+        // Send a string payload to the server.
+        final ChannelFuture writeFuture = channel.write(payload);
+        if (writeFuture != null)
+        {
+            writeFuture.awaitUninterruptibly();
+        }
+        return channel;
+    }
+
+}

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/codec/EsbMessageEncoderUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/codec/EsbMessageEncoderUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/rosetta/tests/src/org/jboss/soa/esb/listeners/gateway/netty/codec/EsbMessageEncoderUnitTest.java	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.gateway.netty.codec;
+
+import static org.junit.Assert.assertEquals;
+import junit.framework.JUnit4TestAdapter;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.junit.Test;
+
+/**
+ * Unit test for {@link EsbMessageEncoder}.
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class EsbMessageEncoderUnitTest
+{
+    @Test
+    public void encodeNoneEsbMessageObject() throws Exception
+    {
+        final String payload = "some text";
+        final EsbMessageEncoder encoder = new EsbMessageEncoder();
+        assertEquals(payload, encoder.encode(null, null, payload));
+    }
+    
+    @Test
+    public void encodeEsbMessageObject() throws Exception
+    {
+        final String payload = "message payload";
+        final Message esbMessage = MessageFactory.getInstance().getMessage();
+        esbMessage.getBody().add(payload);
+        
+        final EsbMessageEncoder encoder = new EsbMessageEncoder();
+        assertEquals(payload, encoder.encode(null, null, payload));
+    }
+    
+    public static junit.framework.Test suite()
+    {
+        return new JUnit4TestAdapter(EsbMessageEncoderUnitTest.class);
+    }
+
+}

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/build.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/build.xml	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/build.xml	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,25 @@
+<project name="Quickstart_netty_gateway" default="run" basedir=".">
+	
+	<description> 
+		${ant.project.name}
+		${line.separator}
+	</description>
+	
+	<!-- additional deploys -->
+	<property name="additional.deploys" value="*.xsd"/>
+
+	<!-- Import the base Ant build script... -->
+	<import file="../conf/base-build.xml"/>
+
+	<target name="runtest" depends="compile"  description="sends soap message to published web service">
+		<echo>Write to socked and get response.</echo>
+		<java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.nettygateway.test.NettyClient" failonerror="true">
+		      <arg value="localhost"/>	
+		      <arg value="9999"/>	
+		      <arg value="Netty example payload"/>	
+			  <classpath refid="exec-classpath"/>
+		</java>
+		<echo/>
+	</target> 
+
+</project>

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/deployment.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/deployment.xml	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/deployment.xml	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,3 @@
+<jbossesb-deployment>
+</jbossesb-deployment>
+

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/jboss-esb.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/jboss-esb.xml	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/jboss-esb.xml	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,26 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd" parameterReloadSecs="5">
+
+	<services>
+        <service category="NettyTargetService" name="Service" description="EPR Description" invmScope="GLOBAL">
+			<listeners>
+				<netty-listener name="netty-listener" host="localhost" port="9999" is-gateway="true" timeout="5000">
+					<netty-options>
+						<netty-option name="child.tcpNoDelay" value="true"/>
+						<netty-option name="child.keepAlive" value="true"/>
+					</netty-options>
+					<netty-handlers>
+						<netty-handler name="esbMessageDecoder" class="org.jboss.soa.esb.listeners.gateway.netty.codec.EsbMessageDecoder"/>
+						<netty-handler name="esbMessageEncoder" class="org.jboss.soa.esb.listeners.gateway.netty.codec.EsbMessageEncoder"/>
+					</netty-handlers>
+                </netty-listener>
+            </listeners>
+            <actions mep="RequestResponse">
+				<action name="printMessage" class="org.jboss.soa.esb.actions.SystemPrintln">
+					<property name="message" value="NettyTargetService:Service"/>
+					<property name="printfull" value="false"/>
+				</action>
+            </actions>
+		</service>
+	</services>
+</jbossesb>

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/jbossesb-properties.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/jbossesb-properties.xml	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/jbossesb-properties.xml	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  JBoss, Home of Professional Open Source
+  Copyright 2006, JBoss Inc., and others contributors as indicated 
+  by the @authors tag. All rights reserved. 
+  See the copyright.txt in the distribution for a
+  full listing of individual contributors. 
+  This copyrighted material is made available to anyone wishing to use,
+  modify, copy, or redistribute it subject to the terms and conditions
+  of the GNU Lesser General Public License, v. 2.1.
+  This program is distributed in the hope that it will be useful, but WITHOUT A 
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+  PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+  You should have received a copy of the GNU Lesser General Public License,
+  v.2.1 along with this distribution; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+  MA  02110-1301, USA.
+  
+  (C) 2005-2006,
+  @author JBoss Inc.
+-->
+<!-- $Id: jbossesb-unittest-properties.xml $ -->
+<!--
+  These options are described in the JBossESB manual.
+  Defaults are provided here for convenience only.
+ 
+  Please read through this file prior to using the system, and consider
+  updating the specified entries.
+-->
+<esb
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="jbossesb-1_0.xsd">
+    <properties name="core">
+		<property name="org.jboss.soa.esb.jndi.server.type" value="jboss"/>
+		<property name="org.jboss.soa.esb.jndi.server.url" value="localhost"/>
+		<property name="org.jboss.soa.esb.persistence.connection.factory" 	value="org.jboss.internal.soa.esb.persistence.format.MessageStoreFactoryImpl"/>
+        <property name="jboss.esb.invm.scope.default" value="NONE"/>
+    </properties>
+    <properties name="registry">      
+    	<property name="org.jboss.soa.esb.registry.queryManagerURI"     		
+    		value="jnp://localhost:1099/InquiryService?org.apache.juddi.registry.rmi.Inquiry#inquire"/>    		
+    	<property name="org.jboss.soa.esb.registry.lifeCycleManagerURI"     		
+    		value="jnp://localhost:1099/PublishService?org.apache.juddi.registry.rmi.Publish#publish" />
+    	<property name="org.jboss.soa.esb.registry.implementationClass" 
+    		value="org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl"/>
+    	<property name="org.jboss.soa.esb.registry.factoryClass" 
+    		value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/>
+    	<property name="org.jboss.soa.esb.registry.user" 
+    		value="jbossesb"/>
+    	<property name="org.jboss.soa.esb.registry.password" 
+    	  value="password"/>
+    	<!-- the following parameter is scout specific to set the type of communication between scout and the UDDI (embedded, rmi, soap) -->
+    	<property name="org.jboss.soa.esb.scout.proxy.transportClass" 
+    		value="org.apache.ws.scout.transport.RMITransport"/>
+    </properties>
+    <properties name="transports" depends="core">
+    	<property name="org.jboss.soa.esb.mail.smtp.host" value="localhost"/>
+    	<property name="org.jboss.soa.esb.mail.smtp.user" value="jbossesb"/>
+    	<property name="org.jboss.soa.esb.mail.smtp.password" value=""/>
+    	<property name="org.jboss.soa.esb.mail.smtp.port" value="25"/>
+    </properties>
+    <properties name="connection">
+    	<property name="min-pool-size" value="5"/>
+    	<property name="max-pool=size" value="10"/>
+    	<property name="blocking-timeout-millis" value="5000"/>
+    	<property name="abandoned-connection-timeout" value="10000"/>
+    	<property name="abandoned-connection-time-interval" value="30000"/>
+    </properties>
+    <properties name="dbstore">
+		<property name="org.jboss.soa.esb.persistence.db.connection.url" 	value="jdbc:hsqldb:hsql://localhost:9001/"/>
+		<property name="org.jboss.soa.esb.persistence.db.jdbc.driver" 		value="org.hsqldb.jdbcDriver"/>
+		<property name="org.jboss.soa.esb.persistence.db.user" 			value="sa"/>
+		<property name="org.jboss.soa.esb.persistence.db.pwd" 			value=""/>		
+		<property name="org.jboss.soa.esb.persistence.db.pool.initial.size"	value="2"/>
+		<property name="org.jboss.soa.esb.persistence.db.pool.min.size"	value="2"/>
+		<property name="org.jboss.soa.esb.persistence.db.pool.max.size"	value="5"/>
+		<!--table managed by pool to test for valid connections - created by pool automatically -->
+		<property name="org.jboss.soa.esb.persistence.db.pool.test.table"	value="pooltest"/>
+		<!-- # of milliseconds to timeout waiting for a connection from pool -->
+		<property name="org.jboss.soa.esb.persistence.db.pool.timeout.millis"	value="5000"/> 
+                <property name="org.jboss.soa.esb.persistence.db.conn.manager" value="org.jboss.internal.soa.esb.persistence.manager.StandaloneConnectionManager"/>
+    </properties>
+    <properties name="messagerouting">
+    	<property name="org.jboss.soa.esb.routing.cbrClass" value="org.jboss.internal.soa.esb.services.routing.cbr.JBossRulesRouter"/>
+    </properties>
+</esb>

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/jndi.properties
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/jndi.properties	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/jndi.properties	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,5 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming
+java.naming.factory.url.pkgs=org.jnp.interfaces
+

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/juddi.properties
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/juddi.properties	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/juddi.properties	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,69 @@
+# jUDDI Registry Properties (used by RegistryServer)
+# see http://www.juddi.org for more information
+
+# The UDDI Operator Name
+juddi.operatorName = jUDDI.org
+
+# The i18n locale default codes
+juddi.i18n.languageCode = en
+juddi.i18n.countryCode = US
+
+# The UDDI DiscoveryURL Prefix
+juddi.discoveryURL = http://localhost:8080/juddi/uddiget.jsp?
+
+# The UDDI Operator Contact Email Address
+juddi.operatorEmailAddress = admin at juddi.org
+
+# The maximum name size and maximum number
+# of name elements allows in several of the
+# FindXxxx and SaveXxxx UDDI functions.
+juddi.maxNameLength=255
+juddi.maxNameElementsAllowed=5
+
+# The maximum number of UDDI artifacts allowed
+# per publisher. A value of '-1' indicates any 
+# number of artifacts is valid (These values can be
+# overridden at the individual publisher level).
+juddi.maxBusinessesPerPublisher=25
+juddi.maxServicesPerBusiness=20
+juddi.maxBindingsPerService=10
+juddi.maxTModelsPerPublisher=100
+
+# jUDDI Authentication module to use
+juddi.auth = org.apache.juddi.auth.DefaultAuthenticator
+
+# jUDDI DataStore module currently to use
+juddi.dataStore = org.apache.juddi.datastore.jdbc.JDBCDataStore
+
+# use a dataSource (if set to false a direct 
+# jdbc connection will be used.
+juddi.isUseDataSource=false
+juddi.jdbcDriver=com.mysql.jdbc.Driver
+juddi.jdbcUrl=jdbc:mysql://localhost:3306/juddi
+juddi.jdbcUsername=root
+juddi.jdbcPassword=admin
+# jUDDI DataSource to use
+# juddi.dataSource=java:comp/env/jdbc/MySqlDS
+
+# jUDDI UUIDGen implementation to use
+juddi.uuidgen = org.apache.juddi.uuidgen.DefaultUUIDGen
+
+# jUDDI Cryptor implementation to use
+juddi.cryptor = org.apache.juddi.cryptor.DefaultCryptor
+ 
+# jUDDI Validator to use
+juddi.validator=org.apache.juddi.validator.DefaultValidator
+
+# jUDDI Proxy Properties (used by RegistryProxy)
+juddi.proxy.adminURL = http://localhost:8080/juddi/admin
+juddi.proxy.inquiryURL = http://localhost:8080/juddi/inquiry
+juddi.proxy.publishURL = http://localhost:8080/juddi/publish
+juddi.proxy.transportClass = org.apache.juddi.proxy.AxisTransport
+juddi.proxy.securityProvider = com.sun.net.ssl.internal.ssl.Provider
+juddi.proxy.protocolHandler = com.sun.net.ssl.internal.www.protocol
+
+# JNDI settings (used by RMITransport)
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming
+  

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/log4j.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/log4j.xml	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/log4j.xml	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!--                                                                       -->
+<!--  Log4j Configuration                                                  -->
+<!--                                                                       -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml,v 1.26.2.5 2005/09/15 09:31:02 dimitris Exp $ -->
+
+<!--
+   | For more configuration infromation and examples see the Jakarta Log4j
+   | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+   <!-- ============================== -->
+   <!-- Append messages to the console -->
+   <!-- ============================== -->
+
+   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+      <param name="Target" value="System.out"/>
+
+      <layout class="org.apache.log4j.PatternLayout">
+         <!-- The default pattern: Date Priority [Category] Message\n -->
+         <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t][%c{1}] %m%n"/>
+      </layout>
+   </appender>
+
+   <!-- ================================= -->
+   <!-- Preserve messages in a local file -->
+   <!-- ================================= -->
+
+   <!-- A size based file rolling appender -->
+   <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
+     <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+     <param name="File" value="./listener.log"/>
+     <param name="Append" value="false"/>
+     <param name="MaxFileSize" value="500KB"/>
+     <param name="MaxBackupIndex" value="1"/>
+
+     <layout class="org.apache.log4j.PatternLayout">
+       <param name="ConversionPattern" value="%d %-5p [%t][%c] %m%n"/>
+     </layout>	    
+   </appender>
+
+   <!-- ================ -->
+   <!-- Limit categories -->
+   <!-- ================ -->
+
+   <category name="org.jboss">
+      <priority value="WARN"/>
+   </category>
+   <category name="org.jboss.soa.esb">
+      <priority value="ERROR"/>
+   </category>
+   <category name="org.jboss.internal.soa.esb">
+      <priority value="ERROR"/>
+   </category>
+   <category name="org.apache">
+      <priority value="ERROR"/>
+   </category>
+   <category name="quickstart">
+      <priority value="INFO"/>
+   </category>
+   <!-- ======================= -->
+   <!-- Setup the Root category -->
+   <!-- ======================= -->
+
+   <root>
+      <appender-ref ref="CONSOLE"/>
+      <appender-ref ref="FILE"/>
+   </root>
+
+</log4j:configuration>

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/readme.txt
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/readme.txt	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/readme.txt	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,20 @@
+Overview:
+=========
+  The purpose of the netty_gateway quickstart example is to demonstrate
+  how a Netty gateway can accept connections and invoke a target service
+  in the ESB and return a response.
+
+Running this quickstart:
+========================
+  Please refer to 'ant help-quickstarts' for prerequisites about the quickstarts
+  and a more detailed descripton of the different ways to run the quickstarts.
+
+To Run '.esb' archive mode:
+===========================
+  1. In a command terminal window in this folder ("Window1"), type 'ant deploy'.
+  2. Switch back to Application Server console to see the output from the ESB
+  3. Run 'ant runtest' to send a request to the gateway.
+  4. In this folder ("Window1"), type 'ant undeploy'.
+  
+Things to Consider:
+===================

Added: labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/src/org/jboss/soa/esb/samples/quickstart/nettygateway/test/NettyClient.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/src/org/jboss/soa/esb/samples/quickstart/nettygateway/test/NettyClient.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/nettygateway/product/samples/quickstarts/netty_gateway/src/org/jboss/soa/esb/samples/quickstart/nettygateway/test/NettyClient.java	2009-01-18 17:04:04 UTC (rev 24761)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.nettygateway.test;
+
+import java.net.InetSocketAddress;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import org.jboss.netty.bootstrap.ClientBootstrap;
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelFactory;
+import org.jboss.netty.channel.ChannelFuture;
+import org.jboss.netty.channel.ChannelHandler;
+import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
+import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+//import org.jboss.netty.handler.codec.frame.Delimiters;
+//import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
+import org.jboss.soa.esb.listeners.gateway.netty.ResponseHandler;
+import org.jboss.soa.esb.listeners.gateway.netty.PipelineFactory;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.listeners.gateway.netty.decoders.EsbMessageDecoder;
+import org.jboss.soa.esb.listeners.gateway.netty.encoders.EsbMessageEncoder;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+
+public class NettyClient  
+{
+	public static void main(String... args) 
+	{
+		final String host = args[0];
+		final int port = Integer.parseInt(args[1]);
+		final String payload = args[2];
+
+		final ChannelFactory clientFactory = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool());
+        final ClientBootstrap clientBootstrap = new ClientBootstrap(clientFactory);
+        Map<String, ChannelHandler> handlers = new HashMap<String, ChannelHandler>();
+
+        // Client only sends and receives Strings.
+		//handlers.put("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
+        handlers.put("decoder", new StringDecoder());
+        handlers.put("encoder", new StringEncoder());
+
+        clientBootstrap.setPipelineFactory(new PipelineFactory(new ResponseHandler<String>(), handlers));
+        clientBootstrap.setOption("tcpNoDelay", true);
+        clientBootstrap.setOption("keepAlive", true);
+        
+        final ChannelFuture future = clientBootstrap.connect(new InetSocketAddress(host, port));
+        final Channel channel = future.awaitUninterruptibly().getChannel();
+        
+        // Send a string payload to the server.
+        final ChannelFuture writeFuture = channel.write(payload);
+        if (writeFuture != null)
+        {
+            writeFuture.awaitUninterruptibly();
+        }
+
+		final ResponseHandler<String> handler = (ResponseHandler<String>) channel.getPipeline().getLast();
+		System.out.println("ESB returned : '" + handler.getPayload() + "'");
+		channel.getFactory().releaseExternalResources();
+		System.exit(0);
+	}
+}




More information about the jboss-svn-commits mailing list