org.springframework.yarn.support
Class LifecycleObjectSupport

java.lang.Object
  extended by org.springframework.yarn.support.LifecycleObjectSupport
All Implemented Interfaces:
Aware, BeanFactoryAware, InitializingBean, Lifecycle, Phased, SmartLifecycle
Direct Known Subclasses:
AbstractAllocator, AbstractAppmaster, AbstractLauncher, AbstractMonitor

public abstract class LifecycleObjectSupport
extends Object
implements InitializingBean, SmartLifecycle, BeanFactoryAware

Convenient base class for object which needs spring task scheduler, task executor and life cycle handling.

Author:
Janne Valkealahti

Constructor Summary
LifecycleObjectSupport()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  void doStart()
          Subclasses may implement this method with the start behavior.
protected  void doStop()
          Subclasses may implement this method with the stop behavior.
protected  BeanFactory getBeanFactory()
          Gets the BeanFactory for this instance.
 int getPhase()
           
protected  TaskExecutor getTaskExecutor()
          Gets the defined TaskExecutor.
protected  TaskScheduler getTaskScheduler()
          Gets the defined TaskScheduler.
 YarnEventPublisher getYarnEventPublisher()
          Gets the yarn event publisher.
 boolean isAutoStartup()
           
 boolean isRunning()
           
protected  void onInit()
          Subclasses may implement this for initialization logic.
 void setAutoStartup(boolean autoStartup)
          Sets the auto startup.
 void setBeanFactory(BeanFactory beanFactory)
           
 void setPhase(int phase)
          Sets the phase.
 void setTaskExecutor(TaskExecutor taskExecutor)
          Sets the used TaskExecutor.
 void setTaskScheduler(TaskScheduler taskScheduler)
          Sets the used TaskScheduler.
 void setYarnEventPublisher(YarnEventPublisher yarnEventPublisher)
          Sets the yarn event publisher.
 void start()
           
 void stop()
           
 void stop(Runnable callback)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LifecycleObjectSupport

public LifecycleObjectSupport()
Method Detail

afterPropertiesSet

public final void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface InitializingBean

setBeanFactory

public final void setBeanFactory(BeanFactory beanFactory)
                          throws BeansException
Specified by:
setBeanFactory in interface BeanFactoryAware
Throws:
BeansException

isAutoStartup

public final boolean isAutoStartup()
Specified by:
isAutoStartup in interface SmartLifecycle

getPhase

public final int getPhase()
Specified by:
getPhase in interface Phased

isRunning

public final boolean isRunning()
Specified by:
isRunning in interface Lifecycle

start

public final void start()
Specified by:
start in interface Lifecycle

stop

public final void stop()
Specified by:
stop in interface Lifecycle

stop

public final void stop(Runnable callback)
Specified by:
stop in interface SmartLifecycle

setAutoStartup

public void setAutoStartup(boolean autoStartup)
Sets the auto startup.

Parameters:
autoStartup - the new auto startup
See Also:
SmartLifecycle

setPhase

public void setPhase(int phase)
Sets the phase.

Parameters:
phase - the new phase
See Also:
SmartLifecycle

getBeanFactory

protected final BeanFactory getBeanFactory()
Gets the BeanFactory for this instance.

Returns:
the bean factory.

setTaskScheduler

public void setTaskScheduler(TaskScheduler taskScheduler)
Sets the used TaskScheduler.

Parameters:
taskScheduler - the task scheduler

getTaskScheduler

protected TaskScheduler getTaskScheduler()
Gets the defined TaskScheduler.

Returns:
the defined task scheduler

setTaskExecutor

public void setTaskExecutor(TaskExecutor taskExecutor)
Sets the used TaskExecutor.

Parameters:
taskExecutor - the task executor

getYarnEventPublisher

public YarnEventPublisher getYarnEventPublisher()
Gets the yarn event publisher.

Returns:
the yarn event publisher

setYarnEventPublisher

public void setYarnEventPublisher(YarnEventPublisher yarnEventPublisher)
Sets the yarn event publisher.

Parameters:
yarnEventPublisher - the new yarn event publisher

getTaskExecutor

protected TaskExecutor getTaskExecutor()
Gets the defined TaskExecutor.

Returns:
the defined task executor

onInit

protected void onInit()
               throws Exception
Subclasses may implement this for initialization logic. Called during the InitializingBean phase. Implementor should always call super method not to break initialization chain.

Throws:
Exception - exception

doStart

protected void doStart()
Subclasses may implement this method with the start behavior. This method will be invoked while holding the lifecycleLock.


doStop

protected void doStop()
Subclasses may implement this method with the stop behavior. This method will be invoked while holding the lifecycleLock.