[jboss-svn-commits] JBL Code SVN: r15875 - in labs/jbossesb/trunk: product/rosetta/src/org/jboss/internal/soa/esb/couriers and 12 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Oct 17 06:59:50 EDT 2007


Author: kevin.conner at jboss.com
Date: 2007-10-17 06:59:50 -0400 (Wed, 17 Oct 2007)
New Revision: 15875

Added:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/JmsComposer.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/BaseJcaInflow.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/InflowMessageProcessor.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/InflowMessageProcessorAdapter.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaConstants.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaGatewayException.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaGatewayListener.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaJMSInflowMessageProcessorAdapter.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaJMSMessageAwareComposer.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaMessageAwareComposer.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaMessageAwareListener.java
   labs/jbossesb/trunk/qa/junit/resources/server/jbossesb-properties.xml
   labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/
   labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/META-INF/
   labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/META-INF/deployment.xml
   labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/META-INF/jboss-esb.xml
   labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/esb-jbm-service.xml
   labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/esb-jbmq-service.xml
   labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/test-tx-service.xml
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/MyRedeliveryAction.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/Redelivery.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/RedeliveryMBean.java
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jcaTx/
   labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jcaTx/JcaTXUnitTest.java
Modified:
   labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/JmsListenerMapper.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/PackageJmsMessageContents.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaInflowGateway.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/GeneratorUnitTest.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_01_gateways.xml
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_02.xml
   labs/jbossesb/trunk/qa/junit/build.xml
Log:
Commit JCA/JMS integration: JBESB-439

Modified: labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd
===================================================================
--- labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd	2007-10-17 10:57:55 UTC (rev 15874)
+++ labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd	2007-10-17 10:59:50 UTC (rev 15875)
@@ -446,39 +446,75 @@
             </xsd:complexContent>
         </xsd:complexType>
     </xsd:element>
-    <xsd:element name="jms-provider" substitutionGroup="jesb:provider">
+    <xsd:complexType name="jms-provider-type">
         <xsd:annotation>
             <xsd:documentation xml:lang="en">A specific instance of a provider, providing JMS.</xsd:documentation>
         </xsd:annotation>
+        <xsd:complexContent>
+            <xsd:extension base="jesb:bus-provider">
+                <xsd:attribute name="connection-factory" type="xsd:string" use="required">
+                    <xsd:annotation>
+                        <xsd:documentation xml:lang="en">The connection-factory used to lookup queues/topics in a
+                            naming directory (JNDI)
+                        </xsd:documentation>
+                    </xsd:annotation>
+                </xsd:attribute>
+                <xsd:attribute name="jndi-context-factory" type="xsd:string">
+                    <xsd:annotation>
+                        <xsd:documentation xml:lang="en">The context factory class the JBossESB will use to do
+                            naming lookups.
+                        </xsd:documentation>
+                    </xsd:annotation>
+                </xsd:attribute>
+                <xsd:attribute name="jndi-pkg-prefix" type="xsd:string">
+                    <xsd:annotation>
+                        <xsd:documentation xml:lang="en">The pkg-prefix which will be used to do naming lookups. It
+                            is left empty by default.
+                        </xsd:documentation>
+                    </xsd:annotation>
+                </xsd:attribute>
+                <xsd:attribute name="jndi-URL" type="xsd:anyURI">
+                    <xsd:annotation>
+                        <xsd:documentation xml:lang="en">The URL used to do naming lookups.</xsd:documentation>
+                    </xsd:annotation>
+                </xsd:attribute>
+            </xsd:extension>
+        </xsd:complexContent>
+    </xsd:complexType>
+    <xsd:element name="jms-provider" substitutionGroup="jesb:provider" type="jesb:jms-provider-type"/>
+    
+    <xsd:element name="jms-jca-provider" substitutionGroup="jesb:provider">
+        <xsd:annotation>
+            <xsd:documentation xml:lang="en">A specific instance of a provider, providing JMS through JCA inflow.</xsd:documentation>
+        </xsd:annotation>
         <xsd:complexType>
             <xsd:complexContent>
-                <xsd:extension base="jesb:bus-provider">
-                    <xsd:attribute name="connection-factory" type="xsd:string" use="required">
+                <xsd:extension base="jesb:jms-provider-type">
+                    <xsd:attribute name="adapter" type="xsd:string">
                         <xsd:annotation>
-                            <xsd:documentation xml:lang="en">The connection-factory used to lookup queues/topics in a
-                                naming directory (JNDI)
-                            </xsd:documentation>
+                            <xsd:documentation xml:lang="en">The artifact containing the resource adapter.</xsd:documentation>
                         </xsd:annotation>
                     </xsd:attribute>
-                    <xsd:attribute name="jndi-context-factory" type="xsd:string">
+                    <xsd:attribute name="endpointClass" type="xsd:string">
                         <xsd:annotation>
-                            <xsd:documentation xml:lang="en">The context factory class the JBossESB will use to do
-                                naming lookups.
-                            </xsd:documentation>
+                            <xsd:documentation xml:lang="en">The class name of the JCA endpoint.</xsd:documentation>
                         </xsd:annotation>
                     </xsd:attribute>
-                    <xsd:attribute name="jndi-pkg-prefix" type="xsd:string">
+                    <xsd:attribute name="messagingType" type="xsd:string">
                         <xsd:annotation>
-                            <xsd:documentation xml:lang="en">The pkg-prefix which will be used to do naming lookups. It
-                                is left empty by default.
-                            </xsd:documentation>
+                            <xsd:documentation xml:lang="en">The class name of the messaging specific interface.</xsd:documentation>
                         </xsd:annotation>
                     </xsd:attribute>
-                    <xsd:attribute name="jndi-URL" type="xsd:anyURI">
+                    <xsd:attribute name="jcaBridge" type="xsd:string">
                         <xsd:annotation>
-                            <xsd:documentation xml:lang="en">The URL used to do naming lookups.</xsd:documentation>
+                            <xsd:documentation xml:lang="en">The class name of the JCA Bridge.</xsd:documentation>
                         </xsd:annotation>
                     </xsd:attribute>
+                    <xsd:attribute name="transacted" type="xsd:boolean">
+                        <xsd:annotation>
+                            <xsd:documentation xml:lang="en">The transacted flag.</xsd:documentation>
+                        </xsd:annotation>
+                    </xsd:attribute>
                 </xsd:extension>
             </xsd:complexContent>
         </xsd:complexType>

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java	2007-10-17 10:57:55 UTC (rev 15874)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -23,6 +23,7 @@
 package org.jboss.internal.soa.esb.couriers;
 
 import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.couriers.helpers.JmsComposer;
 import org.jboss.internal.soa.esb.rosetta.pooling.ConnectionException;
 import org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPool;
 import org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPoolContainer;
@@ -35,20 +36,16 @@
 import org.jboss.soa.esb.helpers.NamingContext;
 import org.jboss.soa.esb.listeners.gateway.DefaultESBPropertiesSetter;
 import org.jboss.soa.esb.listeners.gateway.ESBPropertiesSetter;
-import org.jboss.soa.esb.listeners.message.errors.Factory;
 import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.util.Type;
 import org.jboss.soa.esb.notification.jms.DefaultJMSPropertiesSetter;
 import org.jboss.soa.esb.notification.jms.JMSPropertiesSetter;
 import org.jboss.soa.esb.util.Util;
-import org.xml.sax.SAXException;
 
 import javax.jms.*;
 import javax.naming.Context;
 import javax.naming.NamingException;
 import javax.xml.parsers.ParserConfigurationException;
 import java.io.IOException;
-import java.io.Serializable;
 import java.net.URISyntaxException;
 import java.util.List;
 import java.util.Properties;
