stella
Class MessageListener

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by util.rmi.RmiPropertyContainer
                  extended by util.rmi.AbstractRmiListener
                      extended by stella.MessageListener
All Implemented Interfaces:
Cloneable, Remote, EventListener, RmiAcknowledgeListener, RmiCommandListener, RmiDataListener, RmiDoneListener, RmiErrorListener, RmiSerialListener, RmiWeatherListener, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying, RmiEventListener, RmiListener, RmiPropertyBearing
Direct Known Subclasses:
JMessageListener, TargetChangeListener

public class MessageListener
extends AbstractRmiListener
implements Initializable, RmiCommandListener, RmiErrorListener, RmiAcknowledgeListener, RmiDoneListener, RmiDataListener, RmiSerialListener, RmiWeatherListener

A class to use as message listener. Depending on the various keys, KEY_COMMAND, KEY_ACKNOWLEDGE, KEY_DONE, KEY_ERROR, KEY_DATA, KEY_SERIAL, and KEY_WEATHER this logger registers itself at the appropriate rmi-casters. Any message received from the casters is dumped into the Syslog.


Nested Class Summary
static class MessageListener.Run
          Runs the message listener.
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private static boolean DEFBIND
          The default binding behaviour.
private static String DEFBINDNAME
          The default binding name.
static String KEY_ACKNOWLEDGE
          The key denoting a comma-separated list of acknowledge casters.
static String KEY_BIND
          The key matching the default command casting binding.
static String KEY_BINDNAME
          The key in the properties defining the binding name of this caster.
static String KEY_COMMAND
          The key denoting a comma-separated list of command casters.
static String KEY_DATA
          The key denoting a comma-separated list of data casters.
static String KEY_DONE
          The key denoting a comma-separated list of done casters.
static String KEY_ERROR
          The key denoting a comma-separated list of error casters.
static String KEY_SERIAL
          The key denoting a comma-separated list of serial casters.
static String KEY_WEATHER
          The key denoting a comma-separated list of weather casters.
 
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.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Constructor Summary
MessageListener(Map info)
          Constructs a new message logger.
 
Method Summary
 boolean accepts(CommandEvent ce)
          A message listener accepts all command event types.
protected  boolean deregisterAtCaster(RmiCaster rmi, Class service)
          Deregisters at caster.
 void exit()
          The exit-cleaning functionality.
 void init()
          Register at the appropriate casters found in the various lists.
private  void register(String list, Class casterclass)
          Registers at a caster list.
protected  boolean registerAtCaster(RmiCaster rmi, Class service)
          Registers at the specified caster if the caster is one of the four possible caster instances this class listens to.
 void rmiCommand(CommandEvent ce)
          The receiving edge of the command listener.
 void rmiDataAvailable(DataEvent de)
          The receiving edge of the data listener.
 void rmiErrorOccured(ErrorEvent ee)
          The receiving edge of the error listener.
 void rmiGotAcknowledge(AcknowledgeEvent ae)
          The receiving edge of the acknowledge listener.
 void rmiGotDone(DoneEvent de)
          The receiving edge of the done listener.
 void rmiSerial(SerialEvent se)
          The receiving edge of the serial listener.
 void rmiWeatherChanged(WeatherEvent we)
          The receiving edge of weather events.
 
Methods inherited from class util.rmi.AbstractRmiListener
allBound, blockBinding, blockBinding, disconnect, getIP, getListenerName, isConnected, listenerName, releaseBinding, releaseBinding, rescanned, startBinding, startBinding
 
Methods inherited from class util.rmi.RmiPropertyContainer
containsRemoteProperty, getRemoteProperties, getRemoteProperty, setRemoteProperty
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface util.rmi.RmiEventListener
getListenerName
 
Methods inherited from interface util.rmi.RmiListener
disconnect, isConnected
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 

Field Detail

KEY_COMMAND

public static final String KEY_COMMAND
The key denoting a comma-separated list of command casters.

See Also:
Constant Field Values

KEY_ERROR

public static final String KEY_ERROR
The key denoting a comma-separated list of error casters.

See Also:
Constant Field Values

KEY_DONE

public static final String KEY_DONE
The key denoting a comma-separated list of done casters.

See Also:
Constant Field Values

KEY_ACKNOWLEDGE

public static final String KEY_ACKNOWLEDGE
The key denoting a comma-separated list of acknowledge casters.

