public class Lifecycle extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Lifecycle.Handler |
static class |
Lifecycle.Stage |
Constructor and Description |
---|
Lifecycle() |
Modifier and Type | Method and Description |
---|---|
void |
addHandler(Lifecycle.Handler handler)
Adds a handler to the Lifecycle at the Stage.NORMAL stage.
|
void |
addHandler(Lifecycle.Handler handler,
Lifecycle.Stage stage)
Adds a handler to the Lifecycle.
|
<T> T |
addManagedInstance(T o)
Adds a "managed" instance (annotated with
LifecycleStart and LifecycleStop ) to the Lifecycle at
Stage.NORMAL. |
<T> T |
addManagedInstance(T o,
Lifecycle.Stage stage)
Adds a "managed" instance (annotated with
LifecycleStart and LifecycleStop ) to the Lifecycle. |
void |
addMaybeStartHandler(Lifecycle.Handler handler)
Adds a handler to the Lifecycle at the Stage.NORMAL stage and starts it if the lifecycle has already been started.
|
void |
addMaybeStartHandler(Lifecycle.Handler handler,
Lifecycle.Stage stage)
Adds a handler to the Lifecycle and starts it if the lifecycle has already been started.
|
<T> T |
addMaybeStartManagedInstance(T o)
Adds a "managed" instance (annotated with
LifecycleStart and LifecycleStop ) to the Lifecycle at
Stage.NORMAL and starts it if the lifecycle has already been started. |
<T> T |
addMaybeStartManagedInstance(T o,
Lifecycle.Stage stage)
Adds a "managed" instance (annotated with
LifecycleStart and LifecycleStop ) to the Lifecycle
and starts it if the lifecycle has already been started. |
<T> T |
addMaybeStartStartCloseInstance(T o)
Adds an instance with a start() and/or close() method to the Lifecycle at Stage.NORMAL and starts it if the
lifecycle has already been started.
|
<T> T |
addMaybeStartStartCloseInstance(T o,
Lifecycle.Stage stage)
Adds an instance with a start() and/or close() method to the Lifecycle and starts it if the lifecycle has
already been started.
|
<T> T |
addStartCloseInstance(T o)
Adds an instance with a start() and/or close() method to the Lifecycle at Stage.NORMAL.
|
<T> T |
addStartCloseInstance(T o,
Lifecycle.Stage stage)
Adds an instance with a start() and/or close() method to the Lifecycle.
|
void |
ensureShutdownHook() |
boolean |
isStarted() |
void |
join() |
void |
start() |
void |
stop() |
public <T> T addManagedInstance(T o)
LifecycleStart
and LifecycleStop
) to the Lifecycle at
Stage.NORMAL. If the lifecycle has already been started, it throws an ISE
o
- The object to add to the lifecycleISE
- addHandler(Handler, Stage)
public <T> T addManagedInstance(T o, Lifecycle.Stage stage)
LifecycleStart
and LifecycleStop
) to the Lifecycle.
If the lifecycle has already been started, it throws an ISE
o
- The object to add to the lifecyclestage
- The stage to add the lifecycle atISE
- addHandler(Handler, Stage)
public <T> T addStartCloseInstance(T o)
ISE
o
- The object to add to the lifecycleISE
- addHandler(Handler, Stage)
public <T> T addStartCloseInstance(T o, Lifecycle.Stage stage)
ISE
o
- The object to add to the lifecyclestage
- The stage to add the lifecycle atISE
- addHandler(Handler, Stage)
public void addHandler(Lifecycle.Handler handler)
ISE
handler
- The hander to add to the lifecycleISE
- addHandler(Handler, Stage)
public void addHandler(Lifecycle.Handler handler, Lifecycle.Stage stage)
ISE
handler
- The hander to add to the lifecyclestage
- The stage to add the lifecycle atISE
- indicates that the lifecycle has already been started and thus cannot be added topublic <T> T addMaybeStartManagedInstance(T o) throws Exception
LifecycleStart
and LifecycleStop
) to the Lifecycle at
Stage.NORMAL and starts it if the lifecycle has already been started.o
- The object to add to the lifecycleException
- addMaybeStartHandler(Handler, Stage)
public <T> T addMaybeStartManagedInstance(T o, Lifecycle.Stage stage) throws Exception
LifecycleStart
and LifecycleStop
) to the Lifecycle
and starts it if the lifecycle has already been started.o
- The object to add to the lifecyclestage
- The stage to add the lifecycle atException
- addMaybeStartHandler(Handler, Stage)
public <T> T addMaybeStartStartCloseInstance(T o) throws Exception
o
- The object to add to the lifecycleException
- addMaybeStartHandler(Handler, Stage)
public <T> T addMaybeStartStartCloseInstance(T o, Lifecycle.Stage stage) throws Exception
o
- The object to add to the lifecyclestage
- The stage to add the lifecycle atException
- addMaybeStartHandler(Handler, Stage)
public void addMaybeStartHandler(Lifecycle.Handler handler) throws Exception
handler
- The hander to add to the lifecycleException
- addMaybeStartHandler(Handler, Stage)
public void addMaybeStartHandler(Lifecycle.Handler handler, Lifecycle.Stage stage) throws Exception
handler
- The hander to add to the lifecyclestage
- The stage to add the lifecycle atException
- an exception thrown from handler.start(). If an exception is thrown, the handler is *not* addedpublic void stop()
public void ensureShutdownHook()
public void join() throws InterruptedException
InterruptedException
public boolean isStarted()
Copyright © 2011–2017. All rights reserved.