java.lang.Object
net.jxta.util.AbstractSimpleSelectable
net.jxta.endpoint.AbstractMessenger
net.jxta.impl.endpoint.BlockingMessenger
net.jxta.impl.endpoint.LoopbackMessenger
- All Implemented Interfaces:
- net.jxta.endpoint.Messenger, net.jxta.util.SimpleSelectable
- public class LoopbackMessenger
- extends BlockingMessenger
This class implements local delivery of messages ( for example when the
InputPipe and the OutputPipe are located on the same peer)
The reason this class is useful is that it may not always be possible to
connect to oneself without actually going to a relay. If your peer is an
http client, it is not able to connect to self through the normal http
transport.
Since transports cannot be relied on to perform a loopback, some layer
above has to figure out that a message is looping back.
Since peerid loopback does not explicitly request to go through a real
transport, and since peerid addressing is the job of the router, it is
the router that performs loopback.
The router could probably perform the lookback by delivering the message
to its own input queue, that would take a special transport instead of a
special messenger, which is the same kind of deal but would imply some
incoming message processing by the router for every message. In
contrast, the loopback messenger is setup once and the router will never
sees the messages. That's a good optimization.
Alternatively, the endpoint service itself could figure out the
loopback, but since the API wants to give a messenger to the requestor
rather than just sending a message, the endpoint would have to setup a
loopback messenger anyway. So it is pretty much the same.
Anyone with a better way, speak up.
J-C
| Nested classes inherited from class net.jxta.util.SimpleSelectable |
net.jxta.util.SimpleSelectable.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 |
| 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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LOG
private static final org.apache.log4j.Logger LOG
srcAddress
private net.jxta.endpoint.EndpointAddress srcAddress
- The source address of messages sent on this messenger.
srcAddressElement
private net.jxta.endpoint.MessageElement srcAddressElement
logicalDestination
private net.jxta.endpoint.EndpointAddress logicalDestination
endpoint
net.jxta.endpoint.EndpointService endpoint
- The endpoint we are working for, ie. that we will loop back to.
LoopbackMessenger
public LoopbackMessenger(net.jxta.endpoint.EndpointService ep,
net.jxta.endpoint.EndpointAddress src,
net.jxta.endpoint.EndpointAddress dest,
net.jxta.endpoint.EndpointAddress logicalDest)
- Create a new loopback messenger.
getLogicalDestinationImpl
public net.jxta.endpoint.EndpointAddress getLogicalDestinationImpl()
- null
- Specified by:
getLogicalDestinationImpl in class BlockingMessenger
isIdleImpl
public boolean isIdleImpl()
- null
- Specified by:
isIdleImpl in class BlockingMessenger
closeImpl
public void closeImpl()
- null
- Specified by:
closeImpl in class BlockingMessenger
sendMessageBImpl
public boolean sendMessageBImpl(net.jxta.endpoint.Message message,
java.lang.String service,
java.lang.String serviceParam)
throws java.io.IOException
- Sends a message to the destination
- Specified by:
sendMessageBImpl in class BlockingMessenger