public class LifeSupport extends Object implements Lifecycle
To use this, first add instances to it that implement the Lifecycle interface. When lifecycle methods on this class are called it will try to invoke the same methods on the registered instances.
Components that internally owns other components that has a lifecycle can use this to control them as well.
Lifecycle.Delegate| Constructor and Description |
|---|
LifeSupport() |
| Modifier and Type | Method and Description |
|---|---|
<T extends Lifecycle> |
add(T instance)
Add a new Lifecycle instance.
|
void |
addLifecycleListener(LifecycleListener listener) |
void |
clear()
Shutdown and throw away all the current instances.
|
Iterable<Lifecycle> |
getLifecycleInstances() |
LifecycleStatus |
getStatus() |
void |
init()
Initialize all registered instances, transitioning from status NONE to STOPPED.
|
boolean |
isRunning() |
boolean |
remove(Lifecycle instance) |
void |
shutdown()
Shutdown all registered instances, transitioning from either STARTED or STOPPED to SHUTDOWN.
|
void |
start()
Start all registered instances, transitioning from STOPPED to STARTED.
|
void |
stop()
Stop all registered instances, transitioning from STARTED to STOPPED.
|
String |
toString() |
public void init()
throws LifecycleException
If transition fails, then it goes to STOPPED and then SHUTDOWN, so it cannot be restarted again.
init in interface LifecycleLifecycleExceptionpublic void start()
throws LifecycleException
If it was previously not initialized, it will be initialized first.
If any instance fails to start, the already started instances will be stopped, so that the overall status is STOPPED.
start in interface LifecycleLifecycleExceptionpublic void stop()
throws LifecycleException
If any instance fails to stop, the rest of the instances will still be stopped, so that the overall status is STOPPED.
stop in interface LifecycleLifecycleExceptionpublic void shutdown()
throws LifecycleException
If any instance fails to shutdown, the rest of the instances will still be shut down, so that the overall status is SHUTDOWN.
shutdown in interface LifecycleLifecycleExceptionpublic <T extends Lifecycle> T add(T instance) throws LifecycleException
T - type of the instanceinstance - the Lifecycle instance to addLifecycleException - if the instance could not be transitioned properlypublic boolean remove(Lifecycle instance)
public void clear()
public LifecycleStatus getStatus()
public void addLifecycleListener(LifecycleListener listener)
public boolean isRunning()
Copyright © 2002–2018 The Neo4j Graph Database Project. All rights reserved.