[Jboss-cvs] JBossAS SVN: r57070 - trunk/aspects/src/main/org/jboss/aspects/tx
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Sep 22 09:52:25 EDT 2006
Author: kabir.khan at jboss.com
Date: 2006-09-22 09:52:21 -0400 (Fri, 22 Sep 2006)
New Revision: 57070
Added:
trunk/aspects/src/main/org/jboss/aspects/tx/NullTransactionTimeoutConfigurationReader.java
trunk/aspects/src/main/org/jboss/aspects/tx/TransactionTimeoutConfigurationReader.java
trunk/aspects/src/main/org/jboss/aspects/tx/TxManagerTimeOutReader.java
trunk/aspects/src/main/org/jboss/aspects/tx/TxTimeoutReader.java
trunk/aspects/src/main/org/jboss/aspects/tx/TxTimeoutReaderFactory.java
Modified:
trunk/aspects/src/main/org/jboss/aspects/tx/TxInterceptor.java
Log:
[JBAS-3685] Remove all references to org.jboss.tm.TxManager - I've left a reference in place in TxManagerTimeOutReader.java so that we can work in older versions of JBoss
Added: trunk/aspects/src/main/org/jboss/aspects/tx/NullTransactionTimeoutConfigurationReader.java
===================================================================
--- trunk/aspects/src/main/org/jboss/aspects/tx/NullTransactionTimeoutConfigurationReader.java 2006-09-22 13:51:09 UTC (rev 57069)
+++ trunk/aspects/src/main/org/jboss/aspects/tx/NullTransactionTimeoutConfigurationReader.java 2006-09-22 13:52:21 UTC (rev 57070)
@@ -0,0 +1,14 @@
+package org.jboss.aspects.tx;
+
+import javax.transaction.TransactionManager;
+
+/**
+ * When we don't know where we are
+ */
+class NullTransactionTimeoutConfigurationReader implements TxTimeoutReader
+{
+ public int getTransactionTimeOut(TransactionManager tm)
+ {
+ return 0;
+ }
+}
\ No newline at end of file
Added: trunk/aspects/src/main/org/jboss/aspects/tx/TransactionTimeoutConfigurationReader.java
===================================================================
--- trunk/aspects/src/main/org/jboss/aspects/tx/TransactionTimeoutConfigurationReader.java 2006-09-22 13:51:09 UTC (rev 57069)
+++ trunk/aspects/src/main/org/jboss/aspects/tx/TransactionTimeoutConfigurationReader.java 2006-09-22 13:52:21 UTC (rev 57070)
@@ -0,0 +1,44 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.aspects.tx;
+
+import javax.transaction.TransactionManager;
+
+import org.jboss.tm.TransactionTimeoutConfiguration;
+
+/**
+ * For use with newer versions of JBoss supporting the TransactionTimeoutConfiguration interface
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+class TransactionTimeoutConfigurationReader implements TxTimeoutReader
+{
+ public int getTransactionTimeOut(TransactionManager tm) throws Exception
+ {
+ if (tm instanceof TransactionTimeoutConfiguration)
+ {
+ return ((TransactionTimeoutConfiguration)tm).getTransactionTimeout();
+ }
+ return 0;
+ }
+}
\ No newline at end of file
Modified: trunk/aspects/src/main/org/jboss/aspects/tx/TxInterceptor.java
===================================================================
--- trunk/aspects/src/main/org/jboss/aspects/tx/TxInterceptor.java 2006-09-22 13:51:09 UTC (rev 57069)
+++ trunk/aspects/src/main/org/jboss/aspects/tx/TxInterceptor.java 2006-09-22 13:52:21 UTC (rev 57070)
@@ -26,7 +26,6 @@
import org.jboss.aop.advice.Interceptor;
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.logging.Logger;
-import org.jboss.tm.TransactionTimeoutConfiguration;
/**
* This interceptor handles transactions for AOP
@@ -38,6 +37,7 @@
public class TxInterceptor
{
private static final Logger log = Logger.getLogger(TxInterceptor.class);
+ private static final TxTimeoutReader txTimeoutReader = TxTimeoutReaderFactory.getTxTimeoutReader();
public static class Never implements Interceptor
{
@@ -177,12 +177,8 @@
public Object invoke(Invocation invocation) throws Throwable
{
- int oldTimeout = 0;
-
- if (tm instanceof TransactionTimeoutConfiguration)
- {
- oldTimeout = ((TransactionTimeoutConfiguration)tm).getTransactionTimeout();
- }
+ int oldTimeout = txTimeoutReader.getTransactionTimeOut(tm);
+
try
{
if (timeout != -1 && tm != null)
@@ -203,9 +199,9 @@
}
finally
{
- if (txManager != null)
+ if (tm != null)
{
- txManager.setTransactionTimeout(oldTimeout);
+ tm.setTransactionTimeout(oldTimeout);
}
}
}
@@ -241,13 +237,8 @@
public Object invoke(Invocation invocation) throws Throwable
{
- int oldTimeout = 0;
-
- if (tm instanceof TransactionTimeoutConfiguration)
- {
- oldTimeout = ((TransactionTimeoutConfiguration)tm).getTransactionTimeout();
- }
-
+ int oldTimeout = txTimeoutReader.getTransactionTimeOut(tm);
+
try
{
if (timeout != -1 && tm != null)
Added: trunk/aspects/src/main/org/jboss/aspects/tx/TxManagerTimeOutReader.java
===================================================================
--- trunk/aspects/src/main/org/jboss/aspects/tx/TxManagerTimeOutReader.java 2006-09-22 13:51:09 UTC (rev 57069)
+++ trunk/aspects/src/main/org/jboss/aspects/tx/TxManagerTimeOutReader.java 2006-09-22 13:52:21 UTC (rev 57070)
@@ -0,0 +1,41 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.aspects.tx;
+
+import javax.transaction.TransactionManager;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class TxManagerTimeOutReader implements TxTimeoutReader
+{
+ public int getTransactionTimeOut(TransactionManager tm)
+ {
+ if (tm instanceof org.jboss.tm.TxManager)
+ {
+ return ((org.jboss.tm.TxManager)tm).getTransactionTimeout();
+ }
+ return 0;
+ }
+}
\ No newline at end of file
Added: trunk/aspects/src/main/org/jboss/aspects/tx/TxTimeoutReader.java
===================================================================
--- trunk/aspects/src/main/org/jboss/aspects/tx/TxTimeoutReader.java 2006-09-22 13:51:09 UTC (rev 57069)
+++ trunk/aspects/src/main/org/jboss/aspects/tx/TxTimeoutReader.java 2006-09-22 13:52:21 UTC (rev 57070)
@@ -0,0 +1,35 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.aspects.tx;
+
+import javax.transaction.TransactionManager;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface TxTimeoutReader
+{
+ int getTransactionTimeOut(TransactionManager tm) throws Exception;
+
+}
Added: trunk/aspects/src/main/org/jboss/aspects/tx/TxTimeoutReaderFactory.java
===================================================================
--- trunk/aspects/src/main/org/jboss/aspects/tx/TxTimeoutReaderFactory.java 2006-09-22 13:51:09 UTC (rev 57069)
+++ trunk/aspects/src/main/org/jboss/aspects/tx/TxTimeoutReaderFactory.java 2006-09-22 13:52:21 UTC (rev 57070)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.aspects.tx;
+
+/**
+ * Obtains the correct mechanism to get hold of a transaction timeout.
+ * Newer versions of JBoss should use the TransactionTimeoutConfiguration interfsce.
+ * For older versions we need to access the TxManager directly
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class TxTimeoutReaderFactory
+{
+ public static TxTimeoutReader getTxTimeoutReader()
+ {
+ try
+ {
+ Class clazz = Class.forName("org.jboss.tm.TransactionTimeoutConfiguration");
+ return new TransactionTimeoutConfigurationReader();
+ }
+ catch (ClassNotFoundException e)
+ {
+ }
+
+ try
+ {
+ Class clazz = Class.forName("org.jboss.tm.TxManager");
+ return new TransactionTimeoutConfigurationReader();
+ }
+ catch (ClassNotFoundException e)
+ {
+ }
+
+ return new NullTransactionTimeoutConfigurationReader();
+ }
+}
More information about the jboss-cvs-commits
mailing list