spring-context-support

org.springframework.scheduling.commonj
Class TimerManagerFactoryBean

java.lang.Object
  extended by org.springframework.jndi.JndiAccessor
      extended by org.springframework.jndi.JndiLocatorSupport
          extended by org.springframework.scheduling.commonj.TimerManagerAccessor
              extended by org.springframework.scheduling.commonj.TimerManagerFactoryBean
All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean<commonj.timers.TimerManager>, org.springframework.beans.factory.InitializingBean, org.springframework.context.Lifecycle

public class TimerManagerFactoryBean
extends TimerManagerAccessor
implements org.springframework.beans.factory.FactoryBean<commonj.timers.TimerManager>, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean, org.springframework.context.Lifecycle

FactoryBean that retrieves a CommonJ TimerManager and exposes it for bean references.

This is the central convenience class for setting up a CommonJ TimerManager in a Spring context.

Allows for registration of ScheduledTimerListeners. This is the main purpose of this class; the TimerManager itself could also be fetched from JNDI via JndiObjectFactoryBean. In scenarios that just require static registration of tasks at startup, there is no need to access the TimerManager itself in application code.

Note that the TimerManager uses a TimerListener instance that is shared between repeated executions, in contrast to Quartz which instantiates a new Job for each execution.

Since:
2.0
Author:
Juergen Hoeller
See Also:
ScheduledTimerListener, TimerManager, TimerListener

Field Summary
 
Fields inherited from class org.springframework.jndi.JndiLocatorSupport
CONTAINER_PREFIX
 
Fields inherited from class org.springframework.jndi.JndiAccessor
logger
 
Constructor Summary
TimerManagerFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
 void destroy()
          Cancels all statically registered Timers on shutdown, and stops the underlying TimerManager (if not shared).
 commonj.timers.TimerManager getObject()
           
 java.lang.Class<? extends commonj.timers.TimerManager> getObjectType()
           
 boolean isSingleton()
           
 void setScheduledTimerListeners(ScheduledTimerListener[] scheduledTimerListeners)
          Register a list of ScheduledTimerListener objects with the TimerManager that this FactoryBean creates.
 
Methods inherited from class org.springframework.scheduling.commonj.TimerManagerAccessor
getTimerManager, isRunning, setShared, setTimerManager, setTimerManagerName, start, stop
 
Methods inherited from class org.springframework.jndi.JndiLocatorSupport
convertJndiName, isResourceRef, lookup, lookup, setResourceRef
 
Methods inherited from class org.springframework.jndi.JndiAccessor
getJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.context.Lifecycle
isRunning, start, stop
 

Constructor Detail

TimerManagerFactoryBean

public TimerManagerFactoryBean()
Method Detail

setScheduledTimerListeners

public void setScheduledTimerListeners(ScheduledTimerListener[] scheduledTimerListeners)
Register a list of ScheduledTimerListener objects with the TimerManager that this FactoryBean creates. Depending on each ScheduledTimerListener's settings, it will be registered via one of TimerManager's schedule methods.

See Also:
TimerManager.schedule(commonj.timers.TimerListener, long), TimerManager.schedule(commonj.timers.TimerListener, long, long), TimerManager.scheduleAtFixedRate(commonj.timers.TimerListener, long, long)

afterPropertiesSet

public void afterPropertiesSet()
                        throws javax.naming.NamingException
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Overrides:
afterPropertiesSet in class TimerManagerAccessor
Throws:
javax.naming.NamingException

getObject

public commonj.timers.TimerManager getObject()
Specified by:
getObject in interface org.springframework.beans.factory.FactoryBean<commonj.timers.TimerManager>

getObjectType

public java.lang.Class<? extends commonj.timers.TimerManager> getObjectType()
Specified by:
getObjectType in interface org.springframework.beans.factory.FactoryBean<commonj.timers.TimerManager>

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface org.springframework.beans.factory.FactoryBean<commonj.timers.TimerManager>

destroy

public void destroy()
Cancels all statically registered Timers on shutdown, and stops the underlying TimerManager (if not shared).

Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Overrides:
destroy in class TimerManagerAccessor
See Also:
Timer.cancel(), TimerManager.stop()

spring-context-support