[jboss-svn-commits] JBL Code SVN: r13652 - in labs/jbossesb/trunk/product/rosetta/src/org/jboss: soa/esb/listeners and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Jul 19 16:56:05 EDT 2007


Author: mark.little at jboss.com
Date: 2007-07-19 16:56:05 -0400 (Thu, 19 Jul 2007)
New Revision: 13652

Modified:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/filter/GatewayFilter.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerUtil.java
Log:
http://jira.jboss.com/jira/browse/JBESB-683

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/filter/GatewayFilter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/filter/GatewayFilter.java	2007-07-19 20:44:36 UTC (rev 13651)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/filter/GatewayFilter.java	2007-07-19 20:56:05 UTC (rev 13652)
@@ -70,16 +70,13 @@
 	    ConfigTree config = (ConfigTree) params
 		    .get(Environment.GATEWAY_CONFIG);
 
-	    String notPresent = "not present";  // Ugly, but needed because 'default value of null' in ListenerUtil means throw exception!
-	    
 	    if (config != null)
 	    {
 		try
 		{
-        		String url = ListenerUtil.obtainAtt(config, JDBCEpr.URL_TAG,
-        			notPresent);
+        		String url = ListenerUtil.getValue(config, JDBCEpr.URL_TAG, null);
         
-        		if ((url != null) && (url != notPresent))
+        		if (url != null)
         		    msg.getProperties().setProperty(
         			    Environment.ORIGINAL_URL_PROP, url);
 		}
@@ -91,9 +88,9 @@
 		try
 		{
         		String queueName = ListenerUtil.obtainAtt(config,
-        			JMSEpr.DESTINATION_NAME_TAG, notPresent);
+        			JMSEpr.DESTINATION_NAME_TAG, null);
         
-        		if ((queueName != null) && (queueName != notPresent))
+        		if (queueName != null)
         		    msg.getProperties()
         			    .setProperty(
         				    Environment.ORIGINAL_QUEUE_NAME_MSG_PROP,

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerUtil.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerUtil.java	2007-07-19 20:44:36 UTC (rev 13651)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerUtil.java	2007-07-19 20:56:05 UTC (rev 13652)
@@ -320,9 +320,34 @@
 		}
 	} // ________________________________
 
+	/**
+         * Find an attribute in the tree (arg 0) or assign default value (arg 2)
+         * If no such value exists then the default value will be returned, no
+         * matter what the value. This differs from obtainAtt, which will throw a
+         * ConfigurationException if no value is present and the default value is
+         * null.
+         * 
+         * @param p_oP
+         *            ConfigTree - look for attributes in this Element only
+         * @param p_sAtt
+         *            String - Name of attribute to find
+         * @param p_sDefault
+         *            String -default value if requested attribute is not there
+         * @return String - value of attribute, or default value (if null)
+         */
 	
+        public static String getValue (ConfigTree p_oP, String p_sAtt, String p_sDefault)
+        {
+                String sVal = p_oP.getAttribute(p_sAtt);
+
+                return (sVal != null) ? sVal : p_sDefault;
+        } // ________________________________
+        
         /**
-         * Find an attribute in the tree (arg 0) or assign default value (arg 2)
+         * Find an attribute in the tree (arg 0) or assign default value (arg 2).
+         * If there is no value associated with the attribute and the default
+         * value is null, then a ConfigurationException will be thrown. For more
+         * intuitive behaviour in the presence of default values, use getValue.
          * 
          * @param p_oP
          *            ConfigTree - look for attributes in this Element only
@@ -338,12 +363,13 @@
         public static String obtainAtt (ConfigTree p_oP, String p_sAtt, String p_sDefault)
                         throws ConfigurationException
         {
-                String sVal = p_oP.getAttribute(p_sAtt);
-                if ((null == sVal) && (null == p_sDefault))
+            String sVal = getValue(p_oP, p_sAtt, p_sDefault);
+            
+            if ((sVal == null) && (p_sDefault == null))
                         throw new ConfigurationException(
                                         "Missing or invalid <" + p_sAtt + "> attribute");
 
-                return (null != sVal) ? sVal : p_sDefault;
+            return (sVal != null) ? sVal : p_sDefault;
         } // ________________________________
 
 	private static final boolean LOGWARN = true;




More information about the jboss-svn-commits mailing list