|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.system.RuntimeStore
public final class RuntimeStore
Provides a central location for applications to share information.
The store is not persistent. If the device resets, then information stored in the store is lost.
You will create a memory leak if you add an object instance to the global RuntimeStore and don't remove it.
You can control read and write access to any object you place in the
store by wrapping it in a ControlledAccess
object. Use
code similar to this example:
long MY_DATA_ID = 0x33abf322367f9018L; Hashtable myHashtable = new Hashtable(); // Get the code signing key associated with "ACME". CodeSignKey codeSigningKey = CodeSigningKey.get( moduleHandle, "ACME" ); // Store myHashtable in the RuntimeStore but protect it with the "ACME" code signing key. RuntimeStore.put( MY_DATA_ID, new ControlledAccess( myHashtable, codeSigningKey ) );
Now, only code files signed with the ACME key can read or replace the myHashtable object.
To retrieve something from the RuntimeStore, use code similar to this example:
Hashtable myHashtable = (Hashtable) RuntimeStore.get( MY_DATA_ID ); // Note: no need to unwrap ControlledAccess.
Or, to check if your data is protected with a particular code signing key, use code similar to this:
Hashtable myHashtable = (Hashtable) RuntimeStore.get( MY_DATA_ID, codeSigningKey ); // Note: There is no need to unwrap ControlledAccess.
Method Summary | ||
---|---|---|
|
Object |
get(long id)
Retrieves an object in the store by ID. |
|
Object |
get(long id,
CodeSigningKey readAndReplaceKey)
Retrieves an object in the store by ID, verifying permissions with the provided key. |
|
Object |
get(long id,
CodeSigningKey readKey,
CodeSigningKey replaceKey)
Retrieves an object in the store by ID, verifying permissions with the provided keys. |
|
ControlledAccess |
getControlledAccess(long id)
Retrieves a controlled access object associated with the given ID. |
|
static RuntimeStore |
getRuntimeStore()
Retrieves the system-wide RuntimeStore instance. |
|
void |
put(long id,
Object value)
Adds the given object to the store. |
|
Object |
remove(long id)
Removes an object from the store |
|
Object |
remove(long id,
CodeSigningKey readAndReplaceKey)
Removes an object in the store by ID, verifying permissions with the provided key. |
|
Object |
remove(long id,
CodeSigningKey readKey,
CodeSigningKey replaceKey)
Removes an object in the store by its ID, verifying permissions with the provided keys. |
|
Object |
replace(long id,
Object value)
Adds the given object to the store. |
|
Object |
waitFor(long id)
Retrieves an object in the store by ID. |
|
Object |
waitFor(long id,
CodeSigningKey readAndReplaceKey)
Retrieves an object in the store by ID. |
|
Object |
waitFor(long id,
CodeSigningKey readKey,
CodeSigningKey replaceKey)
Retrieves an object in the store by ID. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public Object get(long id)
ControlledAccess
objects are automatically unwrapped.
id
- Identifier of the object to retrieve.
null
if no object with that ID exists.
ControlledAccessException
- If the caller does not have read permission.public Object get(long id, CodeSigningKey readAndReplaceKey)
Use this method to retrieve an object by ID, and to check that read and replace permissions are protected with the given key.
ControlledAccess
objects are automatically unwrapped.
id
- Identifier of the object to retrieve.readAndReplaceKey
- Key to match for read and replace
permission. Can be null
if the caller doesn't care what keys are in force.
null
if no object with that ID exists.
ControlledAccessException
- If the caller does not have read
permission, or the existing keys do not match the given key.public Object get(long id, CodeSigningKey readKey, CodeSigningKey replaceKey)
Use this method to retrieve an object ID and check that read and replace permissions are protected with the given (separate) keys.
ControlledAccess
objects are automatically unwrapped.
id
- Identifier of the object to retrieve.readKey
- Key to match for read permission. Can be null
if the caller
doesn't care what read key is in force.replaceKey
- Key to match for replace permission. Can be null
if
the caller doesn't care what replace key is in force.
null
if no object with that ID exists.
ControlledAccessException
- If the caller does not have read
permission, or the existing keys do not match the given keys.public ControlledAccess getControlledAccess(long id)
id
- Identifier of the object to check.
null
if the object
was not wrapped in a ControlledAccess object.public void put(long id, Object value)
IllegalArgumentException
is thrown.
id
- Identifier to associate with the stored object.value
- Object to store.
ControlledAccessException
- If the caller does not have
authorization to replace the existing object.public Object replace(long id, Object value)
id
- Identifier to associate with the stored object.value
- Object to store.
null
if
there was no previous object associated with your ID.
ControlledAccessException
- If the caller does not have
authorization to replace the existing object.public Object remove(long id)
id
- The unique key identifying the object.
id
, or null
if no such object exists.public Object remove(long id, CodeSigningKey readAndReplaceKey)
Use this method to remove an object by ID and to check that read and replace permisions are protected with the given key.
ControlledAccess
objects are automatically unwrapped.
id
- Identifier of the object to retrieve.readAndReplaceKey
- Key to match for read and replace.
permission. Can be null
if the caller doesn't care what keys are in force.
null
if no object with that ID exists.
ControlledAccessException
- If the caller does not have read
permission, or the existing keys do not match the given key.public Object remove(long id, CodeSigningKey readKey, CodeSigningKey replaceKey)
Use this method to remove an object ID and check that read and replace permissions are protected with the given (separate) keys.
ControlledAccess
objects are automatically unwrapped.
id
- Identifier of the object to retrieve.readKey
- Key to match for read permission. Can be null
if the caller
doesn't care what read key is in force.replaceKey
- Key to match for replace permission. Can be null
if the
caller doesn't care what replace key is in force.
null
if no object with that ID exists.
ControlledAccessException
- If the caller does not have read
permission, or the existing keys do not match the given keys.public Object waitFor(long id)
MAX_WAIT_MILLIS
,
a RuntimeException
is thrown.
ControlledAccess
objects are automatically unwrapped.
id
- Identifier of the object to retrieve.
ControlledAccessException
- If the caller does not have read
permission.public Object waitFor(long id, CodeSigningKey readAndReplaceKey)
MAX_WAIT_MILLIS
waiting for the object
to be registered. If the object is not registered after MAX_WAIT_MILLIS
,
a RuntimeException
is thrown.
ControlledAccess
objects are automatically unwrapped.
id
- Identifier of the object to retrieve.readAndReplaceKey
- Key to match for read and replace
permission. Can be null
if the caller doesn't care what keys are in force.
ControlledAccessException
- If the caller does not have read
permission.public Object waitFor(long id, CodeSigningKey readKey, CodeSigningKey replaceKey)
MAX_WAIT_MILLIS
waiting for the object
to be registered. If the object is not registered after MAX_WAIT_MILLIS
,
a RuntimeException
is thrown.
ControlledAccess
objects are automatically unwrapped.
id
- Identifier of the object to retrieve.readKey
- Key to match for read permission. Can be null
if the caller
doesn't care what read key is in force.replaceKey
- Key to match for replace permission. Can be null
if the
caller doesn't care what replace key is in force.
ControlledAccessException
- If the caller does not have read
permission.public static RuntimeStore getRuntimeStore()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.