org.apache.hivemind.internal
Interface RegistryInfrastructure

All Superinterfaces:
SymbolSource
All Known Implementing Classes:
RegistryInfrastructureImpl

public interface RegistryInfrastructure
extends SymbolSource

Extension of Registry provided by some internals of HiveMind to faciliate the creation of services and configurations.

Author:
Howard Lewis Ship

Method Summary
 void cleanupThread()
          Convienience for invoking ThreadEventNotifier.fireThreadCleanup().
 boolean containsConfiguration(java.lang.String configurationId, Module module)
          Returns true if a configuration for the specified id exists (and is visible to the specified module).
 boolean containsService(java.lang.Class serviceInterface, Module module)
          Returns true if a single service exists which implements the specified service interface and is visible to the given module.
 boolean containsService(java.lang.String serviceId, java.lang.Class serviceInterface, Module module)
          Returns true if a single service with the given id exists which implements the specified service interface and is visible to the given module.
 java.lang.String expandSymbols(java.lang.String input, Location location)
          Expands any substitution symbols in the input string, replacing each symbol with the symbols value (if known).
 java.util.List getConfiguration(java.lang.String configurationId, Module module)
          Returns the converted items contributed to the configuration point.
 java.util.Map getConfigurationAsMap(java.lang.String configurationId, Module module)
          Returns the elements of the given configuration point as an unmodifiable Map.
 ConfigurationPoint getConfigurationPoint(java.lang.String configurationId, Module module)
          Returns the configuration point.
 ErrorHandler getErrorHander()
          Returns the ErrorHandler for this Registry.
 java.util.Locale getLocale()
          Returns the locale for which the registry was created.
 Module getModule(java.lang.String moduleId)
          Returns the module with the corresponding module id.
 java.lang.Object getService(java.lang.Class serviceInterface, Module module)
          Finds a service that implements the provided interface.
 java.lang.Object getService(java.lang.String serviceId, java.lang.Class serviceInterface, Module module)
          Obtains a service from the registry.
 java.util.List getServiceIds(java.lang.Class serviceInterface)
           
 ServiceModelFactory getServiceModelFactory(java.lang.String name)
          Returns a named service-model factory
 ServicePoint getServicePoint(java.lang.String serviceId, Module module)
          Returns the identified service extension point.
 Translator getTranslator(java.lang.String constructor)
          Gets a Translator instance.
 boolean isConfigurationMappable(java.lang.String configurationId, Module module)
          Returns true if the elements contributed to the given configuration point can be retrieved as a Map.
 void setupThread()
          To be invoked at the start of each request in a multi-threaded environment.
 void shutdown()
          Shuts down the registry; this notifies all RegistryShutdownListener services and objects.
 void startup()
          Invoked once, just after the registry infrastructure is constructed.
 
Methods inherited from interface org.apache.hivemind.SymbolSource
valueForSymbol
 

Method Detail

getService

java.lang.Object getService(java.lang.String serviceId,
                            java.lang.Class serviceInterface,
                            Module module)
Obtains a service from the registry. Typically, what's returned is a proxy, but that's irrelevant to the caller, which simply will invoke methods of the service interface.

Parameters:
serviceId - the fully qualified id of the service to obtain
serviceInterface - the class to which the service will be cast
module - the referencing module, used for visibility checks (null means no module, which requires that the service be public)
Returns:
the service
Throws:
ApplicationRuntimeException - if the service does not exist (or is not visible), or if it can't be cast to the specified service interface

getService

java.lang.Object getService(java.lang.Class serviceInterface,
                            Module module)
Finds a service that implements the provided interface. Exactly one such service may exist or an exception is thrown.

Parameters:
serviceInterface - used to locate the service
module - the referencing module, used for visibility checks. If null, then only public service points will be considered.
Throws:
ApplicationRuntimeException - if either 0, or more than 1, service point is visible to the module

getConfiguration

java.util.List getConfiguration(java.lang.String configurationId,
                                Module module)
Returns the converted items contributed to the configuration point.

Parameters:
configurationId - the fully qualified id of the configuration
module - the referencing module, used for visibility checks (null means no module, which requires that the configuration be public)
Returns:
List of converted elements
Throws:
ApplicationRuntimeException - if no such configuration extension point exists (or visible)

isConfigurationMappable

boolean isConfigurationMappable(java.lang.String configurationId,
                                Module module)
Returns true if the elements contributed to the given configuration point can be retrieved as a Map.

Parameters:
configurationId - the fully qualified id of the configuration
module - the referencing module, used for visibility checks (null means no module, which requires that the configuration be public)
Throws:
ApplicationRuntimeException - if no visible configuration point with the given id exists
Since:
1.1
See Also:
Module.isConfigurationMappable(String)

getConfigurationAsMap

