[jboss-svn-commits] JBL Code SVN: r24246 - in labs/jbossesb/workspace/skeagh: routing/jms/src/main/java/org/jboss/esb/jms and 9 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Dec 5 05:10:16 EST 2008


Author: beve
Date: 2008-12-05 05:10:16 -0500 (Fri, 05 Dec 2008)
New Revision: 24246

Added:
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/inbound/
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/inbound/AbstractJmsInboundRouter.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/inbound/JmsInboundRouter.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/inbound/package.html
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/outbound/
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/outbound/AbstractJmsOutboundRouter.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/outbound/JmsMessageFactory.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/outbound/JmsOutboundRouter.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/outbound/package.html
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/BytesMessageExtractor.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/MapMessageExtractor.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/ObjectMessageExtractor.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/StreamMessageExtractor.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/TextMessageExtractor.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/package.html
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/util/PropertiesExtractor.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/TestInboundRouter.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/inbound/
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/inbound/JmsInboundRouterTest.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/inbound/jms-inbound-router_01.xml
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/outbound/
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/outbound/JmsMessageFactoryTest.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/outbound/JmsOutboundRouterTest.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/outbound/TestOutboundProcessor.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/outbound/jms-outbound-router.xml
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/BytesMessageExtractorTest.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/MapMessageExtractorTest.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/ObjectMessageExtractorTest.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/StreamMessageExtractorTest.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/TextMessageExtractorTest.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/util/
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/util/PropertiesExtractorTest.java
Removed:
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInboundRouter.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsOutboundRouter.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsInboundRouterTest.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsOutboundRouterTest.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/composers/
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-inbound-router_01.xml
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-outbound-router-invalid.xml
   labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-outbound-router.xml
Modified:
   labs/jbossesb/workspace/skeagh/examples/jms-routing/esb/src/main/resources/jboss-esb.xml
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsBus.java
   labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/util/RouterUtil.java
Log:
Work for https://jira.jboss.org/jira/browse/JBESB-2201 "Refactor the JmsInRouter to not use "Composers"


Modified: labs/jbossesb/workspace/skeagh/examples/jms-routing/esb/src/main/resources/jboss-esb.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-routing/esb/src/main/resources/jboss-esb.xml	2008-12-05 09:57:53 UTC (rev 24245)
+++ labs/jbossesb/workspace/skeagh/examples/jms-routing/esb/src/main/resources/jboss-esb.xml	2008-12-05 10:10:16 UTC (rev 24246)
@@ -1,12 +1,15 @@
 <jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
     <services>
         <service serviceCategory="examples" serviceName="helloworld" serviceDescription="First Example" class="org.jboss.esb.examples.jmsrouter.MyTestService">
-            <inRouter name="inrouter1" class="org.jboss.esb.jms.JmsInboundRouter">
+            <inRouter name="inrouter1" class="org.jboss.esb.jms.inbound.JmsInboundRouter">
+				<processors>
+                    <processor class="org.jboss.esb.jms.processors.TextMessageExtractor"/>
+                </processors>
                 <property name="java.naming.provider.url">tcp://localhost:61717</property>
                 <property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property>
                 <property name="jmsDestination">dynamicQueues/jbossesb.TestQueue</property>
             </inRouter>
-			<outRouter name="outrouter" class="org.jboss.esb.jms.JmsOutboundRouter">
+			<outRouter name="outrouter" class="org.jboss.esb.jms.outbound.JmsOutboundRouter">
                 <property name="jmsDestination">jbossesb.TestOutQueue</property>
                 <property name="java.naming.provider.url">tcp://localhost:61717</property>
                 <property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property>

Modified: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsBus.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsBus.java	2008-12-05 09:57:53 UTC (rev 24245)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsBus.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -364,6 +364,7 @@
      * Initialize the shared JMS Sessions.
      *
      * @param localBusProperties Local JMS Bus properties.
