|
Class Destinations.Wisdom
|
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 |
|
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.
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.
private Messenger incomingMessenger
The channel we last used if it happens to be an incoming messenger. We keep
a strong reference to it.
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.
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.
private EndpointAddress xportDest
The transport destination address of the messenger we're caching (if not incoming).
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.
boolean addIncomingMessenger(Messenger m)
boolean addOutgoingMessenger(Messenger m)
Messenger getCurrentMessenger()
Returns a channel for this destination if one is there or can be obtained
readily and works.
private Messenger getIncoming()
Returns an incoming messenger is there is one that works. Nulls reference to any broken one
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.
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.
boolean isExpired()
Return:
true if this wisdom carries no positive information whatsoever.
boolean isNormallyReachable()
Return:
true if we do have an outgoing messenger or, failing that, we had one not too long ago.
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.
void noOutgoingMessenger()