JXTA

net.jxta.impl.endpoint.relay
Class RelayServer

java.lang.Object
  extended by net.jxta.impl.endpoint.relay.RelayServer
All Implemented Interfaces:
Runnable, EventListener, MessageSender, MessageTransport, MessengerEventListener

public class RelayServer
extends Object
implements MessageSender, MessengerEventListener, Runnable

Relay server that maintains outgoing message queues, leases, etc.


Nested Class Summary
(package private) static class RelayServer.BGSend
          Sends a message on an synchronous messenger.
 
Field Summary
protected  AccessList acl
           
protected  File aclFile
           
protected  long aclFileLastModified
           
protected  PeerGroup group
           
protected  String peerId
           
protected  long refreshTime
           
protected  net.jxta.impl.endpoint.relay.RelayServer.RelayServerCache relayServerCache
           
protected  String serviceName
           
 
Constructor Summary
RelayServer(PeerGroup group, String serviceName, RelayConfigAdv relayConfigAdv)
          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.
 List<String> getRelayedClients()
          Debug routine: returns the list of relayedClients with details.
protected  void handleRequest(Message message, EndpointAddress dstAddr)
           
protected  void handleRequest(Messenger messenger, EndpointAddress connectionAddress)
           
(package private)  void handleRequest(String request, String clientPeerId, Messenger messenger)
           
 boolean isConnectionOriented()
          Returns true if the Message Transport is connection oriented (like TCP/IP).
 boolean messengerReady(MessengerEvent event)
          A messenger is ready.
 boolean ping(EndpointAddress addr)
          Deprecated. 
protected  void removeClient(String clientPeerId, RelayServerClient handler)
           
 void run()
          
 boolean startServer()
           
 void stopServer()
           
 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
 

Field Detail

group

protected final PeerGroup group

serviceName

protected final String serviceName

peerId

protected final String peerId

acl

protected final AccessList acl

aclFile

protected File aclFile

refreshTime

protected long refreshTime

aclFileLastModified

protected long aclFileLastModified

relayServerCache

protected net.jxta.impl.endpoint.relay.RelayServer.RelayServerCache relayServerCache
Constructor Detail

RelayServer

public RelayServer(PeerGroup group,
                   String serviceName,
                   RelayConfigAdv relayConfigAdv)
constructor

Method Detail

getRelayedClients

public List<String> getRelayedClients()
Debug routine: returns the list of relayedClients with details.


startServer

public boolean startServer()

stopServer

public void stopServer()

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

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

@Deprecated
public boolean ping(EndpointAddress addr)
Deprecated. 

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.

messengerReady

public boolean messengerReady(MessengerEvent event)
A messenger is ready.

Specified by:
messengerReady in interface MessengerEventListener
Parameters:
event - The Messenger Event.
Returns:
true if the listener wants to claim the Messenger. (Normally means that it will not be offered to any other listener).

handleRequest

protected void handleRequest(Messenger messenger,
                             EndpointAddress connectionAddress)

handleRequest

protected void handleRequest(Message message,
                             EndpointAddress dstAddr)

handleRequest

void handleRequest(String request,
                   String clientPeerId,
                   Messenger messenger)

removeClient

protected void removeClient(String clientPeerId,
                            RelayServerClient handler)

run

public void run()

Specified by:
run in interface Runnable

JXSE