[jboss-cvs] JBossAS SVN: r59991 - trunk/server/src/main/org/jboss/ejb/txtimer.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jan 25 07:33:19 EST 2007
Author: alex.loubyansky at jboss.com
Date: 2007-01-25 07:33:19 -0500 (Thu, 25 Jan 2007)
New Revision: 59991
Modified:
trunk/server/src/main/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
trunk/server/src/main/org/jboss/ejb/txtimer/TimerImpl.java
Log:
JBAS-4014
Modified: trunk/server/src/main/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java 2007-01-25 12:31:32 UTC (rev 59990)
+++ trunk/server/src/main/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java 2007-01-25 12:33:19 UTC (rev 59991)
@@ -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,5 @@
{
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: trunk/server/src/main/org/jboss/ejb/txtimer/TimerImpl.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/txtimer/TimerImpl.java 2007-01-25 12:31:32 UTC (rev 59990)
+++ trunk/server/src/main/org/jboss/ejb/txtimer/TimerImpl.java 2007-01-25 12:33:19 UTC (rev 59991)
@@ -205,6 +205,16 @@
}
/**
+ * killTimer w/o persistence work
+ */
+ private void cancelTimer()
+ {
+ if (timerState != EXPIRED)
+ setTimerState(CANCELED);
+ utilTimer.cancel();
+ }
+
+ /**
* Kill the timer, do not remove from timer service
*/
public void stopTimer()
@@ -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);
+ killTimer();
+ }
+ else
+ {
+ setTimerState(ACTIVE);
+ }
break;
}
}
@@ -459,21 +487,29 @@
switch (timerState)
{
case STARTED_IN_TX:
- killTimer();
+ cancelTimer();
break;
-
+
case CANCELED_IN_TX:
setTimerState(ACTIVE);
break;
-
+
case IN_TIMEOUT:
setTimerState(RETRY_TIMEOUT);
log.debug("retry: " + this);
timerService.retryTimeout(this);
break;
-
+
case RETRY_TIMEOUT:
- setTimerState(periode == 0 ? EXPIRED : ACTIVE);
+ if(periode == 0)
+ {
+ setTimerState(EXPIRED);
+ killTimer();
+ }
+ 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