+     * @throws DeploymentException If an exception occurs while trying to connect.
      */
     private void connectJMSSessions(final Properties localBusProperties) throws DeploymentException
     {
@@ -372,7 +373,7 @@
         topicSession = new JMSSession(JMSSession.Type.TOPIC, localBusProperties);
         try
         {
-            if(resourceLocator != null)
+            if (resourceLocator != null)
             {
                 topicSession.setClassLoader(resourceLocator.getClassLoader());
             }
@@ -386,7 +387,7 @@
         try
         {
             queueSession = new JMSSession(JMSSession.Type.QUEUE, localBusProperties);
-            if(resourceLocator != null)
+            if (resourceLocator != null)
             {
                 queueSession.setClassLoader(resourceLocator.getClassLoader());
             }
@@ -454,7 +455,7 @@
                 {
                     Object objectMessage = ((ObjectMessage) message).getObject();
 
-                    if(objectMessage instanceof byte[])
+                    if (objectMessage instanceof byte[])
                     {
                         Object deserializedObject = deserializeBytes((byte[]) objectMessage);
 
@@ -511,7 +512,7 @@
                 {
                     Object objectMessage = ((ObjectMessage) message).getObject();
 
-                    if(objectMessage instanceof byte[])
+                    if (objectMessage instanceof byte[])
                     {
                         Object deserializedObject = deserializeBytes((byte[]) objectMessage);
 

Deleted: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInboundRouter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInboundRouter.java	2008-12-05 09:57:53 UTC (rev 24245)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInboundRouter.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -1,345 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms;
-
-import org.apache.log4j.Logger;
-import org.jboss.esb.api.annotations.Initialize;
-import org.jboss.esb.api.annotations.Property;
-import org.jboss.esb.api.annotations.Property.Use;
-import org.jboss.esb.api.annotations.Uninitialize;
-import org.jboss.esb.api.context.InvocationContext;
-import org.jboss.esb.api.context.ResourceLocator;
-import org.jboss.esb.api.exception.ConfigurationException;
-import org.jboss.esb.api.message.Message;
-import org.jboss.esb.api.message.MessageProcessingException;
-import org.jboss.esb.api.routing.InboundRouter;
-import org.jboss.esb.api.routing.MessageDispatcher;
-import org.jboss.esb.jms.composers.EsbMessageComposer;
-import org.jboss.esb.jms.util.JmsConstants;
-import org.jboss.esb.jms.util.RouterUtil;
-
-import javax.jms.JMSException;
-import java.util.Properties;
-
-/**
- * Inbound router for JMS.
- * <br><br>
- * Sample usage:
- * <br>
- * <pre>{@code
- *
- * <inRouter name="inrouter1" class="org.jboss.esb.jms.JmsInboundRouter">
- *     <property name="jmsDestination">jbossesb.TestQueue</property>
- * </inRouter>
- *
- * Optional properties (defaults shown):
- *     <property name="extractJmsProperties">true</property>
- *     <property name="esbMessageComposer">org.jboss.esb.jms.composers.EsbMessageComposerImpl</property>
- *     <property name="java.naming.provider.url">jnp://localhost:1099</property>
- *     <property name="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</property>
- *     <property name="java.naming.factory.url.pkgs">org.jboss.naming,org.jnp.interfaces</property>
- *     <property name="org.jboss.esb.jms.connectionFactory">ConnectionFactory</property>
- * }</pre>
- * <br>
- * Properties decription:
- * <lu>
- * <li>extractProperties true if JMS Headers and properties should be extracted and added to the invocation context</li>
- * <li>esbMessageComposer the class name of an concrete implementation of org.jboss.esb.jms.EsbMessageComposer.</li>
- * </lu>
- *
- * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
- */
-public class JmsInboundRouter implements InboundRouter
-{
-    /**
-     * Logger.
-     */
-    private final Logger log = Logger.getLogger(JmsInboundRouter.class);
-
-    /**
-     * MessageDispatcher used to dipatch the message to the ESB.
-     */
-    private MessageDispatcher dispatcher;
-
-    /**
-     * Resource locator.
-     */
-    private ResourceLocator resourceLocator;
-
-    /**
-     * JMS destination name. The destination that this router listenes to.
-     */
-    @Property(use = Use.REQUIRED, name = "jmsDestination")
-    private String destination;
-
-    /**
-     * JMS connection properties.
-     */
-    @org.jboss.esb.api.annotations.Properties
-    private final Properties configProperties = RouterUtil.getDefaultProperties();
-
-    /**
-     * Should JMSHeaders and user properties be extracted from the JMS Message and added
-     * to the inbound ESB Message.
-     */
-    @Property(use = Use.OPTIONAL, defaultVal = "true")
-    private boolean extractJmsProperties;
-
-    /**
-     * The message composer to use.
-     */
-     @Property(use = Use.OPTIONAL, name = "esbMessageComposer", defaultVal = "org.jboss.esb.jms.composers.EsbMessageComposerImpl")
-    private String messageComposerClass;
-
-    /**
-     * The JMS Session on which the listener is created.
-     */
-    private JMSSession jmsSession;
-
-    /**
-     * JmsMessageListener that takes care of the JMS connection.
-     */
-    private JmsMessageListener messageListener;
-
-    /**
-     * MessageComposer strategy.
-     */
-    private EsbMessageComposer esbMessageComposer;
-
-    /**
-     * Set the dispatcher used by this instance.
-     *
-     * @param dispatcher - the dispatcher to use
-     */
-    public final void setDispatcher(final MessageDispatcher dispatcher)
-    {
-        this.dispatcher = dispatcher;
-    }
-
-    /**
-     * Sets up the JmsMesssageListener of this class.
-     *
-     * @throws JMSException if a JMS exception occurs.
-     * @throws ConfigurationException If a message composer could not be created.
-     */
-    @Initialize
-    public final void initialize() throws JMSException, ConfigurationException
-    {
-        setupJmsSession();
-        setupMessageListener();
-        setupMessageComposer();
-    }
-
-    private void setupJmsSession() throws ConfigurationException
-    {
-        try
-        {
-            jmsSession = RouterUtil.createJMSSession(configProperties, resourceLocator);
-            RouterUtil.setDestinationTyp(destination, jmsSession);
-            jmsSession.connect();
-        }
-        catch (final JMSException e)
-        {
-            throw new ConfigurationException(e.getMessage(), e);
-        }
-    }
-
-    private void setupMessageListener() throws ConfigurationException
-    {
-        try
-        {
-            messageListener = createMessageListener(jmsSession);
-            connectMessageListener(messageListener);
-        }
-        catch (final JMSException e)
-        {
-            throw new ConfigurationException(e.getMessage(), e);
-        }
-    }
-
-    /**
-     * Creates and connects a {@link MessageSender}.
-     *
-     * @param session           The {@link JMSSession} to use for creating the MessageSender.
-     * @return MessageSender    The newly create {@link MessageSender}.
-     * @throws JMSException     If an error occurs while trying to create the MessageSender.
-     */
-    private JmsMessageListener createMessageListener(final JMSSession session) throws JMSException
-    {
-        JmsMessageListener listener = null;
-        try
-        {
-            listener = new JmsMessageListener(destination, jmsSession, configProperties, dispatcher);
-            listener.connect();
-        }
-        catch (final JMSException e)
-        {
-            RouterUtil.closeJmsSession(jmsSession);
-            throw e;
-        }
-        catch (final Exception t)
-        {
-            RouterUtil.closeJmsSession(jmsSession);
-            throw (JMSException) (new JMSException("Unexpected exception while connecting JmsMesssageListener.").initCause(t));
-        }
-        return listener;
-    }
-
-    private void connectMessageListener(final JmsMessageListener listener) throws JMSException
-    {
-        try
-        {
-            listener.connect();
-        }
-        catch (final JMSException e)
-        {
-            RouterUtil.closeJmsSession(jmsSession);
-            throw e;
-        }
-        catch (final Throwable t)
-        {
-            RouterUtil.closeJmsSession(jmsSession);
-            throw (JMSException) (new JMSException("Unexpected exception while connecting JmsMesssageListener.").initCause(t));
-        }
-    }
-
-    private void setupMessageComposer() throws ConfigurationException
-    {
-        try
-        {
-            esbMessageComposer = (EsbMessageComposer) RouterUtil.createInstance(messageComposerClass);
-            esbMessageComposer.setConfiguration(configProperties);
-        }
-        catch (final ConfigurationException e)
-        {
-            uninitialize();
-            throw e;
-        }
-    }
-
-    /**
-     * Closes the underlying JMS connection.
-     */
-    @Uninitialize
-    public final void uninitialize()
-    {
-        try
-        {
-            if (messageListener != null)
-            {
-                messageListener.close();
-            }
-        }
-        finally
-        {
-            RouterUtil.closeJmsSession(jmsSession);
-        }
-    }
-
-    /**
-     * Will display the dispatcher and the properties for this instance.
-     *
-     * @return String - string representation of this instance.
-     */
-    @Override
-    public final String toString()
-    {
-        return "[dispatcher=" + dispatcher + ", extractProperties=" + extractJmsProperties + ", jmsProperties=" + configProperties + "]";
-    }
-
-    /**
-     * Gets the JMS properties.
-     *
-     * @return Properties - the properties used by this instance.
-     */
-    public final Properties getProperties()
-    {
-        return (Properties) configProperties.clone();
-    }
-
-    /**
-     * Gets the jms destination(Topic or Queue).
-     *
-     * @return String   the name of the destination.
-     */
-    public final String getDestination()
-    {
-        return destination;
-    }
-
-    /**
-     * JmsMessageListener that listens to incoming messages and uses
-     * the {@link MessageDispatcher} to pass the message along though the ESB.
-     *
-     * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
-     */
-    private class JmsMessageListener extends AbstractMessageListener
-    {
-        /**
-         * The MessageDispather to use.
-         */
-        private final MessageDispatcher dispatcher;
-
-        /**
-         * Protected contstructor.
-         *
-         * @param destinationName the JMS destination name.
-         * @param jmsSession      The JMS Session.
-         * @param jndiProperties  the jndi properties to be used for jndi lookups.
-         * @param dispatcher      the {@link MessageDispatcher} to be used.
-         */
-        protected JmsMessageListener(final String destinationName, final JMSSession jmsSession, final Properties jndiProperties, final MessageDispatcher dispatcher)
-        {
-            super(destinationName, jmsSession, jndiProperties);
-            this.dispatcher = dispatcher;
-        }
-
-        /**
-         * Handles a single JMSMessage, extracts the contents and creates
-         * and populates an ESB Message object instance and dispataches
-         * the ESB Message object instance to the ESB.
-         *
-         * @param jmsMessage the JMS Message object instance
-         */
-        public void onMessage(final javax.jms.Message jmsMessage)
-        {
-            try
-            {
-                final Message esbMessage = esbMessageComposer.composeEsbMessage(jmsMessage, InvocationContext.getContext());
-                log.info("Extracted Jms Payload -> " + esbMessage);
-
-                final InvocationContext context = new InvocationContext();
-                if (extractJmsProperties)
-                {
-                    context.setContextObject(JmsConstants.PROPERTIES, esbMessageComposer.extractJmsProperties(jmsMessage));
-                    log.debug(context.getContextObject(JmsConstants.PROPERTIES));
-                }
-
-                dispatcher.dispatch(esbMessage, context);
-            }
-            catch (MessageProcessingException e)
-            {
-                //TODO: Should errors be reported back to a caller. DLQ?
-                log.error("RoutingException in onMessage", e);
-            }
-        }
-    }
-}

Deleted: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsOutboundRouter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsOutboundRouter.java	2008-12-05 09:57:53 UTC (rev 24245)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsOutboundRouter.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -1,273 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms;
-
-import org.jboss.esb.api.annotations.Initialize;
-import org.jboss.esb.api.annotations.Property;
-import org.jboss.esb.api.annotations.Property.Use;
-import org.jboss.esb.api.annotations.Uninitialize;
-import org.jboss.esb.api.context.InvocationContext;
-import org.jboss.esb.api.context.ResourceLocator;
-import org.jboss.esb.api.exception.ConfigurationException;
-import org.jboss.esb.api.message.Message;
-import org.jboss.esb.api.message.MessageProcessingException;
-import org.jboss.esb.api.routing.OutboundRouter;
-import org.jboss.esb.api.routing.RoutingException;
-import org.jboss.esb.jms.composers.JmsMessageComposer;
-import static org.jboss.esb.jms.util.JmsConstants.PROPERTIES;
-import org.jboss.esb.jms.util.RouterUtil;
-
-import javax.jms.JMSException;
-import java.util.Properties;
-
-/**
- * JmsOutboundRouter is implmentation of {@link OutboundRouter} that uses the JMS transport.
- * <br><br>
- * Sample usage:
- * <br>
- * <pre>{@code
- *
- * <outRouter name="outrouter" class="org.jboss.esb.jms.JmsOutboundRouter">
- *     <property name="jmsDestination">jbossesb.TestOutQueue</property>
- * </outRouter>
- *
- * Optional properties (defaults shown):
- *     <property name="extractProperties">true</property>
- *     <property name="jmsMessageComposer">org.jboss.esb.jms.composers.JmsMessageComposerImpl</property>
- *     <property name="java.naming.provider.url">jnp://localhost:1099</property>
- *     <property name="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</property>
- *     <property name="java.naming.factory.url.pkgs">org.jboss.naming,org.jnp.interfaces</property>
- *     <property name="org.jboss.esb.jms.connectionFactory">ConnectionFactory</property>
- * }</pre>
- * <br>
- * Properties decription:
- * <lu>
- * <li>extractProperties true if JMS Headers and properties should be extracted and added to the invocation context</li>
- * <li>jmsMessageComposer the class name of an concrete implementation of org.jboss.esb.jms.JmsMessageComposer.</li>
- * </lu>
- *
- * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
- *
- */
-public class JmsOutboundRouter implements OutboundRouter
-{
-    /**
-     * The jms destination name.
-     */
-    @Property(use = Use.REQUIRED, name = "jmsDestination")
-    private String destination;
-
-    /**
-     * Properties that are specified in the config but not actually fields on this class.
-     */
-    @org.jboss.esb.api.annotations.Properties
-    private final Properties configProperties = RouterUtil.getDefaultProperties();
-
-    /**
-     * The name of the {@link JmsMessageComposer} implementation to be used.
-     */
-     @Property(use = Use.OPTIONAL, name = "jmsMessageComposer", defaultVal = "org.jboss.esb.jms.composers.JmsMessageComposerImpl")
-    private String messageComposerClass;
-
-    /**
-     * Should ESB Properties from the ESB Message and added to the outgoing JMS Message.
-     */
-    @Property(use = Use.OPTIONAL, defaultVal = "true")
-    private boolean extractEsbProperties;
-
-    /**
-     * The {@link JMSSession}.
-     */
-    private JMSSession jmsSession;
-
-    /**
-     * The {@link ResourceLocator}.
-     */
-    private ResourceLocator resourceLocator;
-
-    /**
-     * The {@link MessageSender}.
-     */
-    private MessageSender messageSender;
-
-    /**
-     * The {@link JmsMessageComposer} strategy.
-     */
-    private JmsMessageComposer jmsMessageComposer;
-
-    /**
-     * Name of this router. Will be injected by the deployment runtime.
-     */
-    private Object objectName;
-
-    /**
-     * Will setup this Router so that it is ready to publish messages to
-     * the configured destination.
-     *
-     * @throws ConfigurationException If there is a configuration error.
-     */
-    @Initialize
-    public final void initialize() throws ConfigurationException
-    {
-        setupJmsSession();
-        setupMessageSender();
-        setupMessageComposer();
-    }
-
-    private void setupJmsSession() throws ConfigurationException
-    {
-        try
-        {
-            jmsSession = RouterUtil.createJMSSession(configProperties, resourceLocator);
-            RouterUtil.setDestinationTyp(destination, jmsSession);
-            jmsSession.connect();
-        }
-        catch (final JMSException e)
-        {
-            throw new ConfigurationException(e.getMessage(), e);
-        }
-    }
-
-    private void setupMessageSender() throws ConfigurationException
-    {
-        try
-        {
-            messageSender = new MessageSender(destination, jmsSession);
-            connectMessageSender(messageSender);
-        }
-        catch (final JMSException e)
-        {
-            throw new ConfigurationException(e.getMessage(), e);
-        }
-    }
-
-    private void connectMessageSender(final MessageSender sender) throws JMSException
-    {
-        try
-        {
-            sender.connect();
-        }
-        catch (final JMSException e)
-        {
-            RouterUtil.closeJmsSession(jmsSession);
-            throw e;
-        }
-        catch (final Throwable t)
-        {
-            RouterUtil.closeJmsSession(jmsSession);
-            throw (JMSException) (new JMSException("Unexpected exception while connecting JmsMesssageSender.").initCause(t));
-        }
-    }
-
-    private void setupMessageComposer() throws ConfigurationException
-    {
-        try
-        {
-            jmsMessageComposer = (JmsMessageComposer) RouterUtil.createInstance(messageComposerClass);
-            jmsMessageComposer.setConfiguration(configProperties);
-        }
-        catch (final ConfigurationException e)
-        {
-            uninitialize();
-            throw e;
-        }
-    }
-
-    /**
-     * Send the contents of the ESB Message object to the configured
-     * JMS destination.
-     *
-     * @param message   The ESB Message object
-     * @throws RoutingException If an error occurs while trying to send the JMS Message.
-     */
-    public final void route(final Message esbMessage) throws RoutingException
-    {
-        final javax.jms.Message jmsMessage = composeJmsMessage(esbMessage);
-        publishJmsMessage(jmsMessage);
-    }
-
-    private javax.jms.Message composeJmsMessage(final Message esbMessage) throws RoutingException
-    {
-        try
-        {
-            javax.jms.Message jmsMessage = jmsMessageComposer.composeJmsMessage(esbMessage, jmsSession.getSession());
-            if (extractEsbProperties)
-            {
-                final Properties jmsProperties = (Properties) InvocationContext.getContext().getContextObject(PROPERTIES);
-                jmsMessageComposer.addEsbProperties(jmsProperties, jmsMessage);
-            }
-            return jmsMessage;
-        }
-        catch (final MessageProcessingException e)
-        {
-            throw new RoutingException(e.getMessage(), e);
-        }
-    }
-
-    private void publishJmsMessage(final javax.jms.Message jmsMessage) throws RoutingException
-    {
-        try
-        {
-            messageSender.send(jmsMessage);
-        }
-        catch (final JMSException e)
-        {
-            throw new RoutingException(e.getMessage(), e);
-        }
-    }
-
-    /**
-     * Closes the underlying JMS connection.
-     * This method will be called by the runtime upon deployment.
-     */
-    @Uninitialize
-    public final void uninitialize()
-    {
-        try
-        {
-            if (messageSender != null)
-            {
-                messageSender.close();
-            }
-        }
-        finally
-        {
-            RouterUtil.closeJmsSession(jmsSession);
-        }
-    }
-
-    public String getDestination()
-    {
-        return destination;
-    }
-
-    public Properties getJmsProperties()
-    {
-        return (Properties) configProperties.clone();
-    }
-
-    @Override
-    public final String toString()
-    {
-        return "JMSOutboundRouter [name='" + objectName + "', destination='" + destination + "', jmsProperties='" + configProperties + "']";
-    }
-
-}

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/inbound/AbstractJmsInboundRouter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/inbound/AbstractJmsInboundRouter.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/inbound/AbstractJmsInboundRouter.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,278 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.inbound;
+
+import java.util.Properties;
+
+import javax.jms.JMSException;
+
+import org.jboss.esb.api.annotations.Initialize;
+import org.jboss.esb.api.annotations.Property;
+import org.jboss.esb.api.annotations.Uninitialize;
+import org.jboss.esb.api.annotations.Property.Use;
+import org.jboss.esb.api.context.ResourceLocator;
+import org.jboss.esb.api.exception.ConfigurationException;
+import org.jboss.esb.api.routing.InboundRouter;
+import org.jboss.esb.api.routing.MessageDispatcher;
+import org.jboss.esb.jms.AbstractMessageListener;
+import org.jboss.esb.jms.JMSSession;
+import org.jboss.esb.jms.util.RouterUtil;
+
+/**
+ * Abstract InboundRouter for JMS.
+ * <br><br>
+ *
+ * Sample usage:
+ * <br>
+ * <pre>{@code
+ * <inRouter name="inrouter1" class="org.jboss.esb.jms.JmsInboundRouter">
+ *     <property name="jmsDestination">jbossesb.TestQueue</property>
+ * </inRouter>
+ *
+ * Optional properties (defaults shown):
+ *     <property name="java.naming.provider.url">jnp://localhost:1099</property>
+ *     <property name="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</property>
+ *     <property name="java.naming.factory.url.pkgs">org.jboss.naming,org.jnp.interfaces</property>
+ *     <property name="org.jboss.esb.jms.connectionFactory">ConnectionFactory</property>
+ * }</pre>
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ * @since 5.0
+ */
+public abstract class AbstractJmsInboundRouter implements InboundRouter
+{
+    /**
+     * MessageDispatcher used to dipatch the message to the ESB.
+     */
+    private MessageDispatcher dispatcher;
+
+    /**
+     * Resource locator.
+     */
+    private ResourceLocator resourceLocator;
+
+    /**
+     * JMS destination name. The destination that this router listenes to.
+     */
+    @Property(use = Use.REQUIRED, name = "jmsDestination")
+    private String destination;
+
+    /**
+     * JMS connection properties.
+     */
+    @org.jboss.esb.api.annotations.Properties
+    private final Properties configProperties = RouterUtil.getDefaultProperties();
+
+    /**
+     * The JMS Session on which the listener is created.
+     */
+    private JMSSession jmsSession;
+
+    /**
+     * JmsMessageListener that takes care of the JMS connection.
+     */
+    private AbstractMessageListener messageListener;
+
+    /**
+     * Set the dispatcher used by this instance.
+     *
+     * @param dispatcher - the dispatcher to use
+     */
+    public final void setDispatcher(final MessageDispatcher dispatcher)
+    {
+        this.dispatcher = dispatcher;
+    }
+
+    /**
+     * Takes care of creating a concrete implementation of {@link AbstractMessageListener}.
+     *
+     * @param session The {@link JMSSession} to use for creation.
+     * @return AbstractMessageListener The concreate {@link AbstractMessageListener}.
+     * @throws JMSException If an exception occure while creating.
+     */
+    protected abstract AbstractMessageListener createMessageListener(final JMSSession session) throws JMSException;
+
+    /**
+     * Sets up the JmsMesssageListener of this class.
+     *
+     * @throws JMSException if a JMS exception occurs.
+     * @throws ConfigurationException If a message composer could not be created.
+     */
+    @Initialize
+    public final void initialize() throws JMSException, ConfigurationException
+    {
+        setupJmsSession();
+        setupMessageListener();
+    }
+
+    /**
+     * Setup the JMS Session for usage.
+     *
+     * @throws ConfigurationException If a JMSException is thrown.
+     */
+    private void setupJmsSession() throws ConfigurationException
+    {
+        try
+        {
+            jmsSession = RouterUtil.createJMSSession(configProperties, resourceLocator);
+            RouterUtil.setDestinationType(destination, jmsSession);
+            jmsSession.connect();
+        }
+        catch (final JMSException e)
+        {
+            throw new ConfigurationException(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * Sets up the message listener.
+     *
+     * @throws ConfigurationException If a JMSException is thrown.
+     */
+    private void setupMessageListener() throws ConfigurationException
+    {
+        try
+        {
+            messageListener = createMessageListener(jmsSession);
+            messageListener.connect();
+            connectMessageListener(messageListener);
+        }
+        catch (final Exception e)
+        {
+            RouterUtil.closeJmsSession(getJmsSession());
+            throw new ConfigurationException(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * Connects the message listener.
+     *
+     * @param listener The listener to connect.
+     * @throws JMSException If an exception occurs while connecting.
+     */
+    private void connectMessageListener(final AbstractMessageListener listener) throws JMSException
+    {
+        try
+        {
+            listener.connect();
+        }
+        catch (final JMSException e)
+        {
+            RouterUtil.closeJmsSession(jmsSession);
+            throw e;
+        }
+        catch (final Throwable t)
+        {
+            RouterUtil.closeJmsSession(jmsSession);
+            throw (JMSException) (new JMSException("Unexpected exception while connecting JmsMesssageListener.").initCause(t));
+        }
+    }
+
+    /**
+     * Closes the underlying JMS connection.
+     */
+    @Uninitialize
+    public final void uninitialize()
+    {
+        try
+        {
+            if (messageListener != null)
+            {
+                messageListener.close();
+            }
+        }
+        finally
+        {
+            RouterUtil.closeJmsSession(jmsSession);
+        }
+    }
+
+    /**
+     * Will display the dispatcher and the properties for this instance.
+     *
+     * @return String - string representation of this instance.
+     */
+    @Override
+    public final String toString()
+    {
+        return "[dispatcher=" + dispatcher + ", jmsProperties=" + configProperties + "]";
+    }
+
+    /**
+     * Gets the JMS properties.
+     *
+     * @return Properties - the properties used by this instance.
+     */
+    public final Properties getProperties()
+    {
+        return (Properties) configProperties.clone();
+    }
+
+    /**
+     * Gets the jms destination(Topic or Queue).
+     *
+     * @return String   the name of the destination.
+     */
+    public final String getDestination()
+    {
+        return destination;
+    }
+
+    /**
+     * @return MessageDispatcher The {@link MessageDispatcher}.
+     */
+    public final MessageDispatcher getDispatcher()
+    {
+        return dispatcher;
+    }
+
+    /**
+     * @return {@link ResourceLocator} The {@link ResourceLocator}.
+     */
+    public final ResourceLocator getResourceLocator()
+    {
+        return resourceLocator;
+    }
+
+    /**
+     * @return {@link Properties} The configuration properties.
+     */
+    public final Properties getConfigProperties()
+    {
+        return configProperties;
+    }
+
+    /**
+     * @return JMSSession The {@link JMSSession}.
+     */
+    public final JMSSession getJmsSession()
+    {
+        return jmsSession;
+    }
+
+    /**
+     * @return AbstractMessageListener The {@link AbstractMessageListener}.
+     */
+    public final AbstractMessageListener getMessageListener()
+    {
+        return messageListener;
+    }
+}

Copied: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/inbound/JmsInboundRouter.java (from rev 24231, labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInboundRouter.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/inbound/JmsInboundRouter.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/inbound/JmsInboundRouter.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,183 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.inbound;
+
+import java.util.Map;
+import java.util.Properties;
+
+import javax.jms.JMSException;
+
+import org.jboss.esb.api.annotations.Property;
+import org.jboss.esb.api.annotations.Property.Use;
+import org.jboss.esb.api.context.InvocationContext;
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.jboss.esb.api.routing.MessageDispatcher;
+import org.jboss.esb.jms.AbstractMessageListener;
+import org.jboss.esb.jms.JMSSession;
+import org.jboss.esb.jms.util.PropertiesExtractor;
+
+/**
+ * Inbound router for JMS which will receive messages in it's onMessage method.
+ * onMessage will take the JMS Message and add it as the Message's payload.
+ *
+ * Processors can be added to transform/extract the JMS Message payload. Pre existing
+ * processor exist and can be located in the org.jboss.esb.jms.processors package.
+ *
+ * <br><br>
+ * Sample usage:
+ * <pre>{@code
+ *
+ * <inRouter name="inrouter1" class="org.jboss.esb.jms.JmsInboundRouter">
+ *     <processors>
+ *         <processor class="org.jboss.esb.jms.processors.TextMessageExtractor"/>
+ *     </processors>
+ *     <property name="jmsDestination">jbossesb.TestQueue</property>
+ * </inRouter>
+ *
+ * Optional properties (defaults shown):
+ *     <property name="extractJmsProperties">true</property>
+ *     <property name="java.naming.provider.url">jnp://localhost:1099</property>
+ *     <property name="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</property>
+ *     <property name="java.naming.factory.url.pkgs">org.jboss.naming,org.jnp.interfaces</property>
+ *     <property name="org.jboss.esb.jms.connectionFactory">ConnectionFactory</property>
+ * }</pre>
+ * <br>
+ * Properties decription:
+ * <lu>
+ * <li>extractProperties true if JMS Headers and properties should be extracted and added to the invocation context</li>
+ * </lu>
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ * @since 5.0
+ */
+public class JmsInboundRouter extends AbstractJmsInboundRouter
+{
+    /**
+     * Should JMSHeaders and user properties be extracted from the JMS Message and added
+     * to the inbound ESB Message.
+     */
+    @Property(use = Use.OPTIONAL, defaultVal = "true")
+    private boolean extractJmsProperties;
+
+    /**
+     * Creates and connects a {@link MessageSender}.
+     *
+     * @param session           The {@link JMSSession} to use for creating the MessageSender.
+     * @return MessageSender    The newly create {@link MessageSender}.
+     * @throws JMSException     If an error occurs while trying to create the MessageSender.
+     */
+    @Override
+    public final JmsMessageListener createMessageListener(final JMSSession session) throws JMSException
+    {
+        return new JmsMessageListener(getDestination(), getJmsSession(), getConfigProperties(), getDispatcher());
+    }
+
+    /**
+     * JmsMessageListener that listens to incoming messages and uses
+     * the {@link MessageDispatcher} to pass the message along though the ESB.
+     *
+     * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
+     */
+    private class JmsMessageListener extends AbstractMessageListener
+    {
+        /**
+         * The MessageDispather to use.
+         */
+        private final MessageDispatcher dispatcher;
+
+        /**
+         * Protected contstructor.
+         *
+         * @param destinationName the JMS destination name.
+         * @param jmsSession      The JMS Session.
+         * @param jndiProperties  the jndi properties to be used for jndi lookups.
+         * @param dispatcher      the {@link MessageDispatcher} to be used.
+         */
+        protected JmsMessageListener(final String destinationName, final JMSSession jmsSession, final Properties jndiProperties, final MessageDispatcher dispatcher)
+        {
+            super(destinationName, jmsSession, jndiProperties);
+            this.dispatcher = dispatcher;
+        }
+
+        /**
+         * Handles a single JMSMessage, creates and populates an ESB Message object instance and dispataches
+         * the ESB Message object instance to the ESB.
+         * The payload of the ESB Message will be the JMS Message object itself. Processors can be added to
+         * this inbound router to transform/extract the actual payload from the JMS Message and set the
+         * ESB Message body to a different type that the destination service expects.
+         *
+         * @param jmsMessage the JMS Message object instance
+         */
+        public void onMessage(final javax.jms.Message jmsMessage)
+        {
+            final InvocationContext invocationContext = createInvocationContext(jmsMessage, extractJmsProperties);
+
+            final Message esbMessage = new Message();
+            esbMessage.setPayload(jmsMessage);
+
+            dispatcher.dispatch(esbMessage, invocationContext);
+        }
+
+        /**
+         * Creates a new InvocationContext.
+         *
+         * @param extractJmsHeaders If extractJmsProperties is set to true, JMS Headers fields and user defined
+         *                          properties will be extracted from the JMS Message and added as invocation
+         *                          parameters to the InvocationContext.
+         * @param jmsMessage The JMS Message.
+         * @return InvocationContext The newly created {@link InvocationContext}.
+         *
+         */
+        private InvocationContext createInvocationContext(final javax.jms.Message jmsMessage, final boolean extractJmsHeaders)
+        {
+            final InvocationContext invocationContext;
+            if (extractJmsHeaders)
+            {
+                Map<String, String> invocationParameters = getJmsProperties(jmsMessage);
+                invocationContext = new InvocationContext(invocationParameters);
+            }
+            else
+            {
+                invocationContext = new InvocationContext();
+            }
+            return invocationContext;
+        }
+
+        /**
+         * Extracts the JMS Headers and user defined properties from the JMS Message.
+         *
+         * @param from The JMS Message.
+         * @return Map Containing the properties.
+         */
+        private Map<String,String> getJmsProperties(final javax.jms.Message from)
+        {
+            try
+            {
+                return PropertiesExtractor.extractAll(from);
+            }
+            catch (final MessageProcessingException e)
+            {
+                throw new IllegalStateException(e.getMessage(), e);
+            }
+        }
+    }
+}


Property changes on: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/inbound/JmsInboundRouter.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/inbound/package.html
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/inbound/package.html	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/inbound/package.html	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,9 @@
+<html>
+<head></head>
+<body>
+JMS Inbound Routing.
+
+<h2>Package Specification</h2>
+Contains Inbound JMS Router classes.
+</body>
+</html>

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/outbound/AbstractJmsOutboundRouter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/outbound/AbstractJmsOutboundRouter.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/outbound/AbstractJmsOutboundRouter.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,254 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.outbound;
+
+import java.util.Properties;
+
+import javax.jms.JMSException;
+
+import org.jboss.esb.api.annotations.Initialize;
+import org.jboss.esb.api.annotations.Property;
+import org.jboss.esb.api.annotations.Uninitialize;
+import org.jboss.esb.api.annotations.Property.Use;
+import org.jboss.esb.api.context.ResourceLocator;
+import org.jboss.esb.api.exception.ConfigurationException;
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.routing.OutboundRouter;
+import org.jboss.esb.api.routing.RoutingException;
+import org.jboss.esb.jms.JMSSession;
+import org.jboss.esb.jms.MessageSender;
+import org.jboss.esb.jms.util.RouterUtil;
+
+/**
+ * AbstractJmsOutboundRouter is implmentation of {@link OutboundRouter} that uses the JMS transport.
+ * <br><br>
+ *
+ * Sample usage:
+ * <br>
+ * <pre>{@code
+ * <outRouter name="outrouter" class="org.jboss.esb.jms.JmsOutboundRouter">
+ *     <property name="jmsDestination">jbossesb.TestOutQueue</property>
+ * </outRouter>
+ *
+ * Optional properties (defaults shown):
+ *     <property name="java.naming.provider.url">jnp://localhost:1099</property>
+ *     <property name="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</property>
+ *     <property name="java.naming.factory.url.pkgs">org.jboss.naming,org.jnp.interfaces</property>
+ *     <property name="org.jboss.esb.jms.connectionFactory">ConnectionFactory</property>
+ * }</pre>
+ * <br>
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ * @since 5.0
+ */
+public abstract class AbstractJmsOutboundRouter implements OutboundRouter
+{
+    /**
+     * The jms destination name.
+     */
+    @Property(use = Use.REQUIRED, name = "jmsDestination")
+    private String destination;
+
+    /**
+     * Properties that are specified in the config but not actually fields on this class.
+     */
+    @org.jboss.esb.api.annotations.Properties
+    private final Properties configProperties = RouterUtil.getDefaultProperties();
+
+    /**
+     * The {@link JMSSession}.
+     */
+    private JMSSession jmsSession;
+
+    /**
+     * The {@link ResourceLocator}.
+     */
+    private ResourceLocator resourceLocator;
+
+    /**
+     * The {@link MessageSender}.
+     */
+    private MessageSender messageSender;
+
+    /**
+     * Name of this router. Will be injected by the deployment runtime.
+     */
+    private Object objectName;
+
+    /**
+     * Will setup this Router so that it is ready to publish messages to
+     * the configured destination.
+     *
+     * @throws ConfigurationException If there is a configuration error.
+     */
+    @Initialize
+    public final void initialize() throws ConfigurationException
+    {
+        setupJmsSession();
+        setupMessageSender();
+    }
+
+    /**
+     * @throws ConfigurationException If a JMSException occurs while trying to setup the session.
+     */
+    private void setupJmsSession() throws ConfigurationException
+    {
+        try
+        {
+            jmsSession = RouterUtil.createJMSSession(configProperties, resourceLocator);
+            RouterUtil.setDestinationType(destination, jmsSession);
+            jmsSession.connect();
+        }
+        catch (final JMSException e)
+        {
+            throw new ConfigurationException(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * @throws ConfigurationException If a JMSException occurs while trying to setup the message sender.
+     */
+    private void setupMessageSender() throws ConfigurationException
+    {
+        try
+        {
+            messageSender = new MessageSender(destination, jmsSession);
+            connectMessageSender(messageSender);
+        }
+        catch (final JMSException e)
+        {
+            throw new ConfigurationException(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * @param sender The {@link MessageSender} to use.
+     * @throws JMSException If an exception occurs while trying to setup the message sender.
+     */
+    private void connectMessageSender(final MessageSender sender) throws JMSException
+    {
+        try
+        {
+            sender.connect();
+        }
+        catch (final JMSException e)
+        {
+            RouterUtil.closeJmsSession(jmsSession);
+            throw e;
+        }
+        catch (final Throwable t)
+        {
+            RouterUtil.closeJmsSession(jmsSession);
+            throw (JMSException) (new JMSException("Unexpected exception while connecting JmsMesssageSender.").initCause(t));
+        }
+    }
+
+    /**
+     * Send the contents of the ESB Message object to the configured
+     * JMS destination.
+     *
+     * @param esbMessage   The ESB Message object
+     * @throws RoutingException If an error occurs while trying to send the JMS Message.
+     */
+    public final void route(final Message esbMessage) throws RoutingException
+    {
+        final javax.jms.Message jmsMessage = createJmsMessage(esbMessage);
+        publishJmsMessage(jmsMessage);
+    }
+
+    /**
+     * Implementations can control the creation of JMS Messages by implementing this method.
+     *
+     * @param esbMessage The ESB Message object from which the payload can be extracted.
+     * @return javax.jms.Message The newly created JMS Message object
+     * @throws RoutingException If an exception occurs while trying to create the JMS Message object.
+     */
+    protected abstract javax.jms.Message createJmsMessage(final Message esbMessage) throws RoutingException;
+
+    /**
+     * @param jmsMessage The JMS Message to publish.
+     * @throws RoutingException If a JMSExcepton is throws while sending.
+     */
+    private void publishJmsMessage(final javax.jms.Message jmsMessage) throws RoutingException
+    {
+        try
+        {
+            messageSender.send(jmsMessage);
+        }
+        catch (final JMSException e)
+        {
+            throw new RoutingException(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * Closes the underlying JMS connection.
+     * This method will be called by the runtime upon deployment.
+     */
+    @Uninitialize
+    public final void uninitialize()
+    {
+        try
+        {
+            if (messageSender != null)
+            {
+                messageSender.close();
+            }
+        }
+        finally
+        {
+            RouterUtil.closeJmsSession(jmsSession);
+        }
+    }
+
+    /**
+     * @return String The JMS destination.
+     */
+    public final String getDestination()
+    {
+        return destination;
+    }
+
+    /**
+     * @return Properties The jndi properties.
+     */
+    public final Properties getJmsProperties()
+    {
+        return (Properties) configProperties.clone();
+    }
+
+    /**
+     * @return JMSSession The {@link JMSSession}.
+     */
+    public final JMSSession getJmsSession()
+    {
+        return jmsSession;
+    }
+
+    /**
+     * @return String String representation of this object.
+     */
+    @Override
+    public final String toString()
+    {
+        return "JMSOutboundRouter [name='" + objectName + "', destination='" + destination + "', jmsProperties='" + configProperties + "']";
+    }
+}

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/outbound/JmsMessageFactory.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/outbound/JmsMessageFactory.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/outbound/JmsMessageFactory.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,331 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.outbound;
+
+import static org.jboss.esb.jms.util.JmsConstants.CORRELATION_ID;
+import static org.jboss.esb.jms.util.JmsConstants.MESSAGE_ID;
+import static org.jboss.esb.jms.util.JmsConstants.REDELIVERED;
+
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.jms.StreamMessage;
+import javax.jms.TextMessage;
+
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.jboss.esb.util.AssertArgument;
+
+/**
+ * JMSMessageFactory methods.
+ *
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
+ *
+ */
+public final class JmsMessageFactory
+{
+    /**
+     * Singleton instance.
+     */
+    private static JmsMessageFactory factory = new JmsMessageFactory();
+
+    /**
+     * Private constructor.
+     */
+    private JmsMessageFactory()
+    {
+    }
+
+    /**
+     * @return JmsMessageFactory The factory instance.
+     */
+    public static JmsMessageFactory getInstance()
+    {
+        return factory;
+    }
+
+    /**
+     * Extracts the payload from the ESB Message and creates a JMS Message.
+     * <p/>
+     * The type of the ESB Message payload will determine the type of the JMS Message instance:
+     * <pre>
+     * | Payload type           |   JMS Message Type                                |
+     * |----------------------------------------------------------------------------|
+     * |    null                |   ObjectMessage with null retured from getObject()|
+     * |    String              |   TextMessage                                     |
+     * |    byte[]              |   BytesMessage                                    |
+     * |    Map                 |   MapMessage                                      |
+     * |    InputStream         |   StreamMessage                                   |
+     * |    Object(Serializable)|   ObjectMessage                                   |
+     * |----------------------------------------------------------------------------|
+     * </pre>
+     *
+     * @param esbMessage The ESB Message object.
+     * @param session The jms session that will be used to create the different types of JMS Message instances.
+     * @return javax.jms.jms.Message The newly created JMS Message with the type and contect of the passed-in ESB Message objects payload.
+     * @throws MessageProcessingException If an exception occurs while extracting the payload from the ESB Message.
+     */
+    @SuppressWarnings("unchecked")
+    public javax.jms.Message create(final Message esbMessage, final Session session) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(esbMessage, "esbMessage");
+        AssertArgument.isNotNull(session, "session");
+
+        final Object payload = esbMessage.getPayload();
+        if (payload == null)
+        {
+            return createObjectMessage(null, session);
+        }
+        else if (payload instanceof String)
+        {
+            return createTextMessage((String)payload, session);
+        }
+        else if (payload instanceof byte[])
+        {
+            return createBytesMessage((byte[])payload, session);
+        }
+        else if (payload instanceof Map)
+        {
+            return createMapMessage((Map) payload, session);
+        }
+        else if (payload instanceof InputStream)
+        {
+            return createStreamMessage((InputStream) payload, session);
+        }
+        else if (payload instanceof Serializable)
+        {
+            return createObjectMessage((Serializable) payload, session);
+        }
+        else
+        {
+            throw new MessageProcessingException("Exception in composeJmsMessage: Unsupported payload type '" + payload.getClass().getName() + "'");
+        }
+    }
+
+    /**
+     * @param object The object payload.
+     * @param session The {@link JMSSession} used for creating the JMS Message.
+     * @return ObjectMessage The newly created JMS Message.
+     * @throws MessageProcessingException If a JMSException occurs.
+     */
+    public ObjectMessage createObjectMessage(final Serializable object, final Session session) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(session, "session");
+        try
+        {
+            final ObjectMessage objectMessage = session.createObjectMessage();
+            objectMessage.setObject(object);
+            return objectMessage;
+        }
+        catch (final JMSException e)
+        {
+            throw new MessageProcessingException("Could not create ObjectMessage with payload '" + object + "'", e);
+        }
+    }
+
+    /**
+     * @param string The string payload.
+     * @param session The {@link JMSSession} used for creating the JMS Message.
+     * @return TextMessage The newly created JMS Message.
+     * @throws MessageProcessingException If a JMSException occurs.
+     */
+    public TextMessage createTextMessage(final String string, final Session session) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(session, "session");
+        try
+        {
+            final TextMessage textMessage = session.createTextMessage();
+            textMessage.setText(string);
+            return textMessage;
+        }
+        catch (final JMSException e)
+        {
+            throw new MessageProcessingException("Could not create TextMessage with payload '" + string + "'", e);
+        }
+    }
+
+    /**
+     * @param bytes The byte[] payload.
+     * @param session The {@link JMSSession} used for creating the JMS Message.
+     * @return BytesMessage The newly created JMS Message.
+     * @throws MessageProcessingException If a JMSException occurs.
+     */
+    public BytesMessage createBytesMessage(final byte[] bytes, final Session session) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(session, "session");
+        try
+        {
+            final BytesMessage bytesMessage = session.createBytesMessage();
+            bytesMessage.writeBytes(bytes);
+            return bytesMessage;
+        }
+        catch (final JMSException e)
+        {
+            throw new MessageProcessingException("Could not create BytesMessage with payload '" + bytes + "'", e);
+        }
+    }
+
+    /**
+     * @param map The Map payload.
+     * @param session The {@link JMSSession} used for creating the JMS Message.
+     * @return MapMessage The newly created JMS Message.
+     * @throws MessageProcessingException If a JMSException occurs.
+     */
+    @SuppressWarnings("unchecked")
+    public MapMessage createMapMessage(final Map map, final Session session) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(session, "session");
+        try
+        {
+            final MapMessage mapMessage = session.createMapMessage();
+            final Set<Map.Entry<String, ?>> entrySet = map.entrySet();
+            for (Map.Entry<String,?> me : entrySet)
+            {
+                mapMessage.setObject(me.getKey(), me.getValue());
+            }
+            return mapMessage;
+        }
+        catch (final JMSException e)
+        {
+            throw new MessageProcessingException("Could not create MapMessage with payload '" + map + "'", e);
+        }
+    }
+
+    /**
+     * @param inputStream The InputStream payload.
+     * @param session The {@link JMSSession} used for creating the JMS Message.
+     * @return StreamMessage The newly created JMS Message.
+     * @throws MessageProcessingException If a JMSException occurs.
+     */
+    public StreamMessage createStreamMessage(final InputStream inputStream, final Session session) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(session, "session");
+        try
+        {
+            final StreamMessage streamMessage = session.createStreamMessage();
+            return streamMessage;
+        }
+        catch (final JMSException e)
+        {
+            throw new MessageProcessingException("Could not create StreamMessage with payload '" + inputStream + "'", e);
+        }
+    }
+
+    /**
+     * The following JMS Headers are set on the outbound JMS Message.
+     * <ul>
+     * <li>JMSCorrelationID     -> get(JmsConstants.CORRELATION_ID) or get(JmsConstants.MESSAGE_ID)</li>
+     * <li>JMSRedelivered       -> get(JmsConstants.REDELIVERED)</li>
+     * </ul>
+     *
+     * @param invocationParameters The {@link InvocationContext} invocation paramters.
+     * @param jmsMessage The JMS Message to set the header on.
+     * @throws MessageProcessingException Error extracting properties.
+     */
+    public void addInvocationParameters(final Map<String,String> invocationParameters, final javax.jms.Message jmsMessage) throws MessageProcessingException
+    {
+        if (invocationParameters == null)
+        {
+            return;
+        }
+        setCorrelationId(invocationParameters, jmsMessage);
+        setRedelivered(invocationParameters, jmsMessage);
+    }
+
+    /**
+     * @param invocationParameters The {@link InvocationContext} invocation paramters.
+     * @param jmsMessage The JMS Message to set the header on.
+     * @throws MessageProcessingException Error extracting properties.
+     */
+    public void setCorrelationId(final Map<String,String> invocationParameters, final javax.jms.Message jmsMessage) throws MessageProcessingException
+    {
+        final String correlationId = (String) invocationParameters.get(CORRELATION_ID);
+        if (correlationId != null)
+        {
+            try
+            {
+                jmsMessage.setJMSCorrelationID(correlationId);
+            }
+            catch (final JMSException e)
+            {
+                throw new MessageProcessingException("JMSException while trying to set the JMSCorrelationID Header to '" + correlationId + "'", e);
+            }
+        }
+        else
+        {
+            setCorrelationIdToMessageId(invocationParameters, jmsMessage);
+        }
+    }
+
+    /**
+     * Since the JMSMessageID header is set by the JMS Provider when sending there is no way for a
+     * producer to set the id prior to sending.
+     * We revert to setting the JMSMessageID as the JMSCorrelationID for the outbound JMS Message
+     * so messages can be correlated.
+     *
+     * @param invocationParameters The {@link InvocationContext} invocation paramters.
+     * @param jmsMessage The JMS Message to set the header on.
+     * @throws MessageProcessingException If it was not possible to set the JMSCorrelationID.
+     */
+    public void setCorrelationIdToMessageId(final Map<String,String> invocationParameters, final javax.jms.Message jmsMessage) throws MessageProcessingException
+    {
+        final String messageId = (String) invocationParameters.get(MESSAGE_ID);
+        if (messageId != null)
+        {
+            try
+            {
+                jmsMessage.setJMSCorrelationID(messageId);
+            }
+            catch (JMSException e)
+            {
+                throw new MessageProcessingException("JMSException while trying to set the JMSCorrelationID Header to '" + messageId + "'", e);
+            }
+        }
+    }
+
+    /**
+     * @param invocationParameters The {@link InvocationContext} invocation paramters.
+     * @param jmsMessage The JMS Message to set the header on.
+     * @throws MessageProcessingException If it was not possible to set the JMSCorrelationID.
+     */
+    public void setRedelivered(final Map<String,String> invocationParameters, final javax.jms.Message jmsMessage) throws MessageProcessingException
+    {
+        final String redelivered = invocationParameters.get(REDELIVERED);
+        if (redelivered != null)
+        {
+            try
+            {
+                jmsMessage.setJMSRedelivered(Boolean.valueOf(redelivered));
+            }
+            catch (JMSException e)
+            {
+                throw new MessageProcessingException("JMSException while trying to set the JMSRedelivered Header to '" + redelivered + "'", e);
+            }
+        }
+    }
+}

Copied: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/outbound/JmsOutboundRouter.java (from rev 24231, labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsOutboundRouter.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/outbound/JmsOutboundRouter.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/outbound/JmsOutboundRouter.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.outbound;
+
+import java.util.Map;
+
+import org.jboss.esb.api.annotations.Property;
+import org.jboss.esb.api.annotations.Property.Use;
+import org.jboss.esb.api.context.InvocationContext;
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.jboss.esb.api.routing.RoutingException;
+
+/**
+ * JmsOutboundRouter is implmentation of {@link OutboundRouter} that uses the JMS transport.
+ * <br><br>
+ * Sample usage:
+ * <br>
+ * <pre>{@code
+ *
+ * <outRouter name="outrouter" class="org.jboss.esb.jms.JmsOutboundRouter">
+ *     <property name="jmsDestination">jbossesb.TestOutQueue</property>
+ * </outRouter>
+ *
+ * Optional properties (defaults shown):
+ *     <property name="extractProperties">true</property>
+ *     <property name="java.naming.provider.url">jnp://localhost:1099</property>
+ *     <property name="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</property>
+ *     <property name="java.naming.factory.url.pkgs">org.jboss.naming,org.jnp.interfaces</property>
+ *     <property name="org.jboss.esb.jms.connectionFactory">ConnectionFactory</property>
+ * }</pre>
+ * <br>
+ * Properties decription:
+ * <lu>
+ * <li>extractProperties true if JMS Headers and properties should be extracted and added to the invocation context</li>
+ * </lu>
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ * @since 5.0
+ */
+public class JmsOutboundRouter extends AbstractJmsOutboundRouter
+{
+    /**
+     * Should ESB Properties from the ESB Message and added to the outgoing JMS Message.
+     */
+    @Property(use = Use.OPTIONAL, defaultVal = "true")
+    private boolean extractEsbProperties;
+
+    /**
+     * @param esbMessage The ESB Message object from which the payload can be extracted.
+     * @return javax.jms.Message The newly created JMS Message object
+     * @throws RoutingException If an exception occurs while trying to create the JMS Message object.
+     */
+    @Override
+    public final javax.jms.Message createJmsMessage(final Message esbMessage) throws RoutingException
+    {
+        try
+        {
+            final JmsMessageFactory factory = JmsMessageFactory.getInstance();
+            final javax.jms.Message jmsMessage = factory.create(esbMessage, getJmsSession().getSession());
+
+            if (extractEsbProperties)
+            {
+                final Map<String, String> invocationParameters = InvocationContext.getContext().getInvocationParameters();
+                factory.addInvocationParameters(invocationParameters, jmsMessage);
+            }
+
+            return jmsMessage;
+        }
+        catch (final MessageProcessingException e)
+        {
+            throw new RoutingException(e.getMessage(), e);
+        }
+    }
+
+}


Property changes on: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/outbound/JmsOutboundRouter.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/outbound/package.html
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/outbound/package.html	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/outbound/package.html	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,9 @@
+<html>
+<head></head>
+<body>
+JMS Outbound Routing.
+
+<h2>Package Specification</h2>
+Contains Outbound JMS Router classes.
+</body>
+</html>

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/BytesMessageExtractor.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/BytesMessageExtractor.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/BytesMessageExtractor.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.processors;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.jboss.esb.api.message.MessageProcessor;
+import org.jboss.esb.util.AssertArgument;
+
+/**
+ * Extracts the bytes from the message payload which is expected to be
+ * a JMS BytesMessage.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class BytesMessageExtractor implements MessageProcessor
+{
+    /**
+     * Extracts the bytes contained in the BytesMessage that is expected to be the type of
+     * the ESB Message payload.
+     *
+     * If the payload is not of type BytesMessage this method will simply fall through.
+     *
+     * @param message The ESB Message object.
+     * @return Message The same message instance but with it payload replaced by the byte[] from the BytesMessage.
+     * @throws MessageProcessingException If the message or the payload is null.
+     */
+    public final Message process(final Message message) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(message, "message");
+
+        final Object payload = message.getPayload();
+        if (payload instanceof BytesMessage)
+        {
+            try
+            {
+                final BytesMessage bytesMessage = (BytesMessage) payload;
+                message.setPayload(readBytes(bytesMessage));
+            }
+            catch (final JMSException e)
+            {
+                throw new MessageProcessingException("JMSException while trying to extract byte[] from BytesMessage '" + payload + "'", e);
+            }
+        }
+        return message;
+    }
+
+    /**
+     * Read the bytes from the supplied JMS Message.
+     * @param jmsMessage The JMS Message.
+     * @return The message bytes.
+     * @throws JMSException Error Access message bytes.
+     */
+    private byte[] readBytes(final BytesMessage jmsMessage) throws JMSException
+    {
+        jmsMessage.reset();
+        int msgLength = 0;
+        final int buffSize = 50000;
+        byte[] data = new byte[buffSize];
+        while (true)
+        {
+            int len = jmsMessage.readBytes(data);
+            if (len > 0)
+            {
+                msgLength += len;
+            }
+            else
+            {
+                break;
+            }
+        }
+        if (msgLength == 0)
+        {
+            return null;
+        }
+        byte[] content = new byte[msgLength];
+        if (msgLength <= buffSize)
+        {
+            System.arraycopy(data, 0, content, 0, msgLength);
+        }
+        else
+        {
+            jmsMessage.reset();
+            jmsMessage.readBytes(content);
+        }
+        return content;
+    }
+}

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/MapMessageExtractor.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/MapMessageExtractor.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/MapMessageExtractor.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.processors;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.jboss.esb.api.message.MessageProcessor;
+import org.jboss.esb.util.AssertArgument;
+
+/**
+ * Extracts the Map from the message payload which is expected to be
+ * a JMS MapMessage.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class MapMessageExtractor implements MessageProcessor
+{
+    /**
+     * Extracts the Map contained in the MapMessage that is expected to be the type of
+     * the ESB Message payload.
+     *
+     * If the payload is not of type MapMessage this method will simply fall through.
+     *
+     * @param message The ESB Message object.
+     * @return Message The same message instance but with it payload replaced by the Map from the MapMessage.
+     * @throws MessageProcessingException If the message or the payload is null.
+     */
+    public final Message process(final Message message) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(message, "message");
+
+        final Object payload = message.getPayload();
+        if (payload instanceof MapMessage)
+        {
+            try
+            {
+                final MapMessage mapMessage = (MapMessage) payload;
+                message.setPayload(getMap(mapMessage));
+            }
+            catch (final JMSException e)
+            {
+                throw new MessageProcessingException("JMSException while trying to extract Map from MapMessage '" + payload + "'", e);
+            }
+        }
+        return message;
+    }
+
+    /**
+     * Gets the Map from a JMS MessageMap instance.
+     *
+     * @param jmsMessage            The JMS Message Object instance.
+     * @return Map                  The extracted Map.
+     * @throws JMSException         If an exception occurs during extraction.
+     */
+    private Map<String, Object> getMap(final javax.jms.Message jmsMessage) throws JMSException
+    {
+        final MapMessage jmsMap = (MapMessage) jmsMessage;
+        final Map<String, Object> esbMap = new HashMap<String, Object>();
+        final Enumeration<?> mapNames = jmsMap.getMapNames();
+        while (mapNames.hasMoreElements())
+        {
+            final String key = (String) mapNames.nextElement();
+            final Object value = jmsMap.getObject(key);
+            esbMap.put(key, value);
+        }
+        return esbMap;
+    }
+}

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/ObjectMessageExtractor.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/ObjectMessageExtractor.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/ObjectMessageExtractor.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.processors;
+
+import javax.jms.JMSException;
+import javax.jms.ObjectMessage;
+
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.jboss.esb.api.message.MessageProcessor;
+import org.jboss.esb.util.AssertArgument;
+
+/**
+ * Extracts the Object from the message payload which is expected to be
+ * a JMS ObjectMessage.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class ObjectMessageExtractor implements MessageProcessor
+{
+    /**
+     * Extracts the Object contained in the ObjectMessage that is expected to be the type of
+     * the ESB Message payload.
+     *
+     * If the payload is not of type ObjectMessage this method will simply fall through.
+     *
+     * @param message The ESB Message object.
+     * @return Message The same message instance but with it payload replaced by the Object from the ObjectMessage.
+     * @throws MessageProcessingException If the message or the payload is null.
+     */
+    public final Message process(final Message message) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(message, "message");
+
+        final Object payload = message.getPayload();
+        if (payload instanceof ObjectMessage)
+        {
+            try
+            {
+                message.setPayload(((ObjectMessage)payload).getObject());
+            }
+            catch (final JMSException e)
+            {
+                throw new MessageProcessingException("JMSException while trying to extract object from ObjectMessage '" + payload + "'", e);
+            }
+        }
+        return message;
+    }
+}

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/StreamMessageExtractor.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/StreamMessageExtractor.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/StreamMessageExtractor.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.processors;
+
+import javax.jms.StreamMessage;
+
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.jboss.esb.api.message.MessageProcessor;
+import org.jboss.esb.jms.StreamMessageInputStream;
+import org.jboss.esb.util.AssertArgument;
+
+/**
+ * Extracts the Stream from the message payload which is expected to be
+ * a JMS StreamMessage.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class StreamMessageExtractor implements MessageProcessor
+{
+    /**
+     * Extracts the Map contained in the StreamMessage that is expected to be the type of
+     * the ESB Message payload.
+     *
+     * If the payload is not of type StreamMessage this method will simply fall through.
+     *
+     * @param message The ESB Message object.
+     * @return Message The same message instance but with it payload replaced by the Stream from the MapMessage.
+     * @throws MessageProcessingException If the message or the payload is null.
+     */
+    public final Message process(final Message message) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(message, "message");
+
+        final Object payload = message.getPayload();
+        if (payload instanceof StreamMessage)
+        {
+            final StreamMessage streamMessage = (StreamMessage) payload;
+            message.setPayload(new StreamMessageInputStream(streamMessage));
+        }
+        return message;
+    }
+
+}

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/TextMessageExtractor.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/TextMessageExtractor.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/TextMessageExtractor.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.processors;
+
+import javax.jms.JMSException;
+import javax.jms.TextMessage;
+
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.jboss.esb.api.message.MessageProcessor;
+import org.jboss.esb.util.AssertArgument;
+
+/**
+ * Extracts the text from the message payload which is expected to be
+ * a JMS TextMessage.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class TextMessageExtractor implements MessageProcessor
+{
+    /**
+     * Extracts the String contained in the TestMessage that is expected to be the type of
+     * the ESB Message payload.
+     *
+     * If the payload is not of type TextMessage this method will simply fall through.
+     *
+     * @param message The ESB Message object.
+     * @return Message The same message instance but with it payload replaced by the String from the TextMessage.
+     * @throws MessageProcessingException If the message or the payload is null.
+     */
+    public final Message process(final Message message) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(message, "message");
+
+        final Object payload = message.getPayload();
+        if (payload instanceof TextMessage)
+        {
+            try
+            {
+                message.setPayload(((TextMessage)payload).getText());
+            }
+            catch (final JMSException e)
+            {
+                throw new MessageProcessingException("JMSException while trying to extract text from TextMessage '" + payload + "'", e);
+            }
+        }
+        return message;
+    }
+}

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/package.html
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/package.html	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/processors/package.html	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,9 @@
+<html>
+<head></head>
+<body>
+JMS Routing Message Processors.
+
+<h2>Package Specification</h2>
+Processor for extracting information from JMS Messages.
+</body>
+</html>

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/util/PropertiesExtractor.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/util/PropertiesExtractor.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/util/PropertiesExtractor.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,343 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.util;
+
+import static org.jboss.esb.jms.util.JmsConstants.CORRELATION_ID;
+import static org.jboss.esb.jms.util.JmsConstants.DELIVERY_MODE;
+import static org.jboss.esb.jms.util.JmsConstants.EXPIRATION;
+import static org.jboss.esb.jms.util.JmsConstants.MESSAGE_ID;
+import static org.jboss.esb.jms.util.JmsConstants.PRIORITY;
+import static org.jboss.esb.jms.util.JmsConstants.REDELIVERED;
+import static org.jboss.esb.jms.util.JmsConstants.REPLY_TO;
+import static org.jboss.esb.jms.util.JmsConstants.TIMESTAMP;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.Topic;
+
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.jboss.esb.util.AssertArgument;
+
+/**
+ * Properties Exctractor is a util for extracting JMS Header fields and
+ * user defined properties from a JMS Message object.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ * @since 5.0
+ */
+public final class PropertiesExtractor
+{
+    /**
+     * Sole private constructor.
+     */
+    private PropertiesExtractor()
+    {
+    }
+
+    /**
+     * Will extract all the properties that have been set on the JMS Message and
+     * also extract all the set JMS Headers.
+     * <p/>
+     * The following JMS Headers are extracted:
+     * <ul>
+     * <li>JMSCorrelationID     -> get(JmsConstants.CORRELATION_ID</li>
+     * <li>JMSExpiration        -> get(JmsConstants.EXPIRATOIN</li>
+     * <li>JMSRedelivered       -> get(JmsConstants.REDELIVERED</li>
+     * <li>JMSMessageID         -> get(JmsConstants.MESSAGE_ID</li>
+     * <li>JMSTimestamp         -> get(JmsConstants.TIMESTAMP</li>
+     * <li>JMSReplyTo           -> get(JmsConstants.REPLY_TO</li>
+     * <li>JMSPriority          -> get(JmsConstants.PRIORITY</li>
+     * <li>JMSDeliveryMode      -> get(JmsConstants.DELIVERY_MODE</li>
+     * </ul>
+     * Note that user defined properties will also be added to the
+     * returned Properties object. They will simple have the key and
+     * values as they had in the JMS Message object.
+     *
+     * @param jmsMessage    The JMS Message.
+     * @return Propertis    The JMS Properties.
+     * @throws MessageProcessingException Error extracting properties.
+     */
+    public static Map<String, String> extractAll(final javax.jms.Message jmsMessage) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(jmsMessage, "jmsMessage");
+
+        final Map<String,String> map = new HashMap<String,String>();
+        addUserDefinedProperties(jmsMessage, map);
+        addCorrelationId(jmsMessage, map);
+        addExpiration(jmsMessage, map);
+        addRedelivered(jmsMessage, map);
+        addMessageId(jmsMessage, map);
+        addTimestamp(jmsMessage, map);
+        addPriority(jmsMessage, map);
+        addDeliveryMode(jmsMessage, map);
+        addReplyTo(jmsMessage, map);
+        return map;
+    }
+
+    /**
+     * Note that JMS standard header fields are not considered properties and are not set by this method.
+     *
+     * @param jmsMessage The JMS Message.
+     * @param map The Map to add the properties to.
+     * @throws MessageProcessingException Error extracting properties.
+     */
+    @SuppressWarnings("unchecked")
+    public static void addUserDefinedProperties(final javax.jms.Message jmsMessage, final Map<String,String> map) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(jmsMessage, "jmsMessage");
+        AssertArgument.isNotNull(map, "map");
+
+        String propertyName =  null;
+        Object value = null;
+        try
+        {
+            final Enumeration<String> propertyNames = jmsMessage.getPropertyNames();
+            while (propertyNames.hasMoreElements())
+            {
+                propertyName = propertyNames.nextElement();
+                value = jmsMessage.getObjectProperty(propertyName);
+                map.put(propertyName, value.toString());
+            }
+        }
+        catch (JMSException e)
+        {
+            throw new MessageProcessingException("JMSException while trying to retrieve user defined property '" + propertyName + "' which had the value '" + value + "'", e);
+        }
+    }
+
+    /**
+     * Adds the correlation id.
+     *
+     * @param jmsMessage    The JMS Message.
+     * @param map The Map to add the properties to.
+     * @throws MessageProcessingException Error extracting properties.
+     */
+    public static void addCorrelationId(final javax.jms.Message jmsMessage, final Map<String,String> map) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(jmsMessage, "jmsMessage");
+        AssertArgument.isNotNull(map, "map");
+
+        try
+        {
+            final String correlationID = jmsMessage.getJMSCorrelationID();
+            if (correlationID != null)
+            {
+                map.put(CORRELATION_ID, correlationID);
+            }
+        }
+        catch (JMSException e)
+        {
+            throw new MessageProcessingException("JMSException while trying to retrieve JMSCorrelationID property from JMS Message:", e);
+        }
+    }
+
+    /**
+     * Adds the JMSExpiration header.
+     *
+     * @param jmsMessage    The JMS Message.
+     * @param map The Map to add the properties to.
+     * @throws MessageProcessingException Error extracting properties.
+     */
+    public static void addExpiration(final javax.jms.Message jmsMessage, final Map<String,String> map) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(jmsMessage, "jmsMessage");
+        AssertArgument.isNotNull(map, "map");
+
+        try
+        {
+            final long expiration = jmsMessage.getJMSExpiration();
+            if (expiration > 0L)
+            {
+                map.put(EXPIRATION, Long.toString(expiration));
+            }
+        }
+        catch (JMSException e)
+        {
+            throw new MessageProcessingException("JMSException while trying to retrieve JMSExpiration property from JMS Message:", e);
+        }
+
+    }
+
+    /**
+     * Adds the JMSRedelivered header.
+     *
+     * @param jmsMessage    The JMS Message.
+     * @param map The Map to add the properties to.
+     * @throws MessageProcessingException Error extracting properties.
+     */
+    public static void addRedelivered(final javax.jms.Message jmsMessage, final Map<String,String> map) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(jmsMessage, "jmsMessage");
+        AssertArgument.isNotNull(map, "map");
+
+        try
+        {
+            final boolean redelivered = jmsMessage.getJMSRedelivered();
+            map.put(REDELIVERED, Boolean.toString(redelivered));
+        }
+        catch (JMSException e)
+        {
+            throw new MessageProcessingException("JMSException while trying to retrieve JMSRedelivered property from JMS Message:", e);
+        }
+    }
+
+    /**
+     * Adds the JMSMessageID header.
+     *
+     * @param jmsMessage    The JMS Message.
+     * @param map The Map to add the properties to.
+     * @throws MessageProcessingException Error extracting properties.
+     */
+    public static void addMessageId(final javax.jms.Message jmsMessage, final Map<String,String> map) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(jmsMessage, "jmsMessage");
+        AssertArgument.isNotNull(map, "map");
+
+        try
+        {
+            final String messageId = jmsMessage.getJMSMessageID();
+            /*
+             * Need to check for null as a client may have called MessageProducer.setDisableMessageID.
+             */
+            if (messageId != null)
+            {
+                map.put(MESSAGE_ID, messageId);
+            }
+        }
+        catch (JMSException e)
+        {
+            throw new MessageProcessingException("JMSException while trying to retrieve JMSMessageId property from JMS Message:", e);
+        }
+
+    }
+
+    /**
+     * Adds the JMSTimestamp header.
+     *
+     * @param jmsMessage    The JMS Message.
+     * @param map The Map to add the properties to.
+     * @throws MessageProcessingException Error extracting properties.
+     */
+    public static void addTimestamp(final javax.jms.Message jmsMessage, final Map<String,String> map) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(jmsMessage, "jmsMessage");
+        AssertArgument.isNotNull(map, "map");
+
+        try
+        {
+            final long timestamp = jmsMessage.getJMSTimestamp();
+            map.put(TIMESTAMP, Long.toString(timestamp));
+        }
+        catch (JMSException e)
+        {
+            throw new MessageProcessingException("JMSException while trying to retrieve JMSTimestamp property from JMS Message:", e);
+        }
+    }
+
+    /**
+     * Adds the JMSReplyTo header.
+     *
+     * @param jmsMessage    The JMS Message.
+     * @param map The Map to add the properties to.
+     * @throws MessageProcessingException Error extracting properties.
+     */
+    public static void addReplyTo(final javax.jms.Message jmsMessage, final Map<String,String> map) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(jmsMessage, "jmsMessage");
+        AssertArgument.isNotNull(map, "map");
+
+        try
+        {
+            Destination replyTo = jmsMessage.getJMSReplyTo();
+            String destinationName;
+            if (replyTo != null)
+            {
+                if (replyTo instanceof Queue)
+                {
+                    destinationName = ((Queue)replyTo).getQueueName();
+                }
+                else
+                {
+                    destinationName = ((Topic)replyTo).getTopicName();
+                }
+                map.put(REPLY_TO, destinationName);
+            }
+        }
+        catch (JMSException e)
+        {
+            throw new MessageProcessingException("JMSException while trying to retrieve JMSReplyTo property from JMS Message:", e);
+        }
+    }
+
+    /**
+     * Adds the JMSPriority header.
+     *
+     * @param jmsMessage    The JMS Message.
+     * @param map The Map to add the properties to.
+     * @throws MessageProcessingException Error extracting properties.
+     */
+    public static void addPriority(final javax.jms.Message jmsMessage, final Map<String,String> map) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(jmsMessage, "jmsMessage");
+        AssertArgument.isNotNull(map, "map");
+
+        try
+        {
+            int priority = jmsMessage.getJMSPriority();
+            if (priority >= 0 && priority <= 9)
+            {
+                map.put(PRIORITY, Integer.toString(priority));
+            }
+        }
+        catch (final JMSException e)
+        {
+            throw new MessageProcessingException("JMSException while trying to retrieve JMSPriority property from JMS Message:", e);
+        }
+    }
+
+    /**
+     * Adds the JMSDeliveryMode header..
+     *
+     * @param jmsMessage    The JMS Message.
+     * @param map The Map to add the properties to.
+     * @throws MessageProcessingException Error extracting properties.
+     */
+    public static void addDeliveryMode(final javax.jms.Message jmsMessage, final Map<String,String> map) throws MessageProcessingException
+    {
+        AssertArgument.isNotNull(jmsMessage, "jmsMessage");
+        AssertArgument.isNotNull(map, "map");
+
+        try
+        {
+            int deliveryMode = jmsMessage.getJMSDeliveryMode();
+            map.put(DELIVERY_MODE, Integer.toString(deliveryMode));
+        }
+        catch (final JMSException e)
+        {
+            throw new MessageProcessingException("JMSException while trying to retrieve JMSDeliveredMode property from JMS Message:", e);
+        }
+    }
+
+}

