|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectutil.PropertyContainer
util.rmi.RmiPropertyContainer
util.rmi.AbstractRmiListener
public abstract class AbstractRmiListener
The common base class for all implementations of rmi-based listeners. It
provides base implementation for the RmiEventListener methods. The
isConnected() method returns true. The connection to the casters is
checked with the innner AbstractRmiListener.CheckCaster class. The functionality of
this class
is served with a TimerTask at a fixed delay.
Please note that subclasses should always use the getCaster(java.lang.String)
method to derive a remote reference to the caster this listener wants to
subscribe to together with the registerAtCaster(util.rmi.RmiCaster, java.lang.Class>) method.
The #rebind method is also served, allowing first for a
deregistration at the appropriate caster, see deregisterAtCaster(util.rmi.RmiCaster, java.lang.Class>),
a timed wait and a new cycle of registering. Note that during the
rebinding phase, the #isValid timer task is blocked.
For convenience this abstract base class provides the two methods defined
in the ListenerControlling interface. They default to the
#initBinding and releaseBinding(java.lang.String) methods. Daugther classes
that do not require special treatment of the listener control capabilities
can therefore simply implement the
ListenerControlling interface
without further caring about an implementation.
| Nested Class Summary | |
|---|---|
private class |
AbstractRmiListener.BindingThread
A thread that initiates a binding to a special service. |
private class |
AbstractRmiListener.CheckCaster
Checks if all casters are still valid references. |
private static class |
AbstractRmiListener.ServiceReference
Combines a service name, which should be a valid registry reference and a service class to a single Map key. |
| Nested classes/interfaces inherited from class util.PropertyContainer |
|---|
PropertyContainer.URLResource |
| Field Summary | |
|---|---|
private boolean |
cancel
Cancel the get caster loop. |
private TimerTask |
check
The timer task to run. |
private static long |
DEFALIVE
The default connection check intervall, ms (1min). |
private static int |
DEFEXPORTPORT
The port at which unicast should export. |
private static long |
DEFINIT
The default connection check initial delay, ms (1min). |
private static int |
DEFRETRY
The default maximum nuber of binding retries. |
private static long |
DEFRETRYSLEEP
The default sleep intervall between binding retries, in ms. |
private static long |
DEFSHUTDOWNDELAY
The default shutdown delay time, 5 sec. |
static String |
KEY_ALIVE
The key to the connection check intervall. |
static String |
KEY_EXPORTPORT
For unicast exports, the port at which we should export. |
static String |
KEY_INIT
The key to the connection check initial delay. |
static String |
KEY_LISTENERNAME
The key to the name of this listener. |
static String |
KEY_RETRY
The key in the properties for the maximum nuber of binding retries. |
static String |
KEY_RETRYSLEEP
The key for the sleep intervall between binding retries. |
static String |
KEY_SHUTDOWNDELAY
The time delay from receiving quit-command until orderly shutdown. |
private Map<AbstractRmiListener.ServiceReference,RmiCaster> |
namingToRemote
The map of full URL names to RMICaster references. |
private List<AbstractRmiListener.BindingThread> |
running
A list of currently active binding thread. |
private static Timer |
validate
The timer to schedule the #isValid timer task. |
| Fields inherited from class util.PropertyContainer |
|---|
KEY_LISTSEPARATOR, KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR, KEY_NOINITONCREATE, KEY_RESOURCEBUNDLES |
| Fields inherited from interface util.PropertyBearing |
|---|
CONFIG, KEY_CLASS, KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME |
| Constructor Summary | |
|---|---|
protected |
AbstractRmiListener(Map<String,String> prop)
Constructs a new rmi-listener base class. |
| Method Summary | |
|---|---|
private void |
addCasterForCheck(String name,
Class<?> only,
RmiCaster server)
Adds a server defined by its binding reference and its service class to our look-up table that checks routinely for validity of the server. |
boolean |
allBound()
Returns true, if all bindings are valid in the sense that there is no active binding thread. |
boolean |
blockBinding(String name)
Initializes a binding without type constraints. |
boolean |
blockBinding(String name,
Class<?> only)
Initializes a binding. |
protected abstract boolean |
deregisterAtCaster(RmiCaster caster,
Class<?> reference)
Deregisters this listener at a certain csater. |
void |
disconnect(RmiCaster from)
Called by the caster to signal that the listener should remove itself. |
void |
exit()
Prior to performing a shutdown, we de-register from all valid casters. |
private RmiCaster |
getCaster(String name)
Returns a remote reference to the rmi-caster resolvable by the given name. |
InetAddress |
getIP()
Returns the IP-address of the machine this listener runs on. |
String |
getListenerName()
Returns the property name KEY_LISTENERNAME. |
boolean |
isConnected()
Returns true. |
protected String |
listenerName()
Returns the property name KEY_LISTENERNAME. |
protected abstract boolean |
registerAtCaster(RmiCaster caster,
Class<?> reference)
Registers this listener at a certain caster. |
boolean |
releaseBinding(String name)
Releases a binding without type constraints. |
boolean |
releaseBinding(String name,
Class<?> only)
Releases a binding. |
protected double |
rescanned(String key,
String old,
String newval)
Reloads all relevant parameters for this listener to allow subclasses to become reloadable. |
Thread |
startBinding(String name)
Initializes a binding without type constraints. |
Thread |
startBinding(String name,
Class<?> only)
Initializes a binding. |
| Methods inherited from class util.rmi.RmiPropertyContainer |
|---|
containsRemoteProperty, getRemoteProperties, getRemoteProperty, setRemoteProperty |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String KEY_LISTENERNAME
public static final String KEY_RETRY
public static final String KEY_RETRYSLEEP
public static final String KEY_ALIVE
public static final String KEY_INIT
public static final String KEY_SHUTDOWNDELAY
public static final String KEY_EXPORTPORT
private static final int DEFEXPORTPORT
private static final int DEFRETRY
private static final long DEFRETRYSLEEP
private static final long DEFALIVE
private static final long DEFINIT
private static final long DEFSHUTDOWNDELAY
private static Timer validate
#isValid timer task.
private Map<AbstractRmiListener.ServiceReference,RmiCaster> namingToRemote
private List<AbstractRmiListener.BindingThread> running
private TimerTask check
private boolean cancel
| Constructor Detail |
|---|
protected AbstractRmiListener(Map<String,String> prop)
#initBinding call.
| Method Detail |
|---|
public void exit()
deregisterAtCaster(util.rmi.RmiCaster, java.lang.Class>).
exit in interface ExitCleaning
protected double rescanned(String key,
String old,
String newval)
rescanned in class PropertyContainerpublic boolean blockBinding(String name)
public boolean blockBinding(String name,
Class<?> only)
RmiCaster the
listener registers itself to the caster by a call to
the (abstract) registerAtCaster(util.rmi.RmiCaster, java.lang.Class>) method.namingToRemote
look-up table.AbstractRmiListener.CheckCaster thread is constructed and scheduled in the timer
task.
public Thread startBinding(String name)
public Thread startBinding(String name,
Class<?> only)
RmiCaster the
listener registers itself to the caster by a call to
the (abstract) registerAtCaster(util.rmi.RmiCaster, java.lang.Class>) method.namingToRemote
look-up table.AbstractRmiListener.CheckCaster thread is constructed and scheduled in the timer
task.
public boolean releaseBinding(String name)
public boolean releaseBinding(String name,
Class<?> only)
RmiCaster the
listener deregisters itself to the caster by a call to
the (abstract) deregisterAtCaster(util.rmi.RmiCaster, java.lang.Class>) method.namingToRemote
look-up table.
public boolean allBound()
public InetAddress getIP()
throws RemoteException
RemoteException
public boolean isConnected()
throws RemoteException
isConnected in interface RmiListenerRemoteException
public void disconnect(RmiCaster from)
throws RemoteException
disconnect in interface RmiListenerRemoteException
private void addCasterForCheck(String name,
Class<?> only,
RmiCaster server)
public String getListenerName()
throws RemoteException
KEY_LISTENERNAME.
getListenerName in interface RmiEventListenerRemoteExceptionprotected String listenerName()
KEY_LISTENERNAME.
protected abstract boolean registerAtCaster(RmiCaster caster,
Class<?> reference)
protected abstract boolean deregisterAtCaster(RmiCaster caster,
Class<?> reference)
private RmiCaster getCaster(String name)
namingToRemote
hash-map. This method is called only in a synchronized on
namingToRemote state.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||