Project JXTA

net.jxta.impl.endpoint.router
Class RouterMessenger

java.lang.Object
  extended bynet.jxta.util.AbstractSimpleSelectable
      extended bynet.jxta.endpoint.AbstractMessenger
          extended bynet.jxta.impl.endpoint.BlockingMessenger
              extended bynet.jxta.impl.endpoint.router.RouterMessenger
All Implemented Interfaces:
Messenger, SimpleSelectable

class RouterMessenger
extends BlockingMessenger

Messenger for destinations which are logical peers. This messenger is used only at the origin of routes. Incoming messages that are being forwarded to another peer to not go through here.


Nested Class Summary
 
Nested classes inherited from class net.jxta.util.SimpleSelectable
SimpleSelectable.IdentityReference
 
Field Summary
protected  EndpointRouter router
          The router we are working for.
 
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
RouterMessenger(EndpointAddress srcAddress, EndpointAddress dstAddress, EndpointRouter r, Object hint)
          Constructor for a RouterMessenger.
 
Method Summary
 void closeImpl()
          Close connection.
 EndpointAddress getLogicalDestinationImpl()
          Obtain the logical destination address from the implementer (a transport for example).
 boolean isIdleImpl()
          return true if this messenger has not been used for a long time.
 boolean sendMessageBImpl(Message message, String service, String serviceParam)
          send message. block as needed. throw IOException or runtime exception as needed. The boolean return value is for historical reasons: so that transports just need to rename their sendMessage() methods. No need to change a bit of the code.
 
Methods inherited from class net.jxta.impl.endpoint.BlockingMessenger
close, getChannelMessenger, getDestAddressToUse, getLogicalDestinationAddress, getState, isClosed, resolve, sendMessageB, sendMessageN, setOwner, shutdown
 
Methods inherited from class net.jxta.endpoint.AbstractMessenger
flush, getDestinationAddress, getDestinationAddressObject, getMTU, isIdle, isSynchronous, itemChanged, sendMessage, 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.util.SimpleSelectable
getIdentityReference, register, unregister
 

Field Detail

router

protected EndpointRouter router
The router we are working for. Also who we make route queries to.

Constructor Detail

RouterMessenger

public RouterMessenger(EndpointAddress srcAddress,
                       EndpointAddress dstAddress,
                       EndpointRouter r,
                       Object hint)
                throws IOException
Constructor for a RouterMessenger.

Parameters:
srcAddress - the peer which will be identified as the message sender.
dstAddress - the peer which is the final destination of the message.
r - the router which this messenger is servicing.
hint - potential hint information that we passed
Throws:
IOException - Thrown if the messenger cannot be constructed for this destination.
Method Detail

getLogicalDestinationImpl

public EndpointAddress getLogicalDestinationImpl()
Description copied from class: BlockingMessenger
Obtain the logical destination address from the implementer (a transport for example).

Specified by:
getLogicalDestinationImpl in class BlockingMessenger

closeImpl

public void closeImpl()
Description copied from class: BlockingMessenger
Close connection. May fail current send.

Specified by:
closeImpl in class BlockingMessenger

isIdleImpl

public boolean isIdleImpl()
Description copied from class: BlockingMessenger
return true if this messenger has not been used for a long time. The definition of long time is: "so long that closing it is worth the risk of having to re-open". A messenger should self close if it thinks it meets the definition of idle. BlockingMessenger leaves the evaluation to the transport but does the work automatically. Important: if self destruction is used, this method must work; not just return false. See the constructor. In general, if closeImpl does not need to do anyhing, then self destruction is not needed.

Specified by:
isIdleImpl in class BlockingMessenger

sendMessageBImpl

public boolean sendMessageBImpl(Message message,
                                String service,
                                String serviceParam)
                         throws IOException
send message. block as needed. throw IOException or runtime exception as needed. The boolean return value is for historical reasons: so that transports just need to rename their sendMessage() methods. No need to change a bit of the code.

Specified by:
sendMessageBImpl in class BlockingMessenger
Throws:
IOException

JXTA J2SE