net.sf.ehcache.distribution

Class JNDIManualRMICacheManagerPeerProvider

public class JNDIManualRMICacheManagerPeerProvider extends Object implements CacheManagerPeerProvider

A provider of RMI CachePeers through JNDI lookup.

The design allows for a peer server to go down. When it is up again the peer will be provided again.

The JNDI Context and the CachePeers are cached locally. When listRemoteCachePeers is called each CachePeer is tested for staleness. If it is stale, the peer is looked up again in JNDI.

Version: $Id: JNDIManualRMICacheManagerPeerProvider.java 100 2006-05-30 08:19:29Z gregluck $

Author: Andy McNutt Greg Luck

Field Summary
protected MapcachePeers
CachePeers keyed by jndiProviderUrl
protected MappeerUrls
Contains registered JNDI URLs as keys to their Context
Constructor Summary
JNDIManualRMICacheManagerPeerProvider(boolean isStashContexts, boolean isStashRemoteCachePeers)
Constructor
JNDIManualRMICacheManagerPeerProvider(CacheManager cacheManager)
Constructor
Method Summary
voiddispose()
Providers may be doing all sorts of exotic things and need to be able to clean up on dispose.
CacheManagergetCacheManager()
The cacheManager this provider is bound to
longgetTimeForClusterToForm()
Time for a cluster to form.
voidinit()
Notifies providers to initialise themselves.
ListlistRemoteCachePeers(Ehcache cache)
voidregisterPeer(String jndiProviderUrl)
Register a new peer
StringtoString()
Returns a string representation of the object.
voidunregisterPeer(String jndiProviderUrl)
Unregisters a peer

Field Detail

cachePeers

protected Map cachePeers
CachePeers keyed by jndiProviderUrl

peerUrls

protected Map peerUrls
Contains registered JNDI URLs as keys to their Context

Constructor Detail

JNDIManualRMICacheManagerPeerProvider

public JNDIManualRMICacheManagerPeerProvider(boolean isStashContexts, boolean isStashRemoteCachePeers)
Constructor

Parameters: isStashRemoteCachePeers isStashContexts

JNDIManualRMICacheManagerPeerProvider

public JNDIManualRMICacheManagerPeerProvider(CacheManager cacheManager)
Constructor

Parameters: cacheManager

Method Detail

dispose

public void dispose()
Providers may be doing all sorts of exotic things and need to be able to clean up on dispose.

Throws: net.sf.ehcache.CacheException

getCacheManager

public CacheManager getCacheManager()
The cacheManager this provider is bound to

getTimeForClusterToForm

public long getTimeForClusterToForm()
Time for a cluster to form. This varies considerably, depending on the implementation.

Returns: the time in ms, for a cluster to form

init

public void init()
Notifies providers to initialise themselves.

Throws: CacheException

listRemoteCachePeers

public List listRemoteCachePeers(Ehcache cache)

Returns: a list of CachePeer peers, excluding the local peer.

registerPeer

public void registerPeer(String jndiProviderUrl)
Register a new peer

Parameters: jndiProviderUrl

toString

public String toString()
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns: a string representation of the object.

unregisterPeer

public void unregisterPeer(String jndiProviderUrl)
Unregisters a peer

Parameters: jndiProviderUrl