public class AutomaticJobRegistrar
extends java.lang.Object
implements org.springframework.core.Ordered, org.springframework.context.Lifecycle, org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean
Jobs when the application context is created and destroyed. Each resource provided is
loaded as an application context with the current context as its parent, and then all the jobs from the child context
are registered under their bean names. A JobRegistry is required.| Constructor and Description |
|---|
AutomaticJobRegistrar() |
| Modifier and Type | Method and Description |
|---|---|
void |
addApplicationContextFactory(ApplicationContextFactory applicationContextFactory)
Add some factories to the set that will be used to load contexts and jobs.
|
void |
afterPropertiesSet() |
int |
getOrder() |
boolean |
isRunning()
Check if this component has been started.
|
void |
onApplicationEvent(org.springframework.context.ApplicationEvent event)
Creates all the application contexts required and set up job registry entries with all the instances of
Job found therein. |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
The enclosing application context, which can be used to check if
events come from the
expected source. |
void |
setApplicationContextFactories(ApplicationContextFactory[] applicationContextFactories)
Add some factories to the set that will be used to load contexts and jobs.
|
void |
setJobLoader(JobLoader jobLoader)
The job loader that will be used to load and manage jobs.
|
void |
setOrder(int order)
The order to start up and shutdown.
|
void |
start()
Take all the contexts from the factories provided and pass them to the
JobLoader. |
void |
stop()
Delegates to
JobLoader.clear(). |
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
events come from the
expected source.setApplicationContext in interface org.springframework.context.ApplicationContextAwareapplicationContext - the enclosing application context if there is oneApplicationContextAware.setApplicationContext(ApplicationContext)public void addApplicationContextFactory(ApplicationContextFactory applicationContextFactory)
applicationContextFactory - the ApplicationContextFactory values to usepublic void setApplicationContextFactories(ApplicationContextFactory[] applicationContextFactories)
applicationContextFactories - the ApplicationContextFactory values to usepublic void setJobLoader(JobLoader jobLoader)
jobLoader - the JobLoader to setpublic int getOrder()
getOrder in interface org.springframework.core.Orderedpublic void setOrder(int order)
order - the order (default Ordered.LOWEST_PRECEDENCE).Orderedpublic void afterPropertiesSet()
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanpublic final void onApplicationEvent(org.springframework.context.ApplicationEvent event)
Job found therein. Also closes the contexts when the enclosing context is closed.onApplicationEvent in interface org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>InitializingBean.afterPropertiesSet()public void stop()
JobLoader.clear().stop in interface org.springframework.context.LifecycleLifecycle.stop()public void start()
JobLoader.start in interface org.springframework.context.LifecycleLifecycle.start()public boolean isRunning()
isRunning in interface org.springframework.context.LifecycleLifecycle.isRunning()