com.sun.ejb.containers
Class TimerBean
java.lang.Object
com.sun.ejb.containers.TimerBean
- All Implemented Interfaces:
- TimerLocal
public class TimerBean
- extends Object
- implements TimerLocal
TimerBean is a facade for the persistent state of an EJB Timer.
It is part of the EJB container and is implemented using
Java Persistence API. The standard JPA behavior is useful in
implementing the transactional properties of EJB timers.
When an EJB timer is created by an application, it is not
eligible for expiration until the transaction commits.
Likewise, if a timer is cancelled and the transaction rolls
back, the timer must be reactivated.
To accomplish this, TimerBean registers callbacks with the
transaction manager and interacts with the EJBTimerService
accordingly.
- Author:
- Kenneth Saks, Marina Vatkina
|
Nested Class Summary |
static class |
TimerBean.Blob
To be used to read in TimerBean.Blob and replace with TimerState.Blob
on v2.x upgrade |
|
Method Summary |
void |
cancel(TimerPrimaryKey timerId)
Cancel timer. |
void |
cancelTimers(Collection<TimerState> timers)
|
boolean |
checkStatus(String resourceJndiName,
boolean checkDatabase)
|
int |
countActiveTimersByContainer(long containerId)
|
int |
countActiveTimersOwnedBy(String ownerId)
|
int |
countActiveTimersOwnedByThisServer()
|
int |
countActiveTimersOwnedByThisServerByContainer(long containerId)
|
int |
countCancelledTimersByContainer(long containerId)
|
int |
countCancelledTimersOwnedBy(String ownerId)
|
int |
countCancelledTimersOwnedByThisServer()
|
int |
countCancelledTimersOwnedByThisServerByContainer(long containerId)
|
int |
countTimersByApplication(long applicationId)
|
int |
countTimersByContainer(long containerId)
|
int |
countTimersByContainerAndOwner(long containerId,
String ownerId)
|
int |
countTimersByContainerAndOwnerAndState(long containerId,
String ownerId,
int state)
|
int |
countTimersByContainerAndState(long containerId,
int state)
|
int |
countTimersByOwner(String ownerId)
|
int |
countTimersByOwnerAndState(String ownerId,
int state)
|
int |
countTimersOwnedBy(String ownerId)
|
String[] |
countTimersOwnedByServerIds(String[] serverIds)
|
int |
countTimersOwnedByThisServer()
|
int |
countTimersOwnedByThisServerByContainer(long containerId)
|
TimerState |
createTimer(String timerId,
long containerId,
long applicationId,
String ownerId,
Object timedObjectPrimaryKey,
Date initialExpiration,
long intervalDuration,
TimerSchedule schedule,
TimerConfig timerConfig)
|
int |
deleteTimersByApplication(long applicationId)
|
int |
deleteTimersByContainer(long containerId)
|
Set |
findActiveNonPersistentTimersOwnedByThisServer()
|
Set |
findActiveTimerIdsByContainer(long containerId)
|
Set |
findActiveTimerIdsOwnedBy(String ownerId)
|
Set |
findActiveTimerIdsOwnedByThisServer()
|
Set |
findActiveTimerIdsOwnedByThisServerByContainer(long containerId)
|
Set |
findActiveTimersByContainer(long containerId)
|
Set |
findActiveTimersOwnedBy(String ownerId)
|
Set |
findActiveTimersOwnedByThisServer()
|
Set |
findActiveTimersOwnedByThisServerByContainer(long containerId)
|
Set |
findCancelledTimerIdsByContainer(long containerId)
|
Set |
findCancelledTimerIdsOwnedBy(String ownerId)
|
Set |
findCancelledTimerIdsOwnedByThisServer()
|
Set |
findCancelledTimerIdsOwnedByThisServerByContainer(long containerId)
|
Set |
findCancelledTimersByContainer(long containerId)
|
Set |
findCancelledTimersOwnedBy(String ownerId)
|
Set |
findCancelledTimersOwnedByThisServer()
|
Set |
findCancelledTimersOwnedByThisServerByContainer(long containerId)
|
TimerState |
findTimer(TimerPrimaryKey timerId)
|
Set |
findTimerIdsByContainer(long containerId)
|
Set |
findTimerIdsByContainerAndOwner(long containerId,
String ownerId)
|
Set |
findTimerIdsByContainerAndOwnerAndState(long containerId,
String ownerId,
int state)
|
Set |
findTimerIdsByContainerAndState(long containerId,
int state)
|
Set |
findTimerIdsByOwner(String ownerId)
|
Set |
findTimerIdsByOwnerAndState(String ownerId,
int state)
|
Set |
findTimerIdsOwnedBy(String ownerId)
|
Set |
findTimerIdsOwnedByThisServer()
|
Set |
findTimerIdsOwnedByThisServerByContainer(long containerId)
|
Set |
findTimersByContainer(long containerId)
|
Set |
findTimersByContainerAndOwner(long containerId,
String ownerId)
|
Set |
findTimersByContainerAndOwnerAndState(long containerId,
String ownerId,
int state)
|
Set |
findTimersByContainerAndState(long containerId,
int state)
|
Set |
findTimersByOwnerAndState(String ownerId,
int state)
|
Set |
findTimersOwnedBy(String ownerId)
|
Set |
findTimersOwnedByThisServer()
|
Set |
findTimersOwnedByThisServerByContainer(long containerId)
|
static BaseContainer |
getContainer(long containerId)
|
int |
migrateTimers(String fromOwnerId,
String toOwnerId)
|
void |
remove(Set<TimerPrimaryKey> timerIds)
|
void |
remove(TimerPrimaryKey timerId)
|
void |
setSessionContext(SessionContext context)
|
static void |
testCreate(String timerId,
EJBContext context,
String ownerId,
Date initialExpiration,
long intervalDuration,
Serializable info)
|
static void |
testMigrate(String fromOwnerId)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TimerBean
public TimerBean()
findTimer
public TimerState findTimer(TimerPrimaryKey timerId)
- Specified by:
findTimer in interface TimerLocal
findTimerIdsByContainer
public Set findTimerIdsByContainer(long containerId)
- Specified by:
findTimerIdsByContainer in interface TimerLocal
findTimerIdsByContainerAndState
public Set findTimerIdsByContainerAndState(long containerId,
int state)
findTimerIdsByContainerAndOwner
public Set findTimerIdsByContainerAndOwner(long containerId,
String ownerId)
findTimerIdsByContainerAndOwnerAndState
public Set findTimerIdsByContainerAndOwnerAndState(long containerId,
String ownerId,
int state)
findTimerIdsByOwner
public Set findTimerIdsByOwner(String ownerId)
findTimerIdsByOwnerAndState
public Set findTimerIdsByOwnerAndState(String ownerId,
int state)
findTimersByContainer
public Set findTimersByContainer(long containerId)
- Specified by:
findTimersByContainer in interface TimerLocal
findTimersByContainerAndState
public Set findTimersByContainerAndState(long containerId,
int state)
findTimersByContainerAndOwner
public Set findTimersByContainerAndOwner(long containerId,
String ownerId)
findTimersByContainerAndOwnerAndState
public Set findTimersByContainerAndOwnerAndState(long containerId,
String ownerId,
int state)
findTimersByOwnerAndState
public Set findTimersByOwnerAndState(String ownerId,
int state)
countTimersByApplication
public int countTimersByApplication(long applicationId)
- Specified by:
countTimersByApplication in interface TimerLocal
countTimersByContainer
public int countTimersByContainer(long containerId)
- Specified by:
countTimersByContainer in interface TimerLocal
countTimersByContainerAndState
public int countTimersByContainerAndState(long containerId,
int state)
countTimersByContainerAndOwner
public int countTimersByContainerAndOwner(long containerId,
String ownerId)
countTimersByContainerAndOwnerAndState
public int countTimersByContainerAndOwnerAndState(long containerId,
String ownerId,
int state)
countTimersByOwner
public int countTimersByOwner(String ownerId)
countTimersByOwnerAndState
public int countTimersByOwnerAndState(String ownerId,
int state)
createTimer
public TimerState createTimer(String timerId,
long containerId,
long applicationId,
String ownerId,
Object timedObjectPrimaryKey,
Date initialExpiration,
long intervalDuration,
TimerSchedule schedule,
TimerConfig timerConfig)
throws CreateException
- Specified by:
createTimer in interface TimerLocal
- Throws:
CreateException
setSessionContext
public void setSessionContext(SessionContext context)
remove
public void remove(TimerPrimaryKey timerId)
- Specified by:
remove in interface TimerLocal
remove
public void remove(Set<TimerPrimaryKey> timerIds)
- Specified by:
remove in interface TimerLocal
cancel
public void cancel(TimerPrimaryKey timerId)
throws FinderException,
Exception
- Description copied from interface:
TimerLocal
- Cancel timer.
- Specified by:
cancel in interface TimerLocal
- Throws:
FinderException
Exception
cancelTimers
public void cancelTimers(Collection<TimerState> timers)
- Specified by:
cancelTimers in interface TimerLocal
findActiveTimerIdsByContainer
public Set findActiveTimerIdsByContainer(long containerId)
- Specified by:
findActiveTimerIdsByContainer in interface TimerLocal
findCancelledTimerIdsByContainer
public Set findCancelledTimerIdsByContainer(long containerId)
- Specified by:
findCancelledTimerIdsByContainer in interface TimerLocal
findTimerIdsOwnedByThisServerByContainer
public Set findTimerIdsOwnedByThisServerByContainer(long containerId)
- Specified by:
findTimerIdsOwnedByThisServerByContainer in interface TimerLocal
findActiveTimerIdsOwnedByThisServerByContainer
public Set findActiveTimerIdsOwnedByThisServerByContainer(long containerId)
- Specified by:
findActiveTimerIdsOwnedByThisServerByContainer in interface TimerLocal
findCancelledTimerIdsOwnedByThisServerByContainer
public Set findCancelledTimerIdsOwnedByThisServerByContainer(long containerId)
- Specified by:
findCancelledTimerIdsOwnedByThisServerByContainer in interface TimerLocal
findTimerIdsOwnedByThisServer
public Set findTimerIdsOwnedByThisServer()
- Specified by:
findTimerIdsOwnedByThisServer in interface TimerLocal
findActiveTimerIdsOwnedByThisServer
public Set findActiveTimerIdsOwnedByThisServer()
- Specified by:
findActiveTimerIdsOwnedByThisServer in interface TimerLocal
findCancelledTimerIdsOwnedByThisServer
public Set findCancelledTimerIdsOwnedByThisServer()
- Specified by:
findCancelledTimerIdsOwnedByThisServer in interface TimerLocal
findTimerIdsOwnedBy
public Set findTimerIdsOwnedBy(String ownerId)
- Specified by:
findTimerIdsOwnedBy in interface TimerLocal
findActiveTimerIdsOwnedBy
public Set findActiveTimerIdsOwnedBy(String ownerId)
- Specified by:
findActiveTimerIdsOwnedBy in interface TimerLocal
findCancelledTimerIdsOwnedBy
public Set findCancelledTimerIdsOwnedBy(String ownerId)
- Specified by:
findCancelledTimerIdsOwnedBy in interface TimerLocal
findActiveTimersByContainer
public Set findActiveTimersByContainer(long containerId)
- Specified by:
findActiveTimersByContainer in interface TimerLocal
findCancelledTimersByContainer
public Set findCancelledTimersByContainer(long containerId)
- Specified by:
findCancelledTimersByContainer in interface TimerLocal
findTimersOwnedByThisServerByContainer
public Set findTimersOwnedByThisServerByContainer(long containerId)
- Specified by:
findTimersOwnedByThisServerByContainer in interface TimerLocal
findActiveTimersOwnedByThisServerByContainer
public Set findActiveTimersOwnedByThisServerByContainer(long containerId)
- Specified by:
findActiveTimersOwnedByThisServerByContainer in interface TimerLocal
findCancelledTimersOwnedByThisServerByContainer
public Set findCancelledTimersOwnedByThisServerByContainer(long containerId)
- Specified by:
findCancelledTimersOwnedByThisServerByContainer in interface TimerLocal
findTimersOwnedByThisServer
public Set findTimersOwnedByThisServer()
- Specified by:
findTimersOwnedByThisServer in interface TimerLocal
findActiveTimersOwnedByThisServer
public Set findActiveTimersOwnedByThisServer()
- Specified by:
findActiveTimersOwnedByThisServer in interface TimerLocal
findCancelledTimersOwnedByThisServer
public Set findCancelledTimersOwnedByThisServer()
- Specified by:
findCancelledTimersOwnedByThisServer in interface TimerLocal
findTimersOwnedBy
public Set findTimersOwnedBy(String ownerId)
- Specified by:
findTimersOwnedBy in interface TimerLocal
findActiveTimersOwnedBy
public Set findActiveTimersOwnedBy(String ownerId)
- Specified by:
findActiveTimersOwnedBy in interface TimerLocal
findCancelledTimersOwnedBy
public Set findCancelledTimersOwnedBy(String ownerId)
- Specified by:
findCancelledTimersOwnedBy in interface TimerLocal
countActiveTimersByContainer
public int countActiveTimersByContainer(long containerId)
- Specified by:
countActiveTimersByContainer in interface TimerLocal
countCancelledTimersByContainer
public int countCancelledTimersByContainer(long containerId)
- Specified by:
countCancelledTimersByContainer in interface TimerLocal
countTimersOwnedByThisServerByContainer
public int countTimersOwnedByThisServerByContainer(long containerId)
- Specified by:
countTimersOwnedByThisServerByContainer in interface TimerLocal
countActiveTimersOwnedByThisServerByContainer
public int countActiveTimersOwnedByThisServerByContainer(long containerId)
- Specified by:
countActiveTimersOwnedByThisServerByContainer in interface TimerLocal
countCancelledTimersOwnedByThisServerByContainer
public int countCancelledTimersOwnedByThisServerByContainer(long containerId)
- Specified by:
countCancelledTimersOwnedByThisServerByContainer in interface TimerLocal
countTimersOwnedByThisServer
public int countTimersOwnedByThisServer()
- Specified by:
countTimersOwnedByThisServer in interface TimerLocal
countTimersOwnedByServerIds
public String[] countTimersOwnedByServerIds(String[] serverIds)
- Specified by:
countTimersOwnedByServerIds in interface TimerLocal
countActiveTimersOwnedByThisServer
public int countActiveTimersOwnedByThisServer()
- Specified by:
countActiveTimersOwnedByThisServer in interface TimerLocal
countCancelledTimersOwnedByThisServer
public int countCancelledTimersOwnedByThisServer()
- Specified by:
countCancelledTimersOwnedByThisServer in interface TimerLocal
countTimersOwnedBy
public int countTimersOwnedBy(String ownerId)
- Specified by:
countTimersOwnedBy in interface TimerLocal
countActiveTimersOwnedBy
public int countActiveTimersOwnedBy(String ownerId)
- Specified by:
countActiveTimersOwnedBy in interface TimerLocal
countCancelledTimersOwnedBy
public int countCancelledTimersOwnedBy(String ownerId)
- Specified by:
countCancelledTimersOwnedBy in interface TimerLocal
checkStatus
public boolean checkStatus(String resourceJndiName,
boolean checkDatabase)
- Specified by:
checkStatus in interface TimerLocal
migrateTimers
public int migrateTimers(String fromOwnerId,
String toOwnerId)
- Specified by:
migrateTimers in interface TimerLocal
deleteTimersByContainer
public int deleteTimersByContainer(long containerId)
- Specified by:
deleteTimersByContainer in interface TimerLocal
deleteTimersByApplication
public int deleteTimersByApplication(long applicationId)
- Specified by:
deleteTimersByApplication in interface TimerLocal
testCreate
public static void testCreate(String timerId,
EJBContext context,
String ownerId,
Date initialExpiration,
long intervalDuration,
Serializable info)
throws CreateException
- Throws:
CreateException
testMigrate
public static void testMigrate(String fromOwnerId)
getContainer
public static BaseContainer getContainer(long containerId)
findActiveNonPersistentTimersOwnedByThisServer
public Set findActiveNonPersistentTimersOwnedByThisServer()
- Specified by:
findActiveNonPersistentTimersOwnedByThisServer in interface TimerLocal
Copyright © 2012 GlassFish Community. All Rights Reserved.