java.util.Map getConfigurationAsMap(java.lang.String configurationId,
                                    Module module)
Returns the elements of the given configuration point as an unmodifiable Map. It may be empty, but not null.

Parameters:
configurationId - the fully qualified id of the configuration
module - the referencing module, used for visibility checks (null means no module, which requires that the configuration be public)
Throws:
ApplicationRuntimeException - if no visible configuration point with the given id exists or if the elements can't be mapped.
Since:
1.1
See Also:
Module.getConfigurationAsMap(String), #isConfigurationMappable(String)

getConfigurationPoint

ConfigurationPoint getConfigurationPoint(java.lang.String configurationId,
                                         Module module)
Returns the configuration point.

Parameters:
configurationId - the fully qualified id of the configuration
module - the referencing module, used for visibility checks (null means no module, which requires that the configuration be public)
Returns:
ConfigurationPoint matching the configuration id
Throws:
ApplicationRuntimeException - if the configurationId does not exist (or is not visible)

getServicePoint

ServicePoint getServicePoint(java.lang.String serviceId,
                             Module module)
Returns the identified service extension point.

Parameters:
serviceId - fully qualified id of the service point
module - the referencing module, used for visibility checks (null means no module, which requires that the service be public)
Throws:
ApplicationRuntimeException - if no such service extension point exists (or is visible to the module)

expandSymbols

java.lang.String expandSymbols(java.lang.String input,
                               Location location)
Expands any substitution symbols in the input string, replacing each symbol with the symbols value (if known). If a symbol is unknown, then the symbol is passed through unchanged (complete with the ${ and } delimiters) and an error is logged.

Parameters:
input - input string to be converted, which may (or may not) contain any symbols.
location - the location from which the string was obtained, used if an error is logged.

getServiceModelFactory

ServiceModelFactory getServiceModelFactory(java.lang.String name)
Returns a named service-model factory


getTranslator

Translator getTranslator(java.lang.String constructor)
Gets a Translator instance. The Translator may be a shared, cached instance (Translators should be stateless). Translators are identified by a constructor, which may be the name of a translator defined in the hivemind.Translators extension point (a single builtin translator, class, is hardcoded). Alternately, the name may consist of a translator name, a comma, and an initializer string for the service (example: int,min=5).

Parameters:
constructor - the name and optional initialization of a Translator
Returns:
a Translator instance
Throws:
ApplicationRuntimeException - if the translator can not be constructed (i.e., the name is not known)

getLocale

java.util.Locale getLocale()
Returns the locale for which the registry was created.


getErrorHander

ErrorHandler getErrorHander()
Returns the ErrorHandler for this Registry.


containsConfiguration

boolean containsConfiguration(java.lang.String configurationId,
                              Module module)
Returns true if a configuration for the specified id exists (and is visible to the specified module).

Parameters:
configurationId - to search for
module - the configuration must be visible to, or null for no module (the application's view
Returns:
true if a configuration for the specified id exists (and is visible to the module)
Since:
1.1

containsService

boolean containsService(java.lang.Class serviceInterface,
                        Module module)
Returns true if a single service exists which implements the specified service interface and is visible to the given module.

Parameters:
serviceInterface -
module - the service must be visible to the module (or null for the application's view)
Returns:
true if a single visible service for the specified service interface exists
Since:
1.1

containsService

boolean containsService(java.lang.String serviceId,
                        java.lang.Class serviceInterface,
                        Module module)
Returns true if a single service with the given id exists which implements the specified service interface and is visible to the given module.

Parameters:
serviceId -
serviceInterface -
module - the service must be visible to the module (or null for the application's view)
Returns:
true if a single visible service for the specified service id and service interface exists
Since:
1.1

startup

void startup()
Invoked once, just after the registry infrastructure is constructed. One time startup operations occur, including execution of any contributions to hivemind.Startup.

Since:
1.1

shutdown

void shutdown()
Shuts down the registry; this notifies all RegistryShutdownListener services and objects. Once the registry is shutdown, it is no longer valid to obtain new services or configurations, or even use existing services and configurations.

Since:
1.1

setupThread

void setupThread()
To be invoked at the start of each request in a multi-threaded environment. Ensures that the receiving Registry will be used if any service proxies are de-serialized.

Since:
1.1
See Also:
ServiceSerializationHelper, ServiceSerializationSupport

cleanupThread

void cleanupThread()
Convienience for invoking ThreadEventNotifier.fireThreadCleanup().

Since:
1.1

getServiceIds

java.util.List getServiceIds(java.lang.Class serviceInterface)
Parameters:
serviceInterface -

getModule

Module getModule(java.lang.String moduleId)
Returns the module with the corresponding module id.

Parameters:
moduleId -
Returns:
the module with the corresponding module id