Project JXTA

net.jxta.endpoint
Interface MessageSender

All Superinterfaces:
MessageTransport

public interface MessageSender
extends MessageTransport

A MessageSender is a MessageTransport that is able to send messages to remote peers using some protocol. MessageSenders provide facilities for:

MessageSenders additionally describe themselves in terms of their abilities. isConnectionOriented() indicates that the MessageTransport can provide effcient transport of a series of messages to the same destination. {link@ #allowRouting()} indicates if the Transport should be used in the routing of messages to destinations which are not directly reachable via this transport.

See Also:
MessageTransport, EndpointMessenger, EndpointService, MessageReceiver, NewMessage

Method Summary
 boolean allowRouting()
          Returns true if the endpoint protocol can be used by the EndpointRouter.
 EndpointMessenger getMessenger(EndpointAddress dest)
          Creates an EndpointMessenger for sending messages to the specified destination EndpointAddress.
 EndpointAddress getPublicAddress()
          Returns the EndpointAddress which will be used as the source address for all messages sent by this message sender.
 boolean isConnectionOriented()
          Returns true if the endpoint protocol can establish connection to the remote host (like TCP).
 boolean ping(EndpointAddress addr)
          Returns true if the target address is reachable via this Message Transport otherwise returns false.
 void propagate(NewMessage msg, java.lang.String serviceName, java.lang.String serviceParams, java.lang.String prunePeer)
          Propagates a Message on this EndpointProtocol.
 
Methods inherited from interface net.jxta.endpoint.MessageTransport
equals, getProtocolName
 

Method Detail

getPublicAddress

public EndpointAddress getPublicAddress()
Returns the EndpointAddress which will be used as the source address for all messages sent by this message sender. This is the "prefered" address to which replies may be sent. This address is not necessarily the best or only address by which the peer may be reached.
Returns:
an EndpointAddress containing the public address for this message receiver.

isConnectionOriented

public boolean isConnectionOriented()
Returns true if the endpoint protocol can establish connection to the remote host (like TCP).
Returns:
boolean true if the protocol is connection oriented.

allowRouting

public boolean allowRouting()
Returns true if the endpoint protocol can be used by the EndpointRouter.

More specifically, this protocol will be used to route messages who's final destination is not one of the endpoint addresses available from getReachableEndpointAddresses.

Returns:
boolean true if the protocol can be used by the EndpointRouter

getMessenger

public EndpointMessenger getMessenger(EndpointAddress dest)
                               throws java.io.IOException
Creates an EndpointMessenger for sending messages to the specified destination EndpointAddress.

FIXME 20020709 bondolo@jxta.org This needs to be more clear about when null is returned and when an exception is thrown. In some cases, an IllegalArgumentException is also being thrown.

Parameters:
dest - EndpointAddress of the destination
Returns:
an EndpointMessenger. null is returned if the EndpointAddress is not reachable.
Throws:
java.io.IOException - when the Endpoint Transport was unable to create an Endpoint Messenger for the given Endpoint Address.

propagate

public void propagate(NewMessage msg,
                      java.lang.String serviceName,
                      java.lang.String serviceParams,
                      java.lang.String prunePeer)
               throws java.io.IOException
Propagates a Message on this EndpointProtocol.
Parameters:
msg - the Message to be propagated
serviceName - Contains the name of the destination service, if any. This will be integrated into the destination address.
serviceParams - Contains the parameters associated with the service, if any. This will be integrated into the destination address.
prunePeer - a peer which should not receive the propagated message or null for all peers. This is sometimes used in flooding type algorithms to avoid sending to the peer that this received the message from.
Throws:
java.io.IOException - is thrown when the message could not be propagated.

ping

public boolean ping(EndpointAddress addr)
Returns true if the target address is reachable via this Message Transport otherwise returns false.
Returns:
boolean true if this protocol claims it can reach the given address otherwise false.

Project JXTA