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 a RegistryDefinition. 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()
          Constructs a new instance that starts with a empty RegistryDefinition which can be requested by getRegistryDefinition().
RegistryBuilder(ErrorHandler errorHandler)
           
RegistryBuilder(RegistryDefinition registryDefinition)
          Constructs a new instance that starts with the provided RegistryDefinition.
RegistryBuilder(RegistryDefinition registryDefinition, ErrorHandler errorHandler)
           
 
Method Summary
 void autoDetectModules()
          Automatically loads hivemind modules on the classpath which are provided by RegistryProviders which are defined in Manifest-Files.
 void checkContributionCounts(RegistryDefinition definition)
          Checks that each configuration extension point has the right number of contributions.
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()
          Constructs the registry from its RegistryDefinition.
 Registry constructRegistry(java.util.Locale locale)
          Constructs the registry from its RegistryDefinition.
static Registry constructRegistry(RegistryDefinition definition, ErrorHandler errorHandler, java.util.Locale locale)
          Constructs the registry from a specified RegistryDefinition.
 ErrorHandler getErrorHandler()
           
 RegistryDefinition getRegistryDefinition()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegistryBuilder

public RegistryBuilder()
Constructs a new instance that starts with a empty RegistryDefinition which can be requested by getRegistryDefinition().


RegistryBuilder

public RegistryBuilder(RegistryDefinition registryDefinition)
Constructs a new instance that starts with the provided RegistryDefinition. The definition can still be altered afterwards.


RegistryBuilder

public RegistryBuilder(ErrorHandler errorHandler)

RegistryBuilder

public RegistryBuilder(RegistryDefinition registryDefinition,
                       ErrorHandler errorHandler)
Method Detail

getRegistryDefinition

public RegistryDefinition getRegistryDefinition()
Returns:
the contained registry definition

constructRegistry

public Registry constructRegistry()
Constructs the registry from its RegistryDefinition. Default locale is used.

See Also:
constructRegistry(Locale)

constructRegistry

public Registry constructRegistry(java.util.Locale locale)
Constructs the registry from its RegistryDefinition.

Parameters:
locale - the locale used for translating resources

constructRegistry

public static Registry constructRegistry(RegistryDefinition definition,
                                         ErrorHandler errorHandler,
                                         java.util.Locale locale)
Constructs the registry from a specified RegistryDefinition.

Parameters:
definition - the registry definition
errorHandler - errorHandler used for handling recoverable errors
locale - the locale used for translating resources
Returns:
the registry

checkContributionCounts

public void checkContributionCounts(RegistryDefinition definition)
Checks that each configuration extension point has the right number of contributions.


autoDetectModules

public void autoDetectModules()
Automatically loads hivemind modules on the classpath which are provided by RegistryProviders which are defined in Manifest-Files.


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 modules for non-standard locations, you must create a RegistryBuilder instance yourself.


getErrorHandler

public ErrorHandler getErrorHandler()


Copyright © 2003-2007 Apache Software Foundation. All Rights Reserved.