public final class RegistryBuilder extends java.lang.Object
Registry
from individual
ModuleDescriptor
. The descriptors are provided by the
ModuleDescriptorProvider
parameter 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.
Constructor and Description |
---|
RegistryBuilder() |
RegistryBuilder(ErrorHandler handler) |
Modifier and Type | Method and Description |
---|---|
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.
|
public RegistryBuilder()
public RegistryBuilder(ErrorHandler handler)
public void addModuleDescriptorProvider(ModuleDescriptorProvider provider)
ModuleDescriptorProvider
as a source for
module descriptors
to this RegistryBuilder. Adding the same provider
instance multiple times has no effect.public Registry constructRegistry(java.util.Locale locale)
public void addDefaultModuleDescriptorProvider()
RegistryBuilder
. A default
module descriptor provider is merely a XmlModuleDescriptorProvider
constructed with a
DefaultClassResolver
.public static Registry constructDefaultRegistry()
addDefaultModuleDescriptorProvider()