public abstract class CasterTorso extends AbstractRmiCasterAndListener implements AlarmHandler, RmiAcknowledgeListener, RmiDoneListener, RmiCommandCaster, ErrorCaster, ReplyDeliverer, CommandLaunching, Initializable
TelescopeCaster. It provides the following capabilities:
castCommand(stella.CommandEvent). This method calls the
RmiCommandListener.rmiCommand(stella.CommandEvent) method of all registered listeners.
Alarm is started to eventually
time-out the acknowledge receiving.AcknowledgeEvent is received in time another alarm is
started, its time-out depending on the completion time handed over with the
acknowledge event.ReplySubscriber relies on in talking to his client.ReplySubscriber can be associated with this caster
instance. All incoming replies (i.e. acknowledge and done
events are checked whether they should be forwarded to the reply subscriber.
The intended use for this is that some sort of a command sequencer is not
necessaryly interested in all acknowledge and done
events sent back to the caster, but only in some that allow the sequencer
optimal timing.ReplySubscriberPropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
private Hashtable |
active
A list of all commands active.
|
private ThreadGroup |
alarmGroup
The ThreadGroup the alarms should run in.
|
private int |
alarmNumber
The numbering for the alarms.
|
private static char |
ALARMSEPARATOR
The separator char between execute-keys and alarm number.
|
private Hashtable |
alarmTable
The table mapping commands to alarms.
|
private Vector |
commandList
The registered command listeners.
|
private static String |
COMPLETE
The name for alarms waiting for done or additional acknowledges.
|
private boolean |
crash
To avoid repeating crash errors.
|
private static boolean |
DEFBIND
The default command-binding behaviour.
|
private static long |
DEFTIMEOUT
The default acknowledge time-out value, in ms.
|
private static String |
FIRSTACKNOWLEDGE
The name for alarms waiting for the first acknowledge.
|
private ReplySubscriber |
forward
The registered reply subscriber.
|
static String |
KEY_ACKNOWLEDGECASTER
The key in the properties for the acknowledge casters.
|
static String |
KEY_ACKNOWLEDGETIMEOUT
The key in the properties for the acknowledge time out.
|
static String |
KEY_ALARMGROUP
The key in the properties for the alarm thread group.
|
static String |
KEY_BIND
The key matching the default command casting binding.
|
static String |
KEY_DONECASTER
The key in the properties for the done casters.
|
private CommandEvent |
lastCommand
A copy of the last command cast.
|
private Vector |
pattern
The replies the reply subscriber is interested in.
|
private Hashtable |
setOffAlarms
The table mapping alarms that have been set off to commands.
|
KEY_ALIVE, KEY_EXPORTPORT, KEY_INIT, KEY_LISTENERNAME, KEY_RETRY, KEY_RETRYSLEEP, KEY_SHUTDOWNDELAYKEY_NOINITONCREATE, POSTFIX_ALPHABET, POSTFIX_BYTES, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_MODTIME, POSTFIX_URLKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORNAMING_EXTENSIONCONFIG, KEY_CLASSKEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME| Modifier | Constructor and Description |
|---|---|
protected |
CasterTorso(Map qualify)
Constructs a new caster with the specified properties.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRmiCommandListener(RmiCommandListener ear)
Registers a rmi command event listener to this property container.
|
void |
announceInterest(ReplyEvent re)
Adds a new reply event pattern to the pattern list.
|
void |
castCommand(CommandEvent ce)
The public method called to cast a command to registered listeners.
|
private void |
checkForward(ReplyEvent re)
Checks if the received reply message should be forwarded to the
registered reply subscriber.
|
protected boolean |
deregisterAtCaster(RmiCaster caster,
Class service)
Deregisters at the specified caster if the caster is either an
RmiDoneCaster or an RmiAcknowledgeCaster |
void |
exit()
Derigsters from the acknowledge and done casters and unbinds from the
registry.
|
long |
getAcknowledgeTimeOut()
Returns the acknowledge time out, in ms.
|
ThreadGroup |
getAlarmGroup()
Returns the thread group the done and acknowledge time-out alarms should
run in.
|
String |
getClientName()
Returns the name of this caster.
|
CommandEvent |
getExitCommand()
Default implementation of exit command is null.
|
void |
init()
Initializes the command caster.
|
boolean |
isReady()
Checks if all connections to registered listeners are intact.
|
private int |
nextAlarmNumber()
Returns the next available number for the alarm numbering.
|
void |
recastCommand()
Recasts the last command.
|
protected boolean |
registerAtCaster(RmiCaster caster,
Class service)
Binds to an caster.
|
void |
registerReplySubscriber(ReplySubscriber forward)
Registers the reply subscriber.
|
void |
removeRmiCommandListener(RmiCommandListener ear)
Deregisters an rmi command event listener from this property container.
|
void |
rmiGotAcknowledge(AcknowledgeEvent ae)
The receiver method for acknowledge events.
|
void |
rmiGotDone(DoneEvent de)
The receiver method for done events.
|
void |
setOff(String alarm)
The method called by the internal alarms of this caster if a problem with
in-time replies occured.
|
String |
toString()
Returns a short description of the receiver torso.
|
addErrorListener, addRmiErrorListener, bindToRegistry, getBindName, isValid, notifyErrorListener, removeErrorListener, removeRmiErrorListener, sendError, sendError, sendError, sendStatus, sendStatus, sendStatus, unbindFromRegistryallBound, blockBinding, blockBinding, disconnect, getIP, getListenerName, isConnected, listenerName, releaseBinding, releaseBinding, rescanned, startBinding, startBindingcontainsRemoteProperty, getRemoteProperties, getRemoteProperty, setRemotePropertyclone, createFrom, createFrom, createFrom, createInstance, getApplet, getAsResources, getLocate, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, hasLocalURLs, initProperties, keyCreate, keyCreate, reload, setAppletaugment, augment, 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, parseObject, reload, removeProperty, requires, setObject, setProperties, setProperty, stringPropertiesequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetListenerNamedisconnect, isConnectedbindToRegistry, isValid, unbindFromRegistryaddErrorListener, removeErrorListenergetShutdownCommand, handlesdefaultBoolean, 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, stringPropertiespublic static final String KEY_BIND
public static final String KEY_ACKNOWLEDGECASTER
public static final String KEY_DONECASTER
public static final String KEY_ACKNOWLEDGETIMEOUT
public static final String KEY_ALARMGROUP
private static final long DEFTIMEOUT
private static final boolean DEFBIND
private static final String FIRSTACKNOWLEDGE
private static final String COMPLETE
private static final char ALARMSEPARATOR
private CommandEvent lastCommand
private final Hashtable active
private final Vector commandList
private ReplySubscriber forward
private final Vector pattern
private ThreadGroup alarmGroup
private final Hashtable alarmTable
private final Hashtable setOffAlarms
private int alarmNumber
private boolean crash
protected CasterTorso(Map qualify) throws RemoteException
KEY_ACKNOWLEDGETIMEOUT), the thread group the alarms should run
in KEY_ALARMGROUP and the caster bind name #KEY_BINDNAME
is always set. Additionally the retry intervall and the maximum number of
retries is set if not already given.qualify - The properties of this casterRemoteExceptionpublic void init()
According to the binding rules defined in
AbstractRmiListener#initBinding some wait cycles may be
introduced if the according caster cannot be found in the registry.
init in interface Initializablepublic void exit()
exit in interface ExitCleaningexit in class AbstractRmiCasterAndListenerpublic String toString()
toString in class PropertyContainerprotected boolean registerAtCaster(RmiCaster caster, Class service)
RmiCaster is an instance of
RmiDoneCaster this done listener registers to it via the
RmiDoneCaster.addRmiDoneListener(stella.rmi.RmiDoneListener) method. If the argumental
RmiCaster is an instance of RmiAcknowledgeCaster this
acknowledge listener registers to it via the
RmiAcknowledgeCaster.addRmiAcknowledgeListener(stella.rmi.RmiAcknowledgeListener) method.
If the argument is neither of these two types the method returns silently.
registerAtCaster in class AbstractRmiListenerderegisterAtCaster(util.rmi.RmiCaster, java.lang.Class)protected boolean deregisterAtCaster(RmiCaster caster, Class service)
RmiDoneCaster or an RmiAcknowledgeCasterderegisterAtCaster in class AbstractRmiListenerregisterAtCaster(util.rmi.RmiCaster, java.lang.Class)public CommandEvent getExitCommand()
getExitCommand in interface CommandLaunchingpublic String getClientName()
getClientName in interface CommandLaunchingpublic long getAcknowledgeTimeOut()
public ThreadGroup getAlarmGroup()
public void registerReplySubscriber(ReplySubscriber forward)
registerReplySubscriber in interface ReplyDelivererforward - The reply subscriber interested in received replies.public void castCommand(CommandEvent ce)
castCommand in interface CommandLaunchingpublic void recastCommand()
Because recasting of a command is only useful if the command has not been completely received at the receiver, only a first acknowledge may be in the waiting queue.
recastCommand in interface CommandLaunchingprivate int nextAlarmNumber()
public void rmiGotAcknowledge(AcknowledgeEvent ae) throws RemoteException
rmiGotAcknowledge in interface RmiAcknowledgeListenerRemoteExceptionpublic void rmiGotDone(DoneEvent de) throws RemoteException
rmiGotDone in interface RmiDoneListenerRemoteExceptionprivate void checkForward(ReplyEvent re)
ReplyEvent.matches(stella.ReplyEvent) all
stored reply patterns are used as arguments to the reply event
under question.
If the argument is matched to one of the patterns the argument is immediately passed to the registered reply subscriber and the pattern is removed from the list.
Note that this method synchronizes on the pattern vector.
public void announceInterest(ReplyEvent re)
castCommand(stella.CommandEvent)).
Otherwise timing fluctuation may cause problems.announceInterest in interface ReplyDelivererpublic void setOff(String alarm)
setOff in interface AlarmHandlerpublic void addRmiCommandListener(RmiCommandListener ear) throws RemoteException
addRmiCommandListener in interface RmiCommandCasterRemoteExceptionpublic void removeRmiCommandListener(RmiCommandListener ear) throws RemoteException
removeRmiCommandListener in interface RmiCommandCasterRemoteExceptionpublic boolean isReady()
Simply calls the RmiListener.isConnected() method, which
should return true or throw a remote exception.
isReady in interface CommandLaunching