util.rmi
Class AbstractRmiCaster

java.lang.Object
  extended by util.PropertyContainer
      extended by util.rmi.RmiPropertyContainer
          extended by util.rmi.AbstractRmiCaster
All Implemented Interfaces:
Cloneable, Remote, ExitCleaning, Initializable, PropertyBearing, RmiCaster, RmiPropertyBearing
Direct Known Subclasses:
AbstractRmiDataSink, AbstractSensor, AbstractWeatherSurveyor, CastingContainer, SensorRepository, SubComponentNotify

public abstract class AbstractRmiCaster
extends RmiPropertyContainer
implements RmiCaster, ExitCleaning

Base implementation of an rmi-enabled caster. This class provides method bodies for all interfaces in the RmiCaster class, but is defined abstract to insist on subclassing.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyContainer
PropertyContainer.URLResource
 
Field Summary
private static Registry alternate
          An alternate registry, if ALTERNATEHOST sys-property is set.
static String ALTERNATEHOST
          The system property of an alternate registry host.
static String ALTERNATEPORT
          The system property of an alternate registry host.
private static int COUNT
          An internal counter for automatic naming.
private static int DEFEXPORTPORT
          The port at which unicast should export.
private static int DEFREGISTRYPORT
          The port at which the registry accepts connections.
private  boolean isbound
          True if this caster is bound to the registry.
static String KEY_BINDNAME
          The key in the Map referring to the bind name of the sensor.
static String KEY_EXPORTPORT
          For unicast exports, the port at which we should export.
static String KEY_REGISTRYHOST
          The key to the registry host or null for the local host.
static String KEY_REGISTRYPORT
          The key to the port the registry is accepting requests.
 
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 AbstractRmiCaster(Map<String,String> prop)
          Constructs a new rmi-caster.
 
Method Summary
static boolean bindAlternate(Remote rem, String as)
          Tries to bind to an alternate registry.
private static boolean bindNow(Remote rem, PropertyBearing info)
          Binds a property container to the registry.
 boolean bindToRegistry()
          Binds this class's casting capabilities to a running registry.
static boolean bindToRegistry(PropertyBearing info)
          Binds a property container to the registry.
static boolean bindToRegistry(PropertyComposed info)
          Binds a property container to the registry.
 void casterExit(List listeners)
          Signals to this list of listeners that they should remove themself from getting events from this caster.
static void casterExit(PropertyBearing caster, List<?> listeners)
          Signals to this list of listeners that they should remove themself from getting events from this caster.
 void exit()
          On exit, we unbind from the registry.
 String getBindName()
          Returns the binding name of this caster.
static String getBindName(PropertyBearing info)
          Returns the binding name of this caster.
 boolean isValid()
          The method for listeners to check if the remote reference is still valid.
private static int nextCount()
          Gets the next available number at automatic naming.
 boolean unbindFromRegistry()
          Unbinds this repository from the registry.
static boolean unbindFromRegistry(PropertyBearing info)
          Unbinds this repository from the registry.
 
Methods inherited from class util.rmi.RmiPropertyContainer
containsRemoteProperty, getRemoteProperties, getRemoteProperty, setRemoteProperty
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, clone, createFrom, createFrom, createFrom, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getLocalClassLoader, getLocalized, getLocalized, getLocalizedString, getLocalizedString, getProperties, getPropertiesToKey, getPropertiesToKey, getProperty, getResource, getResourceAsStream, getResourceFromKey, getResources, has, init, isNew, keyCreate, keyCreate, parseObject, reload, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALTERNATEHOST

public static final String ALTERNATEHOST
The system property of an alternate registry host.

See Also:
Constant Field Values

ALTERNATEPORT

public static final String ALTERNATEPORT
The system property of an alternate registry host.

See Also:
Constant Field Values

KEY_REGISTRYHOST

public static final String KEY_REGISTRYHOST
The key to the registry host or null for the local host.

See Also:
Constant Field Values

KEY_REGISTRYPORT

public static final String KEY_REGISTRYPORT
The key to the port the registry is accepting requests.

