|
Project JXTA | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jxta.util.AbstractSimpleSelectable
net.jxta.endpoint.AbstractMessenger
net.jxta.endpoint.ChannelMessenger
net.jxta.endpoint.AsyncChannelMessenger
Nested Class Summary | |
protected static class |
AsyncChannelMessenger.PendingMessage
|
Nested classes inherited from class net.jxta.util.SimpleSelectable |
SimpleSelectable.IdentityReference |
Field Summary |
Fields inherited from class net.jxta.endpoint.ChannelMessenger |
InsertedServicePrefix, origService, origServiceParam |
Fields inherited from class net.jxta.endpoint.AbstractMessenger |
DEFAULT_MTU, dstAddress |
Fields inherited from class net.jxta.util.AbstractSimpleSelectable |
identityReference |
Fields inherited from interface net.jxta.endpoint.Messenger |
ANYSTATE, BREAKING, BROKEN, CLOSED, CLOSING, CONNECTED, DISCONNECTED, DISCONNECTING, IDLE, RECONCLOSING, RECONNECTING, RECONSATURATED, RESOLCLOSING, RESOLPENDING, RESOLSATURATED, RESOLVED, RESOLVING, SATURATED, SENDING, SENDINGSATURATED, TERMINAL, UNRESOLVABLE, UNRESOLVED, UNRESOLVING, USABLE |
Constructor Summary | |
AsyncChannelMessenger(EndpointAddress baseAddress,
PeerGroupID redirection,
String origService,
String origServiceParam,
int queueSize,
boolean connected)
Create a new AsyncChannelMessenger. |
Method Summary | |
void |
close()
Close this messenger after processing any pending messages. This method is not blocking. Upon return, the messenger will be in one of the non Messenger.USABLE states, which means that no message may be sent through it. Any other effect of this
method, such as an underlying connection being closed, or all pending messages being processed, may be deferred
indefinitely. When the messenger has completely processed the closure request, it will be in one of the Messenger.TERMINAL
states (which are also Messenger.IDLE states). Therefore, if one is interrested in the outcome of the closure, one may wait
for the messenger to be in a Messenger.TERMINAL or Messenger.IDLE state, and check which it is. Messenger.CLOSED denotes success
(all outstanding messages have been sent), as opposed to Messenger.UNRESOLVABLE or Messenger.BROKEN . |
protected abstract void |
connectImpl()
We invoke this method to be placed on the list of channels that are waiting for resolution. |
protected void |
down()
The implementation invokes this method when it becomes broken. |
Messenger |
getChannelMessenger(PeerGroupID redirection,
String service,
String serviceParam)
If applicable, returns another messenger that will send messages to the same destination address than this one, but with the specified default service and serviceParam, possibly rewriting addresses to ensure delivery through the specified redirection. This is not generaly usefull to applications and most messengers will return null. This method is needed by the EndpointService when interacting with Messengers provided by Transport modules. If you are not implementing a Transport module, then you can ignore this method. Important: The channel so obtained is not configured to support the Messenger.sendMessage(Message, String, String,
OutgoingMessageEventListener) legacy method. If use of this method is desired, ChannelMessenger.setMessageWatcher(net.jxta.endpoint.ListenerAdaptor)
must be used first.
By default a channel refuses to make a channel. |
int |
getState()
Returns the current state. |
protected AsyncChannelMessenger.PendingMessage |
peek()
Here, we behave like a queue to the shared messenger. |
protected boolean |
pop()
One message done. |
protected abstract void |
resolPendingImpl()
This is invoked to inform the implementation that this channel is now in the resolPending or resolSaturated state. |
void |
resolve()
Force the messenger to start resolving if it is not resolved yet. Any attempt at sending a message has the same effect, but the message may fail as a result, depending upon the method used. |
void |
sendMessageB(Message msg,
String rService,
String rServiceParam)
Simple sending: blocks until the message was accepted for sending or the messenger is not Messenger.USABLE ; whichever occurs
first. If a service name and service param are specified, they will replace those specified at construction for the
purpose of sending this message only.
Error Handling:
Messenger.sendMessageB(net.jxta.endpoint.Message, java.lang.String, java.lang.String) :
There is no guarantee that a message successfully sent will actually be received. |
boolean |
sendMessageN(Message msg,
String rService,
String rServiceParam)
Sends a message to the destination specified at construction. If a service name and service param are specified, they will replace those specified at construction for the purpose of sending this message only. This method is identical to Messenger.sendMessage(Message, String, String) , except that it does not throw an exception. The invoker
has to retrieve a detailed status from the message if needed.
Error Handling:
Messenger.sendMessageN(net.jxta.endpoint.Message, java.lang.String, java.lang.String) :
There is no guarantee that a message successfully sent will actually be received. |
protected abstract void |
startImpl()
We invoke this method to be placed on the list of channels that have message to send. |
protected void |
up()
The implementation will invoke this method when it becomes resolved, after connectImpl was invoked. |
Methods inherited from class net.jxta.endpoint.ChannelMessenger |
effectiveParam, effectiveService, sendMessage, setMessageWatcher |
Methods inherited from class net.jxta.endpoint.AbstractMessenger |
flush, getDestinationAddress, getDestinationAddressObject, getMTU, isClosed, isIdle, isSynchronous, itemChanged, sendMessage, sendMessage, setStateLock, waitState |
Methods inherited from class net.jxta.util.AbstractSimpleSelectable |
getIdentityReference, haveListeners, notifyChange, register, registerListener, unregister, unregisterListener |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.jxta.endpoint.Messenger |
flush, getDestinationAddress, getDestinationAddressObject, getLogicalDestinationAddress, getMTU, isClosed, isIdle, isSynchronous, sendMessage, sendMessage, waitState |
Methods inherited from interface net.jxta.util.SimpleSelectable |
getIdentityReference, itemChanged, register, unregister |
Constructor Detail |
public AsyncChannelMessenger(EndpointAddress baseAddress, PeerGroupID redirection, String origService, String origServiceParam, int queueSize, boolean connected)
baseAddress
- The network address messages go to; regardless of service, param, or group.redirection
- Group to which the messages must be redirected. This is used to implement the automatic group
seggregation which has become a de-facto standard. If not null, the unique portion of the specified groupID is
prepended with ChannelMessenger.InsertedServicePrefix
and inserted in every message's destination address in place of the
the original service name, which gets shifted into the begining of the service parameter. The opposite is done
on arrival to restore the original destination address before the message is delivered to the listener in the
the specified group. Messages that already bear a group redirection are not affected.origService
- The default destination service for messages sent without specifying a different service.origServiceParam
- The default destination service parameter for messages sent without specifying a different service
parameter.queueSize
- the queue size that channels should have.connected
- true if the channel is created in the connected state.Method Detail |
public final void close()
Messenger.USABLE
states, which means that no message may be sent through it. Any other effect of this
method, such as an underlying connection being closed, or all pending messages being processed, may be deferred
indefinitely. When the messenger has completely processed the closure request, it will be in one of the Messenger.TERMINAL
states (which are also Messenger.IDLE
states). Therefore, if one is interrested in the outcome of the closure, one may wait
for the messenger to be in a Messenger.TERMINAL
or Messenger.IDLE
state, and check which it is. Messenger.CLOSED
denotes success
(all outstanding messages have been sent), as opposed to Messenger.UNRESOLVABLE
or Messenger.BROKEN
.
public final boolean sendMessageN(Message msg, String rService, String rServiceParam)
Messenger.sendMessage(Message, String, String)
, except that it does not throw an exception. The invoker
has to retrieve a detailed status from the message if needed.
Error Handling:
false
indicates that the message was not accepted to be sent. This may be due to
local resource limits being reached or to the messenger being in a state that is not Messenger.USABLE
or to the message
being invalid. The exact cause of the failure can be retrieved from the message by using
Message.getMessageProperty(Messenger.class)
. If appropriate,
another attempt at sending the message, may be made after waiting for the congestion to clear (for example by using
Messenger.waitState(int, long)
).true
indicates that the message was accepted for sending. It does not imply that
the message will be sent or that the destination will receive the message. There will be no indication by this method
of any errors in sending the message. If this messenger subsequently reaches an Messenger.IDLE
state that is either Messenger.CLOSED
or a Messenger.USABLE
state, then it may be inferred that all outsdanding messages have been processed without this
messenger detecting an error.Message.getMessageProperty(Messenger.class)
will return an object of class OutgoingMessageEvent
. Changes in a message's set of properties may be tracked by
selecting the message.
Messenger.sendMessageN(net.jxta.endpoint.Message, java.lang.String, java.lang.String)
:
messenger.sendMessageN( (Message) myMessage.clone(), theService, theParam );
There is no guarantee that a message successfully sent will actually be received.
msg
- The message to send.rService
- Optionally replaces the service in the destination
address. If null
then the destination address's default
service will be used. If the empty string ("") is used then
no service is included in the destination address.rServiceParam
- Optionally replaces the service param in the
destination address. If null
then the destination address's
default service parameter will be used. If the empty string ("") is used
then no service param is included in the destination address.
true
if the message has been accepted for sending, otherwise false
.public final void sendMessageB(Message msg, String rService, String rServiceParam) throws IOException
Messenger.USABLE
; whichever occurs
first. If a service name and service param are specified, they will replace those specified at construction for the
purpose of sending this message only.
Error Handling:
IOException
means that this message is invalid or that this messenger is now in one of the non Messenger.USABLE
states and may no longer send new messages, and means that the message was not sent. The exact state of the
messenger may be obtained from the Messenger.getState()
method. If no exception is thrown, the message is accepted for
sending and may or may not be fully processed.Message#getMessageProperty(Messenger.class)
will return an
object of class OutgoingMessageEvent
. Changes in a message's set of properties may be tracked by selecting the
message. If an exception was thrown, the message's properties will not be modified
Messenger.IDLE
state that is either Messenger.CLOSED
or a Messenger.USABLE
state, then it may be inferred
that all outsdanding messages have been processed without this messenger detecting an error.Messenger.sendMessageB(net.jxta.endpoint.Message, java.lang.String, java.lang.String)
:
messenger.sendMessageB( (Message) myMessage.clone(), theService, theParam );
There is no guarantee that a message successfully sent will actually be received.
rService
- Optionally replaces the service in the destination
address. If null
then the destination address's default
service will be used. If the empty string ("") is used then
no service is included in the destination address.rServiceParam
- Optionally replaces the service param in the
destination address. If null
then the destination address's
default service parameter will be used. If the empty string ("") is used
then no service param is included in the destination address.
IOException
- Thrown if the message cannot be sent.public final void resolve()
public final int getState()
public final Messenger getChannelMessenger(PeerGroupID redirection, String service, String serviceParam)
Messenger.sendMessage(Message, String, String,
OutgoingMessageEventListener)
legacy method. If use of this method is desired, ChannelMessenger.setMessageWatcher(net.jxta.endpoint.ListenerAdaptor)
must be used first.
By default a channel refuses to make a channel.
getChannelMessenger
in interface Messenger
getChannelMessenger
in class ChannelMessenger
protected void up()
protected void down()
protected AsyncChannelMessenger.PendingMessage peek()
protected boolean pop()
protected abstract void startImpl()
protected abstract void connectImpl()
protected abstract void resolPendingImpl()
|
JXTA J2SE | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |