org.apache.hivemind.impl
Class RegistryImpl

java.lang.Object
  |
  +--org.apache.hivemind.impl.RegistryImpl
All Implemented Interfaces:
Registry, RegistryInfrastructure, SymbolSource

public final class RegistryImpl
extends java.lang.Object
implements Registry, RegistryInfrastructure

Implementation of Registry.

Author:
Howard Lewis Ship

Constructor Summary
RegistryImpl(ErrorHandler errorHandler, java.util.Locale locale)
           
 
Method Summary
 void addConfigurationPoint(ConfigurationPoint point)
           
 void addServicePoint(ServicePoint point)
           
 void cleanupThread()
          Convienience for invoking ThreadEventNotifier.fireThreadCleanup().
 java.lang.String expandSymbols(java.lang.String text, Location location)
          Note: a little cut-n-paste from org.apache.tapestry.script.AbstractTokenRule.
 java.util.List getConfiguration(java.lang.String configurationId)
          Returns a configuration as a List of elements (as defined by the schema for the configuration point, or as Elements if no configuration point does not define a schema.
 ConfigurationPoint getConfigurationPoint(java.lang.String configurationId)
          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.
 java.lang.Object getService(java.lang.Class serviceInterface)
          Convenience method to obtain a service with a single implementation from the registry.
 java.lang.Object getService(java.lang.String serviceId, java.lang.Class serviceInterface)
          Obtains a service from the registry.
 ServiceModelFactory getServiceModelFactory(java.lang.String name)
          Returns a named service-model factory
 ServicePoint getServicePoint(java.lang.String serviceId)
          Returns the identified service extension point.
 Translator getTranslator(java.lang.String translator)
          Gets a Translator instance.
 void setLocale(java.util.Locale locale)
           
 void setShutdownCoordinator(ShutdownCoordinator coordinator)
           
 void shutdown()
          Invokes ShutdownCoordinator.shutdown(), then releases the coordinator, modules and variable sources.
 void startup()
          Starts up the Registry after all service and configuration points have been defined.
 java.lang.String toString()
           
 java.lang.String valueForSymbol(java.lang.String name)
          Returns the value for the symbol, if this source can provide one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RegistryImpl

public RegistryImpl(ErrorHandler errorHandler,
                    java.util.Locale locale)
Method Detail

getLocale

public java.util.Locale getLocale()
Description copied from interface: Registry
Returns the locale for which the registry was created.

Specified by:
getLocale in interface Registry

addServicePoint

public void addServicePoint(ServicePoint point)

addConfigurationPoint

public void addConfigurationPoint(ConfigurationPoint point)

getServicePoint

public ServicePoint getServicePoint(java.lang.String serviceId)
Description copied from interface: RegistryInfrastructure
Returns the identified service extension point.

Specified by:
getServicePoint in interface RegistryInfrastructure
Parameters:
serviceId - fully qualified id of the service point

getService

public java.lang.Object getService(java.lang.String serviceId,
                                   java.lang.Class serviceInterface)
Description copied from interface: Registry
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.

Specified by:
getService in interface Registry
Parameters:
serviceId - the fully qualified id of the service to obtain
serviceInterface - the class to which the service will be cast
Returns:
the service

getService

public java.lang.Object getService(java.lang.Class serviceInterface)
Description copied from interface: Registry
Convenience method to obtain a service with a single implementation from the registry. Exactly one service point must implement the service.

Specified by:
getService in interface Registry
Parameters:
serviceInterface - the class to which the service will be cast.
Returns:
the service implementing the given interface.
See Also:
Registry.getService(String, Class)

getConfigurationPoint

public ConfigurationPoint getConfigurationPoint(java.lang.String configurationId)
Description copied from interface: RegistryInfrastructure
Returns the configuration point.

Specified by:
getConfigurationPoint in interface RegistryInfrastructure
Parameters:
configurationId - the fully qualified id of the configuration
Returns:
ConfigurationPoint matching the configuration id

getConfiguration

public java.util.List getConfiguration(java.lang.String configurationId)
Description copied from interface: Registry
Returns a configuration as a List of elements (as defined by the schema for the configuration point, or as Elements if no configuration point does not define a schema.

Specified by:
getConfiguration in interface Registry
Parameters:
configurationId - the fully qualified id of the configuration to obtain
Returns:
the configuration as an immutable List

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

expandSymbols

public java.lang.String expandSymbols(java.lang.String text,
                                      Location location)
Note: a little cut-n-paste from org.apache.tapestry.script.AbstractTokenRule.

Specified by:
expandSymbols in interface Registry
Parameters:
text - 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.

valueForSymbol

public java.lang.String valueForSymbol(java.lang.String name)
Description copied from interface: SymbolSource
Returns the value for the symbol, if this source can provide one. Returns null if the source can not provide a value.

Specified by:
valueForSymbol in interface SymbolSource

setShutdownCoordinator

public void setShutdownCoordinator(ShutdownCoordinator coordinator)

shutdown

public void shutdown()
Invokes ShutdownCoordinator.shutdown(), then releases the coordinator, modules and variable sources.

Specified by:
shutdown in interface Registry

startup

public void startup()
Starts up the Registry after all service and configuration points have been defined. This locks down the Registry so that no further extension points may be added. This method may only be invoked once.

In addition, the service hivemind.Startup is obtained and run() is invoked on it. This allows additional startup, provided in the hivemind.Startup configuration point, to be executed.


getServiceModelFactory

public ServiceModelFactory getServiceModelFactory(java.lang.String name)
Description copied from interface: RegistryInfrastructure
Returns a named service-model factory

Specified by:
getServiceModelFactory in interface RegistryInfrastructure

cleanupThread

public void cleanupThread()
Description copied from interface: Registry
Convienience for invoking ThreadEventNotifier.fireThreadCleanup().

Specified by:
cleanupThread in interface Registry

setLocale

public void setLocale(java.util.Locale locale)

getErrorHander

public ErrorHandler getErrorHander()
Description copied from interface: RegistryInfrastructure
Returns the ErrorHandler for this Registry.

Specified by:
getErrorHander in interface RegistryInfrastructure

getTranslator

public Translator getTranslator(java.lang.String translator)
Description copied from interface: RegistryInfrastructure
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).

Specified by:
getTranslator in interface RegistryInfrastructure
Returns:
a Translator instance