|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.grizzly.utils.StateHolder<E>
public class StateHolder<E>
Class, which holds the state. Provides API for state change notification, state read/write access locking.
| Constructor Summary | |
|---|---|
StateHolder()
Constructs StateHolder. |
|
StateHolder(boolean isLockEnabled)
Constructs StateHolder. |
|
StateHolder(boolean isLockEnabled,
E initialState)
Constructs StateHolder. |
|
| Method Summary | |
|---|---|
void |
addConditionListener(ConditionListener<E,?> conditionListener)
Add new ConditionListener to listen this StateHolder's
state changes. |
E |
getState()
Gets current state Current StateHolder locking mode will be used |
E |
getState(boolean locked)
Gets current state |
ReentrantReadWriteLock |
getStateLocker()
Gets Read/Write locker, which is used by this StateHolder |
boolean |
isLockEnabled()
Gets current locking mode |
protected void |
notifyConditionListeners(E state)
|
ConditionListener |
notifyWhenConditionMatchState(Condition<E> condition,
Object notificationObject)
Register listener, which will be notified, when state will match the condition. |
ConditionListener<E,Object> |
notifyWhenStateIsEqual(E state,
Object notificationObject)
Register listener, which will be notified, when state will be equal to passed one. |
ConditionListener<E,Object> |
notifyWhenStateIsNotEqual(E state,
Object notificationObject)
Register listener, which will be notified, when state will become not equal to passed one. |
void |
removeConditionListener(ConditionListener<E,?> conditionListener)
|
void |
setState(E state)
Sets current state Current StateHolder locking mode will be used |
void |
setState(E state,
boolean locked)
Sets current state |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StateHolder()
StateHolder.
StateHolder will work in not-locking mode.
public StateHolder(boolean isLockEnabled)
StateHolder.
isLockEnabled - locking mode
public StateHolder(boolean isLockEnabled,
E initialState)
StateHolder.
isLockEnabled - locking mode| Method Detail |
|---|
public E getState()
public E getState(boolean locked)
locked - if true, get will be invoked in locking mode, false - non-locked
public void setState(E state)
state -
public void setState(E state,
boolean locked)
state - locked - if true, set will be invoked in locking mode, false - non-lockingpublic ReentrantReadWriteLock getStateLocker()
StateHolder
public boolean isLockEnabled()
public ConditionListener<E,Object> notifyWhenStateIsEqual(E state,
Object notificationObject)
StateHolder's listener set.
state - State, listener is interested innotificationObject - Object, which will be notified. This StateHolder
implementation works with Runnable, Callable, CountDownLatch, Object
listeners
ConditionListener, if current state is not equal to required
and listener was registered, null if current state is equal to required.
In both cases listener will be notified
public ConditionListener<E,Object> notifyWhenStateIsNotEqual(E state,
Object notificationObject)
StateHolder's listener set.
state - State, listener is interested innotificationObject - Object, which will be notified. This StateHolder
implementation works with Runnable, Callable, CountDownLatch, Object
listeners
ConditionListener, if current state is equal to required
and listener was registered, null if current state is not equal to required.
In both cases listener will be notified
public ConditionListener notifyWhenConditionMatchState(Condition<E> condition,
Object notificationObject)
StateHolder's listener set.
condition - Condition, the listener is interested innotificationObject - Object, which will be notified. This StateHolder
implementation works with Runnable, Callable, CountDownLatch, Object
listeners
ConditionListener, if current state doesn't match the condition
and listener was registered, null if current state matches the condition.
In both cases listener will be notifiedpublic void addConditionListener(ConditionListener<E,?> conditionListener)
ConditionListener to listen this StateHolder's
state changes.
conditionListener - public void removeConditionListener(ConditionListener<E,?> conditionListener)
protected void notifyConditionListeners(E state)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||