Modified: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/util/RouterUtil.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/util/RouterUtil.java	2008-12-05 09:57:53 UTC (rev 24245)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/util/RouterUtil.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -41,6 +41,9 @@
  */
 public final class RouterUtil
 {
+    /**
+     * Private constructor.
+     */
     private RouterUtil()
     {
     }
@@ -80,6 +83,8 @@
      /**
      * Create a new JMSSession.
      *
+     * @param jmsProperties Environment properties(jndi) to use when creating the JMSSession.
+     * @param resourceLocator {@link ResourceLocator} to use.
      * @return JMSSession   The newly created connected session.
      * @throws JMSException If and error occurs while trying to create or connect.
      */
@@ -90,7 +95,14 @@
         return session;
     }
 
-    public static void setDestinationTyp(final String destinationName, final JMSSession session) throws JMSException
+    /**
+     * Sets the Destination type (Queue or Topic).
+     *
+     * @param destinationName The name of the destination.
+     * @param session The {@link JMSSession} to use.
+     * @throws JMSException If an exception occurs while trying to set the session type.
+     */
+    public static void setDestinationType(final String destinationName, final JMSSession session) throws JMSException
     {
         final Destination destination = session.lookupDestination(destinationName);
         if (destination instanceof Queue)
@@ -103,6 +115,9 @@
         }
     }
 
