ehcache

net.sf.ehcache.distribution
Class JNDIManualRMICacheManagerPeerProvider

java.lang.Object
  extended by net.sf.ehcache.distribution.JNDIManualRMICacheManagerPeerProvider
All Implemented Interfaces:
CacheManagerPeerProvider

public class JNDIManualRMICacheManagerPeerProvider
extends java.lang.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  java.util.Map cachePeers
          CachePeers keyed by jndiProviderUrl
protected  java.util.Map peerUrls
          Contains registered JNDI URLs as keys to their Context
 
Constructor Summary
JNDIManualRMICacheManagerPeerProvider(boolean isStashContexts, boolean isStashRemoteCachePeers)
          Constructor
JNDIManualRMICacheManagerPeerProvider(CacheManager cacheManager)
          Constructor
 
Method Summary
 void dispose()
          Providers may be doing all sorts of exotic things and need to be able to clean up on dispose.
 CacheManager getCacheManager()
          The cacheManager this provider is bound to
 long getTimeForClusterToForm()
          Time for a cluster to form.
 void init()
          Notifies providers to initialise themselves.
 java.util.List listRemoteCachePeers(Ehcache cache)
           
 void registerPeer(java.lang.String jndiProviderUrl)
          Register a new peer
 java.lang.String toString()
          Returns a string representation of the object.
 void unregisterPeer(java.lang.String jndiProviderUrl)
          Unregisters a peer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

peerUrls

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


cachePeers

protected java.util.Map cachePeers
CachePeers keyed by jndiProviderUrl

Constructor Detail

JNDIManualRMICacheManagerPeerProvider

public JNDIManualRMICacheManagerPeerProvider(boolean isStashContexts,
                                             boolean isStashRemoteCachePeers)
Constructor

Parameters:
isStashRemoteCachePeers -
isStashContexts -

JNDIManualRMICacheManagerPeerProvider

public JNDIManualRMICacheManagerPeerProvider(CacheManager cacheManager)
Constructor

Parameters:
cacheManager -
Method Detail

init

public void init()
Notifies providers to initialise themselves.

Specified by:
init in interface CacheManagerPeerProvider
Throws:
CacheException

registerPeer

public void registerPeer(java.lang.String jndiProviderUrl)
Register a new peer

Specified by:
registerPeer in interface CacheManagerPeerProvider
Parameters:
jndiProviderUrl -

unregisterPeer

public void unregisterPeer(java.lang.String jndiProviderUrl)
Unregisters a peer

Specified by:
unregisterPeer in interface CacheManagerPeerProvider
Parameters:
jndiProviderUrl -

listRemoteCachePeers

public java.util.List listRemoteCachePeers(Ehcache cache)
                                    throws CacheException
Specified by:
listRemoteCachePeers in interface CacheManagerPeerProvider
Returns:
a list of CachePeer peers, excluding the local peer.
Throws:
CacheException

dispose

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

Specified by:
dispose in interface CacheManagerPeerProvider
Throws:
CacheException

getTimeForClusterToForm

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

Specified by:
getTimeForClusterToForm in interface CacheManagerPeerProvider
Returns:
the time in ms, for a cluster to form

getCacheManager

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


toString

public java.lang.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())
 

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the object.

ehcache