org.apache.hivemind.impl
Class RegistryBuilder

java.lang.Object
  |
  +--org.apache.hivemind.impl.RegistryBuilder

public final class RegistryBuilder
extends java.lang.Object

Class used to build a Registry from individual ModuleDescriptor. The descriptors are processed one at a time and the registry is constructed using a single call to constructRegistry(Locale) at the end.

A note about threadsafety: The assumption is that a single thread will access the RegistryBuilder at one time (typically, a startup class within some form of server or application). Code here and in many of the related classes is divided into construction-time logic and runtime logic. Runtime logic is synchronized and threadsafe. Construction-time logic is not threadsafe. Methods such as org.apache.hivemind.impl.RegistryImpl#addModule(Module), org.apache.hivemind.impl.ModuleImpl#addConfigurationPoint(ConfigurationPoint), ConfigurationPointImpl.addContribution(Contribution) and the like are construction-time. Once the registry is fully constructed, it is not allowed to invoke those methods (though, at this time, no checks occur).

Runtime methods, such as ModuleImpl.getService(String, Class) are fully threadsafe.

Author:
Howard Lewis Ship

Field Summary
static java.lang.String HIVE_MODULE_XML
          The path, within a JAR or the classpath, to the XML HiveMind module deployment descriptor: META-INF/hivemodule.xml.
 
Constructor Summary
RegistryBuilder()
           
RegistryBuilder(ErrorHandler handler)
           
 
Method Summary
static Registry constructDefaultRegistry()
          Constructs a default registry based on just the modules visible to the thread context class loader (this is sufficient is the majority of cases), and using the default locale.
 Registry constructRegistry(java.util.Locale locale)
          Invoked after all modules have been added with processModule(ClassResolver, Resource).
 void processModule(ClassResolver resolver, Resource moduleDescriptorResource)
          Parses a module and processes its contents.
 void processModule(ModuleDescriptor md)
          Processes a parsed HiveMind module descriptor.
 void processModules(ClassResolver resolver)
          Processes all modules that can be found using the resolver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HIVE_MODULE_XML

public static final java.lang.String HIVE_MODULE_XML
The path, within a JAR or the classpath, to the XML HiveMind module deployment descriptor: META-INF/hivemodule.xml.

See Also:
Constant Field Values
Constructor Detail

RegistryBuilder

public RegistryBuilder()

RegistryBuilder

public RegistryBuilder(ErrorHandler handler)
Method Detail

processModules

public void processModules(ClassResolver resolver)
Processes all modules that can be found using the resolver.


processModule

public void processModule(ClassResolver resolver,
                          Resource moduleDescriptorResource)
Parses a module and processes its contents. This is often used in conjunction with processModules(ClassResolver) to parse additional modules that are not in the standard location (for whatever reason).


processModule

public void processModule(ModuleDescriptor md)
Processes a parsed HiveMind module descriptor. This may be called repeatedly before invoking constructRegistry(Locale).

Parameters:
md - the parsed module descriptor

constructRegistry

public Registry constructRegistry(java.util.Locale locale)
Invoked after all modules have been added with processModule(ClassResolver, Resource). This first resolves all the contributions, then constructs and returns the registry.


constructDefaultRegistry

public static Registry constructDefaultRegistry()
Constructs a default registry based on just the modules visible to the thread context class loader (this is sufficient is the majority of cases), and using the default locale. If you have different error handling needs, or wish to pick up HiveMind module deployment descriptors for non-standard locations, you must create a RegistryBuilder instance yourself.