| |
|
| java.lang.Object net.sf.ehcache.distribution.RMICacheManagerPeerListener
RMICacheManagerPeerListener | public class RMICacheManagerPeerListener implements CacheManagerPeerListener(Code) | | A cache server which exposes available cache operations remotely through RMI.
It acts as a Decorator to a Cache. It holds an instance of cache, which is a local cache it talks to.
This class could specify a security manager with code like:
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
Doing so would require the addition of grant statements in the java.policy file.
Per the JDK documentation: "If no security manager is specified no class loading, by RMI clients or servers, is allowed,
aside from what can be found in the local CLASSPATH." The classpath of each instance of this class should have
all required classes to enable distribution, so no remote classloading is required or desirable. Accordingly,
no security manager is set and there are no special JVM configuration requirements.
This class opens a ServerSocket. The dispose method should be called for orderly closure of that socket. This class
has a shutdown hook which calls dispose() as a convenience feature for developers.
author: Greg Luck version: $Id: RMICacheManagerPeerListener.java 519 2007-07-27 07:11:45Z gregluck $ |
cachePeers | final protected Map cachePeers(Code) | | The cache peers. The value is an RMICachePeer.
|
RMICacheManagerPeerListener | public RMICacheManagerPeerListener(String hostName, Integer port, CacheManager cacheManager, Integer socketTimeoutMillis) throws UnknownHostException(Code) | | Constructor with full arguments.
Parameters: hostName - may be null, in which case the hostName will be looked up. Machines with multipleinterfaces should specify this if they do not want it to be the default NIC. Parameters: port - a port in the range 1025 - 65536 Parameters: cacheManager - the CacheManager this listener belongs to Parameters: socketTimeoutMillis - TCP/IP Socket timeout when waiting on response |
dispose | public void dispose() throws CacheException(Code) | | Stop the listener. It
- unbinds the objects from the registry
- unexports Remote objects
|
disposeRMICachePeer | protected void disposeRMICachePeer(RMICachePeer rmiCachePeer) throws Exception(Code) | | A template method to dispose an individual RMICachePeer. This consists of:
- Unbinding the peer from the naming service
- Unexporting the peer
Override to specialise behaviour
Parameters: rmiCachePeer - the cache peer to dispose of throws: Exception - thrown if something goes wrong |
getBoundCachePeers | public List getBoundCachePeers()(Code) | | All of the caches which are listening for remote changes.
a list of RMICachePeer objects. The list if not live |
getStatus | public Status getStatus()(Code) | | Returns the listener status.
|
getUniqueResourceIdentifier | public String getUniqueResourceIdentifier()(Code) | | A listener will normally have a resource that only one instance can use at the same time,
such as a port. This identifier is used to tell if it is unique and will not conflict with an
existing instance using the resource.
a String identifier for the resource |
isDistributed | protected boolean isDistributed(Ehcache cache)(Code) | | Determine if the given cache is distributed.
Parameters: cache - the cache to check true if a CacheReplicator is found in the listeners |
listBoundRMICachePeers | protected String[] listBoundRMICachePeers() throws CacheException(Code) | | Returns a list of bound objects.
This should match the list of cachePeers i.e. they should always be bound
a list of String representations of RMICachePeer objects |
lookupPeer | protected Remote lookupPeer(String name) throws CacheException(Code) | | Returns a reference to the remote object.
Parameters: name - the name of the cache e.g. sampleCache1 |
notifyCacheAdded | public void notifyCacheAdded(String cacheName) throws CacheException(Code) | | Called immediately after a cache has been added and activated.
Note that the CacheManager calls this method from a synchronized method. Any attempt to call a synchronized
method on CacheManager from this method will cause a deadlock.
Note that activation will also cause a CacheEventListener status change notification from
net.sf.ehcache.Status.STATUS_UNINITIALISED to
net.sf.ehcache.Status.STATUS_ALIVE . Care should be
taken on processing that notification because:
- the cache will not yet be accessible from the CacheManager.
- the addCaches methods whih cause this notification are synchronized on the CacheManager. An attempt to call
net.sf.ehcache.CacheManager.getCache(String) will cause a deadlock.
The calling method will block until this method returns.
Repopulates the list of cache peers and rebinds the list.
This method should be called if a cache is dynamically added
Parameters: cacheName - the name of the Cache the operation relates to See Also: net.sf.ehcache.event.CacheEventListener |
notifyCacheRemoved | public void notifyCacheRemoved(String cacheName)(Code) | | Called immediately after a cache has been disposed and removed. The calling method will block until
this method returns.
Note that the CacheManager calls this method from a synchronized method. Any attempt to call a synchronized
method on CacheManager from this method will cause a deadlock.
Note that a
net.sf.ehcache.event.CacheEventListener status changed will also be triggered. Any attempt from that notification
to access CacheManager will also result in a deadlock.
Parameters: cacheName - the name of the Cache the operation relates to |
populateListOfRemoteCachePeers | protected void populateListOfRemoteCachePeers() throws RemoteException(Code) | | Should be called on init because this is one of the last things that should happen on CacheManager startup.
|
startRegistry | protected void startRegistry() throws RemoteException(Code) | | Start the rmiregistry.
The alternative is to use the rmiregistry binary, in which case:
rmiregistry running
-Djava.rmi.server.codebase="file:///Users/gluck/work/ehcache/build/classes/ file:///Users/gluck/work/ehcache/lib/commons-logging-1.0.4.jar"
throws: RemoteException - |
unbind | protected void unbind(RMICachePeer rmiCachePeer) throws Exception(Code) | | Unbinds an RMICachePeer and unexports it.
We unbind from the registry first before unexporting.
Unbinding first removes the very small possibility of a client
getting the object from the registry while we are trying to unexport it.
This method may take up to 4 seconds to complete, if we are having trouble
unexporting the peer.
Parameters: rmiCachePeer - the bound and exported cache peer throws: Exception - |
|
|
|