summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWeston M. Price <wprice@apache.org>2012-04-18 01:34:52 +0000
committerWeston M. Price <wprice@apache.org>2012-04-18 01:34:52 +0000
commit472e67bf5e30b7a14e5d58bae312c12d766a6144 (patch)
tree56f11205aec8d9c5dd9603eb1881637f887932b7
parent5e09be7cc6ed2de1be4db0f8d345e0e4685ba801 (diff)
downloadqpid-python-472e67bf5e30b7a14e5d58bae312c12d766a6144.tar.gz
QPID-3955: Qpid JCA Adapter should throw ResourceException if
TransactionManager Cannot be located. QPID-3956: Add WLSTransactionManagerLocatorClass. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1327352 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/jca/src/main/java/org/apache/qpid/ra/QpidResourceAdapter.java6
-rw-r--r--qpid/java/jca/src/main/java/org/apache/qpid/ra/tm/WLSTransactionManagerLocator.java64
-rw-r--r--qpid/java/jca/src/test/java/org/apache/qpid/ra/QpidResourceAdapterTest.java31
3 files changed, 98 insertions, 3 deletions
diff --git a/qpid/java/jca/src/main/java/org/apache/qpid/ra/QpidResourceAdapter.java b/qpid/java/jca/src/main/java/org/apache/qpid/ra/QpidResourceAdapter.java
index 84c1414617..14b5354062 100644
--- a/qpid/java/jca/src/main/java/org/apache/qpid/ra/QpidResourceAdapter.java
+++ b/qpid/java/jca/src/main/java/org/apache/qpid/ra/QpidResourceAdapter.java
@@ -681,7 +681,7 @@ public class QpidResourceAdapter implements ResourceAdapter, Serializable
return map;
}
- private void locateTM()
+ private void locateTM() throws ResourceAdapterInternalException
{
if(_raProperties.getTransactionManagerLocatorClass() != null && _raProperties.getTransactionManagerLocatorMethod() != null)
{
@@ -703,8 +703,8 @@ public class QpidResourceAdapter implements ResourceAdapter, Serializable
if (_tm == null)
{
- _log.warn("It wasn't possible to lookup a Transaction Manager through the configured properties TransactionManagerLocatorClass and TransactionManagerLocatorMethod");
- _log.warn("Qpid Resource Adapter won't be able to set and verify transaction timeouts in certain cases.");
+ _log.error("It wasn't possible to locate javax.transaction.TransactionManager via the RA properties TransactionManagerLocatorClass and TransactionManagerLocatorMethod");
+ throw new ResourceAdapterInternalException("Could not locate javax.transaction.TransactionManager");
}
else
{
diff --git a/qpid/java/jca/src/main/java/org/apache/qpid/ra/tm/WLSTransactionManagerLocator.java b/qpid/java/jca/src/main/java/org/apache/qpid/ra/tm/WLSTransactionManagerLocator.java
new file mode 100644
index 0000000000..29e673d28e
--- /dev/null
+++ b/qpid/java/jca/src/main/java/org/apache/qpid/ra/tm/WLSTransactionManagerLocator.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.apache.qpid.ra.tm;
+
+
+import javax.naming.InitialContext;
+import javax.transaction.TransactionManager;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class WLSTransactionManagerLocator
+{
+ private static final Logger _log = LoggerFactory.getLogger(WLSTransactionManagerLocator.class);
+
+ private static final String TM_JNDI_NAME = "javax.transaction.TransactionManager";
+
+ public TransactionManager getTm() throws Exception
+ {
+ InitialContext ctx = null;
+ TransactionManager tm = null;
+
+ try
+ {
+ ctx = new InitialContext();
+ tm = (TransactionManager)ctx.lookup(TM_JNDI_NAME);
+ }
+ catch(Exception e)
+ {
+ _log.error("Unable to locate javax.transaction.TransactionManager " + e.getMessage());
+ }
+ finally
+ {
+ try
+ {
+ if(ctx != null)
+ {
+ ctx.close();
+ }
+ }
+ catch(Exception ignore){}
+ }
+
+ return tm;
+ }
+}
+
diff --git a/qpid/java/jca/src/test/java/org/apache/qpid/ra/QpidResourceAdapterTest.java b/qpid/java/jca/src/test/java/org/apache/qpid/ra/QpidResourceAdapterTest.java
index 0db7c710d9..ccad952d64 100644
--- a/qpid/java/jca/src/test/java/org/apache/qpid/ra/QpidResourceAdapterTest.java
+++ b/qpid/java/jca/src/test/java/org/apache/qpid/ra/QpidResourceAdapterTest.java
@@ -20,9 +20,11 @@
*/
package org.apache.qpid.ra;
+import javax.resource.spi.ResourceAdapterInternalException;
import junit.framework.TestCase;
+
public class QpidResourceAdapterTest extends TestCase
{
public void testGetXAResources() throws Exception
@@ -31,4 +33,33 @@ public class QpidResourceAdapterTest extends TestCase
assertNull(ra.getXAResources(null));
}
+ public void testTransactionManagerLocatorException() throws Exception
+ {
+
+ QpidResourceAdapter ra = new QpidResourceAdapter();
+ assertNull(ra.getTransactionManagerLocatorClass());
+ assertNull(ra.getTransactionManagerLocatorMethod());
+
+ try
+ {
+ ra.start(null);
+ }
+ catch(ResourceAdapterInternalException e)
+ {
+
+ }
+
+ ra.setTransactionManagerLocatorClass("DummyLocator");
+
+ try
+ {
+ ra.start(null);
+ }
+ catch(ResourceAdapterInternalException e)
+ {
+
+ }
+
+ }
+
}