Project JXTA

net.jxta.util.endpoint
Class WeakMessengerCache

java.lang.Object
  extended byjava.util.AbstractMap
      extended byjava.util.WeakHashMap
          extended bynet.jxta.util.endpoint.WeakMessengerCache
All Implemented Interfaces:
Map

Deprecated. The new endpoint implemenation introduced in JXTA J2SE 2.3 makes this cache largely unnecessary. It should not be used in new code.

public class WeakMessengerCache
extends WeakHashMap

This class implements a cache of Messenger, indexed by their EndpointAddress based on WeakReference.

The life time of an Messenger in the cache is the same as the life time of the Messenger itself.

This allow applications and services to reuse an existing Messenger for sending a new message.


Constructor Summary
WeakMessengerCache()
          Deprecated. Default Constructor
WeakMessengerCache(int initialCapacity)
          Deprecated. Constructor which includes a capacity hint.
WeakMessengerCache(int initialCapacity, float loadFactor)
          Deprecated. Constructor which includes a capacity hint and a required loading factor.
WeakMessengerCache(Map t)
          Deprecated. Constructor which includes an initial map content.
 
Method Summary
 Messenger getMessenger(EndpointAddress addr)
          Deprecated. Return, if any, a cached Messenger.
 Messenger putMessenger(Messenger messenger)
          Deprecated. Cache an Messenger.
 
Methods inherited from class java.util.WeakHashMap
clear, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

WeakMessengerCache

public WeakMessengerCache()
Deprecated. 
Default Constructor


WeakMessengerCache

public WeakMessengerCache(int initialCapacity)
Deprecated. 
Constructor which includes a capacity hint.


WeakMessengerCache

public WeakMessengerCache(int initialCapacity,
                          float loadFactor)
Deprecated. 
Constructor which includes a capacity hint and a required loading factor.


WeakMessengerCache

public WeakMessengerCache(Map t)
Deprecated. 
Constructor which includes an initial map content.

Method Detail

putMessenger

public Messenger putMessenger(Messenger messenger)
Deprecated. 
Cache an Messenger. If there was already an Messenger cached for the same EndpointAddress, the old cached EndpointMeseenger it returned, and messenger Messenger is cached. This method is not thread-safe: if required, synchronization must be performed by the caller.

Parameters:
messenger - Messenger to be cached.
Returns:
messenger A previously cached Messenger or null.

getMessenger

public Messenger getMessenger(EndpointAddress addr)
Deprecated. 
Return, if any, a cached Messenger. This method is not thread-safe: if required, synchronization must be performed by the caller.

Parameters:
addr - Destination EndpointAddress
Returns:
Messenger cached Messenger, or null.

JXTA J2SE