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 Registryfrom individual ModuleDescriptor. The descriptors are provided by the ModuleDescriptorProviderparameter passed to constructRegistry(Locale)method.

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.RegistryInfrastructureImpl#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

Constructor Summary
RegistryBuilder()
           
RegistryBuilder(ErrorHandler handler)
           
 
Method Summary
 void addModuleDescriptorProvider(ModuleDescriptorProvider provider)
          Adds a ModuleDescriptorProvideras a source for module descriptorsto this RegistryBuilder.
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)
          This first loads all modules provided by the ModuleDescriptorProvider, then resolves all the contributions, then constructs and returns the Registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegistryBuilder

public RegistryBuilder()

RegistryBuilder

public RegistryBuilder(ErrorHandler handler)
Method Detail

addModuleDescriptorProvider

public void addModuleDescriptorProvider(ModuleDescriptorProvider provider)
Adds a ModuleDescriptorProvideras a source for module descriptorsto this RegistryBuilder. Adding the same provider instance multiple times has no effect.

Since:
1.1

constructRegistry

public Registry constructRegistry(java.util.Locale locale)
This first loads all modules provided by the ModuleDescriptorProvider, then 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.