ehcache

net.sf.ehcache.distribution
Class RMICacheManagerPeerListener

java.lang.Object
  extended by net.sf.ehcache.distribution.RMICacheManagerPeerListener
All Implemented Interfaces:
CacheManagerPeerListener

public final class RMICacheManagerPeerListener
extends java.lang.Object
implements CacheManagerPeerListener

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.

Version:
$Id: RMICacheManagerPeerListener.java 52 2006-04-24 14:50:03Z gregluck $
Author:
Greg Luck

Constructor Summary
RMICacheManagerPeerListener(java.lang.String hostName, java.lang.Integer port, CacheManager cacheManager, java.lang.Integer socketTimeoutMillis)
          Constructor with full arguments.
 
Method Summary
 void dispose()
          Stop the listener.
 java.util.List getBoundCachePeers()
          All of the caches which are listenting for remote changes.
(package private)  java.util.List getCachePeers()
          Gets a list of cache peers
 void init()
          Call to start the listeners and do any other network initialisation.
(package private)  java.lang.String[] listBoundRMICachePeers()
          Returns a list of bound objects.
(package private)  java.rmi.Remote lookupPeer(java.lang.String name)
          Returns a reference to the remote object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RMICacheManagerPeerListener

public RMICacheManagerPeerListener(java.lang.String hostName,
                                   java.lang.Integer port,
                                   CacheManager cacheManager,
                                   java.lang.Integer socketTimeoutMillis)
                            throws java.net.UnknownHostException
Constructor with full arguments.

Parameters:
hostName - may be null, in which case the hostName will be looked up. Machines with multiple interfaces should specify this if they do not want it to be the default NIC.
port - a port in the range 1025 - 65536
cacheManager - the CacheManager this listener belongs to
socketTimeoutMillis - TCP/IP Socket timeout when waiting on response
Throws:
java.net.UnknownHostException
Method Detail

init

public final void init()
                throws CacheException
Call to start the listeners and do any other network initialisation.

Specified by:
init in interface CacheManagerPeerListener
Throws:
CacheException

listBoundRMICachePeers

final java.lang.String[] listBoundRMICachePeers()
                                         throws CacheException
Returns a list of bound objects.

This should match the list of cachePeers i.e. they should always be bound

Returns:
a list of String representations of RMICachePeer objects
Throws:
CacheException

lookupPeer

final java.rmi.Remote lookupPeer(java.lang.String name)
                          throws CacheException
Returns a reference to the remote object.

Parameters:
name - the name of the cache e.g. sampleCache1
Throws:
CacheException

dispose

public final void dispose()
                   throws CacheException
Stop the listener. It

Specified by:
dispose in interface CacheManagerPeerListener
Throws:
CacheException

getBoundCachePeers

public final java.util.List getBoundCachePeers()
All of the caches which are listenting for remote changes.

Specified by:
getBoundCachePeers in interface CacheManagerPeerListener
Returns:
a list of RMICachePeer objects

getCachePeers

final java.util.List getCachePeers()
Gets a list of cache peers


ehcache