public class ParameterStub extends AbstractParameter implements CancelRunnable, RmiListener, Reloadable
Note that this globals get() method blocks until this registering
thread dies to ensure proper functionality.
| Modifier and Type | Class and Description |
|---|---|
static class |
ParameterStub.Finger
A class that allows access to parameter skeletons.
|
PropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
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.
|
KEY_FORMAT, KEY_NAME, KEY_PRESERVE, UNKNOWNKEY_NOINITONCREATE, POSTFIX_ALPHABET, POSTFIX_BYTES, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_MODTIME, POSTFIX_URLKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORCONFIG, KEY_CLASSKEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME| Constructor and Description |
|---|
ParameterStub(Map<String,String> prop)
Constructs a new paramter stub.
|
ParameterStub(String remotename)
For convenience, we support a constructor with only the remote name.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
createParameter, delivers, getFormatted, getName, getPreserveFile, getString, getString, overrideDefaultName, register, setName, toStringclone, 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, waitreloaddefaultBoolean, 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_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
public ParameterStub(String remotename) throws RemoteException, InitException
init().InitExceptionRemoteExceptionpublic 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.RemoteExceptionpublic void init()
throws InitException
init in interface Initializableinit in class AbstractParameterInitExceptionpublic void exit()
AbstractParameterexit in interface ExitCleaningexit in class AbstractParameterprivate 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.
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 AbstractParameterpublic boolean isConnected()
throws RemoteException
isConnected in interface RmiListenerRemoteExceptionpublic 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()
protected void rebind()
public String getFormatted()
getFormatted in interface ParametergetFormatted in class AbstractParameter