Class Destinations.Wisdom
package: src.net.jxta.impl.endpoint.router
class Destinations.Wisdom
This class stores knowlege about one particular destination. It does not provide any synchronization. This is provided by the Destinations class.
Field Summary
final static long
   How long we consider that a past outgoingMessenger is an indication that one is possible in the future.
 
private long
   This tells when the outgoing messenger information expires.
 
private Messenger
   The channel we last used if it happens to be an incoming messenger.
 
private SoftReference
   The channel we last used, if any.
 
private boolean
   When a new destination is added, we're supposed to send our welcome along with the first message.
 
private EndpointAddress
   The transport destination address of the messenger we're caching (if not incoming).
 
Constructor Summary
 
Wisdom(Messenger messenger, boolean incoming)
Method Summary
boolean
boolean
Messenger
   Returns a channel for this destination if one is there or can be obtained readily and works.
 
private Messenger
   Returns an incoming messenger is there is one that works.
 
private Messenger
   Returns an outgoingMessenger if there is one or one can be made without delay.
 
boolean
   We think the destination is reachable somehow.
 
boolean
boolean
boolean
   Tells whether a welcome message is needed.
 
void
Field Detail
expiration
final static long expiration = 10 * TimeUtils.AMINUTE
How long we consider that a past outgoingMessenger is an indication that one is possible in the future.

expiresAt
private long expiresAt = 0
This tells when the outgoing messenger information expires. Incoming messengers have no expiration per se. We draw no conclusion from their past presence; only current presence. A wisdom is totally expired (and may thus be removed) when its outgoing messenger information is expired AND it has no incoming messenger.

incomingMessenger
private Messenger incomingMessenger
The channel we last used if it happens to be an incoming messenger. We keep a strong reference to it.

messenger
private SoftReference messenger
The channel we last used, if any. They disappear faster than the canonical, but, as long as the canonical is around, they can be obtained at a near-zero cost.

welcomeNeeded
private boolean welcomeNeeded = true
When a new destination is added, we're supposed to send our welcome along with the first message. This tells whether isWelcomeNeeded was once invoked or not.

xportDest
private EndpointAddress xportDest
The transport destination address of the messenger we're caching (if not incoming).
Constructor Detail
Wisdom
Wisdom(Messenger messenger, boolean incoming)
Parameters:
channel The messenger to cache information about.
incoming If true, this is an incoming messenger, which means that if the channel is lost it cannot be re-obtained. It must strongly referenced until it closes for disuse, or breaks.
Method Detail
addIncomingMessenger
boolean addIncomingMessenger(Messenger m)

addOutgoingMessenger
boolean addOutgoingMessenger(Messenger m)

getCurrentMessenger
Messenger getCurrentMessenger()
Returns a channel for this destination if one is there or can be obtained readily and works.

getIncoming
private Messenger getIncoming()
Returns an incoming messenger is there is one that works. Nulls reference to any broken one

getOutgoing
private Messenger getOutgoing()
Returns an outgoingMessenger if there is one or one can be made without delay. Renews a broken one if it can be. Refreshes expiration time if a messenger is returned.

isCurrentlyReachable
boolean isCurrentlyReachable()
We think the destination is reachable somehow. Not sure how long.
Return:
true if we have any kind of messenger or, failing that, we had an outgoing one not too long ago.

isExpired
boolean isExpired()
Return:
true if this wisdom carries no positive information whatsoever.

isNormallyReachable
boolean isNormallyReachable()
Return:
true if we do have an outgoing messenger or, failing that, we had one not too long ago.

isWelcomeNeeded
boolean isWelcomeNeeded()
Tells whether a welcome message is needed. The first time we're asked, we say true. Subsequently, always false; assuming it was done when said so (so, ask only if you'll do it).
Return:
true If this is the first time this method is invoked.

noOutgoingMessenger
void noOutgoingMessenger()