|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.opcfoundation.ua.utils.AbstractState<StateType,ErrorType>
public abstract class AbstractState<StateType,ErrorType extends Throwable>
This is a default implementation to IStatefulObject.
This class can be subclassed or used as it.
The state type is parametrized (typically an enumeration).
TODO Remove locks - use spin set and test
IStatefulObject,
Listener for state modifications| Constructor Summary | |
|---|---|
AbstractState(StateType initialState)
Constructor for AbstractState. |
|
AbstractState(StateType initialState,
StateType errorState)
Creates a state with a error state. |
|
| Method Summary | |
|---|---|
void |
addStateListener(StateListener<StateType> listener)
Add on-event listener. |
void |
addStateNotifiable(StateListener<StateType> listener)
Add post-event notification listener. |
protected void |
assertNoError()
assertNoError. |
protected StateType |
attemptSetState(Set<StateType> prerequisiteState,
StateType newState)
Attempts to change the state. |
protected void |
clearError()
clearError. |
ErrorType |
getError()
Get error state or null |
StateType |
getState()
getState. |
boolean |
hasError()
hasError. |
protected boolean |
isStateTransitionAllowed(StateType oldState,
StateType newState)
Checks whether state transition is allowed. |
protected void |
onListenerException(RuntimeException rte)
Override this. |
protected void |
onStateTransition(StateType oldState,
StateType newState)
Override this. |
void |
removeStateListener(StateListener<StateType> listener)
removeStateListener. |
void |
removeStateNotifiable(StateListener<StateType> listener)
removeStateNotifiable. |
protected void |
setError(ErrorType error)
setError. |
protected boolean |
setState(StateType state)
Setter for the field state. |
protected StateType |
setState(StateType state,
Executor listenerExecutor,
Set<StateType> prerequisiteStates)
Set state |
StateType |
waitForState(Set<StateType> set)
Wait until state changes to one of the given states. |
StateType |
waitForState(Set<StateType> set,
long timeout,
TimeUnit unit)
Wait until state changes to one of the given states or until time out occurs. |
StateType |
waitForStateUninterruptibly(Set<StateType> set)
Wait until state changes to one of the given states. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractState(StateType initialState)
Constructor for AbstractState.
initialState - a StateType object.
public AbstractState(StateType initialState,
StateType errorState)
initialState - a StateType object.errorState - a StateType object.| Method Detail |
|---|
public void addStateListener(StateListener<StateType> listener)
addStateListener in interface IStatefulObject<StateType,ErrorType extends Throwable>listener - a StateListener object.public void addStateNotifiable(StateListener<StateType> listener)
addStateNotifiable in interface IStatefulObject<StateType,ErrorType extends Throwable>listener - a StateListener object.public ErrorType getError()
getError in interface IStatefulObject<StateType,ErrorType extends Throwable>public StateType getState()
getState.
getState in interface IStatefulObject<StateType,ErrorType extends Throwable>public boolean hasError()
hasError.
public void removeStateListener(StateListener<StateType> listener)
removeStateListener.
removeStateListener in interface IStatefulObject<StateType,ErrorType extends Throwable>listener - a StateListener object.public void removeStateNotifiable(StateListener<StateType> listener)
removeStateNotifiable.
removeStateNotifiable in interface IStatefulObject<StateType,ErrorType extends Throwable>listener - a StateListener object.
public StateType waitForState(Set<StateType> set)
throws InterruptedException,
ErrorType extends Throwable
waitForState in interface IStatefulObject<StateType,ErrorType extends Throwable>set - states that ends waiting
InterruptedException - if any.
ErrorType - if any.
ErrorType extends Throwable
public StateType waitForState(Set<StateType> set,
long timeout,
TimeUnit unit)
throws InterruptedException,
TimeoutException,
ErrorType extends Throwable
waitForState in interface IStatefulObject<StateType,ErrorType extends Throwable>set - a Set object.timeout - a long.unit - a TimeUnit object.
InterruptedException - thread was interrupted
TimeoutException - timeout occured
ErrorType - if any.
ErrorType extends Throwable
public StateType waitForStateUninterruptibly(Set<StateType> set)
throws ErrorType extends Throwable
waitForStateUninterruptibly in interface IStatefulObject<StateType,ErrorType extends Throwable>set - states that ends waiting
ErrorType - if any.
ErrorType extends Throwable
protected void assertNoError()
throws ErrorType extends Throwable
assertNoError.
ErrorType - if any.
ErrorType extends Throwable
protected StateType attemptSetState(Set<StateType> prerequisiteState,
StateType newState)
prerequisiteState - expected current statenewState - a StateType object.
protected void clearError()
clearError.
protected boolean isStateTransitionAllowed(StateType oldState,
StateType newState)
oldState - a StateType object.newState - a StateType object.
protected void onListenerException(RuntimeException rte)
rte - a RuntimeException object.
protected void onStateTransition(StateType oldState,
StateType newState)
oldState - a StateType object.newState - a StateType object.protected void setError(ErrorType error)
setError.
error - a ErrorType object.protected boolean setState(StateType state)
Setter for the field state.
state - a StateType object.
protected StateType setState(StateType state,
Executor listenerExecutor,
Set<StateType> prerequisiteStates)
state - a StateType object.listenerExecutor - executor for post listener handling or null for immediateprerequisiteStates - old state prerequisite or null
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||