stella
Class MasterLauncher

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by util.rmi.RmiPropertyContainer
                  extended by util.rmi.AbstractRmiCaster
                      extended by stella.CastingContainer
                          extended by stella.AbstractCommandLauncher
                              extended by stella.MasterLauncher
All Implemented Interfaces:
Cloneable, Remote, Caster, CommandLaunching, ErrorCaster, ReplyDeliverer, RmiCommandCaster, RmiErrorCaster, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying, RmiCaster, RmiPropertyBearing

public class MasterLauncher
extends AbstractCommandLauncher
implements ErrorCaster, RmiErrorCaster, RmiCommandCaster, Initializable, ExitCleaning

The CommandLaunching instance for master commands. Master commands are internally handled commands that may appear in a sequence definition. To allow the sequencer to cast this command as remote command to remote CommandLaunching instances, this class acts as the 'missing link'. Note that this class is highly specific in the sense that internal commands will in most cases not be recognizable on different systems.

This class also acts as a ReplyDeliverer though it is not an acknowledge or done caster. Reply events are only generated if they match To allow the SCS to cast errors similar to other CommandLaunching instances, this class extends the CastingContainer class. Additionally, RmiCommandCaster may be enabled. The rmi-casting capabilities are intended for remote logging only.


Nested Class Summary
protected  class MasterLauncher.MasterHelper
          The master launcher helper thread.
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  MasterMind chef
          The master mind.
private  List command
          The list of rmi-command listeners.
private static double DEFACCELERATE
          The default acceleration factor.
private static boolean DEFBIND
          The default error-binding behaviour.
private static String DEFNAME
          The default name of the master launcher (SCS).
private static long DEFSHUTDOWNDELAY
          The default shutdown delay time, 5 sec.
private static String DEFSTARTGRAB
          The default start-grab script.
private static String DEFSTOPGRAB
          The default start-grab script.
private  ReplySubscriber forward
          The registered reply subscriber.
static String KEY_ACCELERATE
          The key matching possible acceleration of the internal counter.
static String KEY_BIND
          The key matching the default error casting binding.
static String KEY_BINDNAME
          The key linked to the server name.
static String KEY_NAME
          The key linked to the client's name.
static String KEY_SHUTDOWNDELAY
          The time delay from receiving quit-command until orderly shutdown.
static String KEY_STARTGRAB
          The key to the command line for starting the grabbing.
static String KEY_STOPGRAB
          The key to the command line for starting the grabbing.
private  List pattern
          The replies the reply subscriber is interested in.
private  AlarmWatch stopwatch
          An alarm to act as an interruptable stop-watch.
 
Fields inherited from class util.rmi.AbstractRmiCaster
ALTERNATEHOST, ALTERNATEPORT, KEY_EXPORTPORT, KEY_REGISTRYHOST, KEY_REGISTRYPORT
 
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 stella.rmi.RmiCommandCaster
NAMING_EXTENSION
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Constructor Summary
MasterLauncher(Map prop)
          Constructs a new master launcher with the specified properties.
 
Method Summary
 void addRmiCommandListener(RmiCommandListener ear)
          Registers a command listener to the master launcher.
 void announceInterest(ReplyEvent re)
          Adds a new reply event pattern to the pattern list.
 void castCommand(CommandEvent ce)
          Cast the command to the SCS.
 void cont()
          For times the guiding was lost.
 void exit()
          Unbind thyself from the rwgistry.
 String getBindName()
          Returns the name of the master launcher used for readability improvement.
 String getClientName()
          Returns the name of the master launcher used for readability improvement.
 CommandEvent getExitCommand()
          Default implementation of exit command is null.
 CommandEvent getShutdownCommand()
          Returns the shutdown command.
 void halt()
          For times the guiding was lost.
 boolean handles(CommandEvent ce)
          The master launcher handles ScsCommands.
 void init()
          Initializes the master launcher.
 boolean isReady()
          This is an internal command launcher.
protected  void processCommand(CommandEvent ce)
          The method to handle internal (master) commands.
 void recastCommand()
          Empty method.
protected  void registerMasterMind(MasterMind sub)
          Registers the reply subscriber.
 void registerReplySubscriber(ReplySubscriber sub)
          Registers the reply subscriber.
 void removeRmiCommandListener(RmiCommandListener ear)
          Deregisters a command listener to the master launcher.
 
Methods inherited from class stella.AbstractCommandLauncher
createCommandLauncher
 
Methods inherited from class stella.CastingContainer
addErrorListener, addRmiErrorListener, isValid, notifyErrorListener, removeErrorListener, removeRmiErrorListener, sendError, sendError, sendError, sendStatus, sendStatus, sendStatus
 
Methods inherited from class util.rmi.AbstractRmiCaster
bindAlternate, bindToRegistry, bindToRegistry, bindToRegistry, casterExit, casterExit, getBindName, unbindFromRegistry, unbindFromRegistry
 
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, rescanned, 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 stella.ErrorCaster
addErrorListener, removeErrorListener
 
Methods inherited from interface stella.rmi.RmiErrorCaster
addRmiErrorListener, removeRmiErrorListener
 
Methods inherited from interface util.rmi.RmiCaster
bindToRegistry, isValid, unbindFromRegistry
 
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
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Field Detail

KEY_NAME

public static final String KEY_NAME
The key linked to the client's name.

See Also:
Constant Field Values

KEY_BINDNAME

public static final String KEY_BINDNAME
The key linked to the server name.

See Also:
Constant Field Values

KEY_BIND

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

