[jboss-cvs] JBossAS SVN: r114561 - projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/mdb.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Nov 15 06:22:23 EST 2013


Author: soul2zimate
Date: 2013-11-15 06:22:22 -0500 (Fri, 15 Nov 2013)
New Revision: 114561

Modified:
   projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/mdb/MessagingContainer.java
Log:
[JBPAPP-10820], fix substitution in @ActivationConfigProperty and @ResourceAdapter

Modified: projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/mdb/MessagingContainer.java
===================================================================
--- projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/mdb/MessagingContainer.java	2013-11-15 11:14:01 UTC (rev 114560)
+++ projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/mdb/MessagingContainer.java	2013-11-15 11:22:22 UTC (rev 114561)
@@ -53,9 +53,12 @@
 import javax.management.ObjectName;
 import javax.naming.Context;
 import javax.naming.NamingException;
+
 import java.lang.reflect.Method;
 import java.util.Hashtable;
 import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import static org.jboss.ejb3.core.timer.TimerCallbackInvocationHelper.setTimer;
 
@@ -66,7 +69,9 @@
 public abstract class MessagingContainer extends TimerServiceContainer implements MultiTimeoutMethodTimedObjectInvoker, MessageDrivenBeanManager
 {
    private static final Logger log = Logger.getLogger(MessagingContainer.class);
-   
+
+   private static final Pattern pattern = Pattern.compile("\\$\\{([^:}]+)(?:\\:([^}]+))?\\}");
+
    private Method timeout;
    
    private static final String MDB_TIMEOUT_METHOD_AOP_INTERCEPTOR_STACK_NAME = "MessageDrivenBeanTimeoutMethodStack";
@@ -134,14 +139,31 @@
    {
       this.messageEndpointFactory = messageEndpointFactory;
    }
-   
+
+   public String replaceVariables(String prop, String expression) {
+       Matcher matcher = pattern.matcher(expression);
+
+       while (matcher.find()) {
+           String var = matcher.group(1);
+           String defaultValue = matcher.group(2);
+           String value = System.getProperty(var, defaultValue);
+           if (value == null)
+               throw new RuntimeException("could not find value for variable " + var);
+           expression = expression.replace(matcher.group(0), value);
+           log.debug("replaced " + matcher.group(0) + " by " + value + " in " + prop + "=" + expression);
+           matcher = pattern.matcher(expression);
+       }
+
+       return expression;
+    }
+
    public String getResourceAdaptorName()
    {
       ResourceAdapter annotation = (ResourceAdapter) resolveAnnotation(ResourceAdapter.class);
       if (annotation == null)
          return JMS_ADAPTOR;
-      
-      return annotation.value();
+
+      return replaceVariables("ResourceAdapter", annotation.value());
    }
    
    protected void addActivationSpecProperty(Map<String, ActivationConfigPropertyMetaData> result, ActivationConfigProperty property)
@@ -150,7 +172,7 @@
       {
          ActivationConfigPropertyMetaData metaData = new ActivationConfigPropertyMetaData();
          metaData.setName(property.propertyName());
-         metaData.setValue(property.propertyValue());   
+         metaData.setValue(replaceVariables(property.propertyName(), property.propertyValue()));   
          result.put(property.propertyName(), metaData);
       }
    }



More information about the jboss-cvs-commits mailing list