See Also:
Constant Field Values

KEY_BINDNAME

public static final String KEY_BINDNAME
The key in the Map referring to the bind name of the sensor.

See Also:
Constant Field Values

KEY_EXPORTPORT

public static final String KEY_EXPORTPORT
For unicast exports, the port at which we should export.

See Also:
Constant Field Values

DEFREGISTRYPORT

private static final int DEFREGISTRYPORT
The port at which the registry accepts connections.

See Also:
Constant Field Values

DEFEXPORTPORT

private static final int DEFEXPORTPORT
The port at which unicast should export. Zero means anonymous port.

See Also:
Constant Field Values

isbound

private boolean isbound
True if this caster is bound to the registry.


COUNT

private static int COUNT
An internal counter for automatic naming.


alternate

private static Registry alternate
An alternate registry, if ALTERNATEHOST sys-property is set.

Constructor Detail

AbstractRmiCaster

protected AbstractRmiCaster(Map<String,String> prop)
Constructs a new rmi-caster. The object is not exported.

Method Detail

nextCount

private static int nextCount()
Gets the next available number at automatic naming.


isValid

public boolean isValid()
                throws RemoteException
The method for listeners to check if the remote reference is still valid. Needed for rmi error-caster abilities. Returns true.

Specified by:
isValid in interface RmiCaster
Throws:
RemoteException

bindToRegistry

public boolean bindToRegistry()
                       throws RemoteException
Binds this class's casting capabilities to a running registry.

Specified by:
bindToRegistry in interface RmiCaster
Returns:
True if successful.
Throws:
RemoteException

bindToRegistry

public static boolean bindToRegistry(PropertyBearing info)
                              throws RemoteException
Binds a property container to the registry. The static method can be used with objects that do not want to extends the AbstractRmiCaster directly.

Throws:
RemoteException

bindToRegistry

public static boolean bindToRegistry(PropertyComposed info)
                              throws RemoteException
Binds a property container to the registry. The static method can be used with objects that do not want to extends the AbstractRmiCaster directly.

Throws:
RemoteException

bindNow

private static boolean bindNow(Remote rem,
                               PropertyBearing info)
                        throws RemoteException
Binds a property container to the registry. The static method can be used with objects that do not want to extends the AbstractRmiCaster directly.

Throws:
RemoteException

bindAlternate

public static boolean bindAlternate(Remote rem,
                                    String as)
Tries to bind to an alternate registry. This implies the following:

Returns:
False, if not bound for any reason.

exit

public void exit()
On exit, we unbind from the registry. If the subclass wants to signal to its listeners that it is exiting, override this method and use the casterExit(java.util.List) method, then call the super method. Non-subclasses of this class can use the static unbindFromRegistry().

Specified by:
exit in interface ExitCleaning

casterExit

public void casterExit(List listeners)
Signals to this list of listeners that they should remove themself from getting events from this caster.


casterExit

public static void casterExit(PropertyBearing caster,
                              List<?> listeners)
Signals to this list of listeners that they should remove themself from getting events from this caster.


unbindFromRegistry

public boolean unbindFromRegistry()
                           throws RemoteException
Unbinds this repository from the registry.

Specified by:
unbindFromRegistry in interface RmiCaster
Returns:
True on success.
Throws:
RemoteException

unbindFromRegistry

public static boolean unbindFromRegistry(PropertyBearing info)
                                  throws RemoteException
Unbinds this repository from the registry. The static method can be used with objects that do not want to extends the AbstractRmiCaster directly.

Throws:
RemoteException

getBindName

public String getBindName()
Returns the binding name of this caster. If the property KEY_BINDNAME is set it is used, otherwise we bind using our class name and a running number and set this in the properties for proper unbinding.


getBindName

public static String getBindName(PropertyBearing info)
Returns the binding name of this caster. If the property KEY_BINDNAME is set it is used, otherwise we bind using our class name and a running number and set this in the properties for proper unbinding. The static method can be used with objects that do not want to extends the AbstractRmiCaster directly.