LifeCycle.Status| Modifier and Type | Field and Description |
|---|---|
protected List<LifeCycle> |
dependencies |
protected AtomicReference<Exception> |
exception |
protected Logger |
logger |
protected LifeCycle.Status |
status |
protected Object |
statusLock |
protected com.google.common.util.concurrent.ListeningExecutorService |
userExecutor |
| Constructor and Description |
|---|
BaseLifeCycle(com.google.common.util.concurrent.ListeningExecutorService userExecutor,
LifeCycle... dependencies) |
| Modifier and Type | Method and Description |
|---|---|
void |
addDependency(LifeCycle lifeCycle) |
protected void |
awaitShutdown(long timeout) |
protected void |
awaitStatus(LifeCycle.Status intended,
long timeout) |
protected abstract void |
doShutdown() |
protected abstract void |
doWork() |
protected void |
exceptionIfDependenciesNotActive() |
protected void |
exceptionIfNotActive() |
Exception |
getException() |
protected Exception |
getExceptionFromDependenciesOrNull() |
LifeCycle.Status |
getStatus() |
void |
run() |
protected boolean |
shouldDoWork() |
void |
shutdown()
Requests shutdown of the component.
|
void |
shutdown(long waitMs)
Requests shutdown, but will only wait @link waitms milliseconds
|
void |
start()
Asynchronously starts the component
|
protected Logger logger
protected final com.google.common.util.concurrent.ListeningExecutorService userExecutor
protected final Object statusLock
protected volatile LifeCycle.Status status
protected AtomicReference<Exception> exception
public BaseLifeCycle(com.google.common.util.concurrent.ListeningExecutorService userExecutor,
LifeCycle... dependencies)
public void addDependency(LifeCycle lifeCycle)
public LifeCycle.Status getStatus()
protected abstract void doShutdown()
protected boolean shouldDoWork()
@PostConstruct public void start()
LifeCycleprotected void exceptionIfDependenciesNotActive()
protected Exception getExceptionFromDependenciesOrNull()
public Exception getException()
getException in interface LifeCycleprotected void awaitShutdown(long timeout)
throws InterruptedException
InterruptedExceptionprotected void awaitStatus(LifeCycle.Status intended, long timeout) throws InterruptedException
InterruptedException@PreDestroy public void shutdown()
LifeCyclepublic void shutdown(long waitMs)
LifeCycleprotected void exceptionIfNotActive()
Copyright © 2009-2016 The Apache Software Foundation. All Rights Reserved.