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 Object
Create an instance of the service component implementation classvoid
Decommisions a service component instance.void
dispose()
Dispose a service component instance.org.apache.avalon.framework.configuration.Configuration
org.apache.avalon.framework.context.Context
Class
<?> org.apache.avalon.framework.logger.Logger
getName()
Get the unique name of the service component instance.org.apache.avalon.framework.parameters.Parameters
org.apache.avalon.framework.logger.Logger
protected Object
getRawInstance
(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.ServiceManager
Get the shorthand of the service component instance.void
Incarnates a service component instance.protected abstract void
boolean
protected final boolean
void
loadImplemtationClass
(ClassLoader classLoader) Loads the implementaion class.abstract void
Reconfigures a service component instancevoid
setConfiguration
(org.apache.avalon.framework.configuration.Configuration configuration) Sets the Configuration to be used by this component.void
setContext
(org.apache.avalon.framework.context.Context context) Sets the Context to be used by this component.void
setLogger
(org.apache.avalon.framework.logger.Logger logger) Sets the logger to be used by this component.void
setParameters
(org.apache.avalon.framework.parameters.Parameters parameters) Sets the Parameters to be used by this component.protected void
setProxyInstance
(Object proxy) void
setServiceManager
(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:ServiceComponentLifecycle
Loads the implementaion class.- Specified by:
loadImplemtationClass
in interfaceServiceComponentLifecycle
- Parameters:
classLoader
- the classloader to use for loading the implementation class- Throws:
ClassNotFoundException
- loading of the class failed
-
getInstance
- Specified by:
getInstance
in interfaceServiceComponentLifecycle
- Returns:
- Returns the instance of the singleton
- Throws:
Exception
- the operation failed
-
incarnate
Description copied from interface:ServiceComponentLifecycle
Incarnates a service component instance.- Specified by:
incarnate
in interfaceServiceComponentLifecycle
- Throws:
Exception
- the operation failed
-
reconfigure
Description copied from interface:ServiceComponentLifecycle
Reconfigures a service component instance- Specified by:
reconfigure
in interfaceServiceComponentLifecycle
- Throws:
Exception
- the operation failed
-
decommision
Description copied from interface:ServiceComponentLifecycle
Decommisions a service component instance.- Specified by:
decommision
in interfaceServiceComponentLifecycle
- Throws:
Exception
- the operation failed
-
dispose
public void dispose()Description copied from interface:ServiceComponentLifecycle
Dispose a service component instance.- Specified by:
dispose
in interfaceServiceComponentLifecycle
-
setLogger
public void setLogger(org.apache.avalon.framework.logger.Logger logger) Description copied from interface:ServiceComponentLifecycle
Sets the logger to be used by this component.- Specified by:
setLogger
in interfaceServiceComponentLifecycle
- Parameters:
logger
- The logger to set
-
setContext
public void setContext(org.apache.avalon.framework.context.Context context) Description copied from interface:ServiceComponentLifecycle
Sets the Context to be used by this component.- Specified by:
setContext
in interfaceServiceComponentLifecycle
- Parameters:
context
- The context to set.
-
setServiceManager
public void setServiceManager(org.apache.avalon.framework.service.ServiceManager serviceManager) Description copied from interface:ServiceComponentLifecycle
Sets the ServiceManager to be used by this component.- Specified by:
setServiceManager
in interfaceServiceComponentLifecycle
- Parameters:
serviceManager
- The serviceManager to set.
-
setConfiguration
public void setConfiguration(org.apache.avalon.framework.configuration.Configuration configuration) Description copied from interface:ServiceComponentLifecycle
Sets the Configuration to be used by this component.- Specified by:
setConfiguration
in interfaceServiceComponentLifecycle
- Parameters:
configuration
- The configuration to set.
-
setParameters
public void setParameters(org.apache.avalon.framework.parameters.Parameters parameters) Description copied from interface:ServiceComponentLifecycle
Sets the Parameters to be used by this component.- Specified by:
setParameters
in 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:ServiceComponent
Get the unique name of the service component instance.- Specified by:
getName
in interfaceServiceComponent
- Returns:
- the name of the service component
-
getRoleEntry
Description copied from interface:ServiceComponent
Returns the associates role entry parsed from the role configuration file.- Specified by:
getRoleEntry
in 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:ServiceComponent
Get the shorthand of the service component instance. The shorthand is usually used to lookup the configuration entries.- Specified by:
getShorthand
in 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
-