替换一个运行时对象
>调用 replace().
|
RuntimeStore store = RuntimeStore.getRuntimeStore();
String newmsg = "Some new text";
try {
// Returns the existing object with the specified ID if it exists; null
// otherwise.
Object obj = store.replace( 0x60ac754bc0867248L, newmsg);
}
catch(ControlledAccessException e) {
// Handle exception - insufficient permissions.
}
|
获取一个注册的运行时对象
>调用RuntimeStore.get(). 将对象ID作为参数.
|
RuntimeStore store = RuntimeStore.getRuntimeStore();
// get() throws a ControlledAccessException if your application does not have read access to the specified object.
try {
// get() returns the objectm with the specified ID if it exists; null
// otherwise.
Object obj = store.get(0x60ac754bc0867248L);
}
catch(ControlledAccessException e) {
// Handle exception.
}
|
获取一个未注册的运行时对象
>调用RuntimeStore.waitFor() 等待一个运行时对象注册.
|
RuntimeStore store = RuntimeStore.getRuntimeStore();
try {
Object obj = store.waitFor(0x60ac754bc0867248L);
}
catch(ControlledAccessException e) {
// Handle exception - insufficient permissions.
}
catch(RuntimeException e) {
// Handle exception - time out.
}
|
注如果指定ID的对象不存在, waitFor()会阻止一个MAX_WAIT_MILLIS的最大数.如果此时对象还没有注册, waitFor()将会抛出一个RuntimeException异常.