+    /**
+     * @return Properties The default jndi properties.
+     */
     public static Properties getDefaultProperties()
     {
         final Properties defaults = new Properties();
@@ -111,6 +126,9 @@
         return defaults;
     }
 
+    /**
+     * @param session The {@link JMSSession} to close.
+     */
     public static void closeJmsSession(final JMSSession session)
     {
         if (session != null)

Deleted: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsInboundRouterTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsInboundRouterTest.java	2008-12-05 09:57:53 UTC (rev 24245)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsInboundRouterTest.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -1,133 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms;
-
-import org.jboss.esb.deploy.DeploymentRuntime;
-import org.jboss.esb.deploy.DeploymentUtil;
-import org.jboss.esb.jms.test.JmsTestBusProvider;
-import org.junit.AfterClass;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import javax.jms.JMSException;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Test for {@link JmsInboundRouter}.
- *
- * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
- */
-public class JmsInboundRouterTest
-{
-    private static final String DESTINATION_NAME = "jbossesb.TestQueue";
-
-    private static JmsTestBusProvider jmsProvider;
-
-    @BeforeClass
-    public static void startProvider() throws Exception
-    {
-        jmsProvider = new JmsTestBusProvider();
-        jmsProvider.start();
-    }
-
-    @AfterClass
-    public static void stopProvider() throws Exception
-    {
-        jmsProvider.stop();
-    }
-
-    @Test
-    public final void recieveAndDispatch() throws Exception
-    {
-        DeploymentRuntime runtime = DeploymentUtil.createRuntime(getClass().getResourceAsStream("jms-inbound-router_01.xml"));
-        final String messageContent = "Some text as payload";
-
-        runtime.deploy();
-        try
-        {
-            TimeUnit.SECONDS.sleep(3);
-            sendMessage(messageContent, DESTINATION_NAME);
-        }
-        finally
-        {
-            runtime.undeploy();
-        }
-
-        assertNotNull(MyTestService.getMessage());
-        assertEquals(messageContent, MyTestService.getMessage().getPayload());
-    }
-
-    @Test
-    public final void recieveAndDispatchMultiple() throws Exception
-    {
-        DeploymentRuntime runtime = DeploymentUtil.createRuntime(getClass().getResourceAsStream("jms-inbound-router_01.xml"));
-        final String messageContent = "Some text as payload";
-
-        runtime.deploy();
-        try
-        {
-            TimeUnit.SECONDS.sleep(3);
-            sendMessage(messageContent, DESTINATION_NAME);
-        }
-        finally
-        {
-            runtime.undeploy();
-        }
-
-        assertNotNull(MyTestService.getMessage());
-        assertEquals(messageContent, MyTestService.getMessage().getPayload());
-    }
-
-    private void sendMessage(final String payload, final String destination) throws JMSException, InterruptedException
-    {
-        Properties jndiProperties = jmsProvider.getJndiProperties();
-        jndiProperties.setProperty("queue." + destination, destination);
-        JMSSession jmsSession = new JMSSession(JMSSession.Type.QUEUE, jndiProperties);
-
-        jmsSession.connect();
-        try
-        {
-            MessageSender sender = new MessageSender(destination, jmsSession);
-            try
-            {
-                sender.connect();
-                Session session = sender.getSession();
-                TextMessage textMessage = session.createTextMessage(payload);
-                sender.send(textMessage);
-                Thread.sleep(3000);
-            }
-            finally
-            {
-                sender.close();
-            }
-        }
-        finally
-        {
-            jmsSession.close();
-        }
-    }
-
-}

Deleted: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsOutboundRouterTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsOutboundRouterTest.java	2008-12-05 09:57:53 UTC (rev 24245)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsOutboundRouterTest.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -1,155 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.QueueConnection;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.QueueSession;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.jboss.esb.api.context.InvocationContext;
-import org.jboss.esb.api.message.Message;
-import org.jboss.esb.api.routing.OutboundRouter;
-import org.jboss.esb.api.routing.RoutingException;
-import org.jboss.esb.api.service.ServiceName;
-import org.jboss.esb.api.exception.DeploymentException;
-import org.jboss.esb.deploy.DeploymentRuntime;
-import org.jboss.esb.deploy.DeploymentUtil;
-import org.jboss.esb.deploy.config.OutboundRouterConfig;
-import org.jboss.esb.jms.test.JmsTestBusProvider;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Test for {@link JmsOutboundRouter}.
- *
- * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
- *
- */
-public class JmsOutboundRouterTest
-{
-    private static JmsTestBusProvider jmsProvider;
-
-    @Test
-    public void route() throws DeploymentException, IOException, InterruptedException, RoutingException, JMSException, NamingException
-    {
-        final DeploymentRuntime runtime = getRuntime();
-        final JmsOutboundRouter router = (JmsOutboundRouter)getRouter(runtime);
-        InvocationContext.setContext(new InvocationContext());
-        assertNotNull(router);
-
-        try
-        {
-            runtime.deploy();
-            TimeUnit.SECONDS.sleep(3);
-
-            final String payload = "<message/>";
-            final Message message = new Message();
-            message.setPayload(payload);
-            router.route(message);
-
-            javax.jms.Message jmsMessage = recieveMessage(router.getDestination(), router.getJmsProperties(), 5000L);
-            assertTrue(jmsMessage instanceof TextMessage);
-            assertEquals(payload, ((TextMessage)jmsMessage).getText());
-        }
-        finally
-        {
-            runtime.undeploy();
-        }
-    }
-
-    @Test (expected = DeploymentException.class)
-    public void shouldThrowIfInvalidMessageComposerIsConfigured() throws DeploymentException, IOException, InterruptedException
-    {
-        DeploymentRuntime runtime = DeploymentUtil.createRuntime(getClass().getResourceAsStream("jms-outbound-router-invalid.xml"));
-        runtime.deploy();
-    }
-
-    @BeforeClass
-    public static void startProvider() throws Exception
-    {
-        jmsProvider = new JmsTestBusProvider();
-        jmsProvider.start();
-    }
-
-    @AfterClass
-    public static void stopProvider() throws Exception
-    {
-        jmsProvider.stop();
-    }
-
-    private DeploymentRuntime getRuntime() throws DeploymentException, IOException
-    {
-        return DeploymentUtil.createRuntime(getClass().getResourceAsStream("jms-outbound-router.xml"));
-    }
-
-    private OutboundRouter getRouter(final DeploymentRuntime runtime) throws DeploymentException
-    {
-        final OutboundRouterConfig routerConfig = DeploymentUtil.getOutboundRouter(new ServiceName("serviceCat", "serviceName"), "outrouter", runtime);
-        return routerConfig.getRouter();
-    }
-
-    private javax.jms.Message recieveMessage(String destinationName, Properties jndiProperties,  long timeout) throws JMSException, NamingException
-    {
-        QueueConnection connection = null;
-        QueueSession session = null;
-        try
-        {
-            final InitialContext ctx = new InitialContext(jndiProperties);
-            QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
-            connection = factory.createQueueConnection();
-            connection.start();
-            session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
-            MessageConsumer consumer = session.createConsumer((Destination)ctx.lookup(destinationName));
-            return consumer.receive(timeout);
-        }
-        finally
-        {
-            if (session != null)
-            {
-                session.close();
-            }
-            if (connection != null)
-            {
-                connection.close();
-            }
-        }
-    }
-
-    static class InvalidJmsMessageComposer
-    {
-    }
-}

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/TestInboundRouter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/TestInboundRouter.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/TestInboundRouter.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,45 @@
+package org.jboss.esb.jms;
+
+import org.jboss.esb.api.context.InvocationContext;
+import org.jboss.esb.api.history.ProcessingEventLog;
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.routing.InboundRouter;
+import org.jboss.esb.api.routing.MessageDispatcher;
+
+/**
+ *
+ */
+public class TestInboundRouter implements InboundRouter
+{
+    private MessageDispatcher dispatcher;
+    private ProcessingEventLog eventLog;
+
+    public void setDispatcher(MessageDispatcher dispatcher)
+    {
+        this.dispatcher = dispatcher;
+    }
+
+    public InvocationContext sendMessage(String message)
+    {
+        return sendMessage(message, false);
+    }
+
+    public InvocationContext sendMessage(String message, boolean propagateEventLog)
+    {
+        Message esbMessage = new Message();
+        InvocationContext invocationContext = new InvocationContext();
+
+        eventLog = new ProcessingEventLog(propagateEventLog);
+        ProcessingEventLog.setEventLog(eventLog, invocationContext);
+
+        esbMessage.setPayload(message);
+        dispatcher.dispatch(esbMessage, invocationContext);
+
+        return invocationContext;
+    }
+
+    public ProcessingEventLog getEventLog()
+    {
+        return eventLog;
+    }
+}

Copied: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/inbound/JmsInboundRouterTest.java (from rev 24231, labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsInboundRouterTest.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/inbound/JmsInboundRouterTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/inbound/JmsInboundRouterTest.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.inbound;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import javax.jms.JMSException;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.jboss.esb.api.exception.DeploymentException;
+import org.jboss.esb.deploy.DeploymentRuntime;
+import org.jboss.esb.deploy.DeploymentUtil;
+import org.jboss.esb.jms.JMSSession;
+import org.jboss.esb.jms.MessageSender;
+import org.jboss.esb.jms.MyTestService;
+import org.jboss.esb.jms.inbound.JmsInboundRouter;
+import org.jboss.esb.jms.test.JmsTestBusProvider;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test for {@link JmsInboundRouter}.
+ *
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
+ */
+public class JmsInboundRouterTest
+{
+    private static final String DESTINATION_NAME = "jbossesb.TestQueue";
+
+    private static JmsTestBusProvider jmsProvider;
+
+    @BeforeClass
+    public static void startProvider() throws Exception
+    {
+        jmsProvider = new JmsTestBusProvider();
+        jmsProvider.start();
+    }
+
+    @AfterClass
+    public static void stopProvider() throws Exception
+    {
+        jmsProvider.stop();
+    }
+
+    private DeploymentRuntime runtime;
+
+    @Before
+    public void createRuntime() throws DeploymentException, IOException
+    {
+        runtime = DeploymentUtil.createRuntime(getClass().getResourceAsStream("jms-inbound-router_01.xml"));
+    }
+
+    @Test
+    public final void recieveAndDispatch() throws Exception
+    {
+        final String messageContent = "Some text as payload";
+
+        runtime.deploy();
+        try
+        {
+            TimeUnit.SECONDS.sleep(3);
+            sendMessage(messageContent, DESTINATION_NAME);
+        }
+        finally
+        {
+            runtime.undeploy();
+        }
+
+        assertNotNull(MyTestService.getMessage());
+        Object payload = MyTestService.getMessage().getPayload();
+        assertTrue(payload instanceof String);
+    }
+
+    private void sendMessage(final String payload, final String destination) throws JMSException, InterruptedException
+    {
+        Properties jndiProperties = jmsProvider.getJndiProperties();
+        jndiProperties.setProperty("queue." + destination, destination);
+        JMSSession jmsSession = new JMSSession(JMSSession.Type.QUEUE, jndiProperties);
+
+        jmsSession.connect();
+        try
+        {
+            MessageSender sender = new MessageSender(destination, jmsSession);
+            try
+            {
+                sender.connect();
+                Session session = sender.getSession();
+                TextMessage textMessage = session.createTextMessage(payload);
+                sender.send(textMessage);
+                Thread.sleep(3000);
+            }
+            finally
+            {
+                sender.close();
+            }
+        }
+        finally
+        {
+            jmsSession.close();
+        }
+    }
+
+}


Property changes on: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/inbound/JmsInboundRouterTest.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/inbound/jms-inbound-router_01.xml (from rev 24231, labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-inbound-router_01.xml)
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/inbound/jms-inbound-router_01.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/inbound/jms-inbound-router_01.xml	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,17 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+
+    <services>
+        <service serviceCategory="service-cat" serviceName="service-a" serviceDescription="TestService" class="org.jboss.esb.jms.MyTestService">
+            <inRouter name="inrouter1" class="org.jboss.esb.jms.inbound.JmsInboundRouter">
+                <processors>
+                    <processor class="org.jboss.esb.jms.processors.TextMessageExtractor"/>
+                </processors>
+                <property name="java.naming.provider.url">tcp://localhost:61717</property>
+                <property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property>
+                <property name="jmsDestination">jbossesb.TestQueue</property>
+                <property name="queue.jbossesb.TestQueue">jbossesb.TestQueue</property>
+            </inRouter>
+        </service>
+    </services> 
+    
+</jbossesb>
\ No newline at end of file


Property changes on: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/inbound/jms-inbound-router_01.xml
___________________________________________________________________
Name: svn:mergeinfo
   + 

Deleted: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-inbound-router_01.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-inbound-router_01.xml	2008-12-05 09:57:53 UTC (rev 24245)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-inbound-router_01.xml	2008-12-05 10:10:16 UTC (rev 24246)
@@ -1,14 +0,0 @@
-<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
-
-    <services>
-        <service serviceCategory="service-cat" serviceName="service-a" serviceDescription="TestService" class="org.jboss.esb.jms.MyTestService">
-            <inRouter name="inrouter1" class="org.jboss.esb.jms.JmsInboundRouter">
-                <property name="java.naming.provider.url">tcp://localhost:61717</property>
-                <property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property>
-                <property name="jmsDestination">jbossesb.TestQueue</property>
-                <property name="queue.jbossesb.TestQueue">jbossesb.TestQueue</property>
-            </inRouter>
-        </service>
-    </services> 
-    
-</jbossesb>
\ No newline at end of file

Deleted: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-outbound-router-invalid.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-outbound-router-invalid.xml	2008-12-05 09:57:53 UTC (rev 24245)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-outbound-router-invalid.xml	2008-12-05 10:10:16 UTC (rev 24246)
@@ -1,15 +0,0 @@
-<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
-
-    <services>
-        <service serviceCategory="serviceCat2" serviceName="serviceName2" serviceDescription="TestService" class="org.jboss.esb.jms.MyTestService">
-            <outRouter name="outrouter" class="org.jboss.esb.jms.JmsOutboundRouter">
-                <property name="java.naming.provider.url">tcp://localhost:61717</property>
-                <property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property>
-                <property name="jmsDestination">jbossesb.TestOutQueue</property>
-                <property name="queue.jbossesb.TestOutQueue">jbossesb.TestOutQueue</property>
-                <property name="jmsMessageComposer">org.jboss.esb.jms.JmsOutboundRouterTest$InvalidJmsMessageComposer</property>
-            </outRouter>
-        </service>
-    </services> 
-    
-</jbossesb>
\ No newline at end of file

Deleted: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-outbound-router.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-outbound-router.xml	2008-12-05 09:57:53 UTC (rev 24245)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-outbound-router.xml	2008-12-05 10:10:16 UTC (rev 24246)
@@ -1,14 +0,0 @@
-<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
-
-    <services>
-        <service serviceCategory="serviceCat" serviceName="serviceName" serviceDescription="TestService" class="org.jboss.esb.jms.MyTestService">
-            <outRouter name="outrouter" class="org.jboss.esb.jms.JmsOutboundRouter">
-                <property name="java.naming.provider.url">tcp://localhost:61717</property>
-                <property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property>
-                <property name="jmsDestination">jbossesb.TestOutQueue</property>
-                <property name="queue.jbossesb.TestOutQueue">jbossesb.TestOutQueue</property>
-            </outRouter>
-        </service>
-    </services> 
-    
-</jbossesb>
\ No newline at end of file

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/outbound/JmsMessageFactoryTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/outbound/JmsMessageFactoryTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/outbound/JmsMessageFactoryTest.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,170 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.outbound;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.ObjectMessage;
+import javax.jms.TextMessage;
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.jboss.esb.jms.util.JmsConstants;
+import org.junit.Before;
+import org.junit.Test;
+import com.mockrunner.jms.DestinationManager;
+import com.mockrunner.mock.jms.MockConnection;
+import com.mockrunner.mock.jms.MockSession;
+import com.mockrunner.mock.jms.MockTextMessage;
+
+/**
+ * Test for {@link JmsMessageFactory}.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class JmsMessageFactoryTest
+{
+    private MockSession mockSession;
+    private JmsMessageFactory factory = JmsMessageFactory.getInstance();
+
+    @Test
+    public void createJmsMessageNullPayload() throws MessageProcessingException, JMSException
+    {
+        final Message esbMessage = createMessage(null);
+
+        javax.jms.Message jmsMessage = callFactory(esbMessage);
+
+        assertTrue(jmsMessage instanceof ObjectMessage);
+        assertNull(((ObjectMessage)jmsMessage).getObject());
+    }
+
+    @Test
+    public void createJmsMessageStringPayload() throws MessageProcessingException, JMSException
+    {
+        final String payload = "ESB Message payload";
+        final Message esbMessage = createMessage(payload);
+
+        javax.jms.Message jmsMessage = callFactory(esbMessage);
+
+        assertTrue(jmsMessage instanceof TextMessage);
+        assertEquals(payload, ((TextMessage)jmsMessage).getText());
+    }
+
+    @Test
+    public void composeJmsMessageByteArrayPayload() throws MessageProcessingException, JMSException
+    {
+        final String payload = "ESB Message payload";
+        final Message esbMessage = createMessage(payload.getBytes());
+
+        javax.jms.Message jmsMessage = callFactory(esbMessage);
+
+        assertTrue(jmsMessage instanceof BytesMessage);
+    }
+
+    @Test
+    public void composeJmsMessageMapPayload() throws MessageProcessingException, JMSException
+    {
+        final Map<String, Object> payload = new HashMap<String, Object>();
+        payload.put("key1", "value1");
+        payload.put("key2", "value2");
+
+        final Message esbMessage = createMessage(payload);
+
+        javax.jms.Message jmsMessage = callFactory(esbMessage);
+
+        assertTrue(jmsMessage instanceof MapMessage);
+        final MapMessage mapMessage = (MapMessage)jmsMessage;
+        assertEquals(payload.get("key1"), mapMessage.getObject("key1"));
+        assertEquals(payload.get("key2"), mapMessage.getObject("key2"));
+    }
+
+    @Test
+    public void addEsbPropertiesCorrelationId() throws MessageProcessingException, JMSException
+    {
+        final String correlationId = "correlationId-1234";
+        Map<String, String> invocationParamters = createInvocationParamters(JmsConstants.CORRELATION_ID, correlationId);
+
+        MockTextMessage textMessage = new MockTextMessage();
+
+        factory.addInvocationParameters(invocationParamters, textMessage);
+
+
+        assertEquals(correlationId, textMessage.getJMSCorrelationID());
+    }
+
+    @Test
+    public void addEsbPropertiesRedelivered() throws MessageProcessingException, JMSException
+    {
+        final Boolean redelivered = true;
+        Map<String, String> invocationParamters = createInvocationParamters(JmsConstants.REDELIVERED, redelivered.toString());
+        MockTextMessage textMessage = new MockTextMessage();
+
+        factory.addInvocationParameters(invocationParamters, textMessage);
+        assertEquals(redelivered, textMessage.getJMSRedelivered());
+    }
+
+    @Test
+    public void addEsbPropertiesMessageID() throws MessageProcessingException, JMSException
+    {
+        final String messageId = "1234-32-22";
+        Map<String, String> invocationParamters = createInvocationParamters(JmsConstants.MESSAGE_ID, messageId);
+
+        MockTextMessage textMessage = new MockTextMessage();
+
+        factory.addInvocationParameters(invocationParamters, textMessage);
+        assertEquals(messageId, textMessage.getJMSCorrelationID());
+    }
+
+    private Map<String,String> createInvocationParamters(final String key, final String value)
+    {
+        HashMap<String, String> invparams = new HashMap<String,String>();
+        invparams.put(key, value);
+        return invparams;
+    }
+
+    private javax.jms.Message callFactory(final Message esbMessage) throws MessageProcessingException
+    {
+        return factory.create(esbMessage, mockSession);
+    }
+
+    private Message createMessage(final Object payload)
+    {
+        final Message esbMessage = new Message();
+        esbMessage.setPayload(payload);
+        return esbMessage;
+    }
+
+    @Before
+    public void setup()
+    {
+        DestinationManager destinationManager = new DestinationManager();
+        MockConnection connection = new MockConnection(destinationManager, null);
+        mockSession = new MockSession(connection, true, 0);
+    }
+
+
+}

Copied: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/outbound/JmsOutboundRouterTest.java (from rev 24231, labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsOutboundRouterTest.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/outbound/JmsOutboundRouterTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/outbound/JmsOutboundRouterTest.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,144 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.outbound;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.esb.api.context.InvocationContext;
+import org.jboss.esb.api.exception.DeploymentException;
+import org.jboss.esb.api.routing.OutboundRouter;
+import org.jboss.esb.api.routing.RoutingException;
+import org.jboss.esb.api.service.ServiceName;
+import org.jboss.esb.deploy.DeploymentRuntime;
+import org.jboss.esb.deploy.DeploymentUtil;
+import org.jboss.esb.deploy.config.OutboundRouterConfig;
+import org.jboss.esb.jms.TestInboundRouter;
+import org.jboss.esb.jms.test.JmsTestBusProvider;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test for {@link JmsOutboundRouter}.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class JmsOutboundRouterTest
+{
+    private static JmsTestBusProvider jmsProvider;
+
+    @Test
+    public void route() throws DeploymentException, IOException, InterruptedException, RoutingException, JMSException, NamingException
+    {
+        final DeploymentRuntime runtime = getRuntime();
+        final JmsOutboundRouter router = (JmsOutboundRouter)getRouter(runtime);
+        InvocationContext.setContext(new InvocationContext());
+        assertNotNull(router);
+
+        try
+        {
+            runtime.deploy();
+            TimeUnit.SECONDS.sleep(3);
+
+            final String payload = "<message/>";
+            TestInboundRouter inrouter = (TestInboundRouter) DeploymentUtil.getInboundRouter("inrouter", runtime).getRouter();
+            inrouter.sendMessage(payload);
+            javax.jms.Message jmsMessage = recieveMessage(router.getDestination(), router.getJmsProperties(), 5000L);
+
+            assertTrue(jmsMessage instanceof TextMessage);
+            assertEquals(payload, ((TextMessage)jmsMessage).getText());
+        }
+        finally
+        {
+            runtime.undeploy();
+        }
+    }
+
+    @BeforeClass
+    public static void startProvider() throws Exception
+    {
+        jmsProvider = new JmsTestBusProvider();
+        jmsProvider.start();
+    }
+
+    @AfterClass
+    public static void stopProvider() throws Exception
+    {
+        jmsProvider.stop();
+    }
+
+    private DeploymentRuntime getRuntime() throws DeploymentException, IOException
+    {
+        return DeploymentUtil.createRuntime(getClass().getResourceAsStream("jms-outbound-router.xml"));
+    }
+
+    private OutboundRouter getRouter(final DeploymentRuntime runtime) throws DeploymentException
+    {
+        final OutboundRouterConfig routerConfig = DeploymentUtil.getOutboundRouter(new ServiceName("serviceCat", "serviceName"), "outrouter", runtime);
+        return routerConfig.getRouter();
+    }
+
+    private javax.jms.Message recieveMessage(String destinationName, Properties jndiProperties,  long timeout) throws JMSException, NamingException
+    {
+        QueueConnection connection = null;
+        QueueSession session = null;
+        try
+        {
+            final InitialContext ctx = new InitialContext(jndiProperties);
+            QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
+            connection = factory.createQueueConnection();
+            connection.start();
+            session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+            MessageConsumer consumer = session.createConsumer((Destination)ctx.lookup(destinationName));
+            return consumer.receive(timeout);
+        }
+        finally
+        {
+            if (session != null)
+            {
+                session.close();
+            }
+            if (connection != null)
+            {
+                connection.close();
+            }
+        }
+    }
+
+}


Property changes on: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/outbound/JmsOutboundRouterTest.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/outbound/TestOutboundProcessor.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/outbound/TestOutboundProcessor.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/outbound/TestOutboundProcessor.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.outbound;
+
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.jboss.esb.api.message.MessageProcessor;
+
+/**
+ * Just a simple processor for testing purpose.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class TestOutboundProcessor implements MessageProcessor
+{
+    public Message process(final Message message) throws MessageProcessingException
+    {
+        return message;
+    }
+
+}

Copied: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/outbound/jms-outbound-router.xml (from rev 24231, labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-outbound-router.xml)
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/outbound/jms-outbound-router.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/outbound/jms-outbound-router.xml	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,19 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+
+    <services>
+        <service serviceCategory="serviceCat" serviceName="serviceName" serviceDescription="TestService" class="org.jboss.esb.jms.MyTestService">
+            <inRouter name="inrouter" class="org.jboss.esb.jms.TestInboundRouter"/>
+            
+            <outRouter name="outrouter" class="org.jboss.esb.jms.outbound.JmsOutboundRouter">
+                <processors>
+                    <processor class="org.jboss.esb.jms.outbound.TestOutboundProcessor"/>
+                </processors>
+                <property name="java.naming.provider.url">tcp://localhost:61717</property>
+                <property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property>
+                <property name="jmsDestination">jbossesb.TestOutQueue</property>
+                <property name="queue.jbossesb.TestOutQueue">jbossesb.TestOutQueue</property>
+            </outRouter>
+        </service>
+    </services> 
+    
+</jbossesb>
\ No newline at end of file


Property changes on: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/outbound/jms-outbound-router.xml
___________________________________________________________________
Name: svn:mergeinfo
   + 

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/BytesMessageExtractorTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/BytesMessageExtractorTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/BytesMessageExtractorTest.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.processors;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.junit.Test;
+
+import com.mockrunner.mock.jms.MockBytesMessage;
+import com.mockrunner.mock.jms.MockTextMessage;
+
+
+/**
+ * Test for {@link BytesMessageExtractor}.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class BytesMessageExtractorTest
+{
+    private BytesMessageExtractor extractor = new BytesMessageExtractor();
+
+    @Test (expected = IllegalArgumentException.class )
+    public void processNullMessage() throws MessageProcessingException
+    {
+        extractor.process(null);
+    }
+
+    @Test
+    public void process() throws MessageProcessingException, JMSException
+    {
+        final String payload = "some text";
+        final byte[] bytes = payload.getBytes();
+        final BytesMessage bytesMessage = createBytesMessage(bytes);
+
+        final Message message = new Message();
+        message.setPayload(bytesMessage);
+
+        Message processedMessage = extractor.process(message);
+
+        assertNotNull(processedMessage);
+        assertNotNull(processedMessage.getPayload());
+        assertTrue(processedMessage.getPayload() instanceof Object);
+        assertEquals(payload, new String((byte[])processedMessage.getPayload()));
+    }
+
+    @Test
+    public void processEmptyBytesMessage() throws MessageProcessingException, JMSException
+    {
+        final BytesMessage bytesMessage = new MockBytesMessage();
+        final Message message = new Message();
+        message.setPayload(bytesMessage);
+
+        Message processedMessage = extractor.process(message);
+
+        assertNotNull(processedMessage);
+        assertNull(processedMessage.getPayload());
+    }
+
+    @Test
+    public void processTextMessage() throws MessageProcessingException, JMSException
+    {
+        final MockTextMessage textMessage = new MockTextMessage();
+        final Message message = new Message();
+        message.setPayload(textMessage);
+
+        Message processedMessage = extractor.process(message);
+
+        assertNotNull(processedMessage.getPayload());
+        assertEquals(textMessage, processedMessage.getPayload());
+    }
+
+    private BytesMessage createBytesMessage(final byte[] bytes) throws JMSException
+    {
+        final MockBytesMessage message = new MockBytesMessage();
+        message.writeObject(bytes);
+        return message;
+    }
+
+}

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/MapMessageExtractorTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/MapMessageExtractorTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/MapMessageExtractorTest.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.processors;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.junit.Test;
+
+import com.mockrunner.mock.jms.MockMapMessage;
+import com.mockrunner.mock.jms.MockTextMessage;
+
+
+/**
+ * Test for {@link MapMessageExtractor}.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class MapMessageExtractorTest
+{
+    private MapMessageExtractor extractor = new MapMessageExtractor();
+
+    @Test (expected = IllegalArgumentException.class )
+    public void processNullMessage() throws MessageProcessingException
+    {
+        extractor.process(null);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void process() throws MessageProcessingException, JMSException
+    {
+        final MapMessage mapMessage = new MockMapMessage();
+        mapMessage.setObject("key1", "value1");
+        mapMessage.setObject("key2", "value2");
+
+        final Message message = new Message();
+        message.setPayload(mapMessage);
+
+        Message processedMessage = extractor.process(message);
+
+        assertNotNull(processedMessage);
+        assertNotNull(processedMessage.getPayload());
+        assertTrue(processedMessage.getPayload() instanceof Map);
+        Map map = (Map) processedMessage.getPayload();
+
+        assertTrue(map.containsKey("key1"));
+        assertEquals("value1", map.get("key1"));
+
+        assertTrue(map.containsKey("key2"));
+        assertEquals("value2", map.get("key2"));
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void processEmptyBytesMessage() throws MessageProcessingException, JMSException
+    {
+        final MapMessage mapMessage = new MockMapMessage();
+        final Message message = new Message();
+        message.setPayload(mapMessage);
+
+        Message processedMessage = extractor.process(message);
+
+        assertNotNull(processedMessage);
+        assertTrue(processedMessage.getPayload() instanceof Map);
+        Map map = (Map) processedMessage.getPayload();
+        assertEquals(0, map.size());
+    }
+
+    @Test
+    public void processTextMessage() throws MessageProcessingException, JMSException
+    {
+        final MockTextMessage textMessage = new MockTextMessage();
+        final Message message = new Message();
+        message.setPayload(textMessage);
+
+        Message processedMessage = extractor.process(message);
+
+        assertNotNull(processedMessage.getPayload());
+        assertEquals(textMessage, processedMessage.getPayload());
+    }
+}

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/ObjectMessageExtractorTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/ObjectMessageExtractorTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/ObjectMessageExtractorTest.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.processors;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.Serializable;
+
+import javax.jms.JMSException;
+import javax.jms.ObjectMessage;
+
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.junit.Test;
+
+import com.mockrunner.mock.jms.MockObjectMessage;
+import com.mockrunner.mock.jms.MockTextMessage;
+
+
+/**
+ * Test for {@link ObjectMessageExtractor}.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class ObjectMessageExtractorTest
+{
+    private ObjectMessageExtractor extractor = new ObjectMessageExtractor();
+
+    @Test (expected = IllegalArgumentException.class )
+    public void processNullMessage() throws MessageProcessingException
+    {
+        extractor.process(null);
+    }
+
+    @Test
+    public void process() throws MessageProcessingException, JMSException
+    {
+        final Object object = "some text";
+        final ObjectMessage objectMessage = createObjectMessage(object);
+
+        final Message message = new Message();
+        message.setPayload(objectMessage);
+
+        Message processedMessage = extractor.process(message);
+
+        assertNotNull(processedMessage);
+        assertNotNull(processedMessage.getPayload());
+        assertTrue(processedMessage.getPayload() instanceof Object);
+        assertEquals(object, processedMessage.getPayload());
+    }
+
+    @Test
+    public void processEmptyObjectMessage() throws MessageProcessingException, JMSException
+    {
+        final ObjectMessage objectMessage = new MockObjectMessage();
+        final Message message = new Message();
+        message.setPayload(objectMessage);
+
+        Message processedMessage = extractor.process(message);
+
+        assertNotNull(processedMessage);
+        assertNull(processedMessage.getPayload());
+    }
+
+    @Test
+    public void processTextMessage() throws MessageProcessingException, JMSException
+    {
+        final MockTextMessage textMessage = new MockTextMessage();
+        final Message message = new Message();
+        message.setPayload(textMessage);
+
+        Message processedMessage = extractor.process(message);
+
+        assertNotNull(processedMessage.getPayload());
+        assertEquals(textMessage, processedMessage.getPayload());
+    }
+
+    private ObjectMessage createObjectMessage(final Object object) throws JMSException
+    {
+        final MockObjectMessage message = new MockObjectMessage();
+        message.setObject((Serializable) object);
+        return message;
+    }
+
+}

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/StreamMessageExtractorTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/StreamMessageExtractorTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/StreamMessageExtractorTest.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.processors;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.jms.JMSException;
+
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.jboss.esb.jms.StreamMessageInputStream;
+import org.junit.Test;
+
+import com.mockrunner.mock.jms.MockStreamMessage;
+import com.mockrunner.mock.jms.MockTextMessage;
+
+
+/**
+ * Test for {@link StreamMessageExtractor}.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class StreamMessageExtractorTest
+{
+    private StreamMessageExtractor extractor = new StreamMessageExtractor();
+
+    @Test (expected = IllegalArgumentException.class )
+    public void processNullMessage() throws MessageProcessingException
+    {
+        extractor.process(null);
+    }
+
+    @Test
+    public void process() throws MessageProcessingException, JMSException, IOException
+    {
+        final String expected = "testing text message content";
+        final byte[] content = expected.getBytes();
+        final MockStreamMessage streamMessage = new MockStreamMessage();
+        streamMessage.writeObject(content);
+        final Message message = new Message();
+        message.setPayload(streamMessage);
+
+        Message processedMessage = extractor.process(message);
+
+        assertNotNull(processedMessage.getPayload());
+        assertTrue(processedMessage.getPayload() instanceof InputStream);
+
+        final StreamMessageInputStream adapter = (StreamMessageInputStream)processedMessage.getPayload();
+        adapter.reset();
+        final Object readObject = adapter.getStreamMessage().readObject();
+        assertTrue(readObject instanceof byte[]);
+        assertEquals(expected, new String((byte[])readObject));
+    }
+
+    @Test
+    public void processEmptyBytesMessage() throws MessageProcessingException, JMSException
+    {
+        final MockStreamMessage streamMessage = new MockStreamMessage();
+        final Message message = new Message();
+        message.setPayload(streamMessage);
+
+        Message processedMessage = extractor.process(message);
+
+        assertTrue(processedMessage.getPayload() instanceof InputStream);
+    }
+
+    @Test
+    public void processTextMessage() throws MessageProcessingException, JMSException
+    {
+        final MockTextMessage textMessage = new MockTextMessage();
+        final Message message = new Message();
+        message.setPayload(textMessage);
+
+        Message processedMessage = extractor.process(message);
+
+        assertEquals(textMessage, processedMessage.getPayload());
+    }
+
+}

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/TextMessageExtractorTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/TextMessageExtractorTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/processors/TextMessageExtractorTest.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.processors;
+
+import static org.junit.Assert.*;
+
+import javax.jms.JMSException;
+import javax.jms.TextMessage;
+
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.junit.Test;
+
+import com.mockrunner.mock.jms.MockObjectMessage;
+import com.mockrunner.mock.jms.MockTextMessage;
+
+
+/**
+ * Test for {@link TextMessageExtractor}.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class TextMessageExtractorTest
+{
+    private TextMessageExtractor extractor = new TextMessageExtractor();
+
+    @Test (expected = IllegalArgumentException.class )
+    public void processNullMessage() throws MessageProcessingException
+    {
+        extractor.process(null);
+    }
+
+    @Test
+    public void process() throws MessageProcessingException, JMSException
+    {
+        final Message message = new Message();
+        final String text = "some text";
+        final TextMessage textMessage = createTextMessage(text);
+        message.setPayload(textMessage);
+
+        Message processedMessage = extractor.process(message);
+
+        assertNotNull(processedMessage);
+        assertNotNull(processedMessage.getPayload());
+        assertTrue(processedMessage.getPayload() instanceof String);
+        assertEquals(text, processedMessage.getPayload());
+    }
+
+    @Test
+    public void processEmptyTextMessage() throws MessageProcessingException, JMSException
+    {
+        final Message message = new Message();
+        final MockTextMessage textMessage = new MockTextMessage();
+        message.setPayload(textMessage);
+
+        Message processedMessage = extractor.process(message);
+
+        assertNotNull(processedMessage);
+        assertNull(processedMessage.getPayload());
+    }
+
+    @Test
+    public void processObjectMessage() throws MessageProcessingException, JMSException
+    {
+        final Message message = new Message();
+        final MockObjectMessage objectMessage = new MockObjectMessage();
+        message.setPayload(objectMessage);
+
+        Message processedMessage = extractor.process(message);
+
+        assertNotNull(processedMessage.getPayload());
+        assertEquals(objectMessage, processedMessage.getPayload());
+    }
+
+    private TextMessage createTextMessage(final String text) throws JMSException
+    {
+        final MockTextMessage textMessage = new MockTextMessage();
+        textMessage.setText(text);
+        return textMessage;
+    }
+
+}

Added: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/util/PropertiesExtractorTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/util/PropertiesExtractorTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/util/PropertiesExtractorTest.java	2008-12-05 10:10:16 UTC (rev 24246)
@@ -0,0 +1,182 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, 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.esb.jms.util;
+
+import static org.jboss.esb.jms.util.JmsConstants.CORRELATION_ID;
+import static org.jboss.esb.jms.util.JmsConstants.DELIVERY_MODE;
+import static org.jboss.esb.jms.util.JmsConstants.EXPIRATION;
+import static org.jboss.esb.jms.util.JmsConstants.MESSAGE_ID;
+import static org.jboss.esb.jms.util.JmsConstants.PRIORITY;
+import static org.jboss.esb.jms.util.JmsConstants.REDELIVERED;
+import static org.jboss.esb.jms.util.JmsConstants.REPLY_TO;
+import static org.jboss.esb.jms.util.JmsConstants.TIMESTAMP;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.junit.Test;
+import com.mockrunner.mock.jms.MockQueue;
+import com.mockrunner.mock.jms.MockTextMessage;
+
+
+/**
+ * Test class for {@link PropertiesExtractor}
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ * @since 5.0
+ */
+public class PropertiesExtractorTest
+{
+    @Test
+    public void extractAll() throws MessageProcessingException, JMSException
+    {
+        final MockTextMessage textMessage = new MockTextMessage();
+        textMessage.setObjectProperty("testKey", "testValue");
+        textMessage.setJMSCorrelationID("1234");
+
+        final Map<String,String> jmsProperties = PropertiesExtractor.extractAll(textMessage);
+        assertTrue("User property should have been set", jmsProperties.containsKey("testKey"));
+        assertEquals("testValue", jmsProperties.get("testKey"));
+    }
+
+    @Test
+    public void extractPropertiesJMSCorrelationID() throws JMSException, MessageProcessingException
+    {
+        final MockTextMessage textMessage = new MockTextMessage();
+        textMessage.setJMSCorrelationID("1234");
+
+        final Map<String,String> jmsProperties = PropertiesExtractor.extractAll(textMessage);
+        assertTrue("CorrelationId property should have been set", jmsProperties.containsKey(CORRELATION_ID));
+        assertEquals("1234", jmsProperties.get(CORRELATION_ID));
+    }
+
+    @Test
+    public void extractPropertiesJMSExpiration() throws JMSException, MessageProcessingException
+    {
+        final MockTextMessage textMessage = new MockTextMessage();
+        textMessage.setJMSExpiration(1000l);
+
+        final Map<String,String> jmsProperties = PropertiesExtractor.extractAll(textMessage);
+        assertTrue("Expiration property should have been set", jmsProperties.containsKey(EXPIRATION));
+        assertEquals(Long.toString(1000l), jmsProperties.get(EXPIRATION));
+    }
+
+    @Test
+    public void extractPropertiesJMSMessageID() throws JMSException, MessageProcessingException
+    {
+        final MockTextMessage textMessage = new MockTextMessage();
+        final String messageId = "jmsMessageID1133";
+        textMessage.setJMSMessageID(messageId);
+
+        final Map<String,String> jmsProperties = PropertiesExtractor.extractAll(textMessage);
+        assertTrue("MessageId property should have been set", jmsProperties.containsKey(MESSAGE_ID));
+        assertEquals(messageId, jmsProperties.get(MESSAGE_ID));
+    }
+
+    @Test
+    public void extractPropertiesJMSRedelivered() throws JMSException, MessageProcessingException
+    {
+        final MockTextMessage textMessage = new MockTextMessage();
+        final boolean redelivered = true;
+        textMessage.setJMSRedelivered(redelivered);
+
+        final Map<String,String> jmsProperties = PropertiesExtractor.extractAll(textMessage);
+        assertTrue("Redelivered property should have been set", jmsProperties.containsKey(REDELIVERED));
+        assertEquals(Boolean.toString(redelivered), jmsProperties.get(REDELIVERED));
+    }
+
+    @Test
+    public void extractPropertiesJMSTimestamp() throws JMSException, MessageProcessingException
+    {
+        final MockTextMessage textMessage = new MockTextMessage();
+        final long timestamp = System.currentTimeMillis();
+        textMessage.setJMSTimestamp(timestamp);
+
+        final Map<String,String> jmsProperties = PropertiesExtractor.extractAll(textMessage);
+        assertTrue("Timestamp property should have been set", jmsProperties.containsKey(TIMESTAMP));
+        assertEquals(Long.toString(timestamp), jmsProperties.get(TIMESTAMP));
+    }
+
+    @Test
+    public void extractPropertiesJMSReplyTo() throws JMSException, MessageProcessingException
+    {
+        final MockTextMessage textMessage = new MockTextMessage();
+        final MockQueue destination = new MockQueue("testing");
+        textMessage.setJMSReplyTo(destination);
+
+        final Map<String,String> jmsProperties = PropertiesExtractor.extractAll(textMessage);
+        assertTrue("ReplyTo property should have been set", jmsProperties.containsKey(REPLY_TO));
+        assertEquals(destination.getQueueName(), jmsProperties.get(REPLY_TO));
+    }
+
+    @Test
+    public void extractPropertiesJMSPriority() throws JMSException, MessageProcessingException
+    {
+        final MockTextMessage textMessage = new MockTextMessage();
+        final int priority = 0;
+        textMessage.setJMSPriority(priority);
+
+        final Map<String,String> jmsProperties = PropertiesExtractor.extractAll(textMessage);
+        assertTrue("Priority property should have been set", jmsProperties.containsKey(PRIORITY));
+        assertEquals(Integer.toString(priority), jmsProperties.get(PRIORITY));
+    }
+
+    @Test
+    public void extractPropertiesJMSPriorityNegative() throws JMSException, MessageProcessingException
+    {
+        final MockTextMessage textMessage = new MockTextMessage();
+        final int priority = -1;
+        textMessage.setJMSPriority(priority);
+
+        final Map<String,String> jmsProperties = PropertiesExtractor.extractAll(textMessage);
+        assertFalse("Priority property should not have been set", jmsProperties.containsKey(PRIORITY));
+    }
+
+    @Test
+    public void extractPropertiesJMSPriorityTooLarge() throws JMSException, MessageProcessingException
+    {
+        final MockTextMessage textMessage = new MockTextMessage();
+        final int priority = 10;
+        textMessage.setJMSPriority(priority);
+
+        final Map<String,String> jmsProperties = PropertiesExtractor.extractAll(textMessage);
+        assertFalse("Priority property should not have been set", jmsProperties.containsKey(PRIORITY));
+    }
+
+    @Test
+    public void extractPropertiesJMSDeliveryMode() throws JMSException, MessageProcessingException
+    {
+        final MockTextMessage textMessage = new MockTextMessage();
+        textMessage.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+        Map<String,String> jmsProperties = PropertiesExtractor.extractAll(textMessage);
+        assertEquals(Integer.toString(DeliveryMode.NON_PERSISTENT), jmsProperties.get(DELIVERY_MODE));
+
+        textMessage.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
+        jmsProperties = PropertiesExtractor.extractAll(textMessage);
+        assertEquals(Integer.toString(DeliveryMode.PERSISTENT), jmsProperties.get(DELIVERY_MODE));
+    }
+
+}




More information about the jboss-svn-commits mailing list