See Also:
Constant Field Values

KEY_ACCELERATE

public static final String KEY_ACCELERATE
The key matching possible acceleration of the internal counter.

See Also:
Constant Field Values

KEY_STARTGRAB

public static final String KEY_STARTGRAB
The key to the command line for starting the grabbing.

See Also:
Constant Field Values

KEY_STOPGRAB

public static final String KEY_STOPGRAB
The key to the command line for starting the grabbing.

See Also:
Constant Field Values

KEY_SHUTDOWNDELAY

public static final String KEY_SHUTDOWNDELAY
The time delay from receiving quit-command until orderly shutdown.

See Also:
Constant Field Values

DEFNAME

private static final String DEFNAME
The default name of the master launcher (SCS).

See Also:
Constant Field Values

DEFBIND

private static final boolean DEFBIND
The default error-binding behaviour.

See Also:
Constant Field Values

DEFACCELERATE

private static final double DEFACCELERATE
The default acceleration factor.

See Also:
Constant Field Values

DEFSTARTGRAB

private static final String DEFSTARTGRAB
The default start-grab script.

See Also:
Constant Field Values

DEFSTOPGRAB

private static final String DEFSTOPGRAB
The default start-grab script.

See Also:
Constant Field Values

DEFSHUTDOWNDELAY

private static final long DEFSHUTDOWNDELAY
The default shutdown delay time, 5 sec.

See Also:
Constant Field Values

forward

private ReplySubscriber forward
The registered reply subscriber.


pattern

private List pattern
The replies the reply subscriber is interested in.


stopwatch

private AlarmWatch stopwatch
An alarm to act as an interruptable stop-watch.


command

private List command
The list of rmi-command listeners.


chef

private MasterMind chef
The master mind.

Constructor Detail

MasterLauncher

public MasterLauncher(Map prop)
               throws RemoteException
Constructs a new master launcher with the specified properties. If the name is not set the default name is used, DEFNAME. Binding the rmi error-caster to the registry is defined with the KEY_BIND property. The default setting is DEFBIND. The binding name used is defined with KEY_BINDNAME, defaults to DEFNAME.

Throws:
RemoteException
Method Detail

init

public void init()
Initializes the master launcher. This includes binding of the rmi error casting capabilites to a running registry.

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

exit

public void exit()
Unbind thyself from the rwgistry.

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

getExitCommand

public CommandEvent getExitCommand()
Default implementation of exit command is null.

Specified by:
getExitCommand in interface CommandLaunching

registerReplySubscriber

public void registerReplySubscriber(ReplySubscriber sub)
Registers the reply subscriber. Call this method with a null argument to disable reply forwarding.

Specified by:
registerReplySubscriber in interface ReplyDeliverer
Parameters:
sub - The reply subscriber interested in received replies.

registerMasterMind

protected void registerMasterMind(MasterMind sub)
Registers the reply subscriber. Call this method with a null argument to disable reply forwarding.

Parameters:
sub - The reply subscriber interested in received replies.

announceInterest

public void announceInterest(ReplyEvent re)
Adds a new reply event pattern to the pattern list. This method should be called by the reply subscriber prior to sending the command that will produce the appropriate reply to the caster (castCommand(stella.CommandEvent)). Note that handling of multiple acknowledge commands is not possible in a master launcher.

Specified by:
announceInterest in interface ReplyDeliverer

getClientName

public String getClientName()
Returns the name of the master launcher used for readability improvement.

Specified by:
getClientName in interface CommandLaunching

getBindName

public String getBindName()
Returns the name of the master launcher used for readability improvement.

Overrides:
getBindName in class AbstractRmiCaster

getShutdownCommand

public CommandEvent getShutdownCommand()
Returns the shutdown command. This is the artificial ParkMaster command.

Specified by:
getShutdownCommand in interface CommandLaunching

isReady

public boolean isReady()
This is an internal command launcher. It is always ready.

Specified by:
isReady in interface CommandLaunching

handles

public boolean handles(CommandEvent ce)
The master launcher handles ScsCommands.

Specified by:
handles in interface CommandLaunching

castCommand

public void castCommand(CommandEvent ce)
Cast the command to the SCS. To allow fast return this method spawns its own helper thread. This thread calls back on the master launcher's protected processCommand(stella.CommandEvent) method. Additionally, it checks for registered acknloedge events prior to the call to this method and for registered done events after this method returns.

Specified by:
castCommand in interface CommandLaunching

addRmiCommandListener

public void addRmiCommandListener(RmiCommandListener ear)
                           throws RemoteException
Registers a command listener to the master launcher. Intended for logging only.

Specified by:
addRmiCommandListener in interface RmiCommandCaster
Throws:
RemoteException

removeRmiCommandListener

public void removeRmiCommandListener(RmiCommandListener ear)
                              throws RemoteException
Deregisters a command listener to the master launcher. Intended for logging only.

Specified by:
removeRmiCommandListener in interface RmiCommandCaster
Throws:
RemoteException

recastCommand

public void recastCommand()
Empty method. The master launcher is an internal command processor, therefore relaunching of commands is not necessarry.

Specified by:
recastCommand in interface CommandLaunching

halt

public void halt()
For times the guiding was lost. This method halts the internal watch until the cont() method is called.


cont

public void cont()
For times the guiding was lost. This method re-enables the internal watch after the halt() method has been called.


processCommand

protected void processCommand(CommandEvent ce)
The method to handle internal (master) commands. This method is also responsible for generating error events occuring within the command processing (this behaviour is different to the ReceiverTorso class).