org.apache.hivemind.impl
Class ModuleImpl

java.lang.Object
  extended by org.apache.hivemind.impl.BaseLocatable
      extended by org.apache.hivemind.impl.ModuleImpl
All Implemented Interfaces:
Module, Locatable, LocationHolder, SymbolSource

public final class ModuleImpl
extends BaseLocatable
implements Module

Implementation of Module.

Author:
Howard Lewis Ship

Constructor Summary
ModuleImpl()
           
 
Method Summary
 boolean containsService(java.lang.Class serviceInterface)
          Returns true if a single service exists which implements the specified service interface and is visible to this module.
 java.lang.String expandSymbols(java.lang.String input, Location location)
           
 ClassResolver getClassResolver()
          Returns the resource resolver for this module.
 java.util.List getConfiguration(java.lang.String extensionPointId)
          Returns the List of elements for the specified configuration point.
 java.util.Map getConfigurationAsMap(java.lang.String configurationId)
          Returns the elements of the given configuration point as an unmodifiable Map.
 ErrorHandler getErrorHandler()
          Returns the ErrorHandler for this Registry.
 java.util.Locale getLocale()
           
 Messages getMessages()
          Returns an object that can provide and format localized messages for this module.
 java.lang.String getModuleId()
          Returns the unique identifier for this module.
 java.lang.Object getService(java.lang.Class serviceInterface)
          Finds a service that implements the provided interface.
 java.lang.Object getService(java.lang.String serviceId, java.lang.Class serviceInterface)
          Looks up the ServicePoint (throwing an exception if not found) and invokes ServicePoint.getService(Class).
 ServiceModelFactory getServiceModelFactory(java.lang.String name)
           
 ServicePoint getServicePoint(java.lang.String serviceId)
          Returns the identified service extension point.
 Translator getTranslator(java.lang.String translator)
           
 boolean isConfigurationMappable(java.lang.String configurationId)
          Returns true if the elements contributed to the given configuration point can be retrieved as a Map.
 java.lang.Class resolveType(java.lang.String type)
          Returns the class matching the type.
 void setClassResolver(ClassResolver resolver)
           
 void setModuleId(java.lang.String string)
           
 void setPackageName(java.lang.String packageName)
           
 void setRegistry(RegistryInfrastructure registry)
           
 java.lang.String toString()
           
 java.lang.String valueForSymbol(java.lang.String symbol)
          Returns the value for the symbol, if this source can provide one.
 
Methods inherited from class org.apache.hivemind.impl.BaseLocatable
getLocation, setLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.hivemind.Locatable
getLocation
 

Constructor Detail

ModuleImpl

public ModuleImpl()
Method Detail

getConfiguration

public java.util.List getConfiguration(java.lang.String extensionPointId)
Description copied from interface: Module
Returns the List of elements for the specified configuration point. The returned List is unmodifiable. It may be empty, but won't be null.

It is expressly the caller's job to sort the elements into an appropriate order (a copy will have to be made since the returned List is unmodifiable).

Specified by:
getConfiguration in interface Module
Parameters:
extensionPointId - an unqualified id for a configuration within this module, or a fully qualified id for a configuration in this or any other module

isConfigurationMappable

public boolean isConfigurationMappable(java.lang.String configurationId)
Description copied from interface: Module
Returns true if the elements contributed to the given configuration point can be retrieved as a Map.

Specified by:
isConfigurationMappable in interface Module
See Also:
ConfigurationPoint.areElementsMappable()

getConfigurationAsMap

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

Specified by:
getConfigurationAsMap in interface Module
Parameters:
configurationId - an unqualified id for a configuration within this module, or a fully qualified id for a configuration in this or any other module.
See Also:
ConfigurationPoint.getElementsAsMap(), Module.isConfigurationMappable(String)

getModuleId

public java.lang.String getModuleId()
Description copied from interface: Module
Returns the unique identifier for this module.

Specified by:
getModuleId in interface Module

setPackageName

public void setPackageName(java.lang.String packageName)
Since:
1.1

containsService

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

Specified by:
containsService in interface Module
Returns:
true if a single visible service for the specified service interface exists

getService

public java.lang.Object getService(java.lang.String serviceId,
                                   java.lang.Class serviceInterface)
Description copied from interface: Module
Looks up the ServicePoint (throwing an exception if not found) and invokes ServicePoint.getService(Class).

Specified by:
getService in interface Module
Parameters:
serviceId - an unqualified id for a service within this module, or a fully qualified id for a service in this or any other module
serviceInterface - type the result will be cast to

getService

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

Specified by:
getService in interface Module
Parameters:
serviceInterface - used to locate the service

setModuleId

public void setModuleId(java.lang.String string)

setRegistry

public void setRegistry(RegistryInfrastructure registry)

setClassResolver

public void setClassResolver(ClassResolver resolver)

getClassResolver

public ClassResolver getClassResolver()
Description copied from interface: Module
Returns the resource resolver for this module. The resource resolver is used to locate classes by name (using the correct classloader).

Specified by:
getClassResolver in interface Module

getMessages

public Messages getMessages()
Description copied from interface: Module
Returns an object that can provide and format localized messages for this module. The messages come from a properties file, hivemodule.properties (localized) stored with the HiveMind deployment descriptor in the META-INF folder.

Specified by:
getMessages in interface Module

expandSymbols

public java.lang.String expandSymbols(java.lang.String input,
                                      Location location)
Specified by:
expandSymbols in interface Module
See Also:
RegistryInfrastructure.expandSymbols(String, Location)

toString

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

getServicePoint

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

Specified by:
getServicePoint in interface Module
Parameters:
serviceId - an unqualified id for a service within this module, or a fully qualified id for a service in this or any other module

getServiceModelFactory

public ServiceModelFactory getServiceModelFactory(java.lang.String name)
Specified by:
getServiceModelFactory in interface Module
See Also:
RegistryInfrastructure.getServiceModelFactory(String)

getTranslator

public Translator getTranslator(java.lang.String translator)
Specified by:
getTranslator in interface Module
See Also:
RegistryInfrastructure.getTranslator(String)

getLocale

public java.util.Locale getLocale()
Specified by:
getLocale in interface Module
See Also:
Registry.getLocale()

getErrorHandler

public ErrorHandler getErrorHandler()
Description copied from interface: Module
Returns the ErrorHandler for this Registry.

Specified by:
getErrorHandler in interface Module

valueForSymbol

public java.lang.String valueForSymbol(java.lang.String symbol)
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

resolveType

public java.lang.Class resolveType(java.lang.String type)
Description copied from interface: Module
Returns the class matching the type. First, attempts to resolve the type exactly as is. If that fails, resolves the type within the module's defined package.

Specified by:
resolveType in interface Module
Parameters:
type - the Java type to convert into a class. May be a primitive type, or an array of objects or primitives.
Returns:
the corresponding Class object.