org.apache.hivemind.impl
Class RegistryBuilder

java.lang.Object
  extended by 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 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. 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 addDefaultModuleDescriptorProvider()
          Adds a default module descriptor provider to this RegistryBuilder.
 void addModuleDescriptorProvider(ModuleDescriptorProvider provider)
          Adds a ModuleDescriptorProvider as a source for module descriptors to 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 ModuleDescriptorProvider as a source for module descriptors to 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.


addDefaultModuleDescriptorProvider

public void addDefaultModuleDescriptorProvider()
Adds a default module descriptor provider to this RegistryBuilder. A default module descriptor provider is merely a XmlModuleDescriptorProvider constructed with a DefaultClassResolver.

Since:
1.1

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.

See Also:
addDefaultModuleDescriptorProvider()