Project JXTA

net.jxta.impl.endpoint
Class EndpointServiceImpl

java.lang.Object
  extended by net.jxta.impl.endpoint.EndpointServiceImpl
All Implemented Interfaces:
EventListener, EndpointListener, EndpointService, MessengerEventListener, Module, Service

public class EndpointServiceImpl
extends Object
implements EndpointService, MessengerEventListener

This class implements the frontend for all the JXTA endpoint protocols, as well as the API for the implementation of the core protocols that use directly the EndpointService. It theory it only needs to implement core methods. legacy or convenience methods should stay out. However, that would require a two-level interface for the service (internal and public). May be later.


Field Summary
static MimeMediaType DEFAULT_MESSAGE_TYPE
           
static String ENDPOINTSERVICE_NAME
           
(package private)  EndpointServiceMonitor endpointServiceMonitor
           
static String MESSAGE_DESTINATION_NAME
          Element name in which the message destination address will be placed.
static String MESSAGE_DESTINATION_NS
          Namespace in which the message destination address will be placed.
static String MESSAGE_EMPTY_NS
          The Message empty namespace.
static String MESSAGE_JXTA_NS
          The Message "jxta" namespace.
static String MESSAGE_SOURCE_NAME
          Element name in which the message source address will be placed.
static String MESSAGE_SOURCE_NS
          Namespace in which the message source address will be placed.
static String MESSAGE_SRCPEERHDR_NAME
          Element name in which the message source peer address will be placed.
static String MESSAGE_SRCPEERHDR_NS
          Namespace in which the message source peer address will be placed.
 
Fields inherited from interface net.jxta.endpoint.EndpointService
HighPrecedence, LowPrecedence, MediumPrecedence
 
Fields inherited from interface net.jxta.platform.Module
START_AGAIN_PROGRESS, START_AGAIN_STALLED, START_OK
 
Constructor Summary
EndpointServiceImpl()
          Create a new EndpointService.
 
