public class Lifecycle extends Object
Also allows to stay in the same state. For example, when calling stop on a component, the following logic can be applied:
public void stop() { if (!lifeccycleState.moveToStopped()) { return; } // continue with stop logic }
Note, closed is only allowed to be called when stopped, so make sure to stop the component first. Here is how the logic can be applied:
public void close() { if (lifecycleState.started()) { stop(); } if (!lifecycleState.moveToClosed()) { return; } // perofrm close logic here }
Modifier and Type | Class and Description |
---|---|
static class |
Lifecycle.State |
Constructor and Description |
---|
Lifecycle() |
Modifier and Type | Method and Description |
---|---|
boolean |
canMoveToClosed() |
boolean |
canMoveToStarted() |
boolean |
canMoveToStopped() |
boolean |
closed()
Returns true if the state is closed.
|
boolean |
initialized()
Returns true if the state is initialized.
|
boolean |
moveToClosed() |
boolean |
moveToStarted() |
boolean |
moveToStopped() |
boolean |
started()
Returns true if the state is started.
|
Lifecycle.State |
state() |
boolean |
stopped()
Returns true if the state is stopped.
|
boolean |
stoppedOrClosed() |
String |
toString() |
public Lifecycle.State state()
public boolean initialized()
public boolean started()
public boolean stopped()
public boolean closed()
public boolean stoppedOrClosed()
public boolean canMoveToStarted() throws ElasticsearchIllegalStateException
public boolean moveToStarted() throws ElasticsearchIllegalStateException
public boolean canMoveToStopped() throws ElasticsearchIllegalStateException
public boolean moveToStopped() throws ElasticsearchIllegalStateException
public boolean canMoveToClosed() throws ElasticsearchIllegalStateException
public boolean moveToClosed() throws ElasticsearchIllegalStateException
Copyright © 2009–2015. All rights reserved.