org.springframework.data.hadoop.store.support
Class LifecycleObjectSupport

java.lang.Object
  extended by org.springframework.data.hadoop.store.support.LifecycleObjectSupport
All Implemented Interfaces:
Aware, BeanFactoryAware, InitializingBean, Lifecycle, Phased, SmartLifecycle
Direct Known Subclasses:
StoreObjectSupport

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 behaviour.
protected  void doStop()
          Subclasses may implement this method with the stop behaviour.
protected  BeanFactory getBeanFactory()
          Gets the BeanFactory for this instance.
 int getPhase()
           
 StoreEventPublisher getStoreEventPublisher()
          Gets the store event publisher.
protected  TaskExecutor getTaskExecutor()
          Gets the defined TaskExecutor.
protected  TaskScheduler getTaskScheduler()
          Gets the defined TaskScheduler.
 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 setStoreEventPublisher(StoreEventPublisher storeEventPublisher)
          Sets the store event publisher.
 void setTaskExecutor(TaskExecutor taskExecutor)
          Sets the used TaskExecutor.
 void setTaskScheduler(TaskScheduler taskScheduler)
          Sets the used TaskScheduler.
 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

getStoreEventPublisher

public StoreEventPublisher getStoreEventPublisher()
Gets the store event publisher.

Returns:
the store event publisher

setStoreEventPublisher

public void setStoreEventPublisher(StoreEventPublisher storeEventPublisher)
Sets the store event publisher.

Parameters:
storeEventPublisher - the new store 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

doStart

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


doStop

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