Class AutomaticJobRegistrar
- java.lang.Object
- org.springframework.batch.core.configuration.support.AutomaticJobRegistrar
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.InitializingBean
,org.springframework.context.ApplicationContextAware
,org.springframework.context.Lifecycle
,org.springframework.context.Phased
,org.springframework.context.SmartLifecycle
,org.springframework.core.Ordered
public class AutomaticJobRegistrar extends java.lang.Object implements org.springframework.core.Ordered, org.springframework.context.SmartLifecycle, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean
Loads and unloadsJobs
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. AJobRegistry
is required.- Since:
- 2.1
- Author:
- Lucas Ward, Dave Syer, Mahmoud Ben Hassine
Constructor Summary
Constructors Constructor Description AutomaticJobRegistrar()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addApplicationContextFactory(ApplicationContextFactory applicationContextFactory)
Add some factories to the set that will be used to load contexts and jobs.void
afterPropertiesSet()
int
getOrder()
int
getPhase()
boolean
isAutoStartup()
boolean
isRunning()
Check if this component has been started.void
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
The enclosing application context, which can be used to check ifevents
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
setAutoStartup(boolean autoStartup)
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
setPhase(int phase)
void
start()
Take all the contexts from the factories provided and pass them to theJobLoader
.void
stop()
Delegates toJobLoader.clear()
.void
stop(java.lang.Runnable callback)
Method Detail
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
The enclosing application context, which can be used to check ifevents
come from the expected source.- Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Parameters:
applicationContext
- the enclosing application context if there is one- See Also:
ApplicationContextAware.setApplicationContext(ApplicationContext)
addApplicationContextFactory
public void addApplicationContextFactory(ApplicationContextFactory applicationContextFactory)
Add some factories to the set that will be used to load contexts and jobs.- Parameters:
applicationContextFactory
- theApplicationContextFactory
values to use
setApplicationContextFactories
public void setApplicationContextFactories(ApplicationContextFactory[] applicationContextFactories)
Add some factories to the set that will be used to load contexts and jobs.- Parameters:
applicationContextFactories
- theApplicationContextFactory
values to use
setJobLoader
public void setJobLoader(JobLoader jobLoader)
The job loader that will be used to load and manage jobs.- Parameters:
jobLoader
- theJobLoader
to set
getOrder
public int getOrder()
- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
setOrder
public void setOrder(int order)
The order to start up and shutdown.- Parameters:
order
- the order (defaultOrdered.LOWEST_PRECEDENCE
).- See Also:
Ordered
afterPropertiesSet
public void afterPropertiesSet()
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
stop
public void stop()
Delegates toJobLoader.clear()
.- Specified by:
stop
in interfaceorg.springframework.context.Lifecycle
- See Also:
Lifecycle.stop()
start
public void start()
Take all the contexts from the factories provided and pass them to theJobLoader
.- Specified by:
start
in interfaceorg.springframework.context.Lifecycle
- See Also:
Lifecycle.start()
isRunning
public boolean isRunning()
Check if this component has been started.- Specified by:
isRunning
in interfaceorg.springframework.context.Lifecycle
- Returns:
- true if started successfully and not stopped
- See Also:
Lifecycle.isRunning()
isAutoStartup
public boolean isAutoStartup()
- Specified by:
isAutoStartup
in interfaceorg.springframework.context.SmartLifecycle
setAutoStartup
public void setAutoStartup(boolean autoStartup)
- Parameters:
autoStartup
- true for auto start.- See Also:
isAutoStartup()
getPhase
public int getPhase()
- Specified by:
getPhase
in interfaceorg.springframework.context.Phased
- Specified by:
getPhase
in interfaceorg.springframework.context.SmartLifecycle
setPhase
public void setPhase(int phase)
- Parameters:
phase
- the phase.- See Also:
getPhase()
stop
public void stop(java.lang.Runnable callback)
- Specified by:
stop
in interfaceorg.springframework.context.SmartLifecycle