[jboss-cvs] JBossAS SVN: r59997 - branches/Branch_4_0/server/src/main/org/jboss/ejb/txtimer.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jan 25 08:51:00 EST 2007
Author: alex.loubyansky at jboss.com
Date: 2007-01-25 08:50:59 -0500 (Thu, 25 Jan 2007)
New Revision: 59997
Modified:
branches/Branch_4_0/server/src/main/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
branches/Branch_4_0/server/src/main/org/jboss/ejb/txtimer/TimerImpl.java
Log:
JBAS-4014
Modified: branches/Branch_4_0/server/src/main/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
===================================================================
--- branches/Branch_4_0/server/src/main/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java 2007-01-25 13:49:59 UTC (rev 59996)
+++ branches/Branch_4_0/server/src/main/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java 2007-01-25 13:50:59 UTC (rev 59997)
@@ -31,15 +31,11 @@
import javax.ejb.TimerService;
import javax.management.ObjectName;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
import org.jboss.ejb.ContainerMBean;
import org.jboss.logging.Logger;
import org.jboss.mx.util.MBeanProxyExt;
import org.jboss.system.ServiceMBeanSupport;
-import org.jboss.tm.TransactionManagerLocator;
/**
* This service implements a PersistencePolicy that persistes the timer to a
@@ -64,9 +60,6 @@
private ObjectName dataSource;
private String dbpPluginClassName;
- // The transaction manager, to suspend the current Tx during delete
- private TransactionManager tm;
-
// The persisted timers seen on startup
private List timersToRestore;
@@ -75,8 +68,6 @@
*/
public void startService() throws Exception
{
- tm = TransactionManagerLocator.getInstance().locate();
-
// Get the persistence plugin
if (dbpPluginClassName != null)
{
@@ -125,9 +116,6 @@
*/
public void deleteTimer(String timerId, TimedObjectId timedObjectId)
{
- // suspend the Tx before we get the con, because you cannot get a connection on an already commited Tx
- Transaction threadTx = suspendTransaction();
-
try
{
dbpPlugin.deleteTimer(timerId, timedObjectId);
@@ -136,11 +124,6 @@
{
log.warn("Unable to delete timer", e);
}
- finally
- {
- // resume the Tx
- resumeTransaction(threadTx);
- }
}
/**
@@ -288,33 +271,4 @@
{
this.dbpPluginClassName = dbpPluginClass;
}
- // private **********************************************************************************************************
-
- private Transaction suspendTransaction()
- {
- Transaction threadTx = null;
- try
- {
- threadTx = tm.suspend();
- }
- catch (SystemException e)
- {
- log.warn("Cannot suspend Tx: " + e.toString());
- }
- return threadTx;
- }
-
- private void resumeTransaction(Transaction threadTx)
- {
- try
- {
- if (threadTx != null)
- tm.resume(threadTx);
- }
- catch (Exception e)
- {
- log.warn("Cannot resume Tx: " + e.toString());
- }
- }
}
-
Modified: branches/Branch_4_0/server/src/main/org/jboss/ejb/txtimer/TimerImpl.java
===================================================================
--- branches/Branch_4_0/server/src/main/org/jboss/ejb/txtimer/TimerImpl.java 2007-01-25 13:49:59 UTC (rev 59996)
+++ branches/Branch_4_0/server/src/main/org/jboss/ejb/txtimer/TimerImpl.java 2007-01-25 13:50:59 UTC (rev 59997)
@@ -204,6 +204,16 @@
utilTimer.cancel();
}
+ /**
+ * killTimer w/o persistence work
+ */
+ private void cancelTimer()
+ {
+ if (timerState != EXPIRED)
+ setTimerState(CANCELED);
+ utilTimer.cancel();
+ }
+
/**
* Kill the timer, do not remove from timer service
*/
@@ -346,10 +356,6 @@
{
log.debug("setTimerState: " + TIMER_STATES[state]);
timerState = state;
-
- // get rid of the expired timer
- if (timerState == EXPIRED)
- killTimer();
}
private void startInTx()
@@ -421,6 +427,20 @@
*/
public void beforeCompletion()
{
+ switch(timerState)
+ {
+ case CANCELED_IN_TX:
+ timerService.removeTimer(this);
+ break;
+
+ case IN_TIMEOUT:
+ case RETRY_TIMEOUT:
+ if(periode == 0)
+ {
+ timerService.removeTimer(this);
+ }
+ break;
+ }
}
/**
@@ -443,12 +463,20 @@
break;
case CANCELED_IN_TX:
- killTimer();
+ cancelTimer();
break;
case IN_TIMEOUT:
case RETRY_TIMEOUT:
- setTimerState(periode == 0 ? EXPIRED : ACTIVE);
+ if(periode == 0)
+ {
+ setTimerState(EXPIRED);
+ cancelTimer();
+ }
+ else
+ {
+ setTimerState(ACTIVE);
+ }
break;
}
}
@@ -459,7 +487,7 @@
switch (timerState)
{
case STARTED_IN_TX:
- killTimer();
+ cancelTimer();
break;
case CANCELED_IN_TX:
@@ -473,7 +501,15 @@
break;
case RETRY_TIMEOUT:
- setTimerState(periode == 0 ? EXPIRED : ACTIVE);
+ if(periode == 0)
+ {
+ setTimerState(EXPIRED);
+ cancelTimer();
+ }
+ else
+ {
+ setTimerState(ACTIVE);
+ }
break;
}
}
@@ -532,7 +568,15 @@
if (timerState == IN_TIMEOUT)
{
log.debug("Timer was not registered with Tx, resetting state: " + timer);
- setTimerState(periode == 0 ? EXPIRED : ACTIVE);
+ if(periode == 0)
+ {
+ setTimerState(EXPIRED);
+ killTimer();
+ }
+ else
+ {
+ setTimerState(ACTIVE);
+ }
}
}
}
More information about the jboss-cvs-commits
mailing list