Class ServiceComponentImpl
java.lang.Object
org.apache.fulcrum.yaafi.framework.component.ServiceComponentImpl
- All Implemented Interfaces:
ServiceComponent,ServiceComponentLifecycle
- Direct Known Subclasses:
AvalonServiceComponentImpl
This class implements am abstract base service component singleton with
an arbitrary lifecycle.
- Author:
- Siegfried Goeschl
-
Constructor Summary
ConstructorsConstructorDescriptionServiceComponentImpl(RoleEntry roleEntry, org.apache.avalon.framework.logger.Logger parentLogger, org.apache.avalon.framework.logger.Logger logger) Constructor to parse the configuration. -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectCreate an instance of the service component implementation classvoidDecommisions a service component instance.voiddispose()Dispose a service component instance.org.apache.avalon.framework.configuration.Configurationorg.apache.avalon.framework.context.ContextClass<?> org.apache.avalon.framework.logger.LoggergetName()Get the unique name of the service component instance.org.apache.avalon.framework.parameters.Parametersorg.apache.avalon.framework.logger.Loggerprotected ObjectgetRawInstance(boolean useProxy) Get either the original service object or the dynamic proxyReturns the associates role entry parsed from the role configuration file.org.apache.avalon.framework.service.ServiceManagerGet the shorthand of the service component instance.voidIncarnates a service component instance.protected abstract voidbooleanprotected final booleanvoidloadImplemtationClass(ClassLoader classLoader) Loads the implementaion class.abstract voidReconfigures a service component instancevoidsetConfiguration(org.apache.avalon.framework.configuration.Configuration configuration) Sets the Configuration to be used by this component.voidsetContext(org.apache.avalon.framework.context.Context context) Sets the Context to be used by this component.voidsetLogger(org.apache.avalon.framework.logger.Logger logger) Sets the logger to be used by this component.voidsetParameters(org.apache.avalon.framework.parameters.Parameters parameters) Sets the Parameters to be used by this component.protected voidsetProxyInstance(Object proxy) voidsetServiceManager(org.apache.avalon.framework.service.ServiceManager serviceManager) Sets the ServiceManager to be used by this component.toString()
-
Constructor Details
-
ServiceComponentImpl
public ServiceComponentImpl(RoleEntry roleEntry, org.apache.avalon.framework.logger.Logger parentLogger, org.apache.avalon.framework.logger.Logger logger) Constructor to parse the configuration.- Parameters:
roleEntry- The information extracted from the role configuration fileparentLogger- the logger of the service containerlogger- The logger for the service instance
-
-
Method Details
-
loadImplemtationClass
Description copied from interface:ServiceComponentLifecycleLoads the implementaion class.- Specified by:
loadImplemtationClassin interfaceServiceComponentLifecycle- Parameters:
classLoader- the classloader to use for loading the implementation class- Throws:
ClassNotFoundException- loading of the class failed
-
getInstance
- Specified by:
getInstancein interfaceServiceComponentLifecycle- Returns:
- Returns the instance of the singleton
- Throws:
Exception- the operation failed
-
incarnate
Description copied from interface:ServiceComponentLifecycleIncarnates a service component instance.- Specified by:
incarnatein interfaceServiceComponentLifecycle- Throws:
Exception- the operation failed
-
reconfigure
Description copied from interface:ServiceComponentLifecycleReconfigures a service component instance- Specified by:
reconfigurein interfaceServiceComponentLifecycle- Throws:
Exception- the operation failed
-
decommision
Description copied from interface:ServiceComponentLifecycleDecommisions a service component instance.- Specified by:
decommisionin interfaceServiceComponentLifecycle- Throws:
Exception- the operation failed
-
dispose
public void dispose()Description copied from interface:ServiceComponentLifecycleDispose a service component instance.- Specified by:
disposein interfaceServiceComponentLifecycle
-
setLogger
public void setLogger(org.apache.avalon.framework.logger.Logger logger) Description copied from interface:ServiceComponentLifecycleSets the logger to be used by this component.- Specified by:
setLoggerin interfaceServiceComponentLifecycle- Parameters:
logger- The logger to set
-
setContext
public void setContext(org.apache.avalon.framework.context.Context context) Description copied from interface:ServiceComponentLifecycleSets the Context to be used by this component.- Specified by:
setContextin interfaceServiceComponentLifecycle- Parameters:
context- The context to set.
-
setServiceManager
public void setServiceManager(org.apache.avalon.framework.service.ServiceManager serviceManager) Description copied from interface:ServiceComponentLifecycleSets the ServiceManager to be used by this component.- Specified by:
setServiceManagerin interfaceServiceComponentLifecycle- Parameters:
serviceManager- The serviceManager to set.
-
setConfiguration
public void setConfiguration(org.apache.avalon.framework.configuration.Configuration configuration) Description copied from interface:ServiceComponentLifecycleSets the Configuration to be used by this component.- Specified by:
setConfigurationin interfaceServiceComponentLifecycle- Parameters:
configuration- The configuration to set.
-
setParameters
public void setParameters(org.apache.avalon.framework.parameters.Parameters parameters) Description copied from interface:ServiceComponentLifecycleSets the Parameters to be used by this component.- Specified by:
setParametersin interfaceServiceComponentLifecycle- Parameters:
parameters- The paramaters to set.
-
isEarlyInit
public boolean isEarlyInit()- Returns:
- Return true if the service is created on startup
-
getName
Description copied from interface:ServiceComponentGet the unique name of the service component instance.- Specified by:
getNamein interfaceServiceComponent- Returns:
- the name of the service component
-
getRoleEntry
Description copied from interface:ServiceComponentReturns the associates role entry parsed from the role configuration file.- Specified by:
getRoleEntryin interfaceServiceComponent- Returns:
- the role entry
-
getLogger
public org.apache.avalon.framework.logger.Logger getLogger()- Returns:
- Returns the logger.
-
getParentLogger
public org.apache.avalon.framework.logger.Logger getParentLogger()- Returns:
- Returns the parentLogger.
-
getImplementationClazz
- Returns:
- Returns the implementationClazz.
-
getConfiguration
public org.apache.avalon.framework.configuration.Configuration getConfiguration()- Returns:
- Returns the configuration.
-
getContext
public org.apache.avalon.framework.context.Context getContext()- Returns:
- Returns the context.
-
getParamaters
public org.apache.avalon.framework.parameters.Parameters getParamaters()- Returns:
- Returns the parameters.
-
getServiceManager
public org.apache.avalon.framework.service.ServiceManager getServiceManager()- Returns:
- Returns the serviceManager.
-
getShorthand
Description copied from interface:ServiceComponentGet the shorthand of the service component instance. The shorthand is usually used to lookup the configuration entries.- Specified by:
getShorthandin interfaceServiceComponent- Returns:
- the shorthand of the service
-
toString
-
isInstantiated
protected final boolean isInstantiated()- Returns:
- Returns true if the service instance was already instantiated.
-
createInstance
Create an instance of the service component implementation class- Returns:
- instance of the service component class
- Throws:
InstantiationException- if unable to instantiateIllegalAccessException- if unable to access
-
incarnateInstance
- Throws:
Exception- generic exception- See Also:
-
getRawInstance
Get either the original service object or the dynamic proxy- Parameters:
useProxy- set to true if using a proxy- Returns:
- Returns the raw instance, i.e. does not incarnate the instance.
-
setProxyInstance
- Parameters:
proxy- the service proxy instance
-