org.apache.fulcrum.yaafi.framework.component
Class ServiceComponentImpl

java.lang.Object
  extended by org.apache.fulcrum.yaafi.framework.component.ServiceComponentImpl
All Implemented Interfaces:
ServiceComponent, ServiceComponentLifecycle
Direct Known Subclasses:
AvalonServiceComponentImpl

public abstract class ServiceComponentImpl
extends Object
implements ServiceComponent

This class implements am abstract base service component singleton with an arbitrary lifecycle.

Author:
Siegfried Goeschl

Constructor Summary
ServiceComponentImpl(RoleEntry roleEntry, org.apache.avalon.framework.logger.Logger parentLogger, org.apache.avalon.framework.logger.Logger logger)
          Constructor to parse the configuration.
 
Method Summary
protected  Object createInstance()
          Create an instance of the service component implementation class
 void decommision()
          Decommisions a service component instance.
 void dispose()
          Dispose a service component instance.
 org.apache.avalon.framework.configuration.Configuration getConfiguration()
           
 org.apache.avalon.framework.context.Context getContext()
           
 Class getImplementationClazz()
           
 Object getInstance()
           
 org.apache.avalon.framework.logger.Logger getLogger()
           
 String getName()
          Get the unique name of the service component instance.
 org.apache.avalon.framework.parameters.Parameters getParamaters()
           
 org.apache.avalon.framework.logger.Logger getParentLogger()
           
protected  Object getRawInstance(boolean useProxy)
          Get either the original service object or the dynamic proxy
 RoleEntry getRoleEntry()
          Returns the associates role entry parsed from the role configuration file.
 org.apache.avalon.framework.service.ServiceManager getServiceManager()
           
 String getShorthand()
          Get the shorthand of the service component instance.
 void incarnate()
          Incarnates a service component instance.
protected abstract  void incarnateInstance()
           
 boolean isEarlyInit()
           
protected  boolean isInstantiated()
           
 void loadImplemtationClass(ClassLoader classLoader)
          Loads the implementaion class.
abstract  void reconfigure()
          Reconfigures a service component instance
 void 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.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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 file
parentLogger - the logger of the service container
logger - The logger for the service instance
Method Detail

loadImplemtationClass

public void loadImplemtationClass(ClassLoader classLoader)
                           throws ClassNotFoundException
Description copied from interface: ServiceComponentLifecycle
Loads the implementaion class.

Specified by:
loadImplemtationClass in interface ServiceComponentLifecycle
Parameters:
classLoader - the classloader to use for loading the implementation class
Throws:
ClassNotFoundException - loading of the class failed
See Also:
ServiceComponentLifecycle.loadImplemtationClass(java.lang.ClassLoader)

getInstance

public Object getInstance()
                   throws Exception
Specified by:
getInstance in interface ServiceComponentLifecycle
Returns:
Returns the instance of the singleton
Throws:
Exception - the operation failed
See Also:
ServiceComponentLifecycle.getInstance()

incarnate

public void incarnate()
               throws Exception
Description copied from interface: ServiceComponentLifecycle
Incarnates a service component instance.

Specified by:
incarnate in interface ServiceComponentLifecycle
Throws:
Exception - the operation failed
See Also:
ServiceComponentLifecycle.incarnate()

reconfigure

public abstract void reconfigure()
                          throws Exception
Description copied from interface: ServiceComponentLifecycle
Reconfigures a service component instance

Specified by:
reconfigure in interface ServiceComponentLifecycle
Throws:
Exception - the operation failed
See Also:
ServiceComponentLifecycle.reconfigure()

decommision

public void decommision()
                 throws Exception
Description copied from interface: ServiceComponentLifecycle
Decommisions a service component instance.

Specified by:
decommision in interface ServiceComponentLifecycle
Throws:
Exception - the operation failed
See Also:
ServiceComponentLifecycle.decommision()

dispose

public void dispose()
Description copied from interface: ServiceComponentLifecycle
Dispose a service component instance.

Specified by:
dispose in interface ServiceComponentLifecycle
See Also:
ServiceComponentLifecycle.dispose()

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 interface ServiceComponentLifecycle
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 interface ServiceComponentLifecycle
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 interface ServiceComponentLifecycle
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 interface ServiceComponentLifecycle
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 interface ServiceComponentLifecycle
Parameters:
parameters - The parameters to set.

isEarlyInit

public boolean isEarlyInit()
Returns:
Return true if the service is created on startup

getName

public String getName()
Description copied from interface: ServiceComponent
Get the unique name of the service component instance.

Specified by:
getName in interface ServiceComponent
Returns:
the name of the service component
See Also:
ServiceComponent.getName()

getRoleEntry

public RoleEntry getRoleEntry()
Description copied from interface: ServiceComponent
Returns the associates role entry parsed from the role configuration file.

Specified by:
getRoleEntry in interface ServiceComponent
Returns:
Returns the roleEntry.

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

public Class 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 paramaters.

getServiceManager

public org.apache.avalon.framework.service.ServiceManager getServiceManager()
Returns:
Returns the serviceManager.

getShorthand

public String 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 interface ServiceComponent
Returns:
the shorthand of the service

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

isInstantiated

protected final boolean isInstantiated()
Returns:
Returns true if the service instance was already instantiated.

createInstance

protected Object createInstance()
                         throws InstantiationException,
                                IllegalAccessException
Create an instance of the service component implementation class

Throws:
InstantiationException - th
IllegalAccessException

incarnateInstance

protected abstract void incarnateInstance()
                                   throws Exception
Throws:
Exception
See Also:
ServiceComponentLifecycle.incarnate()

getRawInstance

protected Object getRawInstance(boolean useProxy)
Get either the original service object or the dynamic proxy

Returns:
Returns the raw instance, i.e. does not incarnate the instance.

setProxyInstance

protected void setProxyInstance(Object proxy)
Parameters:
proxy - the service proxy instance


Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.