|
Project JXTA | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jxta.endpoint.MessengerState
This class implements the complete standard messenger life cycle state machine that all messengers must obey. Compliant
messengers can be built by implementing and using this class as an engine to orchestrate descreet operations.
In order to use this class, one must implement the various abstract Action methods, so that they trigger the required
operations.
Synchronization has to be externally provided and usualy needs to extend around sections wider than just
the invocation of this classe's methods. For example, if the user of this class maintains a queue, the state of the
queue must be kept consistent with the invocation of msgsEvent()
, saturatedEvent()
, and idleEvent()
, which all
denote different states of that queue. It is suggested to use the instance of this class as the synchronization object.
Constructor Summary | |
protected |
MessengerState(boolean connected)
Constructs a new messenger state machine. |
Method Summary | |
void |
closeEvent()
|
protected abstract void |
closeInputAction()
Reject new messages from now on. |
protected abstract void |
closeOutputAction()
Force close output. |
protected abstract void |
connectAction()
Try to make a connection. |
void |
downEvent()
|
protected abstract void |
failAllAction()
Drain pending messages, all failed. |
int |
getState()
|
void |
idleEvent()
|
void |
msgsEvent()
|
void |
resolveEvent()
Event input. |
void |
saturatedEvent()
|
void |
shutdownEvent()
|
protected abstract void |
startAction()
Start sending. |
void |
upEvent()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected MessengerState(boolean connected)
connected
- If true, the initial state is Messenger.CONNECTED
else, Messenger.UNRESOLVED
.Method Detail |
public int getState()
public void resolveEvent()
public void msgsEvent()
public void saturatedEvent()
public void closeEvent()
public void shutdownEvent()
public void upEvent()
public void downEvent()
public void idleEvent()
protected abstract void connectAction()
protected abstract void startAction()
idleEvent()
when no pending message is left.
protected abstract void closeInputAction()
Messenger.USABLE
to a state
that is not. No event expected once done.
protected abstract void failAllAction()
idleEvent()
when done, as a normal result of no pending messages being left.
protected abstract void closeOutputAction()
downEvent()
, if the output closure caused the sending process to fail, or with an idleEvent()
if the sending of the last message could be sent successfully despite the attempt at interrupting it.
Sending is said to be in progress if, and only if, the last call to startAction is more recent than the last call to
idleEvent()
or downEvent()
.
It is advisable to also cancel an ongoing connect action, but not mandatory. If a connectAction()
later succeeds,
then upEvent()
must be called as usual. This will result in another call to closeOutputAction()
.
|
JXTA J2SE | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |