public abstract class ReceiverTorso extends AbstractRmiCasterAndListener implements RmiAcknowledgeCaster, RmiDoneCaster, ErrorCaster, RmiCommandListener, StepInitializable
rmiCommand(stella.CommandEvent)
method, it generates a reply as an acknowledge command. To get
the correct acknowledge number it calls the getAcknowledgeNumber(stella.CommandEvent)
method with the command received as an
argument. In the default implementation
this method returns 1 which is always the number of the
last acknowledge command. Concrete subclasses may interfere here if
multiple acknowledge events are necessary.getCompletionTime(stella.CommandEvent, int) with the command and
the actual type number of the acknowledge event is called. This method
must return fast otherwise the sending of the acknowledge event is
delayed.processCommand(stella.CommandEvent, int) again with the command and the actual acknowledge
type is called.getLastError(stella.CommandEvent) method.AbstractRmiCasterAndListener.sendStatus(java.lang.String) with the desired
status message as an argument.| Modifier and Type | Class and Description |
|---|---|
protected class |
ReceiverTorso.CommandHandler
Handles the incomming command.
|
PropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
private List<RmiAcknowledgeListener> |
acknowledgeList
The Vector of the registered acknowledge listeners.
|
private ThreadGroup |
commandGroup
The thread group command handlers run in.
|
private static int |
COUNT
An internal counter for automatic naming.
|
private static long |
DEFABORTTIME
The default abort time acknowledge.
|
private static boolean |
DEFBIND
The default auto-binding as a
RmiDoneCaster. |
private static long |
DEFERRORCOOL
The default error-downcool time.
|
private static int |
DEFINITDEPTH
The default depth of the initialization process.
|
private List<RmiDoneListener> |
doneList
The Vector of the registered done listeners.
|
static String |
KEY_BIND
The key in the Map for auto-binding of the receiver.
|
static String |
KEY_BINDNAME
The binding name of this done and acknowledge caster.
|
static String |
KEY_COMMANDCASTER
The key in the properties for the default command casters.
|
static String |
KEY_ERRORCOOL
The key in the Map for error-downcool.
|
private Map<CommandEvent,ErrorEvent> |
process
A vector of commands currently processed.
|
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_EXTENSIONNAMING_EXTENSIONKEY_INITDEPTHKEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOMECONFIG, KEY_CLASS| Modifier | Constructor and Description |
|---|---|
protected |
ReceiverTorso(Map<String,String> qualify)
Constructs a new receiver with the specified properties.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRmiAcknowledgeListener(RmiAcknowledgeListener ear)
Registers an acknowledge listener to this command receiver.
|
void |
addRmiDoneListener(RmiDoneListener ear)
Adds a done event listener to this command receiver.
|
protected boolean |
bindDefault()
Initializes binding to all default command casters.
|
boolean |
containsRemoteProperty(String key)
Tests if this property container contains a certain property.
|
protected boolean |
deregisterAtCaster(RmiCaster caster,
Class ignored)
Deregisters at the command caster.
|
boolean |
equals(Object that)
Two receiver torsos are equal, if their classes are equals.
|
void |
exit()
Exits the receiver torso.
|
protected abstract int |
getAcknowledgeNumber(CommandEvent cmd)
Returns the number of acknowledge event to be sent back
as a function of the
command type.
|
protected abstract long |
getCompletionTime(CommandEvent cmd,
int acknr)
Returns the completion time for the specified command.
|
protected ErrorEvent |
getLastError(CommandEvent cmd)
Returns the error event describing the last error that occured as a
result
of a specified commend.
|
Map<String,Object> |
getRemoteProperties()
Returns the entire properties of this object as a map.
|
String |
getRemoteProperty(String key)
Returns a special property of this property container.
|
int |
hashCode()
Returns the class hash.
|
private void |
init0()
Zero-level, i.e.
|
private void |
init3()
Initializes this receiver by adding its casting capabilities to the
registry if auto-binding is enabled.
|
void |
initStep(int curdepth)
The step-wise initialization.
|
private static int |
nextCount()
Gets the next available number at automatic naming.
|
protected void |
notifyAcknowledgeListener(AcknowledgeEvent ae)
Sends the acknowledge event to all registered acknowledge event
listeners.This method parses
through the Vector of acknowledge listeners and passes the argument to
their gotAcknowledge method.
|
protected void |
notifyDoneListener(DoneEvent de)
Sends the done event to all registered done event listeners.This
method parses
through the Vector of done listeners and passes the argument to their
gotDone method.
|
protected abstract boolean |
processCommand(CommandEvent cmd,
int acknr)
Processes the given command.
|
protected boolean |
registerAtCaster(RmiCaster caster,
Class<?> service)
Registers at the command caster.
|
void |
removeRmiAcknowledgeListener(RmiAcknowledgeListener ear)
Deregisters an acknowledge listener from this command receiver.
|
void |
removeRmiDoneListener(RmiDoneListener ear)
Deregisters a done event listener from this command receiver.
|
protected double |
rescanned(String key,
String old,
String newval)
On reload, unbind default, if command caster is affected.
|
void |
rmiCommand(CommandEvent cmd)
The command receiving method.
|
protected void |
sendAllPrematureDone()
Terminates all command currently processed except
Aborting
commands. |
protected void |
sendPrematureDone(CommandEvent cmd)
Terminates the given command with a final done event.
|
protected void |
setLastError(CommandEvent cmd,
ErrorEvent ee)
Sets the last error event occuring.
|
String |
setRemoteProperty(String key,
String val)
Sets a special property of this property container.
|
String |
toString()
Returns a short description of the receiver torso.
|
protected boolean |
unbindDefault()
Removes binding to all default command casters.
|
addErrorListener, addRmiErrorListener, bindToRegistry, getBindName, isValid, notifyErrorListener, removeErrorListener, removeRmiErrorListener, sendError, sendError, sendError, sendStatus, sendStatus, sendStatus, unbindFromRegistryallBound, blockBinding, blockBinding, disconnect, getIP, getListenerName, isConnected, listenerName, releaseBinding, releaseBinding, startBinding, startBindingclone, 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, stringPropertiesfinalize, getClass, notify, notifyAll, wait, wait, waitbindToRegistry, isValid, unbindFromRegistryaddErrorListener, removeErrorListeneracceptsgetListenerNamedisconnect, isConnecteddefaultBoolean, 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_COMMANDCASTER
public static final String KEY_BINDNAME
public static final String KEY_BIND
public static final String KEY_ERRORCOOL
private static final int DEFINITDEPTH
private static final boolean DEFBIND
RmiDoneCaster.private static final long DEFERRORCOOL
private static final long DEFABORTTIME
private static int COUNT
private Map<CommandEvent,ErrorEvent> process
private final ThreadGroup commandGroup
private List<RmiAcknowledgeListener> acknowledgeList
private List<RmiDoneListener> doneList
protected ReceiverTorso(Map<String,String> qualify)
#init method should be called after construction.private static int nextCount()
public void initStep(int curdepth)
throws InitException
initStep in interface StepInitializableInitExceptionprivate void init0()
private void init3()
public void exit()
exit in interface ExitCleaningexit in class AbstractRmiCasterAndListenerprotected double rescanned(String key, String old, String newval)
rescanned in class AbstractRmiListenerprotected boolean bindDefault()
KEY_COMMANDCASTER.protected boolean unbindDefault()
KEY_COMMANDCASTER.protected boolean registerAtCaster(RmiCaster caster, Class<?> service)
RmiCommandCaster instance.registerAtCaster in class AbstractRmiListenerprotected boolean deregisterAtCaster(RmiCaster caster, Class ignored)
RmiCommandCaster instance.deregisterAtCaster in class AbstractRmiListenerpublic void rmiCommand(CommandEvent cmd) throws RemoteException
This method returns fast, i.e. it spawns a new thread that takes care of
handling the command. This is done by instantaning a helper class
ReceiverTorso.CommandHandler which is a inner class of the Receiver.
It is constructed with the specified command as a parameter therefore
multiple calls to this method oppose no problem.
rmiCommand in interface RmiCommandListenercmd - The command to process.RemoteExceptionprotected ErrorEvent getLastError(CommandEvent cmd)
protected void setLastError(CommandEvent cmd, ErrorEvent ee)
public void addRmiAcknowledgeListener(RmiAcknowledgeListener ear) throws RemoteException
addRmiAcknowledgeListener in interface RmiAcknowledgeCasterRemoteExceptionpublic void removeRmiAcknowledgeListener(RmiAcknowledgeListener ear) throws RemoteException
removeRmiAcknowledgeListener in interface RmiAcknowledgeCasterRemoteExceptionpublic void addRmiDoneListener(RmiDoneListener ear) throws RemoteException
addRmiDoneListener in interface RmiDoneCasterRemoteExceptionpublic void removeRmiDoneListener(RmiDoneListener ear) throws RemoteException
removeRmiDoneListener in interface RmiDoneCasterRemoteExceptionpublic Map<String,Object> getRemoteProperties() throws RemoteException
PropertyContainer.getProperties().getRemoteProperties in interface RmiPropertyBearinggetRemoteProperties in class RmiPropertyContainerRemoteExceptionpublic String getRemoteProperty(String key) throws RemoteException
PropertyContainer.getProperty(java.lang.String).getRemoteProperty in interface RmiPropertyBearinggetRemoteProperty in class RmiPropertyContainerkey - The key for the Map object.PropertyContainer.getProperty(java.lang.String) call.RemoteExceptionpublic String setRemoteProperty(String key, String val)
PropertyContainer.setProperty(java.lang.String, java.lang.String).setRemoteProperty in interface RmiPropertyBearingsetRemoteProperty in class RmiPropertyContainerkey - The key for this Property.value - The value of this Property.public boolean containsRemoteProperty(String key) throws RemoteException
PropertyContainer.has(java.lang.String).containsRemoteProperty in interface RmiPropertyBearingcontainsRemoteProperty in class RmiPropertyContainerRemoteExceptionpublic String toString()
toString in class PropertyContainerpublic boolean equals(Object that)
protected void sendPrematureDone(CommandEvent cmd)
protected void sendAllPrematureDone()
Aborting
commands.protected abstract int getAcknowledgeNumber(CommandEvent cmd)
protected abstract long getCompletionTime(CommandEvent cmd, int acknr)
cmd - The command to process.acknr - The number of the acknowledge that will be sent back.protected abstract boolean processCommand(CommandEvent cmd, int acknr)
The method returns true if the (sub)task was executed without an error.
If it returns false the appropriate error event must be ready for
retrival using the #getLastError() method.
protected void notifyAcknowledgeListener(AcknowledgeEvent ae)
ae - The AcknowledgeEvent to pass to the Listeners.protected void notifyDoneListener(DoneEvent de)
de - The DoneEvent to pass to the Listeners.