JXTA

net.jxta.impl.endpoint.router
Class Destinations

java.lang.Object
  extended by net.jxta.impl.endpoint.router.Destinations

 class Destinations
extends Object

This class is a repository of wisdom regarding destinations. It also provides a messenger if there is one. Currently, the wisdom is very limited and is only about direct destinations (for which a messenger once existed). The wisdom that can be obtained is:

This could be extended to manage more of the life cycle, such as knowing about messengers being resolved or having failed to. This primitive interface is temporary; it is only meant to replace messengerPool without having to change the router too much.


Nested Class Summary
(package private)  class Destinations.Wisdom
          Stores knowledge about one particular destination.
(package private)  class Destinations.WisdomGCTask
          Handles cleanup of expired wisdoms
 
Constructor Summary
Destinations(EndpointService endpoint)
           
 
Method Summary
 boolean addIncomingMessenger(EndpointAddress destination, Messenger messenger)
          Here is an incoming messenger that just popped out.
 boolean addOutgoingMessenger(EndpointAddress destination, Messenger messenger)
          Here is a messenger that we were able to obtain.
 Collection<EndpointAddress> allDestinations()
           
 void close()
          Shutdown this cache.
 Messenger getCurrentMessenger(EndpointAddress destination)
          If there is a messenger at hand (incoming or otherwise), return it.
 boolean isCurrentlyReachable(EndpointAddress destination)
          Do we already have a messenger or is it likely that we can make one?
 boolean isNormallyReachable(EndpointAddress destination)
          Is it likely that one can be made from this end.
 boolean isWelcomeNeeded(EndpointAddress destination)
          Are we supposed to send a welcome to that destination (we can't remember having done it).
 void noOutgoingMessenger(EndpointAddress destination)
          We tried to get a messenger but could not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Destinations

public Destinations(EndpointService endpoint)
Method Detail

close

public void close()
Shutdown this cache. (stop the gc)


allDestinations

public Collection<EndpointAddress> allDestinations()

getCurrentMessenger

public Messenger getCurrentMessenger(EndpointAddress destination)
If there is a messenger at hand (incoming or otherwise), return it.

Parameters:
destination - The destination as an endpoint address (is automatically normalized to protocol and address only).
Returns:
A messenger to that destination if a resolved and usable one is available or can be made instantly. null otherwise.

isNormallyReachable

public boolean isNormallyReachable(EndpointAddress destination)
Is it likely that one can be made from this end. (the last attempt succeeded, not only incoming, and that was not long ago) ? This is a conservative test. It means that declaring that we can route to that destination is a very safe bet, as opposed to isNormallyReachable and getCurrentMessenger, which could be misleading if the only messenger we can ever get is incoming. Not currently used. Should likely be.

Parameters:
destination - The destination as an endpoint address (is automatically normalized to protocol and address only).
Returns:
true if it is likely that we can get a messenger to that destination in the future.

isCurrentlyReachable

public boolean isCurrentlyReachable(EndpointAddress destination)
Do we already have a messenger or is it likely that we can make one? We is will return true more often than isNormallyReachable() since it can be true even when all we have is an incoming messenger.

Just testing that there is an entry is no-longer the same because we may keep the entries beyond the point where we would keep them before, so that we can add some longer-lived information in the future, and do not interfere as much with the gc thread.

Parameters:
destination - The destination as an endpoint address (is automatically normalized to protocol and address only).
Returns:
true is we are confident that we can obtain a messenger, either because we can get one instantly, or because this destination is normally reachable. (So, it is ok to try and route to that destination, now).

isWelcomeNeeded

public boolean isWelcomeNeeded(EndpointAddress destination)
Are we supposed to send a welcome to that destination (we can't remember having done it). It is assumed that once true was returned, it will be acted upon. So, true is not returned a second time.

Parameters:
destination - The destination as an endpoint address (is automatically normalized to protocol and address only).
Returns:
true if this a destination to whish we can't remember sending a welcome message.

addOutgoingMessenger

public boolean addOutgoingMessenger(EndpointAddress destination,
                                    Messenger messenger)
Here is a messenger that we were able to obtain.

Parameters:
destination - The destination as an endpoint address (is automatically normalized to protocol and address only).
messenger - The incoming messenger for that destination.
Returns:
true if this messenger was added (keep it open). false otherwise (do what you want with it).

addIncomingMessenger

public boolean addIncomingMessenger(EndpointAddress destination,
                                    Messenger messenger)
Here is an incoming messenger that just popped out.

Parameters:
destination - The destination as an endpoint address (is automatically normalized to protocol and address only).
messenger - The incoming messenger for that destination.
Returns:
true if this messenger was added (keep it open). false otherwise (do what you want with it).

noOutgoingMessenger

public void noOutgoingMessenger(EndpointAddress destination)
We tried to get a messenger but could not. We know that we do not have connectivity from our end, for now. we may still have an incoming. However, if we had to try and make a messenger, there probably isn't an incoming, but that's not our business here. isNormallyReachable becomes false; but we can still try when solicited.

Parameters:
destination - The destination as an endpoint address (is automatically normalized to protocol and address only).

JXSE