public class AutomaticJobRegistrar extends Object implements org.springframework.core.Ordered, org.springframework.context.Lifecycle, org.springframework.context.ApplicationListener, 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.ApplicationContextAware
applicationContext
- 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.Ordered
public void setOrder(int order)
order
- the order (default Ordered.LOWEST_PRECEDENCE
).Ordered
public void afterPropertiesSet()
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
public 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
InitializingBean.afterPropertiesSet()
public void stop()
JobLoader.clear()
.stop
in interface org.springframework.context.Lifecycle
Lifecycle.stop()
public void start()
JobLoader
.start
in interface org.springframework.context.Lifecycle
Lifecycle.start()
public boolean isRunning()
isRunning
in interface org.springframework.context.Lifecycle
Lifecycle.isRunning()
Copyright © 2014 Pivotal. All rights reserved.