JXTA

net.jxta.impl.endpoint.servlethttp
Class HttpMessageSender

java.lang.Object
  extended by net.jxta.impl.endpoint.servlethttp.HttpMessageSender
All Implemented Interfaces:
MessageSender, MessageTransport

 class HttpMessageSender
extends Object
implements MessageSender

Simple Client MessageSender


Constructor Summary
HttpMessageSender(ServletHttpTransport servletHttpTransport, EndpointAddress publicAddress)
          constructor
 
Method Summary
 boolean allowsRouting()
          Returns true if the Message Transport can be used by the EndpointRouter.
 EndpointService getEndpointService()
          Returns the endpoint service with which this MessageTransport is registered.
 Messenger getMessenger(EndpointAddress destAddr, Object hintIgnored)
          Return a Messenger for sending messages to the specified destination EndpointAddress.
 String getProtocolName()
          Returns a String containing the name of the protocol used by this MessageTransport.
 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 Message Transport is connection oriented (like TCP/IP).
 boolean ping(EndpointAddress addr)
          Returns true if the specified destination address is reachable via this Message Transport otherwise returns false.
 void start()
          shut down all client connections.
 void stop()
          shut down all client connections.
 Object transportControl(Object operation, Object Value)
          Pass a transport control object to a message transport.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpMessageSender

public HttpMessageSender(ServletHttpTransport servletHttpTransport,
                         EndpointAddress publicAddress)
                  throws PeerGroupException
constructor

Throws:
PeerGroupException
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 "preferred" address to which replies should 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.

Specified by:
getPublicAddress in interface MessageSender
Returns:
an EndpointAddress containing the public address for this message receiver.

isConnectionOriented

public boolean isConnectionOriented()
Returns true if the Message Transport is connection oriented (like TCP/IP). Indicates that the Message Transport can provide efficient transport of a series of messages to the same destination.

Specified by:
isConnectionOriented in interface MessageSender
Returns:
true if the Message Transport is connection oriented.

allowsRouting

public boolean allowsRouting()
Returns true if the Message Transport can be used by the EndpointRouter. Indicates that the Message Transport can be used in the routing of messages to destinations which are not directly reachable via this transport.

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

Specified by:
allowsRouting in interface MessageSender
Returns:
true if the protocol can be used by the EndpointRouter

transportControl

public Object transportControl(Object operation,
                               Object Value)
Pass a transport control object to a message transport.

Specified by:
transportControl in interface MessageTransport
Parameters:
operation - Object that specifies the type of control operation to be performed
Value - Object that specifies a value object associated with the control operation
Returns:
returned object

start

public void start()
           throws PeerGroupException
shut down all client connections.

Throws:
PeerGroupException

stop

public void stop()
shut down all client connections.


getMessenger

public Messenger getMessenger(EndpointAddress destAddr,
                              Object hintIgnored)
Return a Messenger for sending messages to the specified destination EndpointAddress.

Specified by:
getMessenger in interface MessageSender
Parameters:
destAddr - The destination address for which a messenger is requested.
hintIgnored - An optional hint for the transport to use when creating the messenger. The format of the hint is specific to each Message Transport and may be null if no hint is provided.
Returns:
a Messenger or null if the destination is not reachable.

ping

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

Specified by:
ping in interface MessageSender
Parameters:
addr - Address to ping
Returns:
true if the specified destination address is reachable via this Message Transport otherwise returns false.

getProtocolName

public String getProtocolName()
Returns a String containing the name of the protocol used by this MessageTransport. The value will match the "protocol" portion of all EndpointAddress.

Specified by:
getProtocolName in interface MessageTransport
Returns:
a String containing the name of the protocol used by this MessageTransport.

getEndpointService

public EndpointService getEndpointService()
Returns the endpoint service with which this MessageTransport is registered. If it is unregistered then null will be returned.

Specified by:
getEndpointService in interface MessageTransport
Returns:
the EndpointService with which this MessageTransport is registered.

JXSE