ehcache

net.sf.ehcache.distribution
Class RMICacheManagerPeerProvider

java.lang.Object
  extended by net.sf.ehcache.distribution.RMICacheManagerPeerProvider
All Implemented Interfaces:
CacheManagerPeerProvider
Direct Known Subclasses:
ManualRMICacheManagerPeerProvider, MulticastRMICacheManagerPeerProvider

public abstract class RMICacheManagerPeerProvider
extends java.lang.Object
implements CacheManagerPeerProvider

A provider of Peer RMI addresses.

Version:
$Id: RMICacheManagerPeerProvider.java 519 2007-07-27 07:11:45Z gregluck $
Author:
Greg Luck

Field Summary
protected  CacheManager cacheManager
          The CacheManager this peer provider is associated with.
protected  java.util.Map peerUrls
          Contains a RMI URLs of the form: "//" + hostName + ":" + port + "/" + cacheName;
 
Constructor Summary
RMICacheManagerPeerProvider()
          Empty constructor
RMICacheManagerPeerProvider(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.
(package private) static java.lang.String extractCacheName(java.lang.String rmiUrl)
          Gets the cache name out of the url
 CacheManager getCacheManager()
          The cacheManager this provider is bound to
abstract  void init()
          Notifies providers to initialise themselves.
abstract  java.util.List listRemoteCachePeers(Ehcache cache)
           
 CachePeer lookupRemoteCachePeer(java.lang.String url)
          The use of one-time registry creation and Naming.rebind should mean we can create as many listeneres as we like.
abstract  void registerPeer(java.lang.String rmiUrl)
          Register a new peer
protected abstract  boolean stale(java.util.Date date)
          Whether the entry should be considered stale.
 void unregisterPeer(java.lang.String rmiUrl)
          Unregisters a peer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.ehcache.distribution.CacheManagerPeerProvider
getTimeForClusterToForm
 

Field Detail

peerUrls

protected final java.util.Map peerUrls
Contains a RMI URLs of the form: "//" + hostName + ":" + port + "/" + cacheName;


cacheManager

protected CacheManager cacheManager
The CacheManager this peer provider is associated with.

Constructor Detail

RMICacheManagerPeerProvider

public RMICacheManagerPeerProvider(CacheManager cacheManager)
Constructor

Parameters:
cacheManager -

RMICacheManagerPeerProvider

public RMICacheManagerPeerProvider()
Empty constructor

Method Detail

init

public abstract void init()
Notifies providers to initialise themselves.

Specified by:
init in interface CacheManagerPeerProvider

registerPeer

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

Specified by:
registerPeer in interface CacheManagerPeerProvider
Parameters:
rmiUrl -

extractCacheName

static java.lang.String extractCacheName(java.lang.String rmiUrl)
Gets the cache name out of the url

Parameters:
rmiUrl -
Returns:
the cache name as it would appear in ehcache.xml

unregisterPeer

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

Specified by:
unregisterPeer in interface CacheManagerPeerProvider
Parameters:
rmiUrl -

listRemoteCachePeers

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

stale

protected abstract boolean stale(java.util.Date date)
Whether the entry should be considered stale. This will depend on the type of RMICacheManagerPeerProvider.

Parameters:
date - the date the entry was created
Returns:
true if stale

lookupRemoteCachePeer

public CachePeer lookupRemoteCachePeer(java.lang.String url)
                                throws java.net.MalformedURLException,
                                       java.rmi.NotBoundException,
                                       java.rmi.RemoteException
The use of one-time registry creation and Naming.rebind should mean we can create as many listeneres as we like. They will simply replace the ones that were there.

Throws:
java.net.MalformedURLException
java.rmi.NotBoundException
java.rmi.RemoteException

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

getCacheManager

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


ehcache