|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectutil.PropertyContainer
util.PropertyResources
util.PropertyBundles
stella.parameter.AbstractParameter
stella.parameter.ParameterStub
public class ParameterStub
The stub to a remote parameter. To allow local access to all paramters, a remote parameter is served by this stub. On construct this stub starts a thread within it tries to register to its remote counterpart. If binding is impossible this stub tries to re-establish contact after a waiting period defined in the properties. Only after a certain number of unsuccessful tries, the run method exits. Note that due to the data event listening schema it is not feasable to register to the remote sensor whenever data is needed.
Note that this globals get() method blocks until this registering
thread dies to ensure proper functionality.
| Nested Class Summary | |
|---|---|
static class |
ParameterStub.Finger
A class that allows access to parameter skeletons. |
| Nested classes/interfaces inherited from class util.PropertyResources |
|---|
PropertyResources.URLResource |
| Field Summary | |
|---|---|
private Thread |
bind
A reference to the registering thread. |
private boolean |
cancel
The cancel flag for the binding thread. |
private static boolean |
DEFBLOCK
The default blocking behaviour. |
private static int |
DEFINITTRY
The default initial tries number (1000). |
private static int |
DEFRETRY
The default retries number (10). |
private static long |
DEFSERVERDELAY
The default delay on server exit rebinds. |
private static long |
DEFWAIT
The default waiting time-out between registering retries (1000ms). |
private long |
delay
A delay for the binding thread to execute. |
private Format |
format
A formatter for the remopte object received. |
static String |
KEY_BLOCK
If true, get() blocks on retries. |
static String |
KEY_FORMATCLASS
The key to the class name of the format to use. |
static String |
KEY_FORMATPATTERN
The key to the format string constructor to use. |
static String |
KEY_INITTRY
The key linked to the number of initial registering tries. |
static String |
KEY_REMOTENAME
The key pointing to the name of the remote reference to bind to. |
static String |
KEY_RETRY
The key linked to the number of registering retries. |
static String |
KEY_SERVERDELAY
The key linked to a delay for binding on server exit. |
static String |
KEY_WAIT
The key linked to the time-out between registering retries. |
private int |
retry
The current number of retries. |
protected RemoteParameter |
sensor
The remote instance of the sensor global. |
| Fields inherited from class stella.parameter.AbstractParameter |
|---|
KEY_FORMAT, KEY_NAME, KEY_PRESERVE, UNKNOWN |
| 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.PropertySupplying |
|---|
CONFIG, KEY_CLASS |
| Fields inherited from interface util.ResourceSupplying |
|---|
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME |
| Constructor Summary | |
|---|---|
ParameterStub(Map<String,String> prop)
Constructs a new paramter stub. |
|
ParameterStub(String remotename)
For convenience, we support a constructor with only the remote name. |
|
| Method Summary | |
|---|---|
private void |
bindToRemote(int retries,
long timeout)
Tries to bind to the remote paramter. |
void |
cancel()
Cancels the binding thread. |
void |
disconnect(RmiCaster name)
Called by the remote parameter if it will stop serve. |
void |
exit()
If we preserve our state, we do this at exit. |
Object |
get()
Gets the value of the remotely wrapped global. |
Thread |
getAsociatedThread()
Returns the binding thread. |
String |
getFormatted()
Tries to format the remote object received according to its formatter. |
void |
init()
Initializes the parameter stub by binding it to the remote reference. |
boolean |
isConnected()
Returns true if sensor is non-null. |
long |
maxTimeToCancel()
Returns the maximum time required for canceling the binding thread. |
protected void |
rebind()
Daughter access after initial binding. |
double |
rescanned(String key,
String old,
String newval)
If the binding name, KEY_REMOTENAME cahnged, we deregister if
we are connected and restart the binding process. |
void |
run()
Tries to register to a remote sensor global. |
Object |
set(Object val)
Setting a sensor value is not allowed. |
| Methods inherited from class stella.parameter.AbstractParameter |
|---|
createParameter, delivers, getFormatted, getName, getPreserveFile, getString, getString, register, setName, toString |
| 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 |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface util.Reloadable |
|---|
reload |
| 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 |
|---|
public static final String KEY_REMOTENAME
public static final String KEY_BLOCK
get() blocks on retries.
public static final String KEY_WAIT
public static final String KEY_RETRY
public static final String KEY_INITTRY
public static final String KEY_SERVERDELAY
public static final String KEY_FORMATCLASS
public static final String KEY_FORMATPATTERN
private static final boolean DEFBLOCK
private static final long DEFWAIT
private static final int DEFRETRY
private static final long DEFSERVERDELAY
private static final int DEFINITTRY
protected RemoteParameter sensor
private Thread bind
private int retry
private long delay
private boolean cancel
private Format format
| Constructor Detail |
|---|
public ParameterStub(String remotename)
throws RemoteException
init().
RemoteException
public ParameterStub(Map<String,String> prop)
throws RemoteException
RemoteParameter. If the remote counterpart is not
yet bound, a retry loop, defined with KEY_RETRY and
KEY_WAIT is started during which the parameter waits for the
server to come up.
RemoteException| Method Detail |
|---|
public void init()
init in interface Initializableinit in class AbstractParameterpublic void exit()
AbstractParameter
exit in interface ExitCleaningexit in class AbstractParameter
private void bindToRemote(int retries,
long timeout)
public void run()
#KEY_REMOTE is
used to locate the registry on the remote machine. Then, the remote
registry is querried for a remote object with the name given by the
KEY_REMOTENAME, augmented with the naming extension defined
in RemoteParameter#NAMING_EXTENSION. If a remote reference is
obtained and is convertable into a remote global instance this thread
dies. Otherwise a retires cycle (see KEY_RETRY for number of
retires ) with a sleeping period defined by KEY_WAIT is
entered. Note that querrying this global is only permitted if this thread has died, i.e. if registering was successful.
run in interface Runnable
public double rescanned(String key,
String old,
String newval)
KEY_REMOTENAME cahnged, we deregister if
we are connected and restart the binding process.
rescanned in interface Reloadablerescanned in class AbstractParameter
public boolean isConnected()
throws RemoteException
isConnected in interface RmiListenerRemoteException
public void disconnect(RmiCaster name)
throws RemoteException
disconnect in interface RmiListenerRemoteExceptionpublic void cancel()
cancel in interface CancelRunnablepublic long maxTimeToCancel()
maxTimeToCancel in interface CancelRunnablepublic Thread getAsociatedThread()
getAsociatedThread in interface CancelRunnablepublic Object get()
get in interface Parameterprotected void rebind()
public Object set(Object val)
set in interface Parameterpublic String getFormatted()
getFormatted in interface ParametergetFormatted in class AbstractParameter
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||