Author: ataylor
Date: 2009-09-02 06:18:43 -0400 (Wed, 02 Sep 2009)
New Revision: 7934
Added:
trunk/src/main/org/hornetq/ra/inflow/JBoss4TransactionManagerLocator.java
trunk/src/main/org/hornetq/ra/inflow/JBoss5TransactionManagerLocator.java
Modified:
trunk/docs/user-manual/en/appserver-integration.xml
trunk/src/config/ra.xml
trunk/src/main/org/hornetq/ra/HornetQRAProperties.java
trunk/src/main/org/hornetq/ra/HornetQResourceAdapter.java
trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java
Log:
https://jira.jboss.org/jira/browse/HORNETQ-119 - added extra configuration to ra.xml to
allow the class toload the transactionmanager to be configurable
Modified: trunk/docs/user-manual/en/appserver-integration.xml
===================================================================
--- trunk/docs/user-manual/en/appserver-integration.xml 2009-08-31 17:11:31 UTC (rev
7933)
+++ trunk/docs/user-manual/en/appserver-integration.xml 2009-09-02 10:18:43 UTC (rev
7934)
@@ -383,6 +383,16 @@
key=val;key=val; and will be specific to the connector
used</entry>
</row>
<row>
+ <entry>TransactionManagerLocatorClass</entry>
+ <entry>String</entry>
+ <entry>The class to use to load the transaction
manager</entry>
+ </row>
+ <row>
+ <entry>TransactionManagerLocatorMethod</entry>
+ <entry>String</entry>
+ <entry>The method to invoke on the
TransactionManagerLocatorClass to get the transaction manager</entry>
+ </row>
+ <row>
<entry>useLocalTx</entry>
<entry>boolean</entry>
<entry>True will enable local transaction
optimisation.</entry>
Modified: trunk/src/config/ra.xml
===================================================================
--- trunk/src/config/ra.xml 2009-08-31 17:11:31 UTC (rev 7933)
+++ trunk/src/config/ra.xml 2009-09-02 10:18:43 UTC (rev 7934)
@@ -51,7 +51,20 @@
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value>true</config-property-value>
</config-property>
- <!-- <config-property>
+ <!--
+ <config-property>
+ <description>The class to use for locatingthe
transactionmanager</description>
+
<config-property-name>TransactionManagerLocatorClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+
<config-property-value>org.hornetq.ra.inflow.JBoss5TransactionManagerLocator</config-property-value>
+ </config-property>
+ <config-property>
+ <description>The method to use for locatingthe
transactionmanager</description>
+
<config-property-name>TransactionManagerLocatorMethod</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>getTm</config-property-value>
+ </config-property>
+ <config-property>
<description>Use A local Transaction instead of XA?</description>
<config-property-name>UseLocalTx</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
Modified: trunk/src/main/org/hornetq/ra/HornetQRAProperties.java
===================================================================
--- trunk/src/main/org/hornetq/ra/HornetQRAProperties.java 2009-08-31 17:11:31 UTC (rev
7933)
+++ trunk/src/main/org/hornetq/ra/HornetQRAProperties.java 2009-09-02 10:18:43 UTC (rev
7934)
@@ -47,6 +47,10 @@
/** Use Local TX instead of XA */
private Boolean localTx = false;
+ private String transactionManagerLocatorClass =
"org.hornetq.ra.inflow.JBoss5TransactionManagerLocator";
+
+ private String transactionManagerLocatorMethod = "getTm";
+
/**
* Constructor
*/
@@ -185,5 +189,24 @@
return useXA != null && useXA;
}
-
+
+ public void setTransactionManagerLocatorClass(String transactionManagerLocatorClass)
+ {
+ this.transactionManagerLocatorClass = transactionManagerLocatorClass;
+ }
+
+ public String getTransactionManagerLocatorClass()
+ {
+ return transactionManagerLocatorClass;
+ }
+
+ public void setTransactionManagerLocatorMethod(String
transactionManagerLocatorMethod)
+ {
+ this.transactionManagerLocatorMethod = transactionManagerLocatorMethod;
+ }
+
+ public String getTransactionManagerLocatorMethod()
+ {
+ return transactionManagerLocatorMethod;
+ }
}
Modified: trunk/src/main/org/hornetq/ra/HornetQResourceAdapter.java
===================================================================
--- trunk/src/main/org/hornetq/ra/HornetQResourceAdapter.java 2009-08-31 17:11:31 UTC (rev
7933)
+++ trunk/src/main/org/hornetq/ra/HornetQResourceAdapter.java 2009-09-02 10:18:43 UTC (rev
7934)
@@ -211,6 +211,36 @@
log.info("HornetQ resource adapter stopped");
}
+ public void setTransactionManagerLocatorClass(final String
transactionManagerLocatorClass)
+ {
+ if (trace)
+ {
+ log.trace("setTransactionManagerLocatorClass(" +
transactionManagerLocatorClass + ")");
+ }
+
+ raProperties.setTransactionManagerLocatorClass(transactionManagerLocatorClass);
+ }
+
+ public String getTransactionManagerLocatorClass()
+ {
+ return raProperties.getTransactionManagerLocatorClass();
+ }
+
+ public void setTransactionManagerLocatorMethod(final String
transactionManagerLocatorMethod)
+ {
+ if (trace)
+ {
+ log.trace("setTransactionManagerLocatorMethod(" +
transactionManagerLocatorMethod + ")");
+ }
+
+ raProperties.setTransactionManagerLocatorMethod(transactionManagerLocatorMethod);
+ }
+
+ public String getTransactionManagerLocatorMethod()
+ {
+ return raProperties.getTransactionManagerLocatorMethod();
+ }
+
public void setConnectorClassName(final String connectorClassName)
{
if (trace)
Modified: trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java
===================================================================
--- trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java 2009-08-31 17:11:31 UTC
(rev 7933)
+++ trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java 2009-09-02 10:18:43 UTC
(rev 7934)
@@ -222,7 +222,18 @@
if (tm == null)
{
- tm = TransactionManagerLocator.locateTransactionManager();
+ try
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ Class aClass = loader.loadClass(ra.getTransactionManagerLocatorClass());
+ Object o = aClass.newInstance();
+ Method m = aClass.getMethod(ra.getTransactionManagerLocatorMethod());
+ tm = (TransactionManager) m.invoke(o);
+ }
+ catch (Exception e)
+ {
+ log.warn("unable to create TransactionManager from " +
ra.getTransactionManagerLocatorClass() + "." +
ra.getTransactionManagerLocatorMethod());
+ }
}
return tm;
Added: trunk/src/main/org/hornetq/ra/inflow/JBoss4TransactionManagerLocator.java
===================================================================
--- trunk/src/main/org/hornetq/ra/inflow/JBoss4TransactionManagerLocator.java
(rev 0)
+++ trunk/src/main/org/hornetq/ra/inflow/JBoss4TransactionManagerLocator.java 2009-09-02
10:18:43 UTC (rev 7934)
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.ra.inflow;
+
+import org.jboss.tm.TransactionManagerLocator;
+
+import javax.transaction.TransactionManager;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ */
+public class JBoss4TransactionManagerLocator
+{
+ public TransactionManager getTm()
+ {
+ return TransactionManagerLocator.getInstance().locate();
+ }
+}
Added: trunk/src/main/org/hornetq/ra/inflow/JBoss5TransactionManagerLocator.java
===================================================================
--- trunk/src/main/org/hornetq/ra/inflow/JBoss5TransactionManagerLocator.java
(rev 0)
+++ trunk/src/main/org/hornetq/ra/inflow/JBoss5TransactionManagerLocator.java 2009-09-02
10:18:43 UTC (rev 7934)
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.ra.inflow;
+
+import org.jboss.tm.TransactionManagerLocator;
+
+import javax.transaction.TransactionManager;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ */
+public class JBoss5TransactionManagerLocator
+{
+ public TransactionManager getTm()
+ {
+ return TransactionManagerLocator.locateTransactionManager();
+ }
+}