@@ -379,52 +376,7 @@
     public Message pickup(long millis) throws CourierException, CourierTimeoutException {
         javax.jms.Message jmsMessage = pickupPayload(millis);
 
-        if(jmsMessage == null) {
-            return null;
-        }
-
-        if (!(jmsMessage instanceof ObjectMessage)) {
-            _logger.error("Unsupported JMS message type: " + jmsMessage.getClass().getName());
-            return null;
-        }
-        try {
-            Serializable obj = (Serializable) ((ObjectMessage) jmsMessage)
-                    .getObject();
-
-            Message msg = Util.deserialize(obj);
-            setPropertiesFromJMSMessage(jmsMessage, msg);
-
-            /*
-                * If this is fault message, then throw an exception with the contents. With the
-                * exception of user-defined exceptions, faults will have nothing in the body, properties etc.
-                */
-
-            if (Type.isFaultMessage(msg))
-                Factory.createExceptionFromFault(msg);
-
-            return msg;
-        }
-        catch (JMSException e1) {
-            _logger.error("Failed to read Serialized Object from JMS message.",
-                    e1);
-            return null;
-        }
-        catch (ClassCastException e2) {
-            _logger
-                    .error(
-                            "Object in JMS message is not a org.jboss.soa.esb.message.Message",
-                            e2);
-        }
-        catch (IOException e3) {
-            _logger.error("Object in JMS message is not a Serializeable", e3);
-        }
-        catch (ParserConfigurationException e4) {
-            _logger.error("Object in JMS message has invalid XML", e4);
-        }
-        catch (SAXException e5) {
-            _logger.error("Object in JMS message has invalid XML", e5);
-        }
-        return null;
+        return JmsComposer.compose(jmsMessage, esbPropertiesStrategy) ;
     }
 
     public javax.jms.Message pickupPayload(long millis) throws CourierException, CourierTimeoutException {

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/JmsComposer.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/JmsComposer.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/JmsComposer.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * 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.internal.soa.esb.couriers.helpers;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import javax.jms.JMSException;
+import javax.jms.ObjectMessage;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.couriers.FaultMessageException;
+import org.jboss.soa.esb.listeners.gateway.ESBPropertiesSetter;
+import org.jboss.soa.esb.listeners.message.errors.Factory;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.util.Type;
+import org.jboss.soa.esb.util.Util;
+import org.xml.sax.SAXException;
+
+public class JmsComposer
+{
+    /**
+     * The logger for this class.
+     */
+    private static final Logger LOGGER = Logger.getLogger(JmsComposer.class) ;
+    
+    /**
+     * Compose a message for the ESB.
+     * @param incomingMessage The incoming JMS message.
+     * @param propertiesSetter The properties setter.
+     * @return The ESB message or null if not a valid ESB message.
+     * @throws FaultMessageException if the message is a fault.
+     */
+    public static Message compose(final Object incomingMessage, final ESBPropertiesSetter propertiesSetter)
+        throws FaultMessageException
+    {
+        if(incomingMessage == null)
+        {
+            return null ;
+        }
+
+        if (!(incomingMessage instanceof ObjectMessage))
+        {
+            LOGGER.error("Unsupported JMS message type: " + incomingMessage.getClass().getName()) ;
+            return null ;
+        }
+        try
+        {
+            final ObjectMessage jmsMessage = (ObjectMessage)incomingMessage ;
+            
+            final Serializable obj = (Serializable)jmsMessage.getObject() ;
+
+            final Message composedMessage = Util.deserialize(obj) ;
+            propertiesSetter.setPropertiesFromJMSMessage(jmsMessage, composedMessage) ;
+
+            /*
+                * If this is fault message, then throw an exception with the contents. With the
+                * exception of user-defined exceptions, faults will have nothing in the body, properties etc.
+                */
+
+            if (Type.isFaultMessage(composedMessage))
+                Factory.createExceptionFromFault(composedMessage) ;
+
+            return composedMessage ;
+        }
+        catch (final JMSException jmse)
+        {
+            LOGGER.error("Failed to read Serialized Object from JMS message.", jmse) ;
+            return null ;
+        }
+        catch (final ClassCastException cce)
+        {
+            LOGGER.error("Object in JMS message is not a org.jboss.soa.esb.message.Message", cce) ;
+        }
+        catch (final IOException ioe)
+        {
+            LOGGER.error("Object in JMS message is not a Serializeable", ioe);
+        }
+        catch (final ParserConfigurationException pce)
+        {
+            LOGGER.error("Object in JMS message has invalid XML", pce);
+        }
+        catch (final SAXException saxe)
+        {
+            LOGGER.error("Object in JMS message has invalid XML", saxe);
+        }
+        return null;
+    }
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/JmsComposer.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/JmsListenerMapper.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/JmsListenerMapper.java	2007-10-17 10:57:55 UTC (rev 15874)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/JmsListenerMapper.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -21,21 +21,27 @@
 
 package org.jboss.soa.esb.listeners.config.mappers;
 
-import java.math.BigInteger;
+import javax.jms.Queue;
+import javax.jms.Topic;
 
-import javax.jms.Message;
-
-import org.jboss.internal.soa.esb.couriers.JmsCourier;
 import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.addressing.eprs.JMSEpr;
 import org.jboss.soa.esb.dom.YADOMUtil;
 import org.jboss.soa.esb.listeners.ListenerTagNames;
 import org.jboss.soa.esb.listeners.config.Generator.XMLBeansModel;
 import org.jboss.soa.esb.listeners.config.xbeanmodel.JmsBusDocument.JmsBus;
+import org.jboss.soa.esb.listeners.config.xbeanmodel.JmsJcaProviderDocument.JmsJcaProvider;
 import org.jboss.soa.esb.listeners.config.xbeanmodel.JmsListenerDocument.JmsListener;
 import org.jboss.soa.esb.listeners.config.xbeanmodel.JmsMessageFilterDocument.JmsMessageFilter;
-import org.jboss.soa.esb.listeners.config.xbeanmodel.JmsProviderDocument.JmsProvider;
+import org.jboss.soa.esb.listeners.config.xbeanmodel.JmsMessageFilterDocument.JmsMessageFilter.DestType;
+import org.jboss.soa.esb.listeners.config.xbeanmodel.JmsProviderType;
 import org.jboss.soa.esb.listeners.gateway.JmsGatewayListener;
+import org.jboss.soa.esb.listeners.gateway.PackageJmsMessageContents;
+import org.jboss.soa.esb.listeners.jca.JcaConstants;
+import org.jboss.soa.esb.listeners.jca.JcaGatewayListener;
+import org.jboss.soa.esb.listeners.jca.JcaJMSInflowMessageProcessorAdapter;
+import org.jboss.soa.esb.listeners.jca.JcaJMSMessageAwareComposer;
+import org.jboss.soa.esb.listeners.jca.JcaMessageAwareListener;
 import org.w3c.dom.Element;
 
 /**
@@ -57,7 +63,7 @@
 	public static Element map(Element root, JmsListener listener, XMLBeansModel model) throws ConfigurationException {
 		Element listenerNode = YADOMUtil.addElement(root, listener.getName());
 		JmsBus bus;
-		JmsProvider provider;
+		JmsProviderType provider;
 		
 		try {
 			bus = (JmsBus) model.getBus(listener.getBusidref());
@@ -65,7 +71,7 @@
 			throw new ConfigurationException("Invalid busid reference [" + listener.getBusidref() + "] on listener [" + listener.getName() + "].  A <jms-listener> must reference a <jms-bus>.");
 		}
 		try {
-			provider = (JmsProvider) model.getProvider(bus);
+			provider = (JmsProviderType) model.getProvider(bus);
 		} catch (ClassCastException e) {
 			throw new ConfigurationException("Invalid bus config [" + listener.getBusidref() + "].  Should be contained within a <jms-provider> instance.  Unexpected exception - this should have caused a validation error!");
 		}
@@ -78,18 +84,29 @@
 			}
 		}
 		
+		final Class<?> gatewayClass ;
+		if (provider instanceof JmsJcaProvider) {
+		    final JmsJcaProvider jmsJcaProvider = (JmsJcaProvider)provider ;
+                    mapJmsJcaAttributes(listener, listenerNode, jmsJcaProvider, messageFilter) ;
+		    gatewayClass = JcaGatewayListener.class ;
+		} else {
+		    gatewayClass = JmsGatewayListener.class ;
+		}
+		
 		// Map the standard listener attributes - common across all listener types...
 		MapperUtil.mapDefaultAttributes(listener, listenerNode, model);
 		// Map the <property> elements targeted at the listener - from the listener itself.
 		MapperUtil.mapProperties(listener.getPropertyList(), listenerNode);			
 		if(listener.getIsGateway()) {
 
-			listenerNode.setAttribute("gatewayClass", JmsGatewayListener.class.getName());
+			listenerNode.setAttribute("gatewayClass", gatewayClass.getName());
 			listenerNode.setAttribute(ListenerTagNames.IS_GATEWAY_TAG, Boolean.toString(listener.getIsGateway()));
 
 			// Map EPR related attributes onto the listener - from the bus and provider and listener.
 			// Note: This will change - the Gateways will also support the EPR element...
 			mapJmsEprProperties(listenerNode, provider, messageFilter);
+                        listenerNode.setAttribute(ListenerTagNames.PROTOCOL_TAG, JMSEpr.JMS_PROTOCOL);
+                        
 			MapperUtil.mapEPRProperties(listener, listenerNode, model);
 		} else {
 			Element eprNode = YADOMUtil.addElement(listenerNode, ListenerTagNames.EPR_TAG);
@@ -110,7 +127,7 @@
 		return listenerNode;
 	}
 
-	private static void mapJmsEprProperties(Element toElement, JmsProvider provider, JmsMessageFilter messageFilter) {
+    private static void mapJmsEprProperties(Element toElement, JmsProviderType provider, JmsMessageFilter messageFilter) {
 		if(messageFilter.getDestType() == JmsMessageFilter.DestType.QUEUE) {
             toElement.setAttribute(JMSEpr.DESTINATION_TYPE_TAG, JMSEpr.QUEUE_TYPE);
         } else {
@@ -124,4 +141,101 @@
 		toElement.setAttribute(JMSEpr.JNDI_URL_TAG, provider.getJndiURL());
 		toElement.setAttribute(JMSEpr.PERSISTENT_TAG, Boolean.toString( messageFilter.getPersistent()));
 	}
+
+    private static void mapJmsJcaAttributes(final JmsListener listener,
+        final Element listenerNode, final JmsJcaProvider jmsJcaProvider,
+        final JmsMessageFilter messageFilter)
+        throws ConfigurationException {
+        setAttribute(listenerNode, JcaConstants.ATTRIBUTE_ADAPTER,
+            jmsJcaProvider.getAdapter(), "jms-ra.rar") ;
+        setAttribute(listenerNode, JcaConstants.ATTRIBUTE_ENDPOINT_CLASS,
+            jmsJcaProvider.getEndpointClass(), JcaJMSInflowMessageProcessorAdapter.class.getName()) ;
+        setAttribute(listenerNode, JcaConstants.ATTRIBUTE_MESSAGING_TYPE,
+            jmsJcaProvider.getMessagingType()) ;
+        setAttribute(listenerNode, JcaConstants.ATTRIBUTE_JCA_BRIDGE,
+            jmsJcaProvider.getJcaBridge()) ;
+        final boolean transacted ;
+        if (jmsJcaProvider.isSetTransacted())
+        {
+            transacted = jmsJcaProvider.getTransacted() ;
+        }
+        else
+        {
+            transacted = true ;
+        }
+        
+        setAttribute(listenerNode, JcaConstants.ATTRIBUTE_TRANSACTED,
+            Boolean.toString(transacted)) ;
+        
+        if (listener.getIsGateway())
+        {
+            setAttribute(listenerNode, ListenerTagNames.GATEWAY_COMPOSER_CLASS_TAG,
+                PackageJmsMessageContents.class.getName()) ;
+            setAttribute(listenerNode, ListenerTagNames.GATEWAY_COMPOSER_METHOD_TAG,
+                "process") ;
+        }
+        else
+        {
+            setAttribute(listenerNode, ListenerTagNames.LISTENER_CLASS_TAG,
+                JcaMessageAwareListener.class.getName()) ;
+            setAttribute(listenerNode, JcaConstants.ATTRIBUTE_LISTENER_COMPOSER_CLASS,
+                JcaJMSMessageAwareComposer.class.getName()) ;
+        }
+        
+        final Element activationConfigElement = YADOMUtil.addElement(listenerNode, JcaConstants.ELEMENT_ACTIVATION_CONFIG) ;
+        addPropertyElement(activationConfigElement, "destination", messageFilter.getDestName()) ;
+        final int destType = messageFilter.getDestType().intValue() ;
+        if (destType == DestType.INT_QUEUE)
+        {
+            addPropertyElement(activationConfigElement, "destinationType", Queue.class.getName()) ;
+        }
+        else if (destType == DestType.INT_TOPIC)
+        {
+            addPropertyElement(activationConfigElement, "destinationType", Topic.class.getName()) ;
+        }
+        else
+        {
+            throw new ConfigurationException("Unknown destination type: " + messageFilter.getDestType()) ;
+        }
+        
+        if (messageFilter.getSelector() != null)
+        {
+            addPropertyElement(activationConfigElement, "messageSelector", messageFilter.getSelector()) ;
+        }
+        if (listener.getMaxThreads() > 0)
+        {
+            addPropertyElement(activationConfigElement, "maxMessages", Integer.toString(listener.getMaxThreads())) ;
+        }
+    }
+
+    private static void setAttribute(final Element listenerNode,
+        final String name, final String value)
+    {
+        if (value != null)
+        {
+            listenerNode.setAttribute(name, value) ;
+        }
+    }
+
+    private static void setAttribute(final Element listenerNode,
+        final String name, final String value, final String defaultValue)
+    {
+        if (value == null)
+        {
+            listenerNode.setAttribute(name, defaultValue) ;
+        }
+        else
+        {
+            listenerNode.setAttribute(name, value) ;
+        }
+    }
+
+    private static void addPropertyElement(final Element activationConfigElement,
+        final String name, final String value)
+    {
+        final Element propertyElement = YADOMUtil.addElement(activationConfigElement,
+            JcaConstants.ELEMENT_PROPERTY) ;
+        propertyElement.setAttribute("name", name) ;
+        propertyElement.setAttribute("value", value) ;
+    }
 }

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/PackageJmsMessageContents.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/PackageJmsMessageContents.java	2007-10-17 10:57:55 UTC (rev 15874)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/PackageJmsMessageContents.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -55,6 +55,10 @@
 	private ESBPropertiesSetter esbPropertiesStrategy = new DefaultESBPropertiesSetter();
     private MessagePayloadProxy payloadProxy;
 
+    public PackageJmsMessageContents(ConfigTree config) {
+        this(createPayloadProxy(config)) ;
+    }
+    
     public PackageJmsMessageContents(MessagePayloadProxy payloadProxy) {
         this.payloadProxy = payloadProxy;
     }

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/BaseJcaInflow.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/BaseJcaInflow.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/BaseJcaInflow.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -0,0 +1,253 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.listeners.jca;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+
+import org.jboss.soa.esb.Configurable;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.lifecycle.AbstractManagedLifecycle;
+import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
+
+/**
+ * @author <a href="bill at jboss.com">Bill Burke</a>
+ * @author <a href="kevin.conner at jboss.com">Kevin Conner</a>
+ */
+abstract class BaseJcaInflow<T> extends AbstractManagedLifecycle
+{
+   private HashMap<String, String> activationSpec = new HashMap<String, String>();
+   private ClassLoader classLoader;
+   private Class<T> inflowInterface;
+   private Class<T> beanClass;
+   private Class<?> messagingType;
+   private ActivationBridge bridge;
+   private String adapter;
+   private boolean isTransacted = true;
+   protected T bean;
+
+   @SuppressWarnings("unchecked")
+   public BaseJcaInflow(ConfigTree config, Class<T> inflowInterface) throws ConfigurationException
+   {
+      super(config);
+
+      this.inflowInterface = inflowInterface ;
+      ConfigTree spec = config.getFirstChild(JcaConstants.ELEMENT_ACTIVATION_CONFIG);
+      for (ConfigTree configProperty : spec.getChildren(JcaConstants.ELEMENT_PROPERTY))
+      {
+         String name = configProperty.getAttribute(JcaConstants.ATTRIBUTE_NAME);
+         String value = configProperty.getAttribute(JcaConstants.ATTRIBUTE_VALUE);
+         activationSpec.put(name, value);
+      }
+
+      this.classLoader = Thread.currentThread().getContextClassLoader();
+      adapter = config.getAttribute(JcaConstants.ATTRIBUTE_ADAPTER);
+
+      String bc = config.getAttribute(JcaConstants.ATTRIBUTE_ENDPOINT_CLASS);
+      if (bc == null) throw new ConfigurationException("endpointClass attribute is required for Jca Gateway");
+      final Class<?> beanClass ;
+      try
+      {
+         beanClass = classLoader.loadClass(bc) ;
+      }
+      catch (ClassNotFoundException e)
+      {
+         throw new ConfigurationException("Unable to load Jca Gateway endpointClass: " + bc, e);
+      }
+      if (!inflowInterface.isAssignableFrom(beanClass))
+          throw new ConfigurationException("endpointClass must implement " + inflowInterface.getSimpleName() + " interface");
+     
+      this.beanClass = (Class<T>)beanClass ;
+      
+      String mt = config.getAttribute(JcaConstants.ATTRIBUTE_MESSAGING_TYPE);
+      if (mt != null)
+      {
+         try
+         {
+            messagingType = classLoader.loadClass(mt);
+         }
+         catch (ClassNotFoundException e)
+         {
+            throw new ConfigurationException("Unable to load Jca Gateway messagingType: " + mt, e);
+         }
+      }
+      else
+      {
+         messagingType = findMessagingType(beanClass);
+      }
+
+      String brdg = config.getAttribute(JcaConstants.ATTRIBUTE_JCA_BRIDGE);
+      if (brdg != null)
+      {
+         try
+         {
+            bridge = (ActivationBridge) classLoader.loadClass(mt).newInstance();
+         }
+         catch (Exception e)
+         {
+            throw new ConfigurationException("Unable to load jcaBridge: " + brdg, e);
+         }
+      }
+      else
+      {
+         bridge = new JBoss42ActivationBridge();
+      }
+      String transacted = config.getAttribute(JcaConstants.ATTRIBUTE_TRANSACTED);
+      if (transacted != null) isTransacted = Boolean.parseBoolean(transacted.trim());
+   }
+
+   private Class<?> findMessagingType(Class<?> clazz)
+           throws ConfigurationException
+   {
+      if (clazz.equals(Object.class)) return null;
+
+      Class<?>[] interfaces = clazz.getInterfaces();
+      Class<?> type = null;
+      for (Class<?> intf : interfaces)
+      {
+         if (intf.equals(inflowInterface) || intf.equals(Configurable.class)) continue;
+         if (type != null)
+         {
+            throw new ConfigurationException("Unable to guess messagingType interface from endpointClass as the base class implements too many interfaces, specify this explicity");
+         }
+         type = intf;
+      }
+      if (type == null) return findMessagingType(clazz.getSuperclass());
+      return type;
+   }
+
+   protected abstract String getDescription() ;
+
+   protected void doInitialise() throws ManagedLifecycleException
+   {
+      try
+      {
+         Constructor<T> beanClassConstructor = beanClass.getConstructor(ConfigTree.class);
+         try
+         {
+            bean = beanClassConstructor.newInstance(getConfig());
+         }
+         catch (InstantiationException e)
+         {
+            throw new RuntimeException("Unable to create endpoint bean", e);
+         }
+         catch (IllegalAccessException e)
+         {
+            throw new RuntimeException("Unable to create endpoint bean", e);
+         }
+         catch (InvocationTargetException e)
+         {
+            throw new RuntimeException("Unable to create endpoint bean", e.getTargetException());
+         }
+      }
+      catch (NoSuchMethodException e)
+      {
+         try
+         {
+            bean = beanClass.newInstance();
+         }
+         catch (Exception e1)
+         {
+            throw new RuntimeException("Unable to create endpoint bean", e1);
+         }
+      }
+      
+      if (bean instanceof Configurable)
+      {
+          try
+          {
+              ((Configurable)bean).setConfiguration(getConfig()) ;
+          }
+          catch (final ConfigurationException ce)
+          {
+              throw new RuntimeException("Unable to configure endpoint bean", ce);
+          }
+      }
+      
+      final Object theBean = bean;
+      
+      final String description = getDescription() ;
+      
+      EndpointContainer container = new EndpointContainer()
+      {
+
+         public String getDescription()
+         {
+            return description + " jca adapter: " + adapter;
+         }
+
+         public Object invoke(Method method, Object[] args) throws Throwable
+         {
+            try
+            {
+               return method.invoke(theBean, args);
+            }
+            catch (IllegalAccessException e)
+            {
+               throw new RuntimeException(e);
+            }
+            catch (InvocationTargetException e)
+            {
+               throw e.getTargetException();
+            }
+         }
+
+         public boolean isDeliveryTransacted(Method method) throws NoSuchMethodException
+         {
+            return isTransacted;
+         }
+      };
+
+
+      EndpointFactory mef = new EndpointFactory();
+      mef.setContainer(container);
+      mef.setLoader(classLoader);
+      mef.setMessagingType(messagingType);
+      mef.start();
+      bridge.setActivationProperties(activationSpec);
+      bridge.setAdapter(adapter);
+      bridge.setMessageEndpointFactory(mef);
+      bridge.setMessagingTypeClass(messagingType);
+   }
+
+   protected void doStart()
+   {
+      bridge.activate();
+   }
+
+   protected void doStop() throws ManagedLifecycleException
+   {
+      bridge.deactivate();
+   }
+   
+   protected void doDestroy() throws ManagedLifecycleException
+   {
+   }
+   
+   protected boolean isTransactional()
+   {
+       return isTransacted ;
+   }
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/BaseJcaInflow.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/InflowMessageProcessor.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/InflowMessageProcessor.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/InflowMessageProcessor.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.listeners.jca;
+
+/**
+ * Interface for inflow message processors.
+ *
+ * @author <a href="kevin.conner at jboss.com">Kevin Conner</a>
+ */
+public interface InflowMessageProcessor
+{
+   public void process(final Object message) ;
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/InflowMessageProcessor.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/InflowMessageProcessorAdapter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/InflowMessageProcessorAdapter.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/InflowMessageProcessorAdapter.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.listeners.jca;
+
+
+/**
+ * Adapter interface for beans supporting inflow message processors.
+ *
+ * @author <a href="kevin.conner at jboss.com">Kevin Conner</a>
+ */
+public interface InflowMessageProcessorAdapter
+{
+   public void setInflowMessageProcessor(final InflowMessageProcessor processor) ;
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/InflowMessageProcessorAdapter.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaConstants.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaConstants.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaConstants.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -0,0 +1,47 @@
+package org.jboss.soa.esb.listeners.jca;
+
+public interface JcaConstants
+{
+    /**
+     * The adapter attribute for the JCA gateway/listener
+     */
+    public final String ATTRIBUTE_ADAPTER = "adapter";
+    /**
+     * The endpoint class attribute for the JCA gateway/listener.
+     */
+    public final String ATTRIBUTE_ENDPOINT_CLASS = "endpointClass";
+    /**
+     * The messaging type attribute for the JCA gateway/listener.
+     */
+    public final String ATTRIBUTE_MESSAGING_TYPE = "messagingType";
+    /**
+     * The JCA bridge attribute for the JCA gateway/listener.
+     */
+    public final String ATTRIBUTE_JCA_BRIDGE = "jcaBridge";
+    /**
+     * The transacted attribute for the JCA gateway/listener.
+     */
+    public final String ATTRIBUTE_TRANSACTED = "transacted";
+    /**
+     * The listener composer class attribute for the JCA listener.
+     */
+    public final String ATTRIBUTE_LISTENER_COMPOSER_CLASS = "listener-composer";
+    
+    
+    /**
+     * The name of the activation config element for the JCA gateway/listener.
+     */
+    public final String ELEMENT_ACTIVATION_CONFIG = "activation-config";
+    /**
+     * The name of the property element for the JCA gateway/listener.
+     */
+    public final String ELEMENT_PROPERTY = "property";
+    /**
+     * The name of the value attribute for the JCA gateway/listener.
+     */
+    public final String ATTRIBUTE_VALUE = "value";
+    /**
+     * The name of the name attribute for the JCA gateway/listener.
+     */
+    public final String ATTRIBUTE_NAME = "name";
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaConstants.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaGatewayException.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaGatewayException.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaGatewayException.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.jca;
+
+/**
+ * Runtime exception for propagating exceptions.
+ * @author kevin
+ */
+public class JcaGatewayException extends RuntimeException
+{
+    /**
+     * Serial version UID.
+     */
+    private static final long serialVersionUID = 5882143551677173486L;
+
+    /**
+     * Construct a default exception.
+     */
+    public JcaGatewayException()
+    {
+    }
+
+    /**
+     * Construct an exception with the specified message.
+     * @param message The message associated with this exception.
+     */
+    public JcaGatewayException(final String message)
+    {
+        super(message);
+    }
+
+    /**
+     * Construct an exception with the specified cause.
+     * @param cause The cause associated with this exception.
+     */
+    public JcaGatewayException(final Throwable cause)
+    {
+        super(cause);
+    }
+
+    /**
+     * Construct an exception with the specified message and cause.
+     * @param message The message associated with this exception.
+     * @param cause The cause associated with this exception.
+     */
+    public JcaGatewayException(final String message, final Throwable cause)
+    {
+        super(message, cause);
+    }
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaGatewayException.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaGatewayListener.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaGatewayListener.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaGatewayListener.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -0,0 +1,204 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.listeners.jca;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.filter.FilterManager;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.ListenerTagNames;
+import org.jboss.soa.esb.listeners.ListenerUtil;
+import org.jboss.soa.esb.listeners.RegistryUtil;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.common.Environment;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.util.ClassUtil;
+import org.jboss.soa.esb.util.Util;
+
+/**
+ * @author <a href="kevin.conner at jboss.com">Kevin Conner</a>
+ */
+public class JcaGatewayListener extends BaseJcaInflow<InflowMessageProcessorAdapter> implements InflowMessageProcessor
+{
+    private final String targetServiceCategory ;
+    private final String targetServiceName ;
+    private final String serviceCategory ;
+    private final String serviceName ;
+    private final EPR serviceEPR ;
+    
+    private final Object composer ;
+    private final Method processMethod ;
+    
+    private ServiceInvoker serviceInvoker ;
+
+    public JcaGatewayListener(final ConfigTree config)
+        throws ConfigurationException
+    {
+        super(config, InflowMessageProcessorAdapter.class);
+        
+        targetServiceCategory = ListenerUtil.getValue(config, ListenerTagNames.TARGET_SERVICE_CATEGORY_TAG) ;
+        if (Util.isNullString(targetServiceCategory))
+        {
+            throw new ConfigurationException("No service category defined!") ;
+        }
+        targetServiceName = ListenerUtil.getValue(config, ListenerTagNames.TARGET_SERVICE_NAME_TAG) ;
+        if (Util.isNullString(targetServiceName))
+        {
+            throw new ConfigurationException("No service name defined!") ;
+        }
+        
+        serviceCategory = ListenerUtil.getValue(config, ListenerTagNames.SERVICE_CATEGORY_NAME_TAG) ;
+        serviceName = ListenerUtil.getValue(config, ListenerTagNames.SERVICE_NAME_TAG) ;
+        
+        if (serviceName != null)
+        {
+            serviceEPR = ListenerUtil.assembleEpr(config) ;
+        }
+        else
+        {
+            serviceEPR = null ;
+        }
+        
+        final String composerName = config.getAttribute(ListenerTagNames.GATEWAY_COMPOSER_CLASS_TAG) ;
+        if (Util.isNullString(composerName))
+        {
+            throw new ConfigurationException("No composer class defined") ;
+        }
+        final Class<?> composerClass ;
+        try
+        {
+            composerClass = ClassUtil.forName(composerName, getClass()) ;
+        }
+        catch (final ClassNotFoundException cnfe)
+        {
+            throw new ConfigurationException("Could not load composer class: " + composerName, cnfe) ;
+        }
+        
+        try
+        {
+            Object composer ;
+            try
+            {
+                final Constructor<?> configConstructor = composerClass.getConstructor(ConfigTree.class) ;
+                composer = configConstructor.newInstance(config) ;
+            }
+            catch (final NoSuchMethodException nsme)
+            {
+                composer = composerClass.newInstance() ;
+            }
+            this.composer = composer ;
+        }
+        catch (final Throwable th)
+        {
+            throw new ConfigurationException("Unexpected error instantiating composer: " + composerName, th) ;
+        }
+        
+        final String processMethodName = config.getAttribute(ListenerTagNames.GATEWAY_COMPOSER_METHOD_TAG) ;
+        try
+        {
+            processMethod = composerClass.getMethod(processMethodName, Object.class) ;
+        }
+        catch (final NoSuchMethodException nsme)
+        {
+            throw new ConfigurationException("Could not locate process method: " + processMethodName, nsme) ;
+        }
+    }
+    
+    @Override
+    protected String getDescription()
+    {
+        return "targetCategory: " + targetServiceCategory + " targetService: " + targetServiceName ;
+    }
+    
+    @Override
+    protected void doInitialise() throws ManagedLifecycleException
+    {
+        super.doInitialise();
+        bean.setInflowMessageProcessor(this);
+        
+        try
+        {
+            serviceInvoker = new ServiceInvoker(targetServiceCategory, targetServiceName) ;
+        }
+        catch (final MessageDeliverException mde)
+        {
+            throw new ManagedLifecycleException("Unexpected exception creating service invoker", mde) ;
+        }
+        
+        if (serviceEPR != null)
+        {
+            try
+            {
+                RegistryUtil.register(getConfig(), serviceEPR) ;
+            }
+            catch (final RegistryException re)
+            {
+                throw new ManagedLifecycleException("Unexpected exception while registering service", re) ;
+            }
+        }
+    }
+    
+    @Override
+    protected void doDestroy() throws ManagedLifecycleException
+    {
+        super.doDestroy();
+        if (serviceEPR != null)
+        {
+            RegistryUtil.unregister(serviceCategory, serviceName, serviceEPR) ;
+        }
+    }
+
+    public void process(final Object messageIn)
+    {
+        try
+        {
+            Message messageOut = (Message)processMethod.invoke(composer, messageIn) ;
+            
+            final Map<String, Object> params = new HashMap<String, Object>() ;
+            params.put(Environment.GATEWAY_CONFIG, getConfig()) ;
+            
+            messageOut = FilterManager.getInstance().doOutputWork(messageOut, params) ;
+            
+            serviceInvoker.deliverAsync(messageOut) ;
+        }
+        catch (final RuntimeException re)
+        {
+            throw re ;
+        }
+        catch (final Error err)
+        {
+            throw err ;
+        }
+        catch (final Throwable th)
+        {
+            throw new JcaGatewayException("Unexpected exception caught while processing JCA message", th) ;
+        }
+    }
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaGatewayListener.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaInflowGateway.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaInflowGateway.java	2007-10-17 10:57:55 UTC (rev 15874)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaInflowGateway.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -21,44 +21,27 @@
 */
 package org.jboss.soa.esb.listeners.jca;
 
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-
 import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.Configurable;
 import org.jboss.soa.esb.helpers.ConfigTree;
 import org.jboss.soa.esb.listeners.ListenerTagNames;
 import org.jboss.soa.esb.listeners.ListenerUtil;
 import org.jboss.soa.esb.client.ServiceInvoker;
 import org.jboss.soa.esb.listeners.message.MessageDeliverException;
-import org.jboss.soa.esb.listeners.lifecycle.AbstractThreadedManagedLifecycle;
 import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
-import org.apache.log4j.Logger;
 
 /**
  * @author <a href="bill at jboss.com">Bill Burke</a>
- * @version $Revision: 1.1 $
+ * @author <a href="kevin.conner at jboss.com">Kevin Conner</a>
  */
-public class JcaInflowGateway extends AbstractThreadedManagedLifecycle
+public class JcaInflowGateway extends BaseJcaInflow<InflowGateway>
 {
-   private static Logger logger = Logger.getLogger(JcaInflowGateway.class);
    private static final long serialVersionUID = 1L;
-   private HashMap<String, String> activationSpec = new HashMap<String, String>();
-   private ClassLoader classLoader;
-   private Class beanClass;
-   private Class messagingType;
-   private ActivationBridge bridge;
-   private String adapter;
    private String serviceName;
    private String serviceCategory;
-   private boolean isTransacted = true;
-   private InflowGateway bean;
 
    public JcaInflowGateway(ConfigTree config) throws ConfigurationException
    {
-      super(config);
+      super(config, InflowGateway.class);
 
       serviceCategory = ListenerUtil.getValue(config,
             ListenerTagNames.TARGET_SERVICE_CATEGORY_TAG, null);
@@ -70,192 +53,26 @@
       
       if (serviceName == null)
     	  throw new ConfigurationException("No service name defined!");
-      
-      ConfigTree spec = config.getFirstChild("activation-config");
-      for (ConfigTree configProperty : spec.getChildren("property"))
-      {
-         String name = configProperty.getAttribute("name");
-         String value = configProperty.getAttribute("value");
-         activationSpec.put(name, value);
-      }
-
-      this.classLoader = Thread.currentThread().getContextClassLoader();
-      adapter = config.getAttribute("adapter");
-
-      String bc = config.getAttribute("endpointClass");
-      if (bc == null) throw new ConfigurationException("endpointClass attribute is required for Jca Gateway");
-      try
-      {
-         beanClass = classLoader.loadClass(bc);
-      }
-      catch (ClassNotFoundException e)
-      {
-         throw new ConfigurationException("Unable to load Jca Gateway endpointClass: " + bc, e);
-      }
-      if (!InflowGateway.class.isAssignableFrom(beanClass))
-         throw new ConfigurationException("endpointClass must implement InflowGateway interface");
-      String mt = config.getAttribute("messagingType");
-      if (mt != null)
-      {
-         try
-         {
-            messagingType = classLoader.loadClass(mt);
-         }
-         catch (ClassNotFoundException e)
-         {
-            throw new ConfigurationException("Unable to load Jca Gateway messagingType: " + mt, e);
-         }
-      }
-      else
-      {
-         messagingType = findMessagingType(beanClass);
-      }
-
-      String brdg = config.getAttribute("jcaBridge");
-      if (brdg != null)
-      {
-         try
-         {
-            bridge = (ActivationBridge) classLoader.loadClass(mt).newInstance();
-         }
-         catch (Exception e)
-         {
-            throw new ConfigurationException("Unable to load jcaBridge: " + brdg, e);
-         }
-      }
-      else
-      {
-         bridge = new JBoss42ActivationBridge();
-      }
-      String transacted = config.getAttribute("transacted");
-      if (transacted != null) isTransacted = Boolean.parseBoolean(transacted.trim());
-
    }
-
-   public static Class findMessagingType(Class clazz)
-           throws ConfigurationException
+   
+   @Override
+   protected String getDescription()
    {
-      if (clazz.equals(Object.class)) return null;
-
-      Class[] interfaces = clazz.getInterfaces();
-      Class type = null;
-      for (Class intf : interfaces)
-      {
-         if (intf.equals(InflowGateway.class) || intf.equals(Configurable.class)) continue;
-         if (type != null)
-         {
-            throw new ConfigurationException("Unable to guess messagingType interface from endpointClass as the base class implements too many interfaces, specify this explicity");
-         }
-         type = intf;
-      }
-      if (type == null) return findMessagingType(clazz.getSuperclass());
-      return type;
+      return "category: " + serviceCategory + " service: " + serviceName ;
    }
-
-
+   
+   @Override
    protected void doInitialise() throws ManagedLifecycleException
    {
+      super.doInitialise();
       try
       {
-         Constructor beanClassConstructor = beanClass.getConstructor(ConfigTree.class);
-         try
-         {
-            bean = (InflowGateway)beanClassConstructor.newInstance(getConfig());
-            if(bean instanceof Configurable) {
-                ((Configurable)bean).setConfiguration(getConfig());
-            }
-         }
-         catch (InstantiationException e)
-         {
-            throw new RuntimeException("Unable to create endpoint bean", e);
-         }
-         catch (IllegalAccessException e)
-         {
-            throw new RuntimeException("Unable to create endpoint bean", e);
-         }
-         catch (InvocationTargetException e)
-         {
-            throw new RuntimeException("Unable to create endpoint bean", e.getTargetException());
-         } catch (ConfigurationException e) {
-             throw new RuntimeException("Unable to create endpoint bean", e);
-         }
-      }
-      catch (NoSuchMethodException e)
-      {
-         try
-         {
-            bean = (InflowGateway)beanClass.newInstance();
-            if(bean instanceof Configurable) {
-                ((Configurable)bean).setConfiguration(getConfig());
-            }
-         }
-         catch (Exception e1)
-         {
-            throw new RuntimeException("Unable to create endpoint bean", e1);
-         }
-      }
-      final Object theBean = bean;
-      
-      EndpointContainer container = new EndpointContainer()
-      {
-
-         public String getDescription()
-         {
-            return "category: " + serviceCategory + " service: " + serviceName + " jca adapter: " + adapter;
-         }
-
-         public Object invoke(Method method, Object[] args) throws Throwable
-         {
-            try
-            {
-               return method.invoke(theBean, args);
-            }
-            catch (IllegalAccessException e)
-            {
-               throw new RuntimeException(e);
-            }
-            catch (InvocationTargetException e)
-            {
-               throw e.getTargetException();
-            }
-         }
-
-         public boolean isDeliveryTransacted(Method method) throws NoSuchMethodException
-         {
-            return isTransacted;
-         }
-      };
-
-
-      EndpointFactory mef = new EndpointFactory();
-      mef.setContainer(container);
-      mef.setLoader(classLoader);
-      mef.setMessagingType(messagingType);
-      mef.start();
-      bridge.setActivationProperties(activationSpec);
-      bridge.setAdapter(adapter);
-      bridge.setMessageEndpointFactory(mef);
-      bridge.setMessagingTypeClass(messagingType);
-   }
-
-   protected void doRun()
-   {
-      ServiceInvoker invoker;
-      try
-      {
-         invoker = new ServiceInvoker(serviceCategory, serviceName);
+         final ServiceInvoker invoker = new ServiceInvoker(serviceCategory, serviceName);
          bean.setServiceInvoker(invoker);
-         bridge.activate();
       }
-      catch (MessageDeliverException e)
+      catch (final MessageDeliverException mde)
       {
-          logger.error("Failed activate JCA Inflow Gateway. Service '" + serviceCategory + ":" + serviceName + "'.", e);
+         throw new ManagedLifecycleException("Failed to activate JCA Inflow Gateway. Service '" + serviceCategory + ":" + serviceName + "'", mde) ;
       }
    }
-
-
-   protected void doStop() throws ManagedLifecycleException
-   {
-      bridge.deactivate();
-   }
 }

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaJMSInflowMessageProcessorAdapter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaJMSInflowMessageProcessorAdapter.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaJMSInflowMessageProcessorAdapter.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.listeners.jca;
+
+import javax.jms.Message;
+import javax.jms.MessageListener;
+
+
+/**
+ * Adapter interface for beans supporting JMS inflow message processors.
+ *
+ * @author <a href="kevin.conner at jboss.com">Kevin Conner</a>
+ */
+public class JcaJMSInflowMessageProcessorAdapter implements InflowMessageProcessorAdapter, MessageListener
+{
+    private InflowMessageProcessor processor ;
+    
+    public void setInflowMessageProcessor(final InflowMessageProcessor processor)
+    {
+        this.processor = processor ;
+    }
+    
+    public void onMessage(final Message message)
+    {
+        processor.process(message) ;
+    }
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaJMSInflowMessageProcessorAdapter.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaJMSMessageAwareComposer.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaJMSMessageAwareComposer.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaJMSMessageAwareComposer.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -0,0 +1,52 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.listeners.jca;
+
+import org.jboss.internal.soa.esb.couriers.helpers.JmsComposer;
+import org.jboss.soa.esb.couriers.FaultMessageException;
+import org.jboss.soa.esb.listeners.gateway.DefaultESBPropertiesSetter;
+import org.jboss.soa.esb.listeners.gateway.ESBPropertiesSetter;
+import org.jboss.soa.esb.message.Message;
+
+/**
+ * JMS message aware composers.
+ *
+ * @author <a href="kevin.conner at jboss.com">Kevin Conner</a>
+ */
+public class JcaJMSMessageAwareComposer implements JcaMessageAwareComposer
+{
+    /**
+     * The ESB properties setter.
+     */
+    private final ESBPropertiesSetter propertiesSetter = new DefaultESBPropertiesSetter() ;
+    /**
+     * Compose an ESB message from the incoming message object.
+     * @param message The incoming message object.
+     * @return The ESB message.
+     * @throws FaultMessageException if the message is a fault.
+     */
+    public Message compose(final Object message)
+        throws FaultMessageException
+    {
+        return JmsComposer.compose(message, propertiesSetter) ;
+    }
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaJMSMessageAwareComposer.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaMessageAwareComposer.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaMessageAwareComposer.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaMessageAwareComposer.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -0,0 +1,42 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.listeners.jca;
+
+import org.jboss.soa.esb.couriers.FaultMessageException;
+import org.jboss.soa.esb.message.Message;
+
+/**
+ * Interface for message aware composers.
+ *
+ * @author <a href="kevin.conner at jboss.com">Kevin Conner</a>
+ */
+public interface JcaMessageAwareComposer
+{
+    /**
+     * Compose an ESB message from the incoming message object.
+     * @param message The incoming message object.
+     * @return The ESB message.
+     * @throws FaultMessageException if the message is a fault.
+     */
+    public Message compose(final Object message)
+        throws FaultMessageException ;
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaMessageAwareComposer.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaMessageAwareListener.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaMessageAwareListener.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaMessageAwareListener.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -0,0 +1,177 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.listeners.jca;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.ListenerTagNames;
+import org.jboss.soa.esb.listeners.ListenerUtil;
+import org.jboss.soa.esb.listeners.RegistryUtil;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.couriers.FaultMessageException;
+import org.jboss.soa.esb.listeners.message.ActionProcessingPipeline;
+import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.util.ClassUtil;
+import org.jboss.soa.esb.util.Util;
+
+/**
+ * @author <a href="kevin.conner at jboss.com">Kevin Conner</a>
+ */
+public class JcaMessageAwareListener extends BaseJcaInflow<InflowMessageProcessorAdapter> implements InflowMessageProcessor
+{
+    private final String serviceCategory ;
+    private final String serviceName ;
+    private final EPR serviceEPR ;
+    private final JcaMessageAwareComposer composer ;
+    
+    private ActionProcessingPipeline pipeline ;
+
+    public JcaMessageAwareListener(final ConfigTree config)
+        throws ConfigurationException
+    {
+        super(config, InflowMessageProcessorAdapter.class);
+        
+        serviceCategory = ListenerUtil.getValue(config, ListenerTagNames.SERVICE_CATEGORY_NAME_TAG) ;
+        if (Util.isNullString(serviceCategory))
+        {
+            throw new ConfigurationException("No service category defined!") ;
+        }
+        
+        serviceName = ListenerUtil.getValue(config, ListenerTagNames.SERVICE_NAME_TAG) ;
+        if (Util.isNullString(serviceName))
+        {
+            throw new ConfigurationException("No service name defined!") ;
+        }
+        
+        final ConfigTree eprElement = config.getFirstChild(ListenerTagNames.EPR_TAG) ;
+        if (eprElement == null)
+        {
+            throw new ConfigurationException("Missing EPR element") ;
+        }
+        
+        serviceEPR = ListenerUtil.assembleEpr(eprElement) ;
+        
+        final String composerName = config.getAttribute(JcaConstants.ATTRIBUTE_LISTENER_COMPOSER_CLASS) ;
+        if (Util.isNullString(composerName))
+        {
+            throw new ConfigurationException("No composer class defined") ;
+        }
+        
+        final Class<?> composerClass ;
+        try
+        {
+            composerClass = ClassUtil.forName(composerName, getClass()) ;
+        }
+        catch (final ClassNotFoundException cnfe)
+        {
+            throw new ConfigurationException("Could not load listener composer class", cnfe) ;
+        }
+        if (!JcaMessageAwareComposer.class.isAssignableFrom(composerClass))
+        {
+            throw new ConfigurationException("Listener composer class does not implement JcaMessageAwareComposer interface") ;
+        }
+        try
+        {
+            composer = (JcaMessageAwareComposer)composerClass.newInstance() ;
+        }
+        catch (final Throwable th)
+        {
+            throw new ConfigurationException("Unexpected exception caught while creating composer class", th) ;
+        }
+    }
+    
+    @Override
+    protected String getDescription()
+    {
+        return "category: " + serviceCategory + " service: " + serviceName ;
+    }
+    
+    @Override
+    protected void doInitialise() throws ManagedLifecycleException
+    {
+        super.doInitialise();
+        bean.setInflowMessageProcessor(this);
+        
+        try
+        {
+            pipeline = new ActionProcessingPipeline(getConfig()) ;
+            pipeline.initialise() ;
+        }
+        catch (final ConfigurationException ce)
+        {
+            throw new ManagedLifecycleException("Unexpected exception configuring action processing pipeline", ce) ;
+        }
+        pipeline.setTransactional(isTransactional()) ;
+        
+        try
+        {
+            RegistryUtil.register(getConfig(), serviceEPR) ;
+        }
+        catch (final RegistryException re)
+        {
+            throw new ManagedLifecycleException("Unexpected exception while registering service", re) ;
+        }
+    }
+    
+    @Override
+    protected void doDestroy() throws ManagedLifecycleException
+    {
+        super.doDestroy();
+        
+        pipeline.destroy() ;
+        pipeline = null ;
+        RegistryUtil.unregister(serviceCategory, serviceName, serviceEPR) ;
+    }
+
+    public void process(final Object messageIn)
+    {
+        try
+        {
+            try
+            {
+                final Message message = composer.compose(messageIn) ;
+                if (message != null)
+                {
+                    pipeline.process(message) ;
+                }
+            }
+            catch (final FaultMessageException fme)
+            {
+                pipeline.process(fme.getReturnedMessage()) ;
+            }
+        }
+        catch (final RuntimeException re)
+        {
+            throw re ;
+        }
+        catch (final Error err)
+        {
+            throw err ;
+        }
+        catch (final Throwable th)
+        {
+            throw new JcaGatewayException("Unexpected exception caught while processing JCA message", th) ;
+        }
+    }
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaMessageAwareListener.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java	2007-10-17 10:57:55 UTC (rev 15874)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -78,6 +78,11 @@
 	private ServiceMessageCounter serviceMessageCounter;
 	
 	/**
+	 * The transactional flag.
+	 */
+	private boolean transactional ;
+	
+	/**
 	 * public constructor
 	 * 
 	 * @param config
@@ -286,6 +291,8 @@
 					 * the error message to the identified recipient.
 					 */
 					
+					final boolean throwRuntime = transactional && (ex instanceof RuntimeException) ;
+					
 					if (ex instanceof ActionProcessingFaultException)
 					{
 						ActionProcessingFaultException fault = (ActionProcessingFaultException) ex;
@@ -297,7 +304,7 @@
 						else
 							faultTo(fromAddress, faultToAddress, fault.getFaultMessage());
 					}
-					else
+					else if (!throwRuntime)
 					{
 						faultTo(fromAddress, faultToAddress, Factory.createErrorMessage(Factory.UNEXPECTED_ERROR, message, ex));
 					}
@@ -308,6 +315,10 @@
 		        	DeliveryObservableLogger.getInstance().logMessage(new MessageStatusBean(procTime, message, 
 		        			MessageStatusBean.MESSAGE_FAILED));
 					
+		        	        if (throwRuntime)
+		        	        {
+		        	            throw (RuntimeException)ex ;
+		        	        }
 					return false;
 				}
 				serviceMessageCounter.update(new ActionStatusBean((System.nanoTime() - start), count,
@@ -338,6 +349,24 @@
 			return false;
 		}
 	}
+	
+	/**
+	 * Set the transactional flag for this pipeline.
+	 * @param transactional true if running within a transaction, false otherwise.
+	 */
+	public void setTransactional(final boolean transactional)
+	{
+	    this.transactional = transactional ;
+	}
+	
+        /**
+         * Get the transactional flag for this pipeline.
+         * @return true if running within a transaction, false otherwise.
+         */
+	public boolean isTransactional()
+	{
+	    return transactional ;
+	}
 
 	/**
 	 * Send the reply.

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/GeneratorUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/GeneratorUnitTest.java	2007-10-17 10:57:55 UTC (rev 15874)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/GeneratorUnitTest.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -34,8 +34,8 @@
 import org.jboss.soa.esb.listeners.config.xbeanmodel.JmsBusDocument.JmsBus;
 import org.jboss.soa.esb.listeners.config.xbeanmodel.JmsListenerDocument.JmsListener;
 import org.jboss.soa.esb.listeners.config.xbeanmodel.JmsMessageFilterDocument.JmsMessageFilter;
-import org.jboss.soa.esb.listeners.config.xbeanmodel.JmsProviderDocument.JmsProvider;
 import org.jboss.soa.esb.listeners.config.xbeanmodel.ServiceDocument.Service;
+import org.jboss.soa.esb.listeners.config.xbeanmodel.JmsProviderType;
 import org.jboss.soa.esb.listeners.config.xbeanmodel.Listener;
 import org.jboss.soa.esb.testutils.FileUtil;
 
@@ -131,7 +131,7 @@
 		XMLBeansModel model = generator.getModel();
 
 		JmsBus bus = (JmsBus)model.getBus("server1-jms");
-		JmsProvider provider = (JmsProvider) model.getProvider(bus);
+		JmsProviderType provider = (JmsProviderType) model.getProvider(bus);
 		assertEquals("server1-jms", bus.getBusid());
 		assertEquals("com.xyz.provider.XYZConnectionFactory", provider.getConnectionFactory());
 		assertEquals("com.xyz.provider.NamingContextFactory", provider.getJndiContextFactory());

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_01_gateways.xml
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_01_gateways.xml	2007-10-17 10:57:55 UTC (rev 15874)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_01_gateways.xml	2007-10-17 10:59:50 UTC (rev 15875)
@@ -1 +1 @@
-<?xml version="1.0" encoding="UTF-8"?><!--	NOTE: DO NOT MODIFY	This file was auto-generated.--><jbossesb-gateways parameterReloadSecs="180"><Bank-JMS-Gateway connection-factory="com.xyz.provider.XYZConnectionFactory" destination-name="queue/A" destination-type="queue" gatewayClass="org.jboss.soa.esb.listeners.gateway.JmsGatewayListener" is-gateway="true" jndi-URL="xyz://server1:9876" jndi-context-factory="com.xyz.provider.NamingContextFactory" jndi-pkg-prefix="com.xyz" maxThreads="1" message-selector="service='Reconciliation'" persistent="true" service-description="Bank Reconciliation Service" target-service-category="Bank" target-service-name="Reconciliation"/><Bank-HTTP-Gateway gatewayClass="org.jboss.soa.esb.listeners.gateway.JBossRemotingGatewayListener" is-gateway="true" jbr-serverBindAddress="192.168.1.111" jbr-serverBindPort="8765" jbr-serverProtocol="http" maxThreads="1" service-description="Bank Reconciliation Service" target-service-category="Bank" target-service-!
 name="Reconciliation"/></jbossesb-gateways>
\ No newline at end of file
+<?xml version="1.0" encoding="UTF-8"?><!--	NOTE: DO NOT MODIFY	This file was auto-generated.--><jbossesb-gateways parameterReloadSecs="180"><Bank-JMS-Gateway connection-factory="com.xyz.provider.XYZConnectionFactory" destination-name="queue/A" destination-type="queue" gatewayClass="org.jboss.soa.esb.listeners.gateway.JmsGatewayListener" is-gateway="true" jndi-URL="xyz://server1:9876" jndi-context-factory="com.xyz.provider.NamingContextFactory" jndi-pkg-prefix="com.xyz" maxThreads="1" message-selector="service='Reconciliation'" persistent="true" protocol="jms" service-description="Bank Reconciliation Service" target-service-category="Bank" target-service-name="Reconciliation"/><Bank-HTTP-Gateway gatewayClass="org.jboss.soa.esb.listeners.gateway.JBossRemotingGatewayListener" is-gateway="true" jbr-serverBindAddress="192.168.1.111" jbr-serverBindPort="8765" jbr-serverProtocol="http" maxThreads="1" service-description="Bank Reconciliation Service" target-service-category="Bank" !
 target-service-name="Reconciliation"/></jbossesb-gateways>
\ No newline at end of file

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_02.xml
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_02.xml	2007-10-17 10:57:55 UTC (rev 15874)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_02.xml	2007-10-17 10:59:50 UTC (rev 15875)
@@ -20,6 +20,7 @@
 			<property name="jndi-context-factory" value="com.xyz.provider.NamingContextFactory" />
 			<property name="jndi-URL" value="xyz://server1:9876" />
 			<property name="jndi-pkg-prefix" value="com.xyz" />
+			<property name="protocol" value="jms" />
 
 			<bus busid="server1-jms">
 				<property name="destination-type" value="queue" />

Modified: labs/jbossesb/trunk/qa/junit/build.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/build.xml	2007-10-17 10:57:55 UTC (rev 15874)
+++ labs/jbossesb/trunk/qa/junit/build.xml	2007-10-17 10:59:50 UTC (rev 15875)
@@ -125,6 +125,17 @@
             <include name="META-INF/*.xml"/>
          </fileset>
       </jar>
+      <jar jarfile="${qa.build.lib}/jca-tx-test.esb">
+         <fileset dir="${qa.junit.classes}">
+            <include name="org/jboss/soa/esb/server/*.class"/>
+            <include name="org/jboss/soa/esb/server/jcaTx/*.class"/>
+         </fileset>
+         <fileset dir="${qa.junit.resources}/server/jcaTx">
+            <include name="esb-${org.jboss.soa.esb.qa.jmsprovider}-service.xml"/>
+            <include name="test-tx-service.xml"/>
+            <include name="META-INF/*.xml"/>
+         </fileset>
+      </jar>
    </target>
 
    <target name="one-test" if="test" depends="jars"

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


Property changes on: labs/jbossesb/trunk/qa/junit/resources/server/jbossesb-properties.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/META-INF/deployment.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/META-INF/deployment.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/META-INF/deployment.xml	2007-10-17 10:59:50 UTC (rev 15875)
@@ -0,0 +1,5 @@
+<jbossesb-deployment>
+  <depends>jboss.esb.qa.junit.destination:service=Queue,name=esb_jca_tx_channel</depends>
+  <depends>jboss.esb.qa.junit.destination:service=Queue,name=esb_channel</depends>
+  <depends>jboss.esb:test=RedeliveryServer</depends>
+</jbossesb-deployment>


Property changes on: labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/META-INF/deployment.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/META-INF/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/META-INF/jboss-esb.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/META-INF/jboss-esb.xml	2007-10-17 10:59:50 UTC (rev 15875)
@@ -0,0 +1,53 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd"
+          parameterReloadSecs="5">
+
+   <providers>
+      <jms-jca-provider name="JBossMQ" connection-factory="ConnectionFactory"
+                    jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
+                    jndi-URL="localhost">
+
+         <jms-bus busid="esb-channel">
+            <jms-message-filter
+                    dest-type="QUEUE"
+                    dest-name="queue/esb_channel"
+                    />
+         </jms-bus>
+         <jms-bus busid="gateway-channel">
+            <jms-message-filter
+                    dest-type="QUEUE"
+                    dest-name="queue/esb_jca_tx_channel"
+                    />
+         </jms-bus>
+      </jms-jca-provider>
+      <bus-provider name="syntax-sugar">
+         <bus busid="syntax-sugar-bus"/>
+      </bus-provider>
+   </providers>
+
+   <services>
+
+      <service category="HelloWorld_ActionESB"
+               name="SimpleListener"
+               description="Hello World">
+         <listeners>
+            <jms-listener name="JMS-ESBListener"
+                          busidref="esb-channel"
+                          maxThreads="1"
+                    />
+            <jms-listener name="JMS-ESBListener"
+                          busidref="gateway-channel"
+                          maxThreads="1"
+                          is-gateway="true"
+                    />
+         </listeners>
+         <actions>
+            <action name="displayAction"
+                    class="org.jboss.soa.esb.server.MyRedeliveryAction"
+                    process="process">
+            </action>
+         </actions>
+      </service>
+   </services>
+
+</jbossesb>


Property changes on: labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/META-INF/jboss-esb.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/esb-jbm-service.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/esb-jbm-service.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/esb-jbm-service.xml	2007-10-17 10:59:50 UTC (rev 15875)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+   <mbean code="org.jboss.jms.server.destination.QueueService"
+      name="jboss.esb.qa.junit.destination:service=Queue,name=esb_jca_tx_channel"
+      xmbean-dd="xmdesc/Queue-xmbean.xml">
+      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+      <depends>jboss.messaging:service=PostOffice</depends>
+   </mbean>
+
+   <mbean code="org.jboss.jms.server.destination.QueueService"
+      name="jboss.esb.qa.junit.destination:service=Queue,name=esb_channel"
+      xmbean-dd="xmdesc/Queue-xmbean.xml">
+      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+      <depends>jboss.messaging:service=PostOffice</depends>
+   </mbean>
+</server>


Property changes on: labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/esb-jbm-service.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/esb-jbmq-service.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/esb-jbmq-service.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/esb-jbmq-service.xml	2007-10-17 10:59:50 UTC (rev 15875)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+  <mbean code="org.jboss.mq.server.jmx.Queue"
+    name="jboss.esb.qa.junit.destination:service=Queue,name=esb_jca_tx_channel">
+    <depends optional-attribute-name="DestinationManager">
+      jboss.mq:service=DestinationManager
+    </depends>
+  </mbean>
+  
+  <mbean code="org.jboss.mq.server.jmx.Queue"
+    name="jboss.esb.qa.junit.destination:service=Queue,name=esb_channel">
+    <depends optional-attribute-name="DestinationManager">
+      jboss.mq:service=DestinationManager
+    </depends>
+  </mbean>
+</server>


Property changes on: labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/esb-jbmq-service.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/test-tx-service.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/test-tx-service.xml	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/test-tx-service.xml	2007-10-17 10:59:50 UTC (rev 15875)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.esb:test=RedeliveryServer" code="org.jboss.soa.esb.server.Redelivery"/>
+</server>


Property changes on: labs/jbossesb/trunk/qa/junit/resources/server/jcaTx/test-tx-service.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/MyRedeliveryAction.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/MyRedeliveryAction.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/MyRedeliveryAction.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -0,0 +1,104 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.server;
+
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+
+import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.soa.esb.actions.AbstractActionLifecycle;
+import org.jboss.soa.esb.actions.ActionPipelineProcessor;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+
+/**
+ * Action class to force a redelivery for the first message.
+ * @author kevin
+ */
+public class MyRedeliveryAction extends AbstractActionLifecycle implements ActionPipelineProcessor
+{
+    private int count ;
+    
+    public MyRedeliveryAction(final ConfigTree config)
+    {
+    }
+
+    public Message process(Message message) throws ActionProcessingException
+    {
+        final String incomingMessage = (String) message.getBody().get() ;
+        
+        System.out.println("\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
+        System.out.println("Body: " + incomingMessage) ;
+        System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\n");
+        
+        getRedeliveryMBean().logMessage(incomingMessage);
+        // Throw an error every second message
+        if ((count++ & 1) == 0)
+        {
+            throw new IllegalArgumentException("An error to force redelivery") ;
+        }
+        return message;
+    }
+    
+    public void processException(final Message message, final Throwable th)
+    {
+        final String incomingMessage = (String) message.getBody().get() ;
+        try
+        {
+            getRedeliveryMBean().logMessage("Exception for message " + incomingMessage + ":" + th.getMessage());
+        }
+        catch (final ActionProcessingException ape)
+        {
+            System.out.println("Caught action processing exception: " + ape) ;
+        }
+    }
+    
+    public void processSuccess(final Message message)
+    {
+        final String incomingMessage = (String) message.getBody().get() ;
+        try
+        {
+            getRedeliveryMBean().logMessage("Success for message " + incomingMessage);
+        }
+        catch (final ActionProcessingException ape)
+        {
+            System.out.println("Caught action processing exception: " + ape) ;
+        }
+    }
+    
+    private RedeliveryMBean getRedeliveryMBean()
+        throws ActionProcessingException
+    {
+        final MBeanServer server = MBeanServerLocator.locateJBoss();
+        
+        try
+        {
+            return (RedeliveryMBean) MBeanProxyExt.create(RedeliveryMBean.class, RedeliveryMBean.objectName, server);
+        }
+        catch (final MalformedObjectNameException mone)
+        {
+            throw new ActionProcessingException("Error creating MBean proxy", mone) ;
+        }
+    }
+}


Property changes on: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/MyRedeliveryAction.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/Redelivery.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/Redelivery.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/Redelivery.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -0,0 +1,94 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.server;
+
+import java.util.ArrayList;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * MBean to monitor redelivery of transaction based messages.
+ *
+ * @author <a href="kevin.conner at jboss.com">Kevin Conner</a>
+ */
+public class Redelivery implements RedeliveryMBean
+{
+    private final ArrayList<String> list = new ArrayList<String>() ;
+    private final Lock lock = new ReentrantLock() ;
+    private final Condition waitCondition = lock.newCondition() ;
+    
+    public String[] waitForMessages(final int numberOfMessages)
+    {
+        final long startTime = System.currentTimeMillis() ;
+        final long endTime = startTime + 30000 ;
+        lock.lock() ;
+        try
+        {
+            while (list.size() != numberOfMessages)
+            {
+                final long now = System.currentTimeMillis() ;
+                final long waitPeriod = endTime - now ;
+                if (waitPeriod > 0)
+                {
+                    try
+                    {
+                        waitCondition.await(waitPeriod, TimeUnit.MILLISECONDS) ;
+                    }
+                    catch (final InterruptedException ie) {} // ignore
+                }
+                else
+                {
+                    break ;
+                }
+            }
+            final String[] results = list.toArray(new String[0]) ;
+            list.clear() ;
+            final int numResults = results.length ;
+            for(int count = 0 ; count < numResults ; count++)
+            {
+                System.out.println("REDELIVER: Returning message[" + count + "]: " + results[count]) ;
+            }
+            return results ;
+        }
+        finally
+        {
+            lock.unlock() ;
+        }
+    }
+
+    public void logMessage(final String message)
+    {
+        lock.lock() ;
+        try
+        {
+            list.add(message) ;
+            System.out.println("REDELIVER: Adding message: " + message) ;
+            waitCondition.signal() ;
+        }
+        finally
+        {
+            lock.unlock() ;
+        }
+    }
+}


Property changes on: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/Redelivery.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/RedeliveryMBean.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/RedeliveryMBean.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/RedeliveryMBean.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.server;
+
+/**
+ * MBean to monitor redelivery of transaction based messages.
+ *
+ * @author <a href="kevin.conner at jboss.com">Kevin Conner</a>
+ */
+public interface RedeliveryMBean
+{
+   public static final String objectName = "jboss.esb:test=RedeliveryServer";
+
+   public String[] waitForMessages(final int numberOfMessages) ;
+
+   public void logMessage(final String message) ;
+}


Property changes on: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/RedeliveryMBean.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jcaTx/JcaTXUnitTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jcaTx/JcaTXUnitTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jcaTx/JcaTXUnitTest.java	2007-10-17 10:59:50 UTC (rev 15875)
@@ -0,0 +1,126 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.server.jcaTx;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.server.RedeliveryMBean;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Unit test for JCA TX tests.
+ *
+ * @author <a href="mailto:kevin.conner at jboss.com">Kevin Conner</a>
+ */
+
+public class JcaTXUnitTest extends JBossTestCase
+{
+    public JcaTXUnitTest(final String name)
+    {
+        super(name);
+    }
+
+    public void sendATextMessage(final String msg, final String destination)
+        throws Exception
+    {
+        final InitialContext initCtx = getInitialContext();
+        final ConnectionFactory connectionFactory = (ConnectionFactory) initCtx.lookup("ConnectionFactory") ;
+        final Connection connection = connectionFactory.createConnection() ;
+        final Queue queue = (Queue)initCtx.lookup(destination) ;
+        final Session session = connection.createSession(false, QueueSession.AUTO_ACKNOWLEDGE) ;
+        connection.start();
+        final MessageProducer messageProducer = session.createProducer(queue) ;
+        final TextMessage message = session.createTextMessage(msg) ;
+        messageProducer.send(message) ;
+        messageProducer.close() ;
+        connection.close() ;
+    }
+
+    public void sendAnESBMessage(final String msg, final String category, final String service)
+        throws Exception
+    {
+        final Message message = MessageFactory.getInstance().getMessage() ;
+        message.getBody().add(msg) ;
+        final ServiceInvoker serviceInvoker = new ServiceInvoker(category, service) ;
+        serviceInvoker.deliverAsync(message) ;
+    }
+
+    public void testJcaJmsGatewayRedelivery()
+        throws Exception
+    {
+        final String message = "Hello TX Gateway World" ;
+        sendATextMessage(message, "queue/esb_jca_tx_channel") ;
+        
+        final String[] messages = (String[])getServer().invoke(new ObjectName(RedeliveryMBean.objectName), "waitForMessages",
+            new Integer[] {Integer.valueOf(4)}, new String[] { Integer.TYPE.getName() });
+        final int numMessages = (messages == null ? 0 : messages.length) ;
+        
+        assertEquals("Message count", 4, numMessages) ;
+        assertEquals("first message", message, messages[0]) ;
+        assertEquals("second message",
+            "Exception for message " + message + ":" + "An error to force redelivery",
+            messages[1]) ;
+        assertEquals("third message", message, messages[2]) ;
+        assertEquals("fourth message",
+            "Success for message " + message,
+            messages[3]) ;
+    }
+
+    public void testJcaJmsESBAwareRedelivery()
+        throws Exception
+    {
+        final String message = "Hello TX ESB World" ;
+        sendAnESBMessage(message, "HelloWorld_ActionESB", "SimpleListener") ;
+        
+        final String[] messages = (String[])getServer().invoke(new ObjectName(RedeliveryMBean.objectName), "waitForMessages",
+            new Integer[] {Integer.valueOf(4)}, new String[] { Integer.TYPE.getName() });
+        final int numMessages = (messages == null ? 0 : messages.length) ;
+        
+        assertEquals("Message count", 4, numMessages) ;
+        assertEquals("first message", message, messages[0]) ;
+        assertEquals("second message",
+            "Exception for message " + message + ":" + "An error to force redelivery",
+            messages[1]) ;
+        assertEquals("third message", message, messages[2]) ;
+        assertEquals("fourth message",
+            "Success for message " + message,
+            messages[3]) ;
+    }
+
+    public static Test suite() throws Exception
+    {
+        return getDeploySetup(JcaTXUnitTest.class, "jca-tx-test.esb");
+    }
+}


Property changes on: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/server/jcaTx/JcaTXUnitTest.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native




More information about the jboss-svn-commits mailing list