Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Registry Definition and Construction

In HiveMind 1 XML was the only way to define a registry.
HiveMind 2 introduces a java definition API which is the base for all additional definition methods.
So currently it is possible to use these techniques:

The construction process

To reflect the various possible sources for module definitions the process of building a registry has changed.
Two things are needed: First of all a registry definition, which contains
a description of the registry with all its modules, extension points
and extensions. This definition is to a registry instance what a class is to an object.
The definition is handed over to a registry builder which is responsible for consistency checks and the construction.

Code Block
RegistryDefinition registryDefinition = new RegistryDefinition();
 
...  add modules, services, configurations etc.

RegistryBuilder builder = new RegistryBuilder(registryDefinition );
Registry registry = builder.constructRegistry(Locale.getDefault());

A xml module that conforms to the 1.1 HiveMind deployment descriptor schema
can be processed using a XmlModuleReader:

Code Block
RegistryDefinition registryDefinition = new RegistryDefinition();

XmlModuleReader reader = new XmlModuleReader(registryDefinition);
reader.readClassPathModule("META-INF/hivemodule.xml");
reader.readClassPathModule("foo/hivemodule2.xml");

RegistryBuilder builder = new RegistryBuilder(registryDefinition );
Registry registry = builder.constructRegistry();

That is working similar for the new annotated modules:

Code Block
AnnotatedModuleReader reader = new AnnotatedModuleReader(registryDefinition);
reader.readModule(org.apache.hivemind.SimpleModule.class);

And finally it is possible to create the module definition by hand:

Code Block
ModuleDefinition module = new ModuleDefinitionImpl("test");

ServicePointDefinition service1 = new ServicePointDefinitionImpl(module, "Service1",
  null, Visibility.PUBLIC, Runnable.class.getName());

module.addServicePoint(service1);
registryDefinition.addModule(module);