| Constructor and Description |
|---|
AbstractLifeCycle() |
| Modifier and Type | Method and Description |
|---|---|
void |
addStateListener(StateListener listener)
Add a new
StateListener |
protected void |
changeState(State from,
State to)
First changes the state from a current value to a target
value.
|
protected abstract void |
doInitLifeCycle()
Similar to
initLifeCycle() for inherited classes. |
protected void |
doPause()
Similar to
pause() for inherited classes. |
protected void |
doResume()
Similar to
resume() for inherited classes. |
protected abstract void |
doStartLifeCycle()
Similar to
startLifeCycle() for inherited classes. |
protected abstract void |
doStopLifeCycle()
Similar to
stopLifeCycle() for inherited classes. |
State |
getState() |
Collection<StateListener> |
getStateListeners() |
void |
initLifeCycle()
Initializes the life cycle before invoking
LifeCycle.startLifeCycle(). |
void |
pause()
Makes an attempt to pause the resumable.
|
protected void |
publishState(State from,
State to)
Propagates a change of
State to all the
StateListenerregistered with this life cycle
object. |
void |
removeStateListener(StateListener listener)
Remove a registered
StateListener |
void |
resume()
Makes an attempt to resume a paused resumable.
|
void |
startLifeCycle()
Starts the life cycle.
|
void |
stopLifeCycle()
Stops the life cycle.
|
String |
toString() |
public State getState()
public Collection<StateListener> getStateListeners()
getStateListeners in interface StatefulStateListener for this.public void initLifeCycle()
throws Exception
LifeCycleLifeCycle.startLifeCycle(). It is expected that
Stateful.getState() should be State.INITIALIZED
after completion of this method.initLifeCycle in interface LifeCycleException - expected to be thrown if the
initialization cannot be complete.public void startLifeCycle()
throws Exception
LifeCycleStateful.getState() should be State.STARTING while
the method is not finished and State.RUNNING on
successful completion.startLifeCycle in interface LifeCycleException - should be thrown if the starting of the
life cycle object cannot complete.public void pause()
throws Exception
Resumablepublic void resume()
throws Exception
Resumablepublic void stopLifeCycle()
throws Exception
LifeCycleStateful.getState() should be State.STOPPING while
the method is not finished and State.STOPPED on
successful completion.stopLifeCycle in interface LifeCycleException - should be thrown if the stopping fails.
It is recommended to perform clean-up guidelines.
In addition, it is recommended to still fail in a
state such that killing JVM process does not have a
corruptive effect on the state.public void addStateListener(StateListener listener)
StateListenerlistener - the StateListener to addpublic void removeStateListener(StateListener listener)
StateListenerlistener - the StateListener to removeprotected void changeState(State from, State to) throws Exception
getStateListeners().from - the current stateto - the new stateException - if the state cannot be changed or some
StateListenerfailed to apply the same
change.protected void publishState(State from, State to) throws Exception
State to all the
StateListenerregistered with this life cycle
object.from - the old stateto - the new stateException - if a listener fails to accept the changechangeState(State, State)protected abstract void doInitLifeCycle()
throws Exception
initLifeCycle() for inherited classes.Exception - See initLifeCycle()LifeCycle.initLifeCycle()protected abstract void doStartLifeCycle()
throws Exception
startLifeCycle() for inherited classes.Exception - See startLifeCycle()LifeCycle.startLifeCycle()protected void doPause()
throws Exception
pause() for inherited classes.Exception - See pause()Resumable.pause()protected void doResume()
throws Exception
resume() for inherited classes.Exception - See resume()Resumable.resume()protected abstract void doStopLifeCycle()
throws Exception
stopLifeCycle() for inherited classes.Exception - See stopLifeCycle()LifeCycle.stopLifeCycle()Copyright © 2015 SDL Fredhopper. All rights reserved.