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 that the Message Transport can be used in the routing of messages to destinations which are not directly reachable via this transport.

See Also:
MessageTransport, Messenger, EndpointService, MessageReceiver, Message

Method Summary
 boolean allowsRouting()
          Returns true if the endpoint protocol can be used by the EndpointRouter.
 Messenger getMessenger(EndpointAddress dest, Object hint)
          Creates an Messenger 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 isPropagateEnabled()
          Returns true if propagation is supported, and enabled.
 boolean isPropagationSupported()
          Returns true if propagation is supported.
 boolean ping(EndpointAddress addr)
          Returns true if the target address is reachable via this Message Transport otherwise returns false.
 void propagate(Message msg, String serviceName, String serviceParams, String prunePeer)
          Propagates a Message on this Message Transport.
 
Methods inherited from interface net.jxta.endpoint.MessageTransport
getEndpointService, getProtocolName, transportControl
 

Method Detail

getPublicAddress

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.

The public address may also be for a different message transport.

Returns:
an EndpointAddress containing the public address for this message receiver.

isConnectionOriented

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.

allowsRouting

boolean allowsRouting()
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

Messenger getMessenger(EndpointAddress dest,
                       Object hint)
Creates an Messenger for sending messages to the specified destination EndpointAddress.

Parameters:
dest - EndpointAddress of the destination
hint - A hint for the transport to use when creating the messenger.
Returns:
a Messenger. null is returned if the EndpointAddress is not reachable.

propagate

void propagate(Message msg,
               String serviceName,
               String serviceParams,
               String prunePeer)
               throws IOException
Propagates a Message on this Message Transport.

WARNING: The message object should not be reused or modified after the call is made. Concurrent modifications will produce unexpected result.

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 peer received the message from.
Throws:
IOException - is thrown when the message could not be propagated.

isPropagateEnabled

boolean isPropagateEnabled()
Returns true if propagation is supported, and enabled.

Returns:
true if propagation is supported and enabled otherwise false.

isPropagationSupported

boolean isPropagationSupported()
Returns true if propagation is supported.

Returns:
true if propagation is supported otherwise false.

ping

boolean ping(EndpointAddress addr)
Returns true if the target address is reachable via this Message Transport otherwise returns false.

Returns:
true if the specified endpoint address is reachable otherwise false.

JXTA J2SE