The registry is a term for a small database built by the Niagara runtime whenever it detects that a module has been added, changed, or removed. During the registry build process all the types in all the modules are scanned. Their classfiles are parsed to build an index for the class hierarchy of all the Niagara types available in the installation.
Some of the functions the registry provides:
BIFile
TypesBOrdScheme
Types
The Registry
database may be accessed via Sys.getRegistry()
. Since
the primary use of the registry is to interrogate the system about modules
and types without loading them into memory, the registry API uses light
weight wrappers:
Registry Wrapper | Real McCoy |
---|---|
ModuleInfo |
BModule |
TypeInfo |
Type |
An agent is a special BObject type that provides services for other BObject types. Agents are registered on their target types via the module manifest and queried via the Registry interface. Agents are used extensively in the framework for late binding - such as defining views, popup menus, or exporters for specified target types. Typically agent queries are combined with a type filter. For example, to find all the BExporters registered on a given file:
AgentFilter filter = AgentFilter.is(BExporter.TYPE);
AgentList exporters = file.getAgents(null).filter(filter);
A couple of examples of how an agent type is registered on a target type
in the module manifest (module-include.xml):
<type name="ValueBinding" class="javax.baja.ui.BValueBinding">
<agent><on type="bajaui:Widget"/></agent>
<agent><on type="baja:Value"/></agent>
</type>
<type name="PropertySheet" class="com.tridium.workbench.propsheet.BPropertySheet">
<agent requiredPermissions="r"><on type="baja:Component"/></agent>
</type>
Agents can be registered on a target only for a specific application
using the app
attribute within the agent
tag. The application name can be queried at runtime via the
AgentInfo.getAppName()
method. Agent application names
are used in conjunction with the getAppName()
method of
BWbProfile
and
BHxProfile
.
An example application specific agent:
<type name="ApplianceUserManager" class="appliance.ui.BApplianceUserManager">
<agent app="demoAppliance">
<on type="baja:UserService"/>
</agent>
</type>
Modules can declare zero or more defs in their module manifest. Defs are simple String name/value pairs that are collapsed into a single global map by the registry. A good use of defs is to map a device id to a typespec, bog file, or some other metadata file. Then the registry may be used to map devices to Niagara information at learn time.
Since the defs of all modules are collapsed into a single map, it is important to avoid name collisions. Convention is to prefix your defs using module name plus a dot, for example "lonworks."
When using Niagara's standard build tools, defs are defined in your "module-include.xml":
<defs>
<def name="test.a" value="alpha"/>
<def name="test.b" value="beta"/>
</defs>
Use the registry API to query for defs:
String val = Sys.getRegistry().getDef("test.a");
A good way to learn about the registry is to navigate its spy pages.
Copyright © 2000-2019 Tridium Inc. All rights reserved.