[jboss-svn-commits] JBL Code SVN: r21413 - in labs/jbossesb/branches/JBESB_4_4_GA_CP/product: rosetta/src/org/jboss/soa/esb/actions/routing and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Aug 8 11:36:16 EDT 2008


Author: kevin.conner at jboss.com
Date: 2008-08-08 11:36:16 -0400 (Fri, 08 Aug 2008)
New Revision: 21413

Modified:
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/docs/ProgrammersGuide.odt
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/routing/JMSRouter.java
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/JmsRouterIntegrationTest.java
Log:
Added "property-strategy" property: JBESB-1913

Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/docs/ProgrammersGuide.odt
===================================================================
(Binary files differ)

Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/routing/JMSRouter.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/routing/JMSRouter.java	2008-08-08 14:22:05 UTC (rev 21412)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/actions/routing/JMSRouter.java	2008-08-08 15:36:16 UTC (rev 21413)
@@ -53,6 +53,7 @@
 import org.jboss.soa.esb.helpers.NamingContextPool;
 import org.jboss.soa.esb.notification.jms.DefaultJMSPropertiesSetter;
 import org.jboss.soa.esb.notification.jms.JMSPropertiesSetter;
+import org.jboss.soa.esb.util.ClassUtil;
 import org.jboss.soa.esb.util.Util;
 
 /**
@@ -75,6 +76,7 @@
  *     <property name="time-to-live" value="javax.jms.Message.DEFAULT_TIME_TO_LIVE"/>
  *     <property name="security-principal" value="username"/>
  *     <property name="security-credential" value="pasword"/>
+ *     <property name="property-strategy" value="<property setter class name>" />
  *     &lt;property name="message-prop-<i>&gt;prop-name&lt;</i>="<i>&gt; value="prop-value&lt;</i>" /&gt;
  * </pre>
  * Description of configuration attribues:
@@ -89,6 +91,7 @@
  * <li><i>time-to-live</i>: the JMS Time-To-Live to be used. Default is "javax.jms.Message.DEFAULT_TIME_TO_LIVE"
  * <li><i>security-principal</i>: security principal use when creating the JMS connection.
  * <li><i>security-credential</i>: the security credentials to use when creating the JMS connection. 
+ * <li><i>property-strategy</i>: the implementation of the JMSPropertiesSetter interface, if overriding the default. 
  * <li><i>message-prop</i>: properties to be set on the message are prefixed with "message-prop-".
  * </ul>
  *
@@ -121,6 +124,10 @@
      * Security credential used when creating the JMS connection 
 	 */
 	public static final String SECURITY_CREDITIAL = "security-credential";
+	/**
+	 * property strategy class.
+	 */
+	public static final String PROPERTY_STRATEGY = "property-strategy" ;
     /**
      * Routing properties.
      */
@@ -136,7 +143,7 @@
     /**
      * Strategy for setting JMSProperties
      */
-    private JMSPropertiesSetter jmsPropertiesStrategy = new DefaultJMSPropertiesSetter();
+    private final JMSPropertiesSetter jmsPropertiesStrategy ;
     /**
      * Whether messages sent by this router should be sent with delivery mode
      * DeliveryMode.PERSISTENT or DeliveryMode.NON_PERSISTENT
@@ -190,6 +197,17 @@
         jndiPkgPrefix = properties.getAttribute( JMSEpr.JNDI_PKG_PREFIX_TAG );
         connectionFactory = properties.getAttribute( JMSEpr.CONNECTION_FACTORY_TAG );
         
+        final String propertyStrategy = properties.getAttribute(PROPERTY_STRATEGY) ;
+        if (propertyStrategy == null) {
+            jmsPropertiesStrategy = new DefaultJMSPropertiesSetter() ;
+        } else {
+            try {
+                final Class propertyStrategyClass = ClassUtil.forName(propertyStrategy, getClass()) ;
+                jmsPropertiesStrategy = (JMSPropertiesSetter)propertyStrategyClass.newInstance() ;
+            } catch (final Throwable th) {
+                throw new ConfigurationException("Failed to instantiate property strategy class: " + propertyStrategy, th) ;
+            }
+        }
         
         final String securityPrincipal = properties.getAttribute(SECURITY_PRINCIPAL);
         final String securityCredential = properties.getAttribute(SECURITY_CREDITIAL);

Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/JmsRouterIntegrationTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/JmsRouterIntegrationTest.java	2008-08-08 14:22:05 UTC (rev 21412)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/JmsRouterIntegrationTest.java	2008-08-08 15:36:16 UTC (rev 21413)
@@ -51,6 +51,7 @@
 import org.jboss.soa.esb.listeners.gateway.DefaultESBPropertiesSetter;
 import org.jboss.soa.esb.message.Message;
 import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.notification.jms.JMSPropertiesSetter;
 import org.jboss.soa.esb.testutils.SerializableMockQueue;
 import org.junit.Before;
 import org.junit.Test;
@@ -75,6 +76,7 @@
 	private final String bodyContent = "hello";
 	private Message msg;
 	private ConfigTree tree;
+	private static final String PROPERTY_SETTER_TEST_NAME = "MockJMSPropertiesSetter" ;
 
 
 	@Test
@@ -250,6 +252,16 @@
 		assertEquals( jndiPkgPrefix, router.getJndiPkgPrefix() );
 		assertEquals( connectionFactory, router.getConnectionFactory() );
 	}
+
+	@Test
+	public void usePropertyStrategy() throws ConfigurationException, NamingException, JMSException, ActionProcessingException
+	{
+		final ConfigTree tree = createConfigTree() ;
+		tree.setAttribute(JMSRouter.PROPERTY_STRATEGY, MockJMSPropertiesSetter.class.getName()) ;
+		final MockJMSRouter router = new MockJMSRouter(tree) ;
+		router.route(msg) ;
+		assertEquals("Property setter value", PROPERTY_SETTER_TEST_NAME, router.getJmsMessage().getStringProperty(PROPERTY_SETTER_TEST_NAME)) ;
+	}
 	
 	@Before
 	public void setup() throws URISyntaxException
@@ -351,6 +363,15 @@
 			return securityCredential;
 		}
 	}
+	
+	static class MockJMSPropertiesSetter implements JMSPropertiesSetter
+	{
+		public void setJMSProperties(final Message esbMsg, final javax.jms.Message jmsMessage)
+			throws JMSException
+		{
+			jmsMessage.setStringProperty(PROPERTY_SETTER_TEST_NAME, PROPERTY_SETTER_TEST_NAME) ;
+		}
+	}
 
 	/*
 	 * Just here to help Ant to find annotated test.




More information about the jboss-svn-commits mailing list