Method Summary
 void addIncomingMessageFilterListener(MessageFilterListener listener, String namespace, String name)
          
 boolean addIncomingMessageListener(EndpointListener listener, String serviceName, String serviceParam)
          
 MessengerEventListener addMessageTransport(MessageTransport transpt)
          
 boolean addMessengerEventListener(MessengerEventListener listener, int prio)
          
 void addOutgoingMessageFilterListener(MessageFilterListener listener, String namespace, String name)
          
 void demux(Message msg)
          (Privileged.
protected  Iterator getAllLocalTransports()
          Return only the message transport registered locally.
 Iterator getAllMessageTransports()
          
 Messenger getCanonicalMessenger(EndpointAddress addr, Object hint)
           Note: canonical messenger itself does not do any address rewritting.
 PeerGroup getGroup()
          Returns the group to which this EndpointServiceImpl is attached.
 Advertisement getImplAdvertisement()
          Returns the advertisment for this service.
 Service getInterface()
          Service objects are not manipulated directly to protect usage of the service.
protected  Messenger getLocalTransportMessenger(EndpointAddress addr, Object hint)
          Returns a messenger from one of the transports registered with this very endpoint service.
 MessageTransport getMessageTransport(String name)
          
 Messenger getMessenger(EndpointAddress addr)
          Deprecated. legacy method.
 Messenger getMessenger(EndpointAddress addr, Object hint)
          convenience method not supported here.
 boolean getMessenger(MessengerEventListener listener, EndpointAddress addr, Object hint)
          Deprecated. legacy method.
 Messenger getMessengerImmediate(EndpointAddress addr, Object hint)
          convenience method not supported here.
 void init(PeerGroup group, ID assignedID, Advertisement impl)
          Initialize the application passing it its peer group and advertisement.
 boolean messengerReady(MessengerEvent event)
          A messenger from a transport is ready.
 boolean ping(EndpointAddress addr)
          Deprecated. Try and get a messenger instead
 void processIncomingMessage(Message msg, EndpointAddress srcAddress, EndpointAddress dstAddress)
          
 void propagate(Message srcMsg, String serviceName, String serviceParam)
          
 MessageFilterListener removeIncomingMessageFilterListener(MessageFilterListener listener, String namespace, String name)
          
 EndpointListener removeIncomingMessageListener(String serviceName, String serviceParam)
          
 boolean removeMessageTransport(MessageTransport transpt)
          
 boolean removeMessengerEventListener(MessengerEventListener listener, int prio)
          
 MessageFilterListener removeOutgoingMessageFilterListener(MessageFilterListener listener, String namespace, String name)
          
 int startApp(String[] args)
          
 void stopApp()
          

The protocols and services are going to be stopped as well.

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

endpointServiceMonitor

EndpointServiceMonitor endpointServiceMonitor

DEFAULT_MESSAGE_TYPE

public static final MimeMediaType DEFAULT_MESSAGE_TYPE

ENDPOINTSERVICE_NAME

public static final String ENDPOINTSERVICE_NAME
See Also:
Constant Field Values

MESSAGE_EMPTY_NS

public static final String MESSAGE_EMPTY_NS
The Message empty namespace. This namespace is reserved for use by applications. It will not be used by core protocols.

See Also:
Constant Field Values

MESSAGE_JXTA_NS

public static final String MESSAGE_JXTA_NS
The Message "jxta" namespace. This namespace is reserved for use by core protocols. It will not be used by applications.

See Also:
Constant Field Values

MESSAGE_SOURCE_NS

public static final String MESSAGE_SOURCE_NS
Namespace in which the message source address will be placed.

See Also:
Constant Field Values

MESSAGE_SOURCE_NAME

public static final String MESSAGE_SOURCE_NAME
Element name in which the message source address will be placed.

See Also:
Constant Field Values

MESSAGE_DESTINATION_NS

public static final String MESSAGE_DESTINATION_NS
Namespace in which the message destination address will be placed.

See Also:
Constant Field Values

MESSAGE_DESTINATION_NAME

public static final String MESSAGE_DESTINATION_NAME
Element name in which the message destination address will be placed. This element is used for loopback detection during propagate. Only propagate messages currently contain this element.

See Also:
Constant Field Values

MESSAGE_SRCPEERHDR_NS

public static final String MESSAGE_SRCPEERHDR_NS
Namespace in which the message source peer address will be placed.

See Also:
Constant Field Values

MESSAGE_SRCPEERHDR_NAME

public static final String MESSAGE_SRCPEERHDR_NAME
Element name in which the message source peer address will be placed. This element is used for loopback detection during propagate. Only propagated messages currently contain this element.

See Also:
Constant Field Values
Constructor Detail

EndpointServiceImpl

public EndpointServiceImpl()
Create a new EndpointService.

Method Detail

init

public void init(PeerGroup group,
                 ID assignedID,
                 Advertisement impl)
          throws PeerGroupException
Initialize the application passing it its peer group and advertisement.

Specified by:
init in interface Module
Parameters:
group - PeerGroup this application is started from
assignedID - The ID which this instance should be known by.
impl - The advertisement for this application
Throws:
PeerGroupException - failure to initialize this application.
Since:
JXTA 1.0

startApp

public int startApp(String[] args)

Specified by:
startApp in interface Module

stopApp

public void stopApp()

The protocols and services are going to be stopped as well. When they are, they will unreference us and we'll go into oblivion.

Specified by:
stopApp in interface Module

getGroup

public PeerGroup getGroup()
Returns the group to which this EndpointServiceImpl is attached.

Specified by:
getGroup in interface EndpointService
Returns:
PeerGroup the group.

getInterface

public Service getInterface()
Service objects are not manipulated directly to protect usage of the service. A Service interface is returned to access the service methods.

Specified by:
getInterface in interface Service
Returns:
Service public interface of the service
Since:
JXTA 1.0

getImplAdvertisement

public Advertisement getImplAdvertisement()
Returns the advertisment for this service.

Specified by:
getImplAdvertisement in interface Service
Returns:
Advertisement the advertisement.
Since:
JXTA 1.0

propagate

public void propagate(Message srcMsg,
                      String serviceName,
                      String serviceParam)
               throws IOException

Specified by:
propagate in interface EndpointService
Throws:
IOException

processIncomingMessage

public void processIncomingMessage(Message msg,
                                   EndpointAddress srcAddress,
                                   EndpointAddress dstAddress)

Specified by:
processIncomingMessage in interface EndpointListener

demux

public void demux(Message msg)
(Privileged. One must have a handle to the implementation. The interface officialy includes this but the interface object's method does nothing only endpoint protocols are given the implementation object.)

Handles the given incoming message by calling the listener specified by its destination as returned by the getDestAddress() method of the message.

Specified by:
demux in interface EndpointService
Parameters:
msg - The message to be delivered.

ping

public boolean ping(EndpointAddress addr)
Deprecated. Try and get a messenger instead

Specified by:
ping in interface EndpointService

addMessageTransport

public MessengerEventListener addMessageTransport(MessageTransport transpt)

Specified by:
addMessageTransport in interface EndpointService

removeMessageTransport

public boolean removeMessageTransport(MessageTransport transpt)

Specified by:
removeMessageTransport in interface EndpointService

getAllMessageTransports

public Iterator getAllMessageTransports()

Specified by:
getAllMessageTransports in interface EndpointService

getMessageTransport

public MessageTransport getMessageTransport(String name)

Specified by:
getMessageTransport in interface EndpointService

addMessengerEventListener

public boolean addMessengerEventListener(MessengerEventListener listener,
                                         int prio)

Specified by:
addMessengerEventListener in interface EndpointService

removeMessengerEventListener

public boolean removeMessengerEventListener(MessengerEventListener listener,
                                            int prio)

Specified by:
removeMessengerEventListener in interface EndpointService

addIncomingMessageListener

public boolean addIncomingMessageListener(EndpointListener listener,
                                          String serviceName,
                                          String serviceParam)

Specified by:
addIncomingMessageListener in interface EndpointService

removeIncomingMessageListener

public EndpointListener removeIncomingMessageListener(String serviceName,
                                                      String serviceParam)

Specified by:
removeIncomingMessageListener in interface EndpointService

getCanonicalMessenger

public Messenger getCanonicalMessenger(EndpointAddress addr,
                                       Object hint)
Note: canonical messenger itself does not do any address rewritting. Any address rewritting must be specified when getting a channel. However canonical knows the default group redirection for its owning endpoint and will automatically skip redirection if it is the same.

Specified by:
getCanonicalMessenger in interface EndpointService

getAllLocalTransports

protected Iterator getAllLocalTransports()
Return only the message transport registered locally.


getLocalTransportMessenger

protected Messenger getLocalTransportMessenger(EndpointAddress addr,
                                               Object hint)
Returns a messenger from one of the transports registered with this very endpoint service. Not one of of the parent ones.


addIncomingMessageFilterListener

public void addIncomingMessageFilterListener(MessageFilterListener listener,
                                             String namespace,
                                             String name)

Specified by:
addIncomingMessageFilterListener in interface EndpointService

addOutgoingMessageFilterListener

public void addOutgoingMessageFilterListener(MessageFilterListener listener,
                                             String namespace,
                                             String name)

Specified by:
addOutgoingMessageFilterListener in interface EndpointService

removeIncomingMessageFilterListener

public MessageFilterListener removeIncomingMessageFilterListener(MessageFilterListener listener,
                                                                 String namespace,
                                                                 String name)

Specified by:
removeIncomingMessageFilterListener in interface EndpointService

removeOutgoingMessageFilterListener

public MessageFilterListener removeOutgoingMessageFilterListener(MessageFilterListener listener,
                                                                 String namespace,
                                                                 String name)

Specified by:
removeOutgoingMessageFilterListener in interface EndpointService

messengerReady

public boolean messengerReady(MessengerEvent event)
A messenger from a transport is ready. Redistribute the event to those interrested.

Specified by:
messengerReady in interface MessengerEventListener

getMessenger

public boolean getMessenger(MessengerEventListener listener,
                            EndpointAddress addr,
                            Object hint)
Deprecated. legacy method.

legacy method not supported here.

Specified by:
getMessenger in interface EndpointService

getMessenger

public Messenger getMessenger(EndpointAddress addr)
Deprecated. legacy method.

legacy method not supported here.

Specified by:
getMessenger in interface EndpointService

getMessengerImmediate

public Messenger getMessengerImmediate(EndpointAddress addr,
                                       Object hint)
convenience method not supported here.

Specified by:
getMessengerImmediate in interface EndpointService

getMessenger

public Messenger getMessenger(EndpointAddress addr,
                              Object hint)
convenience method not supported here.

Specified by:
getMessenger in interface EndpointService

JXTA J2SE