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 Object
implements org.springframework.core.Ordered, org.springframework.context.SmartLifecycle, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean
Loads and unloads
Jobs when the application context is created and
destroyed. Each provided resource is loaded as an application context with the current
context as its parent. Then all the jobs from the child context are registered under
their bean names. A JobRegistry is required.- Since:
- 2.1
- Author:
- Lucas Ward, Dave Syer, Mahmoud Ben Hassine
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCEFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddApplicationContextFactory(ApplicationContextFactory applicationContextFactory) Add a singleApplicationContextFactoryto the set that is used to load contexts and jobs.voidintgetOrder()intgetPhase()booleanbooleanCheck whether this component has been started.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) The enclosing application context, which you can use to check whethereventscome from the expected source.voidsetApplicationContextFactories(ApplicationContextFactory[] applicationContextFactories) Add an array ofApplicationContextFactoryinstances to the set that is used to load contexts and jobs.voidsetAutoStartup(boolean autoStartup) voidsetJobLoader(JobLoader jobLoader) The job loader that is used to load and manage jobs.voidsetOrder(int order) The order in which to start up and shutdown.voidsetPhase(int phase) voidstart()Take all the contexts from the factories provided and pass them to theJobLoader.voidstop()Delegates toJobLoader.clear().void
-
Constructor Details
-
AutomaticJobRegistrar
public AutomaticJobRegistrar()
-
-
Method Details
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) The enclosing application context, which you can use to check whethereventscome from the expected source.- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Parameters:
applicationContext- the enclosing application context, if there is one- See Also:
-
ApplicationContextAware.setApplicationContext(ApplicationContext)
-
addApplicationContextFactory
Add a singleApplicationContextFactoryto the set that is used to load contexts and jobs.- Parameters:
applicationContextFactory- theApplicationContextFactoryvalues to use
-
setApplicationContextFactories
Add an array ofApplicationContextFactoryinstances to the set that is used to load contexts and jobs.- Parameters:
applicationContextFactories- theApplicationContextFactoryvalues to use
-
setJobLoader
The job loader that is used to load and manage jobs.- Parameters:
jobLoader- theJobLoaderto set
-
getOrder
public int getOrder()- Specified by:
getOrderin interfaceorg.springframework.core.Ordered
-
setOrder
public void setOrder(int order) The order in which to start up and shutdown.- Parameters:
order- the order (defaultOrdered.LOWEST_PRECEDENCE).- See Also:
-
Ordered
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
stop
public void stop()Delegates toJobLoader.clear().- Specified by:
stopin 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:
startin interfaceorg.springframework.context.Lifecycle- See Also:
-
Lifecycle.start()
-
isRunning
public boolean isRunning()Check whether this component has been started.- Specified by:
isRunningin interfaceorg.springframework.context.Lifecycle- Returns:
trueif started successfully and not stopped.- See Also:
-
Lifecycle.isRunning()
-
isAutoStartup
public boolean isAutoStartup()- Specified by:
isAutoStartupin interfaceorg.springframework.context.SmartLifecycle
-
setAutoStartup
public void setAutoStartup(boolean autoStartup) - Parameters:
autoStartup-truefor auto start.- See Also:
-
getPhase
public int getPhase()- Specified by:
getPhasein interfaceorg.springframework.context.Phased- Specified by:
getPhasein interfaceorg.springframework.context.SmartLifecycle
-
setPhase
public void setPhase(int phase) - Parameters:
phase- the phase.- See Also:
-
stop
- Specified by:
stopin interfaceorg.springframework.context.SmartLifecycle
-