Author: ataylor
Date: 2011-04-13 07:02:48 -0400 (Wed, 13 Apr 2011)
New Revision: 10499
Modified:
branches/Branch_2_2_EAP/src/config/ra.xml
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAProperties.java
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQResourceAdapter.java
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/Util.java
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/inflow/HornetQActivation.java
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/inflow/HornetQActivationSpec.java
Log:
https://issues.jboss.org/browse/HORNETQ-670 - added jndi params attr to ra
Modified: branches/Branch_2_2_EAP/src/config/ra.xml
===================================================================
--- branches/Branch_2_2_EAP/src/config/ra.xml 2011-04-12 20:10:09 UTC (rev 10498)
+++ branches/Branch_2_2_EAP/src/config/ra.xml 2011-04-13 11:02:48 UTC (rev 10499)
@@ -83,6 +83,12 @@
<config-property-value></config-property-value>
</config-property>
<config-property>
+ <description>The jndi params to use to look up the jms resources if local
jndi is not to be used</description>
+ <config-property-name>JndiParams</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+
<config-property-value>java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory,java.naming.provider.url=jnp://localhost:1199,java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces</config-property-value>
+ </config-property>
+ <config-property>
<description>The discovery group address</description>
<config-property-name>DiscoveryAddress</config-property-name>
<config-property-type>java.lang.String</config-property-type>
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAProperties.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAProperties.java 2011-04-12
20:10:09 UTC (rev 10498)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAProperties.java 2011-04-13
11:02:48 UTC (rev 10499)
@@ -13,6 +13,7 @@
package org.hornetq.ra;
import java.io.Serializable;
+import java.util.Hashtable;
import org.hornetq.core.logging.Logger;
@@ -60,6 +61,10 @@
private long setupInterval = DEFAULT_SETUP_INTERVAL;
+ private Hashtable jndiParams;
+
+ private boolean useJNDI;
+
/**
* Constructor
*/
@@ -127,7 +132,37 @@
this.password = password;
}
+ /**
+ * @return the useJNDI
+ */
+ public boolean isUseJNDI()
+ {
+ return useJNDI;
+ }
+
/**
+ * @param value the useJNDI to set
+ */
+ public void setUseJNDI(final boolean value)
+ {
+ useJNDI = value;
+ }
+
+ /**
+ *
+ * @return return the jndi params to use
+ */
+ public Hashtable getParsedJndiParams()
+ {
+ return jndiParams;
+ }
+
+
+ public void setParsedJndiParams(Hashtable params)
+ {
+ jndiParams = params;
+ }
+ /**
* Get the use XA flag
* @return The value
*/
@@ -202,4 +237,5 @@
return "HornetQRAProperties[localTx=" + localTx +
", userName=" + userName + ", password=" + password +
"]";
}
+
}
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQResourceAdapter.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQResourceAdapter.java 2011-04-12
20:10:09 UTC (rev 10498)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQResourceAdapter.java 2011-04-13
11:02:48 UTC (rev 10499)
@@ -14,6 +14,7 @@
import java.io.Serializable;
import java.util.HashMap;
+import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -103,6 +104,8 @@
private TransactionManager tm;
+ private String unparsedJndiParams;
+
/**
* Constructor
*/
@@ -1090,7 +1093,42 @@
raProperties.setPassword(password);
}
+ /**
+ * @return the useJNDI
+ */
+ public boolean isUseJNDI()
+ {
+ return raProperties.isUseJNDI();
+ }
+
/**
+ * @param value the useJNDI to set
+ */
+ public void setUseJNDI(final boolean value)
+ {
+ raProperties.setUseJNDI(value);
+ }
+
+ /**
+ *
+ * @return return the jndi params to use
+ */
+ public String getJndiParams()
+ {
+ return unparsedJndiParams;
+ }
+
+ public void setJndiParams(String jndiParams)
+ {
+ unparsedJndiParams = jndiParams;
+ raProperties.setParsedJndiParams(Util.parseHashtableConfig(jndiParams));
+ }
+
+ public Hashtable getParsedJndiParams()
+ {
+ return raProperties.getParsedJndiParams();
+ }
+ /**
* Get the client ID
*
* @return The value
@@ -1648,5 +1686,4 @@
cf.setConnectionLoadBalancingPolicyClassName(val5);
}
}
-
}
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/ra/Util.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/ra/Util.java 2011-04-12 20:10:09 UTC (rev
10498)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/ra/Util.java 2011-04-13 11:02:48 UTC (rev
10499)
@@ -13,10 +13,7 @@
package org.hornetq.ra;
import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import javax.naming.Context;
import javax.transaction.TransactionManager;
@@ -176,6 +173,27 @@
return context.lookup(name);
}
+ public static Hashtable parseHashtableConfig(final String config)
+ {
+ Hashtable hashtable = new Hashtable();
+
+ String[] topElements = config.split(",");
+
+ for (String element : topElements)
+ {
+ String expression[] = element.split("=");
+
+ if (expression.length != 2)
+ {
+ throw new IllegalArgumentException("Invalid expression " + element
+ " at " + config);
+ }
+
+ hashtable.put(expression[0].trim(), expression[1].trim());
+ }
+
+ return hashtable;
+ }
+
public static List<Map<String, Object>> parseConfig(final String config)
{
List<Map<String, Object>> result =new ArrayList<Map<String,
Object>>();
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/ra/inflow/HornetQActivation.java
===================================================================
---
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/inflow/HornetQActivation.java 2011-04-12
20:10:09 UTC (rev 10498)
+++
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/inflow/HornetQActivation.java 2011-04-13
11:02:48 UTC (rev 10499)
@@ -397,7 +397,15 @@
if (spec.isUseJNDI())
{
- Context ctx = new InitialContext();
+ Context ctx;
+ if(spec.getParsedJndiParams() == null)
+ {
+ ctx = new InitialContext();
+ }
+ else
+ {
+ ctx = new InitialContext(spec.getParsedJndiParams());
+ }
HornetQActivation.log.debug("Using context " + ctx.getEnvironment() +
" for " + spec);
if (HornetQActivation.trace)
{
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/inflow/HornetQActivationSpec.java
===================================================================
---
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/inflow/HornetQActivationSpec.java 2011-04-12
20:10:09 UTC (rev 10498)
+++
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/inflow/HornetQActivationSpec.java 2011-04-13
11:02:48 UTC (rev 10499)
@@ -13,6 +13,7 @@
package org.hornetq.ra.inflow;
import java.util.HashMap;
+import java.util.Hashtable;
import java.util.List;
import java.util.Map;
@@ -84,8 +85,12 @@
/** Transaction timeout */
private Integer transactionTimeout;
- private boolean useJNDI = true;
+ private Boolean useJNDI = true;
+ private String jndiParams = null;
+
+ private Hashtable parsedJndiParams;
+
/* use local tx instead of XA*/
private Boolean localTx;
@@ -137,6 +142,10 @@
*/
public boolean isUseJNDI()
{
+ if(useJNDI == null)
+ {
+ return ra.isUseJNDI();
+ }
return useJNDI;
}
@@ -149,6 +158,34 @@
}
/**
+ *
+ * @return return the jndi params to use
+ */
+ public String getJndiParams()
+ {
+ if(jndiParams == null)
+ {
+ return ra.getJndiParams();
+ }
+ return jndiParams;
+ }
+
+ public void setJndiParams(String jndiParams)
+ {
+ this.jndiParams = jndiParams;
+ parsedJndiParams = Util.parseHashtableConfig(jndiParams);
+ }
+
+ public Hashtable getParsedJndiParams()
+ {
+ if(parsedJndiParams == null)
+ {
+ return ra.getParsedJndiParams();
+ }
+ return parsedJndiParams;
+ }
+
+ /**
* Set the resource adapter
* @param ra The resource adapter
* @exception ResourceException Thrown if incorrect resource adapter