|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectutil.PropertyContainer
util.PropertyResources
util.PropertyBundles
util.rmi.RmiPropertyContainer
util.rmi.AbstractRmiListener
stella.rmi.AbstractRmiCasterAndListener
stella.rmi.ReceiverTorso
public abstract class ReceiverTorso
The command receiver. This abstract base class comprises all the necessary methods to receive a command, send the acknowledge, process the command and send the done event. Concrete subclasses should provide their implementations of the command processor. The details of the class functionality can be described as follows.
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() method.AbstractRmiCasterAndListener.sendStatus(java.lang.String) with the desired
status message as an argument.
| Nested Class Summary | |
|---|---|
protected class |
ReceiverTorso.CommandHandler
Handles the incomming command. |
| Nested classes/interfaces inherited from class util.PropertyResources |
|---|
PropertyResources.URLResource |
| Field Summary | |
|---|---|
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 List<CommandEvent> |
process
A vector of commands currently processed. |
| 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 stella.rmi.RmiAcknowledgeCaster |
|---|
NAMING_EXTENSION |
| Fields inherited from interface stella.rmi.RmiDoneCaster |
|---|
NAMING_EXTENSION |
| Fields inherited from interface util.StepInitializable |
|---|
KEY_INITDEPTH |
| 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 | |
|---|---|
protected |
ReceiverTorso(Map<String,String> qualify)
Constructs a new receiver with the specified properties. |
| Method Summary | |
|---|---|
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 abstract ErrorEvent |
getLastError()
Returns the error event describing the last error that occured. |
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. |
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. |
| Methods inherited from class stella.rmi.AbstractRmiCasterAndListener |
|---|
addErrorListener, addRmiErrorListener, bindToRegistry, getBindName, isValid, notifyErrorListener, removeErrorListener, removeRmiErrorListener, sendError, sendError, sendError, sendStatus, sendStatus, sendStatus, unbindFromRegistry |
| Methods inherited from class util.rmi.AbstractRmiListener |
|---|
allBound, blockBinding, blockBinding, disconnect, getIP, getListenerName, isConnected, listenerName, releaseBinding, releaseBinding, startBinding, startBinding |
| 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, init, 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 |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface util.rmi.RmiCaster |
|---|
bindToRegistry, isValid, unbindFromRegistry |
| Methods inherited from interface stella.ErrorCaster |
|---|
addErrorListener, removeErrorListener |
| Methods inherited from interface stella.rmi.RmiCommandListener |
|---|
accepts |
| 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 |
| Methods inherited from interface util.Initializable |
|---|
init |
| Field Detail |
|---|
public 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 List<CommandEvent> process
private ThreadGroup commandGroup
private List<RmiAcknowledgeListener> acknowledgeList
private List<RmiDoneListener> doneList
| Constructor Detail |
|---|
protected ReceiverTorso(Map<String,String> qualify)
PropertyResources.init() method should be called after construction.
| Method Detail |
|---|
private static int nextCount()
public void initStep(int curdepth)
initStep in interface StepInitializablecurdepth - The current initialization depth.private void init0()
private void init3()
public void exit()
exit in interface ExitCleaningexit in class AbstractRmiCasterAndListener
protected 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 AbstractRmiListener
protected boolean deregisterAtCaster(RmiCaster caster,
Class ignored)
RmiCommandCaster instance.
deregisterAtCaster in class AbstractRmiListener
public 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.
RemoteException
public void addRmiAcknowledgeListener(RmiAcknowledgeListener ear)
throws RemoteException
addRmiAcknowledgeListener in interface RmiAcknowledgeCasterRemoteException
public void removeRmiAcknowledgeListener(RmiAcknowledgeListener ear)
throws RemoteException
removeRmiAcknowledgeListener in interface RmiAcknowledgeCasterRemoteException
public void addRmiDoneListener(RmiDoneListener ear)
throws RemoteException
addRmiDoneListener in interface RmiDoneCasterRemoteException
public void removeRmiDoneListener(RmiDoneListener ear)
throws RemoteException
removeRmiDoneListener in interface RmiDoneCasterRemoteException
public Map<String,Object> getRemoteProperties()
throws RemoteException
PropertyContainer.getProperties().
getRemoteProperties in interface RmiPropertyBearinggetRemoteProperties in class RmiPropertyContainerRemoteException
public 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.
RemoteException
public 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)
equals in class Objectpublic int hashCode()
hashCode in class Objectprotected 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 abstract ErrorEvent getLastError()
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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||