|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectti.chimera.registry.RegistryCore
ti.chimera.Registry
The registry is a mechanism that allows different parts of the system share data. It is traditionally used to store registered plugins and services, but other parts of the system can use the registry to store or share data. The registry uses a publish-subscribe model, where in order to track the value of a node, the user subscribes to the node, and whenever the value of the node changes the most recent value is published to the subscriber's callback function. The registry will ensure that changes are published in the order they occur, and that all changes will be published, even if they've already been super- ceded by subsequent changes.
The registry is organized as a hierarchical tree, where "nodes" are
either parent nodes (directories) or data nodes. Directory nodes
are just data nodes whose data is a table mapping child names to
nodes. A path
is a /
delimited string that
specifies how to find a node from the root of the tree. Paths can
contain ..
to refer to one level up in the tree, or
.
to refer to the current level in the tree.
The registry can be accessed via Main.getRegistry()
or from the script environment variable registry
.
Main.getRegistry()
Nested Class Summary |
Nested classes inherited from class ti.chimera.registry.RegistryCore |
RegistryCore.DirectoryNode |
Field Summary |
Fields inherited from class ti.chimera.registry.RegistryCore |
main, root |
Method Summary | |
Service |
getService(java.lang.String name)
Get service provided by a plugin by name. |
void |
register(Plugin plugin)
Register a plugin. |
void |
subscribeToCreation(java.lang.String path,
NodeCreationSubscriber subscriber)
Subscribe to the creation of a node. |
void |
subscribeToDeletion(java.lang.String path,
NodeDeletionSubscriber subscriber)
Subscribe to the deletion of a node. |
void |
subscribeToValue(java.lang.String path,
NodeContract contract,
NodeSubscriber subscriber)
Subscribe to receive notification of changes to the value of the node at the specified path. |
void |
unsubscribeFromCreation(NodeCreationSubscriber subscriber)
Unsubscribe to the creation of a node. |
void |
unsubscribeFromDeletion(NodeDeletionSubscriber subscriber)
Unsubscribe to the deletion of a node. |
void |
unsubscribeFromValue(NodeSubscriber subscriber)
Unsubscribe from specified path. |
Methods inherited from class ti.chimera.registry.RegistryCore |
basename, dirname, exists, link, mkdir, normalize, resolve, unlink, unlink |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public void subscribeToValue(java.lang.String path, NodeContract contract, NodeSubscriber subscriber)
path
, and not the node that is currently located at that
path. If there is currently a node at this path, then the subscriber
will be immediately called with the current value, otherwise the
subscriber will be called once the node is created. If the node at
this path is removed, and then at some later time another node is
RegistryCore.link(ti.chimera.registry.Node, java.lang.String)
ed in to this path, then the subscriber will subscribed
to that node (and immediately called with it's value), and so on.
If contract
is not null
, then only subscribe
to the node if it has a compatible contract.
path
- the path to the node to subscribe tocontract
- the optional contract, or null
subscriber
- the subscriberpublic void unsubscribeFromValue(NodeSubscriber subscriber)
subscriber
- the subscriberpublic void subscribeToCreation(java.lang.String path, NodeCreationSubscriber subscriber)
RegistryCore.link(ti.chimera.registry.Node, java.lang.String)
ed in to the specified path. If the
node already exists, the subscriber will be called (pretty much)
immediately.
path
- the path to the node to subscribe tosubscriber
- the subscriberpublic void unsubscribeFromCreation(NodeCreationSubscriber subscriber)
subscriber
- the subscriberpublic void subscribeToDeletion(java.lang.String path, NodeDeletionSubscriber subscriber)
RegistryCore.unlink(java.lang.String)
ed from the specified path.
path
- the path to the node to subscribe tosubscriber
- the subscriberpublic void unsubscribeFromDeletion(NodeDeletionSubscriber subscriber)
subscriber
- the subscriberpublic void register(Plugin plugin)
#getPlugin
and
a service provided by a plugin can be resolved by getService(java.lang.String)
.
The registry will handle starting a plugin if needed.
plugin
- the plugin to register#getPlugin
,
getService(java.lang.String)
public Service getService(java.lang.String name)
name
- the name of the plugin to find#getServiceNames
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |