Package org.jclouds.lifecycle
Class BaseLifeCycle
java.lang.Object
org.jclouds.lifecycle.BaseLifeCycle
// TODO: Adrian: Document this!
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jclouds.lifecycle.LifeCycle
LifeCycle.Status
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AtomicReference
<Exception> protected Logger
protected LifeCycle.Status
protected final Object
protected final com.google.common.util.concurrent.ListeningExecutorService
-
Constructor Summary
ConstructorsConstructorDescriptionBaseLifeCycle
(com.google.common.util.concurrent.ListeningExecutorService userExecutor, LifeCycle... dependencies) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDependency
(LifeCycle lifeCycle) protected void
awaitShutdown
(long timeout) protected void
awaitStatus
(LifeCycle.Status intended, long timeout) protected abstract void
protected abstract void
doWork()
protected void
protected void
protected Exception
void
run()
protected boolean
void
shutdown()
Requests shutdown of the component.void
shutdown
(long waitMs) Requests shutdown, but will only wait @link waitms millisecondsvoid
start()
Asynchronously starts the component
-
Field Details
-
logger
-
userExecutor
protected final com.google.common.util.concurrent.ListeningExecutorService userExecutor -
dependencies
-
statusLock
-
status
-
exception
-
-
Constructor Details
-
BaseLifeCycle
public BaseLifeCycle(com.google.common.util.concurrent.ListeningExecutorService userExecutor, LifeCycle... dependencies)
-
-
Method Details
-
addDependency
-
getStatus
-
run
public void run() -
doWork
- Throws:
Exception
-
doShutdown
protected abstract void doShutdown() -
shouldDoWork
protected boolean shouldDoWork()- Returns:
- false if any dependencies are inactive, or we are inactive, or we have a global exception.
-
start
@PostConstruct public void start()Description copied from interface:LifeCycle
Asynchronously starts the component -
exceptionIfDependenciesNotActive
protected void exceptionIfDependenciesNotActive() -
getExceptionFromDependenciesOrNull
-
getException
- Specified by:
getException
in interfaceLifeCycle
- Returns:
- Exception or null, if there are no fatal Exceptions encountered in the lifecycle of this component.
-
awaitShutdown
- Throws:
InterruptedException
-
awaitStatus
- Throws:
InterruptedException
-
shutdown
@PreDestroy public void shutdown()Description copied from interface:LifeCycle
Requests shutdown of the component. -
shutdown
public void shutdown(long waitMs) Description copied from interface:LifeCycle
Requests shutdown, but will only wait @link waitms milliseconds -
exceptionIfNotActive
protected void exceptionIfNotActive()
-