See Also:
Constant Field Values

KEY_DATA

public static final String KEY_DATA
The key denoting a comma-separated list of data casters.

See Also:
Constant Field Values

KEY_SERIAL

public static final String KEY_SERIAL
The key denoting a comma-separated list of serial casters.

See Also:
Constant Field Values

KEY_WEATHER

public static final String KEY_WEATHER
The key denoting a comma-separated list of weather casters.

See Also:
Constant Field Values

KEY_BINDNAME

public static final String KEY_BINDNAME
The key in the properties defining the binding name of this caster.

See Also:
Constant Field Values

KEY_BIND

public static final String KEY_BIND
The key matching the default command casting binding.

See Also:
Constant Field Values

DEFBINDNAME

private static final String DEFBINDNAME
The default binding name.

See Also:
Constant Field Values

DEFBIND

private static final boolean DEFBIND
The default binding behaviour.

See Also:
Constant Field Values
Constructor Detail

MessageListener

public MessageListener(Map info)
                throws RemoteException
Constructs a new message logger. The properties handed over are also used for constructing the status panel.

Throws:
RemoteException
Method Detail

init

public void init()
Register at the appropriate casters found in the various lists.

Specified by:
init in interface Initializable
Overrides:
init in class PropertyResources

exit

public void exit()
The exit-cleaning functionality. Does a deregistering from all casters before exiting.

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

accepts

public boolean accepts(CommandEvent ce)
                throws RemoteException
A message listener accepts all command event types.

Specified by:
accepts in interface RmiCommandListener
Throws:
RemoteException

rmiCommand

public void rmiCommand(CommandEvent ce)
                throws RemoteException
The receiving edge of the command listener. Passes the command message received to Syslog.info.

Specified by:
rmiCommand in interface RmiCommandListener
Throws:
RemoteException

rmiGotAcknowledge

public void rmiGotAcknowledge(AcknowledgeEvent ae)
                       throws RemoteException
The receiving edge of the acknowledge listener. Passes the acknowledge message received to Syslog.info.

Specified by:
rmiGotAcknowledge in interface RmiAcknowledgeListener
Throws:
RemoteException

rmiGotDone

public void rmiGotDone(DoneEvent de)
                throws RemoteException
The receiving edge of the done listener. Passes the done message received to Syslog.info.

Specified by:
rmiGotDone in interface RmiDoneListener
Throws:
RemoteException

rmiErrorOccured

public void rmiErrorOccured(ErrorEvent ee)
                     throws RemoteException
The receiving edge of the error listener. Passes the error message received to Syslog.error, or, if the argument is a status message to Syslog.info.

Specified by:
rmiErrorOccured in interface RmiErrorListener
Throws:
RemoteException

rmiDataAvailable

public void rmiDataAvailable(DataEvent de)
                      throws RemoteException
The receiving edge of the data listener. Passes the data event to Syslog.info.

Specified by:
rmiDataAvailable in interface RmiDataListener
Throws:
RemoteException

rmiSerial

public void rmiSerial(SerialEvent se)
               throws RemoteException
The receiving edge of the serial listener. Passes the serial event to the Syslog.info. If the serial event was a write command, a '>' is prepended to the serial string, for read events a '<' is prepended.

Specified by:
rmiSerial in interface RmiSerialListener
Throws:
RemoteException

rmiWeatherChanged

public void rmiWeatherChanged(WeatherEvent we)
                       throws RemoteException
The receiving edge of weather events. They are passed to the Syslog.error.

Specified by:
rmiWeatherChanged in interface RmiWeatherListener
Throws:
RemoteException

registerAtCaster

protected boolean registerAtCaster(RmiCaster rmi,
                                   Class service)
Registers at the specified caster if the caster is one of the four possible caster instances this class listens to.

Specified by:
registerAtCaster in class AbstractRmiListener
Returns:
True, if this listener can register at the specified caster

deregisterAtCaster

protected boolean deregisterAtCaster(RmiCaster rmi,
                                     Class service)
Deregisters at caster. Simply checks if the caster handed over is of one of the four supported types and removes itself from its listener list. Note that this can also mean de-registering from casters we never registered to because this info is lost.

Specified by:
deregisterAtCaster in class AbstractRmiListener
Returns:
True, if this listener can deregister at the specified caster

register

private void register(String list,
                      Class casterclass)
Registers at a caster list.