stella.rmi
Class AbstractRmiCasterAndListener

java.lang.Object
  extended by util.PropertyContainer
      extended by util.rmi.RmiPropertyContainer
          extended by util.rmi.AbstractRmiListener
              extended by stella.rmi.AbstractRmiCasterAndListener
All Implemented Interfaces:
Cloneable, Remote, EventListener, ErrorSending, RmiErrorCaster, ExitCleaning, Initializable, PropertyBearing, RmiCaster, RmiEventListener, RmiListener, RmiPropertyBearing
Direct Known Subclasses:
CasterTorso, ReceiverTorso

public abstract class AbstractRmiCasterAndListener
extends AbstractRmiListener
implements RmiCaster, RmiErrorCaster, ErrorSending

The common base class for all classes that are both, casters and listeners. It is an extension to AbstractRmiListener and has all methods of AbstractRmiCaster copied into it.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyContainer
PropertyContainer.URLResource
 
Field Summary
private  List<ErrorListener> errlist
          The vector containing local error listeners.
private  List<RmiErrorListener> rmilist
          The vector containing rmi error listeners.
 
Fields inherited from class util.rmi.AbstractRmiListener
KEY_ALIVE, KEY_EXPORTPORT, KEY_INIT, KEY_LISTENERNAME, KEY_RETRY, KEY_RETRYSLEEP, KEY_SHUTDOWNDELAY
 
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 AbstractRmiCasterAndListener(Map prop)
          Constructs a new rmi-caster.
 
Method Summary
 void addErrorListener(ErrorListener ear)
          Registers an error event listener to this property container.
 void addRmiErrorListener(RmiErrorListener ear)
          Registers a rmi error event listener to this property container.
 boolean bindToRegistry()
          Binds this class's casting capabilities to a running registry.
 void exit()
          Removes my rmi error listeners.
 String getBindName()
          Tries to retrieve my binding name.
 boolean isValid()
          The method for listeners to check if the remote reference is still valid.
protected  void notifyErrorListener(ErrorEvent ee, List<ErrorListener> local, List<RmiErrorListener> remote)
          Notifies all registered ErrorListeners.
 void removeErrorListener(ErrorListener ear)
          Deregisters an error event listener from this property container.
 void removeRmiErrorListener(RmiErrorListener ear)
          Deregisters an rmi error event listener from this property container.
 void sendError(ErrorEvent ee)
          Sends the error message directly.
 void sendError(String mess)
          Wraps the argumental String into an error message and passes it to the error listeners.
 void sendError(Throwable thrown)
          Wraps the argumental THrowable into an error message and passes it to the error listeners.
 void sendStatus(ErrorEvent ee)
          Sends the status event back to registered listeners.
 void sendStatus(List stati)
          Processes an entire list of status messages that should be sent to the error listeners.
 void sendStatus(String mess)
          Wraps the argumental String into an error message and passes it to the error listeners.
 boolean unbindFromRegistry()
          Unbinds this repository from the registry.
 
Methods inherited from class util.rmi.AbstractRmiListener
allBound, blockBinding, blockBinding, deregisterAtCaster, disconnect, getIP, getListenerName, isConnected, listenerName, registerAtCaster, releaseBinding, releaseBinding, rescanned, startBinding, startBinding
 
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, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

errlist

private List<ErrorListener> errlist
The vector containing local error listeners.


rmilist

private List<RmiErrorListener> rmilist
The vector containing rmi error listeners.

Constructor Detail

AbstractRmiCasterAndListener

protected AbstractRmiCasterAndListener(Map prop)
Constructs a new rmi-caster. The object is not exported.

Method Detail

exit

public void exit()
Removes my rmi error listeners.

Specified by:
exit in interface ExitCleaning
Overrides:
exit in class AbstractRmiListener

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

unbindFromRegistry

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

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

getBindName

public String getBindName()
Tries to retrieve my binding name. If #mycast is a subclass of AbstractRmiCaster this is no problem.


addErrorListener

public void addErrorListener(ErrorListener ear)
Registers an error event listener to this property container. This method is used for local listeners.


removeErrorListener

public void removeErrorListener(ErrorListener ear)
Deregisters an error event listener from this property container. This method is used for local listeners.


addRmiErrorListener

public void addRmiErrorListener(RmiErrorListener ear)
                         throws RemoteException
Registers a rmi error event listener to this property container. This method is used for non-local listeners running in a different VM.

Specified by:
addRmiErrorListener in interface RmiErrorCaster
Throws:
RemoteException

removeRmiErrorListener

public void removeRmiErrorListener(RmiErrorListener ear)
                            throws RemoteException
Deregisters an rmi error event listener from this property container. This method is used for non-local listeners running in a different VM.

Specified by:
removeRmiErrorListener in interface RmiErrorCaster
Throws:
RemoteException

sendError

public void sendError(Throwable thrown)
Wraps the argumental THrowable into an error message and passes it to the error listeners.


sendError

public void sendError(String mess)
Wraps the argumental String into an error message and passes it to the error listeners.


sendError

public void sendError(ErrorEvent ee)
Sends the error message directly.

Specified by:
sendError in interface ErrorSending

sendStatus

public void sendStatus(String mess)
Wraps the argumental String into an error message and passes it to the error listeners.


sendStatus

public void sendStatus(List stati)
Processes an entire list of status messages that should be sent to the error listeners.


sendStatus

public void sendStatus(ErrorEvent ee)
Sends the status event back to registered listeners. This method should be called within concrete implementations of the ReceiverTorso.processCommand(stella.CommandEvent, int) method.
Note that from the event type there is no difference between a status and an error event. This method therefore simply passes the argument to this classes notifyErrorListener(stella.ErrorEvent, java.util.List, java.util.List) method.


notifyErrorListener

protected void notifyErrorListener(ErrorEvent ee,
                                   List<ErrorListener> local,
                                   List<RmiErrorListener> remote)
Notifies all registered ErrorListeners. This method parses through the Vector of ErrorListeners and passes the argument to their errorOccured method. Registered listeners are local.

Parameters:
ee - The ErrorEvent to pass to the Listeners.