|
JXTA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jxta.endpoint.ListenerAdaptor
public class ListenerAdaptor
The legacy getMessenger asynchronous API never returns any object to the invoker until a messenger could actually be made, allowing the application to supply a listener to be invoked when the operation completes. The legacy Messenger API also provides a method to send messages that calls a listener to report the outcome of the operation.
The model has changed, so that an asynchronous messenger is made unresolved and returned immediately to the invoker, which can then request opening or even just send a message to force the opening. Subsequently, the messenger can be used as a control block to monitor progress withSimpleSelectable.register(net.jxta.util.SimpleSelector)
and Messenger.waitState(int, long)
.
Likewise, the outcome of sending a message is a property of that message. Messages can be selected to monitor property changes
with AbstractSimpleSelectable.register(net.jxta.util.SimpleSelector)
and Message.getMessageProperty(Object)
(the outcome property key is
Messenger.class
).
This class here provides the legacy listener model on top of the new model for applications that prefer listeners. This class
is used internally to emulate the legacy listener behaviour, so that applications do not need to be adapted.
Note: one instance of this class gets instantiated by each EndpointService interface. However, it does not start using any
resources until it first gets used.
Constructor Summary | |
---|---|
ListenerAdaptor(ThreadGroup threadGroup)
Standard Constructor |
|
ListenerAdaptor(ThreadGroup threadGroup,
Executor executor)
Creates a ListenerAdaptor with a threadpool for notification callback. |
Method Summary | |
---|---|
void |
run()
|
void |
shutdown()
|
boolean |
watchMessage(OutgoingMessageEventListener listener,
Message message)
Select the given message and invoke the given listener when the message sending is complete. |
boolean |
watchMessenger(MessengerEventListener listener,
Messenger messenger)
Select the given messenger and invoke the given listener when the messenger is resolved. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ListenerAdaptor(ThreadGroup threadGroup)
threadGroup
- The ThreadGroup in which this adaptor will run.public ListenerAdaptor(ThreadGroup threadGroup, Executor executor)
threadGroup
- The ThreadGroup in which this adaptor will run.executor
- the excutor to use for notification callbackMethod Detail |
---|
public void shutdown()
public boolean watchMessage(OutgoingMessageEventListener listener, Message message)
listener
- The listener to invoke. If null the resolution will take place, but obviously no listener will be invoked.message
- The message being sent.
public boolean watchMessenger(MessengerEventListener listener, Messenger messenger)
listener
- The listener to invoke. If null the resolution will take place, but obviously no listener will be invoked.messenger
- The messenger being resolved.
public void run()
run
in interface Runnable
|
JXSE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |