org.apache.hivemind.impl
Class RegistryInfrastructureImpl

java.lang.Object
  extended by org.apache.hivemind.impl.RegistryInfrastructureImpl
All Implemented Interfaces:
RegistryInfrastructure, ServiceSerializationSupport

public final class RegistryInfrastructureImpl
extends java.lang.Object
implements RegistryInfrastructure, ServiceSerializationSupport

Implementation of RegistryInfrastructure.

Author:
Howard Lewis Ship

Constructor Summary
RegistryInfrastructureImpl(ErrorHandler errorHandler, java.util.Locale locale)
           
 
Method Summary
 void addConfigurationPoint(ConfigurationPoint point)
           
 void addModule(Module module)
           
 void addServicePoint(ServicePoint point)
           
 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.Object getConfiguration(java.lang.Class configurationType, Module module)
          Finds a configuration of the specified type.
 java.lang.Object getConfiguration(java.lang.String configurationId, Module module)
          Returns the specified configuration.
 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.lang.Object getServiceFromToken(ServiceToken token)
          Returns the service (proxy) for the indicated token.
 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.
 ServiceToken getServiceTokenForService(java.lang.String serviceId)
          Returns a ServiceToken corresponding to the indicated serviceId.
 void setShutdownCoordinator(ShutdownCoordinator coordinator)
           
 void setupThread()
          Sets the current RI up as the ServiceSerializationSupport.
 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()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RegistryInfrastructureImpl

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

getLocale

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

Specified by:
getLocale in interface RegistryInfrastructure

addModule

public void addModule(Module module)

addServicePoint

public void addServicePoint(ServicePoint point)

addConfigurationPoint

public void addConfigurationPoint(ConfigurationPoint point)

getServicePoint

public ServicePoint getServicePoint(java.lang.String serviceId,
                                    Module module)
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
module - the referencing module, used for visibility checks (null means no module, which requires that the service be public)
See Also:
RegistryInfrastructure.getServicePoint(java.lang.String, org.apache.hivemind.internal.Module)

getService

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

getService

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

Specified by:
getService in interface RegistryInfrastructure
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.

getConfigurationPoint

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

Specified by:
getConfigurationPoint in interface RegistryInfrastructure
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

getConfiguration

public java.lang.Object getConfiguration(java.lang.String configurationId,
                                         Module module)
Description copied from interface: RegistryInfrastructure
Returns the specified configuration.

Specified by:
getConfiguration in interface RegistryInfrastructure
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:
the configuration

getConfiguration

public java.lang.Object getConfiguration(java.lang.Class configurationType,
                                         Module module)
Description copied from interface: RegistryInfrastructure
Finds a configuration of the specified type. Exactly one such configuration may exist or an exception is thrown.

Specified by:
getConfiguration in interface RegistryInfrastructure
Parameters:
configurationType - the configuration type
module - the referencing module, used for visibility checks (null means no module, which requires that the configuration be public)
Returns:
the configuration
See Also:
RegistryInfrastructure.getConfiguration(java.lang.Class, org.apache.hivemind.internal.Module)

toString

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

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 RegistryInfrastructure

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.

This instance is stored into ServiceSerializationHelper.setServiceSerializationSupport(ServiceSerializationSupport). This may cause errors (and incorrect behavior) if multiple Registries exist in a single JVM.

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.

Specified by:
startup in interface RegistryInfrastructure

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: RegistryInfrastructure
Convienience for invoking ThreadEventNotifier.fireThreadCleanup().

Specified by:
cleanupThread in interface RegistryInfrastructure

containsConfiguration

public boolean containsConfiguration(java.lang.String configurationId,
                                     Module module)
Description copied from interface: RegistryInfrastructure
Returns true if a configuration for the specified id exists (and is visible to the specified module).

Specified by:
containsConfiguration in interface RegistryInfrastructure
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)

containsService

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

Specified by:
containsService in interface RegistryInfrastructure
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

containsService

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

Specified by:
containsService in interface RegistryInfrastructure
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

getErrorHander

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

Specified by:
getErrorHander in interface RegistryInfrastructure

getServiceFromToken

public java.lang.Object getServiceFromToken(ServiceToken token)
Description copied from interface: ServiceSerializationSupport
Returns the service (proxy) for the indicated token.

Specified by:
getServiceFromToken in interface ServiceSerializationSupport

getServiceTokenForService

public ServiceToken getServiceTokenForService(java.lang.String serviceId)
Description copied from interface: ServiceSerializationSupport
Returns a ServiceToken corresponding to the indicated serviceId. A ServiceToken takes the place of a service (proxy) during serialization.

Specified by:
getServiceTokenForService in interface ServiceSerializationSupport

setupThread

public void setupThread()
Sets the current RI up as the ServiceSerializationSupport. Any service proxy tokens that are de-serialized will find their proxies within this Registry.

Specified by:
setupThread in interface RegistryInfrastructure
Since:
1.1
See Also:
ServiceSerializationHelper, ServiceSerializationSupport

getModule

public Module getModule(java.lang.String moduleId)
Description copied from interface: RegistryInfrastructure
Returns the module with the corresponding module id.

Specified by:
getModule in interface RegistryInfrastructure
Returns:
the module with the corresponding module id

getServiceIds

public java.util.List getServiceIds(java.lang.Class serviceInterface)
Specified by:
getServiceIds in interface RegistryInfrastructure
See Also:
RegistryInfrastructure.getServiceIds(java.lang.Class)


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