You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by pa...@apache.org on 2018/12/13 18:17:40 UTC

svn commit: r1848876 [3/5] - in /turbine/fulcrum/trunk/yaafi/src: java/org/apache/fulcrum/yaafi/framework/component/ java/org/apache/fulcrum/yaafi/framework/container/ java/org/apache/fulcrum/yaafi/framework/crypto/ java/org/apache/fulcrum/yaafi/framew...

Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/container/ServiceLifecycleManager.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/container/ServiceLifecycleManager.java?rev=1848876&r1=1848875&r2=1848876&view=diff
==============================================================================
--- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/container/ServiceLifecycleManager.java (original)
+++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/container/ServiceLifecycleManager.java Thu Dec 13 18:17:39 2018
@@ -79,6 +79,6 @@ public interface ServiceLifecycleManager
      * @param name the name of the service
      * @exception ServiceException the service was not found
      */
-    void decommision( String name )
+    void decommission( String name )
         throws ServiceException;
 }

Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/crypto/CryptoStreamFactory.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/crypto/CryptoStreamFactory.java?rev=1848876&r1=1848875&r2=1848876&view=diff
==============================================================================
--- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/crypto/CryptoStreamFactory.java (original)
+++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/crypto/CryptoStreamFactory.java Thu Dec 13 18:17:39 2018
@@ -1,5 +1,7 @@
 package org.apache.fulcrum.yaafi.framework.crypto;
 
+import java.io.InputStream;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -21,124 +23,103 @@ package org.apache.fulcrum.yaafi.framewo
 
 import org.apache.fulcrum.yaafi.framework.reflection.Clazz;
 
-import java.io.InputStream;
-
 /**
  * Factory class to get a decrypting input stream for reading configuration
- * files. The implementation uses dynamic class loading to make decryption
- * an optional feature which is highly desirable when avoiding the ECCN
- * export code problems.
+ * files. The implementation uses dynamic class loading to make decryption an
+ * optional feature which is highly desirable when avoiding the ECCN export code
+ * problems.
  *
  * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl </a>
  */
 
-public class CryptoStreamFactory
-{
-    /** is the instance already initialized */
-    private static boolean isInitialized;
-
-    /** the factory to create encrypting input streams */
-    private static Object cryptoStreamFactory;
-
-    /** the name of the class to be loaded */
-    private static String className = "org.apache.fulcrum.jce.crypto.CryptoStreamFactoryImpl";
-
-    /**
-     * Create a (potentially) decrypting input stream using the default
-     * password.
-     *
-     * @param is the input stream to be decrypted
-     * @param isEncrypted the encryption mode (true|false|auto)
-     * @return a decrypting input stream
-     * @throws Exception reading the input stream failed
-     */
-    public static InputStream getDecryptingInputStream( InputStream is, String isEncrypted )
-        throws Exception
-    {
-        InputStream result;
-        
-        if( isEncrypted.equalsIgnoreCase("true") )
-        {
-            // a decrypting input stream was requested
-            result = createDecryptingInputStream(is, "getInputStream");
-        }
-        else if( isEncrypted.equalsIgnoreCase("auto") && hasCryptoStreamFactory())
-        {
-            // no user-supplied preferences but crypto stream is available
-            result = createDecryptingInputStream(is, "getSmartInputStream");
-        }
-        else if( isEncrypted.equalsIgnoreCase("auto") && !hasCryptoStreamFactory())
-        {
-            // no user-supplied perferences so we fall back to normal input stream
-            result = is;
-        }
-        else if( isEncrypted.equalsIgnoreCase("false") )
-        {
-            // just use normal input stream
-            result = is;
-        }
-        else
-        {
-            throw new IllegalArgumentException("Unknown decryption mode : " + isEncrypted);
-        }
-
-        return result;
-    }
-
-    /**
-     * Factory method to create a decrypting input stream.
-     *
-     * @param is the input stream to be decrypted
-     * @param factoryMethodName the name of the factory method
-     * @return a decrypting input stream
-     * @throws Exception creating the decrypting input stream failed
-     */
-    private static InputStream createDecryptingInputStream( InputStream is, String factoryMethodName )
-        throws Exception
-    {
-        Class[] signature = {InputStream.class};
-        Object[] args = {is};
-        Object cryptoStreamFactory = getCryptoStreamFactory();
-
-        if(cryptoStreamFactory == null)
-        {
-            throw new IllegalStateException("No CryptoStreamFactory available - unable to create a decrypting input stream");
-        }
-        else
-        {
-            return (InputStream) Clazz.invoke(cryptoStreamFactory, factoryMethodName, signature, args);
-        }
-    }
-
-    /**
-     * Factory method to create a CryptoStreamFactory.
-     */
-    private synchronized static Object getCryptoStreamFactory()
-        throws Exception            
-    {
-        if(!isInitialized)
-        {
-            isInitialized = true;
-            ClassLoader clazzLoader = CryptoStreamFactory.class.getClassLoader();
-
-            if(Clazz.hasClazz(clazzLoader, className))
-            {
-                Class[] signature = {};
-                Object[] args = {};
-                Class<?> clazz = Clazz.getClazz(clazzLoader, className);
-                cryptoStreamFactory = Clazz.newInstance(clazz, signature, args);
-            }
-        }
-                    
-        return cryptoStreamFactory;
-    }
-
-    /**
-     * @return true if a CryptoStreamFactory is available
-     */
-    private static boolean hasCryptoStreamFactory()
-        throws Exception
-    {
-        return ( getCryptoStreamFactory() != null );
-    }
+public class CryptoStreamFactory {
+	/** is the instance already initialized */
+	private static boolean isInitialized;
+
+	/** the factory to create encrypting input streams */
+	private static Object cryptoStreamFactory;
+
+	/** the name of the class to be loaded */
+	private static String className = "org.apache.fulcrum.jce.crypto.CryptoStreamFactoryImpl";
+
+	/**
+	 * Create a (potentially) decrypting input stream using the default password.
+	 *
+	 * @param is          the input stream to be decrypted
+	 * @param isEncrypted the encryption mode (true|false|auto)
+	 * @return a decrypting input stream
+	 * @throws Exception reading the input stream failed
+	 */
+	public static InputStream getDecryptingInputStream(InputStream is, String isEncrypted) throws Exception {
+		InputStream result;
+
+		if (isEncrypted.equalsIgnoreCase("true")) {
+			// a decrypting input stream was requested
+			result = createDecryptingInputStream(is, "getInputStream");
+		} else if (isEncrypted.equalsIgnoreCase("auto") && hasCryptoStreamFactory()) {
+			// no user-supplied preferences but crypto stream is available
+			result = createDecryptingInputStream(is, "getSmartInputStream");
+		} else if (isEncrypted.equalsIgnoreCase("auto") && !hasCryptoStreamFactory()) {
+			// no user-supplied perferences so we fall back to normal input stream
+			result = is;
+		} else if (isEncrypted.equalsIgnoreCase("false")) {
+			// just use normal input stream
+			result = is;
+		} else {
+			throw new IllegalArgumentException("Unknown decryption mode : " + isEncrypted);
+		}
+
+		return result;
+	}
+
+	/**
+	 * Factory method to create a decrypting input stream.
+	 *
+	 * @param is                the input stream to be decrypted
+	 * @param factoryMethodName the name of the factory method
+	 * @return a decrypting input stream
+	 * @throws Exception creating the decrypting input stream failed
+	 */
+	private static InputStream createDecryptingInputStream(InputStream is, String factoryMethodName) throws Exception {
+		Class[] signature = { InputStream.class };
+		Object[] args = { is };
+		Object cryptoStreamFactory = getCryptoStreamFactory();
+
+		if (cryptoStreamFactory == null) {
+			throw new IllegalStateException(
+					"No CryptoStreamFactory available - unable to create a decrypting input stream");
+		} else {
+			return (InputStream) Clazz.invoke(cryptoStreamFactory, factoryMethodName, signature, args);
+		}
+	}
+
+	/**
+	 * Factory method to create a CryptoStreamFactory.
+	 * 
+	 * @return a CryptoStreamFactory
+	 * @throws Exception generic exception
+	 */
+	private synchronized static Object getCryptoStreamFactory() throws Exception {
+		if (!isInitialized) {
+			isInitialized = true;
+			ClassLoader clazzLoader = CryptoStreamFactory.class.getClassLoader();
+
+			if (Clazz.hasClazz(clazzLoader, className)) {
+				Class[] signature = {};
+				Object[] args = {};
+				Class<?> clazz = Clazz.getClazz(clazzLoader, className);
+				cryptoStreamFactory = Clazz.newInstance(clazz, signature, args);
+			}
+		}
+
+		return cryptoStreamFactory;
+	}
+
+	/**
+	 * @return true if a CryptoStreamFactory is available
+	 * @throws Exception generic exception
+	 */
+	private static boolean hasCryptoStreamFactory() throws Exception {
+		return getCryptoStreamFactory() != null;
+	}
 }

Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/factory/ServiceContainerConfiguration.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/factory/ServiceContainerConfiguration.java?rev=1848876&r1=1848875&r2=1848876&view=diff
==============================================================================
--- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/factory/ServiceContainerConfiguration.java (original)
+++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/factory/ServiceContainerConfiguration.java Thu Dec 13 18:17:39 2018
@@ -33,731 +33,642 @@ import org.apache.avalon.framework.conte
 import org.apache.avalon.framework.logger.ConsoleLogger;
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.fulcrum.yaafi.framework.constant.AvalonMerlinConstants;
 import org.apache.fulcrum.yaafi.framework.container.ServiceConstants;
+import org.apache.fulcrum.yaafi.framework.crypto.CryptoStreamFactory;
 import org.apache.fulcrum.yaafi.framework.util.InputStreamLocator;
 import org.apache.fulcrum.yaafi.framework.util.Validate;
-import org.apache.fulcrum.yaafi.framework.crypto.CryptoStreamFactory;
 
 /**
- * Helper class to capture configuration related stuff. The are two ways
- * for setting up the configuration:
+ * Helper class to capture configuration related stuff. The are two ways for
+ * setting up the configuration:
  * <ul>
- *  <li>set all parameters manually</li>
- *  <li>use a containerConfiguration file and provide the remaining settings</li>
+ * <li>set all parameters manually</li>
+ * <li>use a containerConfiguration file and provide the remaining settings</li>
  * </ul>
  *
  * The Avalon context and configuration are created by
  * <ul>
- *  <li>createFinalContext()</li>
- *  <li>createFinalConfiguration()</li>
+ * <li>createFinalContext()</li>
+ * <li>createFinalConfiguration()</li>
  * </ul>
  *
- *  @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
+ * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
  */
 
-public class ServiceContainerConfiguration
-{
-    /** our default implementation class of the service container */
-    private String serviceContainerClazzName;
-
-    /** the location of the component role file */
-    private String componentRolesLocation;
-
-    /** is the component role file encrypted? */
-    private String isComponentRolesEncrypted;
-
-    /** the location of the component configuration file */
-    private String componentConfigurationLocation;
-
-    /** is the component configuration file encrypted? */
-    private String isComponentConfigurationEncrypted;
-
-    /** the location of the paramaters file */
-    private String parametersLocation;
-
-    /** is the parameters file encrypted? */
-    private String isParametersEncrypted;
-
-    /** the user-supplied Avalon context */
-    private DefaultContext context;
-
-    /** the Avalon logger */
-    private Logger logger;
-
-    /** the application directory */
-    private String applicationRootDir;
-
-    /** the temporary directory */
-    private String tempRootDir;
-
-    /** the class loader passed in the Avalon Context */
-    private ClassLoader componentClassLoader;
-
-    /** the type of container where YAAFI is embedded */
-    private String containerFlavour;
-
-    /** the caller-supplied container configuration */
-    private Configuration containerConfiguration;
-
-    /** to lookup service in the parent container */
-    private ServiceManager parentServiceManager;
-
-    /** a list of ServiceManager maintaining their own services */
-    private String[] serviceManagerList;
-
-    /** Constructor */
-    public ServiceContainerConfiguration()
-    {
-        this(ConsoleLogger.LEVEL_DEBUG);
-    }
-
-    /**
-     * Constructor.
-     *
-     * @param logLevel the log level for the console logger.
-     */
-    public ServiceContainerConfiguration(int logLevel)
-    {
-        this.logger = new ConsoleLogger(logLevel);
-        this.containerFlavour = ServiceConstants.AVALON_CONTAINER_YAAFI;
-        this.serviceContainerClazzName = ServiceConstants.CLAZZ_NAME;
-        this.componentRolesLocation = ServiceConstants.COMPONENT_ROLE_VALUE;
-        this.isComponentRolesEncrypted = "false";
-        this.componentConfigurationLocation = ServiceConstants.COMPONENT_CONFIG_VALUE;
-        this.isComponentConfigurationEncrypted = "false";
-        this.parametersLocation = ServiceConstants.COMPONENT_PARAMETERS_VALUE;
-        this.isParametersEncrypted = "false";
-        this.context = new DefaultContext();
-        this.applicationRootDir = new File("").getAbsolutePath();
-        this.tempRootDir = System.getProperty("java.io.tmpdir",".");
-        this.componentClassLoader = this.getClass().getClassLoader();
-    }
-
-    /**
-     * Add a new entry to the context by creating a new one.
-     * @param name the name of the new entry
-     * @param value the value of the new entry
-     */
-    public void addToContext( String name, Object value )
-    {
-        Validate.notEmpty(name,"name");
-        Validate.notNull(value,"value");
-        this.getContext().put( name, value );
-    }
-
-    /**
-     * Add a hashtable to the context
-     * @param hashtable the Hashtable to be added
-     */
-    public void addToContext( Hashtable<?, ?> hashtable )
-    {
-        Validate.notNull(hashtable,"hashtable");
-
-        String name = null;
-        Object value = null;
-        Enumeration<?> keys = hashtable.keys();
-
-        while( keys.hasMoreElements() )
-        {
-            name = (String) keys.nextElement();
-            value = hashtable.get( name );
-            this.addToContext( name, value );
-        }
-    }
-
-    /**
-     * Create the final Avalon context passed to YAAFI containing
-     * <ul>
-     *   <li>user-supplied context</li>
-     *   <li>urn:avalon:home</li>
-     *   <li>urn:avalon:temp</li>
-     *   <li>urn:avalon:name</li>
-     *   <li>urn:avalon:partition</li>
-     *   <li>urn:avalon:classloader</li>
-     * </ul>
-     *
-     * @return the final Context
-     */
-
-    public Context createFinalContext()
-    {
-        // 1) add the application root dir
-
-        this.addToContext(
-            AvalonMerlinConstants.URN_AVALON_HOME,
-            this.getApplicationRootDir()
-            );
-
-        // 2) add the temp root dir
-
-        this.addToContext(
-            AvalonMerlinConstants.URN_AVALON_TEMP,
-            this.getTempRootDir()
-            );
-
-        // 3) add the Avalon name
-
-        this.addToContext(
-            AvalonMerlinConstants.URN_AVALON_NAME,
-            ServiceConstants.ROLE_NAME
-            );
-
-        // 4) add the Avalon partition name
-
-        this.addToContext(
-            AvalonMerlinConstants.URN_AVALON_PARTITION,
-            "root"
-            );
-
-        // 5) add the class loader
-
-        this.addToContext(
-            AvalonMerlinConstants.URN_AVALON_CLASSLOADER,
-            this.getComponentClassLoader()
-            );
-
-        return this.getContext();
-    }
-
-    /**
-     * Create a final configuration.
-     *
-     * @return the configuration
-     */
-    public Configuration createFinalConfiguration()
-    {
-        DefaultConfiguration result = null;
-
-        if( this.getContainerConfiguration() != null )
-        {
-            return this.getContainerConfiguration();
-        }
-        else
-        {
-            // the root element is "fulcrum-yaafi"
-
-            result = new DefaultConfiguration(
-                ServiceConstants.ROLE_NAME
-                );
-
-            // add the following fragement
-            //
-            // <containerFlavour>merlin</containerFlavour>
-
-            DefaultConfiguration containerFlavourConfig = new DefaultConfiguration(
-                ServiceConstants.CONTAINERFLAVOUR_CONFIG_KEY
-                );
-
-            containerFlavourConfig.setValue( this.getContainerFlavour() );
-
-            result.addChild( containerFlavourConfig );
-
-            // add the following fragement
-            //
-            // <containerClazzName>...</containerClazzName>
-
-            DefaultConfiguration containerClazzNameConfig = new DefaultConfiguration(
-                ServiceConstants.CONTAINERCLAZZNAME_CONFIG_KEY
-                );
-
-            containerClazzNameConfig.setValue( this.getServiceContainerClazzName() );
-
-            result.addChild( containerClazzNameConfig );
-
-
-            // add the following fragement
-            //
-            // <componentRoles>
-            //  <location>../conf/componentRoles.xml</location>
-            //  <isEncrypted>true</isEncrypted>
-            // </componentRoles>
-
-            DefaultConfiguration componentRolesConfig = new DefaultConfiguration(
-                ServiceConstants.COMPONENT_ROLE_KEYS
-                );
-
-            DefaultConfiguration componentRolesLocation = new DefaultConfiguration(
-                ServiceConstants.COMPONENT_LOCATION_KEY
-                );
-
-            componentRolesLocation.setValue(
-                this.getComponentRolesLocation()
-                );
-
-            DefaultConfiguration componentRolesIsEncrypted = new DefaultConfiguration(
-                ServiceConstants.COMPONENT_ISENCRYPTED_KEY
-                );
-
-            componentRolesIsEncrypted.setValue(
-                this.isComponentRolesEncrypted()
-                );
-
-            componentRolesConfig.addChild( componentRolesLocation );
-            componentRolesConfig.addChild( componentRolesIsEncrypted );
-
-            result.addChild( componentRolesConfig );
-
-            // add the following fragement
-            //
-            // <componentConfiguration>
-            //  <location>../conf/componentRoles.xml</location>
-            //  <isEncrypted>true</isEncrypted>
-            // </componentConfiguration>
-
-            DefaultConfiguration componentConfigurationConfig = new DefaultConfiguration(
-                ServiceConstants.COMPONENT_CONFIG_KEY
-                );
-
-            DefaultConfiguration componentConfigurationLocation = new DefaultConfiguration(
-                ServiceConstants.COMPONENT_LOCATION_KEY
-                );
-
-            componentConfigurationLocation.setValue(
-                this.getComponentConfigurationLocation()
-                );
-
-            DefaultConfiguration componentConfigurationIsEncrypted = new DefaultConfiguration(
-                ServiceConstants.COMPONENT_ISENCRYPTED_KEY
-                );
-
-            componentConfigurationIsEncrypted.setValue(
-                this.isComponentConfigurationEncrypted()
-                );
-
-            componentConfigurationConfig.addChild( componentConfigurationLocation );
-            componentConfigurationConfig.addChild( componentConfigurationIsEncrypted );
-
-            result.addChild( componentConfigurationConfig );
-
-            // Add the following fragement
-            //
-            // <parameters>
-            //   <location>../conf/parameters.properties</location>
-            //   <isEncrypted>true</isEncrypted>
-            // </parameters>
-
-            DefaultConfiguration parameterConfigurationConfig = new DefaultConfiguration(
-                ServiceConstants.COMPONENT_PARAMETERS_KEY
-                );
-
-            DefaultConfiguration parameterConfigurationLocation = new DefaultConfiguration(
-                ServiceConstants.COMPONENT_LOCATION_KEY
-                );
-
-            parameterConfigurationLocation.setValue(
-                this.getParametersLocation()
-                );
-
-            DefaultConfiguration parameterConfigurationIsEncrypted = new DefaultConfiguration(
-                ServiceConstants.COMPONENT_ISENCRYPTED_KEY
-                );
-
-            parameterConfigurationIsEncrypted.setValue(
-                this.isParametersEncrypted()
-                );
-
-            parameterConfigurationConfig.addChild( parameterConfigurationLocation );
-            parameterConfigurationConfig.addChild( parameterConfigurationIsEncrypted );
-
-            result.addChild( parameterConfigurationConfig );
-
-            // Add the following fragement
-            //
-            // <serviceManagers>
-            //   <serviceManagers>springFrameworkService</serviceManager>
-            // </serviceManagers>
-
-            if(this.hasServiceManagerList())
-            {
-                DefaultConfiguration serviceManagerListConfig = new DefaultConfiguration(
-                    ServiceConstants.SERVICEMANAGER_LIST_KEY
-                    );
-
-                for(int i=0; i<this.serviceManagerList.length; i++)
-                {
-                    DefaultConfiguration serviceManagerConfig = new DefaultConfiguration(
-                        ServiceConstants.SERVICEMANAGER_KEY
-                        );
-
-                    serviceManagerConfig.setValue(this.serviceManagerList[i]);
-
-                    serviceManagerListConfig.addChild(serviceManagerConfig);
-                }
-
-                result.addChild( serviceManagerListConfig );
-            }
-
-
-            return result;
-        }
-    }
-
-    /////////////////////////////////////////////////////////////////////////
-    // Generated Getters/Setters
-    /////////////////////////////////////////////////////////////////////////
-
-    /**
-     * @return Returns the serviceContainerClazzName.
-     */
-    private String getServiceContainerClazzName()
-    {
-        return this.serviceContainerClazzName;
-    }
-
-    /**
-     * @return Returns the componentConfigurationLocation.
-     */
-    private String getComponentConfigurationLocation()
-    {
-        return componentConfigurationLocation;
-    }
-
-    /**
-     * @param componentConfigurationLocation The componentConfigurationLocation to set.
-     */
-    public void setComponentConfigurationLocation(
-        String componentConfigurationLocation)
-    {
-        Validate.notNull(componentConfigurationLocation,"componentConfigurationLocation");
-        this.componentConfigurationLocation = componentConfigurationLocation;
-    }
-
-    /**
-     * @return Returns the componentRolesLocation.
-     */
-    private String getComponentRolesLocation()
-    {
-        return componentRolesLocation;
-    }
-
-    /**
-     * @param componentRolesLocation The componentRolesLocation to set.
-     */
-    public void setComponentRolesLocation(String componentRolesLocation)
-    {
-        this.componentRolesLocation = componentRolesLocation;
-    }
-
-    /**
-     * @return Returns the context.
-     */
-    private DefaultContext getContext()
-    {
-        return context;
-    }
-
-    /**
-     * @param context The context to set.
-     */
-    public void setContext(Context context)
-    {
-        if( context instanceof DefaultContext )
-        {
-            this.context = (DefaultContext) context;
-        }
-        else
-        {
-            this.context = new DefaultContext( context );
-        }
-    }
-
-    /**
-     * @return Returns the isComponentConfigurationEncrypted.
-     */
-    private String isComponentConfigurationEncrypted()
-    {
-        return isComponentConfigurationEncrypted;
-    }
-
-    /**
-     * @param isComponentConfigurationEncrypted The isComponentConfigurationEncrypted to set.
-     */
-    public void setComponentConfigurationEncrypted(
-        String isComponentConfigurationEncrypted)
-    {
-        this.isComponentConfigurationEncrypted = isComponentConfigurationEncrypted;
-    }
-
-    /**
-     * @return Returns the isComponentRolesEncrypted.
-     */
-    private String isComponentRolesEncrypted()
-    {
-        return isComponentRolesEncrypted;
-    }
-    /**
-     * @param isComponentRolesEncrypted The isComponentRolesEncrypted to set.
-     */
-    public void setComponentRolesEncrypted(String isComponentRolesEncrypted)
-    {
-        this.isComponentRolesEncrypted = isComponentRolesEncrypted;
-    }
-
-    /**
-     * @return Returns the isParametersEncrypted.
-     */
-    private String isParametersEncrypted()
-    {
-        return isParametersEncrypted;
-    }
-
-    /**
-     * @param isParametersEncrypted The isParametersEncrypted to set.
-     */
-    public void setParametersEncrypted(String isParametersEncrypted)
-    {
-        Validate.notEmpty(isParametersEncrypted,"isParametersEncrypted");
-        this.isParametersEncrypted = isParametersEncrypted;
-    }
-
-    /**
-     * @return Returns the logger.
-     */
-    public Logger getLogger()
-    {
-        return logger;
-    }
-
-    /**
-     * @param logger The logger to set.
-     */
-    public void setLogger(Logger logger)
-    {
-        this.logger = logger;
-    }
-
-    /**
-     * @return Returns the parametersLocation.
-     */
-    private String getParametersLocation()
-    {
-        return parametersLocation;
-    }
-
-    /**
-     * @param parametersLocation The parametersLocation to set.
-     */
-    public void setParametersLocation(String parametersLocation)
-    {
-        this.parametersLocation = parametersLocation;
-    }
-
-    /**
-     * @return Returns the applicationRootDir.
-     */
-    private File getApplicationRootDir()
-    {
-        return new File(applicationRootDir);
-    }
-
-    /**
-     * @param applicationRootDir The applicationRootDir to set.
-     */
-    public void setApplicationRootDir(String applicationRootDir)
-    {
-        Validate.notNull(applicationRootDir, "applicationRootDir");
-
-        if( applicationRootDir.equals(".") )
-        {
-            this.applicationRootDir = new File("").getAbsolutePath();
-        }
-        else
-        {
-            this.applicationRootDir = new File( applicationRootDir ).getAbsolutePath();
-        }
-    }
-
-    /**
-     * @return Returns the tempRootDir.
-     */
-    private File getTempRootDir()
-    {
-        return makeAbsoluteFile(this.getApplicationRootDir(),this.tempRootDir);
-    }
-
-    /**
-     * @param tempRootDir The tempRootDir to set.
-     */
-    public void setTempRootDir(String tempRootDir)
-    {
-        Validate.notNull(tempRootDir, "tempRootDir");
-        this.tempRootDir = tempRootDir;
-    }
-
-    /**
-     * @return Returns the classLoader.
-     */
-    private ClassLoader getComponentClassLoader()
-    {
-        return componentClassLoader;
-    }
-
-    /**
-     * @param componentClassLoader The classLoader to set.
-     */
-    public void setComponentClassLoader(ClassLoader componentClassLoader)
-    {
-        Validate.notNull(componentClassLoader, "componentClassLoader");
-        this.componentClassLoader = componentClassLoader;
-    }
-
-    /**
-     * @return Returns the containerFlavour.
-     */
-    private String getContainerFlavour()
-    {
-        return containerFlavour;
-    }
-    /**
-     * @param containerFlavour The containerFlavour to set.
-     */
-    public void setContainerFlavour(String containerFlavour)
-    {
-        this.containerFlavour = containerFlavour;
-    }
-
-    /**
-     * @return Returns the containerConfiguration.
-     */
-    private Configuration getContainerConfiguration()
-    {
-        return containerConfiguration;
-    }
-
-    /**
-     * @param containerConfiguration The containerConfiguration to set.
-     */
-    public void setContainerConfiguration(Configuration containerConfiguration)
-    {
-        this.containerConfiguration = containerConfiguration;
-    }
-
-    /**
-     * Get the parent service manager to find service managed by the
-     * parent container.
-     *
-     * @return the parent container
-     */
-
-    public ServiceManager getParentServiceManager() {
-        return parentServiceManager;
-    }
-
-    /**
-     * Set the parent service manager to find service managed by the
-     * parent container.
-     *
-     * @param parentServiceManager the parent container
-     */
-    public void setParentServiceManager(ServiceManager parentServiceManager) {
-        this.parentServiceManager = parentServiceManager;
-    }
-
-    /**
-     * Get a list of service manager managing their own set of services.
-     *
-     * @return a list of service implementing the ServiceManager interface
-     */
-    public String[] getServiceManagerList() {
-        return serviceManagerList;
-    }
-
-    /**
-     * Set a list of service manager managing their own set of services.
-     *
-     * @param serviceManagerList a list of service implementing the ServiceManager interface
-     */
-    public void setServiceManagerList(String[] serviceManagerList) {
-        this.serviceManagerList = serviceManagerList;
-    }
-
-    /**
-     * @return is a list of service manager managing their own set of services defined
-     */
-    public boolean hasServiceManagerList()
-    {
-        return ((this.serviceManagerList != null) && (this.serviceManagerList.length > 0));
-    }
-
-    /**
-     * Loads a containerConfiguration file and set is as the Avalon
-     * configuration to be used for Configurable.configure(). Take
-     * care that the implementation uses an InputStreamLocator to
-     * find the containerConfiguration which uses the previously
-     * set application root directory.
-     *
-     * @param location the location of the containerConfiguration
-     * @throws IOException loading the configuration failed
-     */
-    public void loadContainerConfiguration( String location )
-        throws IOException
-    {
-        this.loadContainerConfiguration( location, "false" );
-    }
-
-    /**
-     * Loads a containerConfiguration file and set is as the Avalon
-     * configuration to be used for Configurable.configure(). Take
-     * care that the implementation uses an InputStreamLocator to
-     * find the containerConfiguration which uses the previously
-     * set application root directory.
-     *
-     * @param location the location of the containerConfiguration
-     * @param isEncrypted is the file encrypted
-     * @throws IOException loading the configuration failed
-     */
-    public void loadContainerConfiguration( String location, String isEncrypted )
-        throws IOException
-    {
-        Configuration result = null;
-
-        InputStreamLocator locator = new InputStreamLocator(
-            this.getApplicationRootDir(),
-            this.getLogger()
-            );
-
-        DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
-        InputStream is = locator.locate( location );
-
-        if( is != null )
-        {
-            try
-            {
-                is = CryptoStreamFactory.getDecryptingInputStream(is ,isEncrypted);
-                result = builder.build( is );
-                this.setContainerConfiguration( result );
-            }
-            catch ( Exception e )
-            {
-                String msg = "Unable to parse the following file : " + location;
-                this.getLogger().error( msg , e );
-                throw new IOException(msg);
-            }
-        }
-        else
-        {
-            String msg = "Unable to locate the containerConfiguration file : " + location;
-            this.getLogger().error(msg);
-            throw new IOException(msg);
-        }
-    }
-
-    /**
-     * Determines the absolute file.
-     * @param baseDir the base directory
-     * @param fileName the filename
-     * @return the absolute path
-     */
-    private static File makeAbsoluteFile( File baseDir, String fileName )
-    {
-        File result = new File(fileName);
-
-        if(!result.isAbsolute())
-        {
-            result = new File( baseDir, fileName );
-        }
-
-        return result;
-    }
+public class ServiceContainerConfiguration {
+	/** our default implementation class of the service container */
+	private String serviceContainerClazzName;
+
+	/** the location of the component role file */
+	private String componentRolesLocation;
+
+	/** is the component role file encrypted? */
+	private String isComponentRolesEncrypted;
+
+	/** the location of the component configuration file */
+	private String componentConfigurationLocation;
+
+	/** is the component configuration file encrypted? */
+	private String isComponentConfigurationEncrypted;
+
+	/** the location of the paramaters file */
+	private String parametersLocation;
+
+	/** is the parameters file encrypted? */
+	private String isParametersEncrypted;
+
+	/** the user-supplied Avalon context */
+	private DefaultContext context;
+
+	/** the Avalon logger */
+	private Logger logger;
+
+	/** the application directory */
+	private String applicationRootDir;
+
+	/** the temporary directory */
+	private String tempRootDir;
+
+	/** the class loader passed in the Avalon Context */
+	private ClassLoader componentClassLoader;
+
+	/** the type of container where YAAFI is embedded */
+	private String containerFlavour;
+
+	/** the caller-supplied container configuration */
+	private Configuration containerConfiguration;
+
+	/** to lookup service in the parent container */
+	private ServiceManager parentServiceManager;
+
+	/** a list of ServiceManager maintaining their own services */
+	private String[] serviceManagerList;
+
+	/** Constructor */
+	public ServiceContainerConfiguration() {
+		this(ConsoleLogger.LEVEL_DEBUG);
+	}
+
+	/**
+	 * Constructor.
+	 *
+	 * @param logLevel the log level for the console logger.
+	 */
+	public ServiceContainerConfiguration(int logLevel) {
+		this.logger = new ConsoleLogger(logLevel);
+		this.containerFlavour = ServiceConstants.AVALON_CONTAINER_YAAFI;
+		this.serviceContainerClazzName = ServiceConstants.CLAZZ_NAME;
+		this.componentRolesLocation = ServiceConstants.COMPONENT_ROLE_VALUE;
+		this.isComponentRolesEncrypted = "false";
+		this.componentConfigurationLocation = ServiceConstants.COMPONENT_CONFIG_VALUE;
+		this.isComponentConfigurationEncrypted = "false";
+		this.parametersLocation = ServiceConstants.COMPONENT_PARAMETERS_VALUE;
+		this.isParametersEncrypted = "false";
+		this.context = new DefaultContext();
+		this.applicationRootDir = new File("").getAbsolutePath();
+		this.tempRootDir = System.getProperty("java.io.tmpdir", ".");
+		this.componentClassLoader = this.getClass().getClassLoader();
+	}
+
+	/**
+	 * Add a new entry to the context by creating a new one.
+	 * 
+	 * @param name  the name of the new entry
+	 * @param value the value of the new entry
+	 */
+	public void addToContext(String name, Object value) {
+		Validate.notEmpty(name, "name");
+		Validate.notNull(value, "value");
+		this.getContext().put(name, value);
+	}
+
+	/**
+	 * Add a hashtable to the context
+	 * 
+	 * @param hashtable the Hashtable to be added
+	 */
+	public void addToContext(Hashtable<?, ?> hashtable) {
+		Validate.notNull(hashtable, "hashtable");
+
+		String name = null;
+		Object value = null;
+		Enumeration<?> keys = hashtable.keys();
+
+		while (keys.hasMoreElements()) {
+			name = (String) keys.nextElement();
+			value = hashtable.get(name);
+			this.addToContext(name, value);
+		}
+	}
+
+	/**
+	 * Create the final Avalon context passed to YAAFI containing
+	 * <ul>
+	 * <li>user-supplied context</li>
+	 * <li>urn:avalon:home</li>
+	 * <li>urn:avalon:temp</li>
+	 * <li>urn:avalon:name</li>
+	 * <li>urn:avalon:partition</li>
+	 * <li>urn:avalon:classloader</li>
+	 * </ul>
+	 *
+	 * @return the final Context
+	 * @throws Exception if filename not defined
+	 * @throws IOException if file not found
+	 */
+
+	public Context createFinalContext() throws IOException, Exception {
+		// 1) add the application root dir
+
+		this.addToContext(AvalonMerlinConstants.URN_AVALON_HOME, this.getApplicationRootDir());
+
+		// 2) add the temp root dir
+
+		this.addToContext(AvalonMerlinConstants.URN_AVALON_TEMP, this.getTempRootDir());
+
+		// 3) add the Avalon name
+
+		this.addToContext(AvalonMerlinConstants.URN_AVALON_NAME, ServiceConstants.ROLE_NAME);
+
+		// 4) add the Avalon partition name
+
+		this.addToContext(AvalonMerlinConstants.URN_AVALON_PARTITION, "root");
+
+		// 5) add the class loader
+
+		this.addToContext(AvalonMerlinConstants.URN_AVALON_CLASSLOADER, this.getComponentClassLoader());
+
+		return this.getContext();
+	}
+
+	/**
+	 * Create a final configuration.
+	 *
+	 * @return the configuration
+	 */
+	public Configuration createFinalConfiguration() {
+		DefaultConfiguration result = null;
+
+		if (this.getContainerConfiguration() != null) {
+			return this.getContainerConfiguration();
+		} else {
+			// the root element is "fulcrum-yaafi"
+
+			result = new DefaultConfiguration(ServiceConstants.ROLE_NAME);
+
+			// add the following fragement
+			//
+			// <containerFlavour>merlin</containerFlavour>
+
+			DefaultConfiguration containerFlavourConfig = new DefaultConfiguration(
+					ServiceConstants.CONTAINERFLAVOUR_CONFIG_KEY);
+
+			containerFlavourConfig.setValue(this.getContainerFlavour());
+
+			result.addChild(containerFlavourConfig);
+
+			// add the following fragement
+			//
+			// <containerClazzName>...</containerClazzName>
+
+			DefaultConfiguration containerClazzNameConfig = new DefaultConfiguration(
+					ServiceConstants.CONTAINERCLAZZNAME_CONFIG_KEY);
+
+			containerClazzNameConfig.setValue(this.getServiceContainerClazzName());
+
+			result.addChild(containerClazzNameConfig);
+
+			// add the following fragement
+			//
+			// <componentRoles>
+			// <location>../conf/componentRoles.xml</location>
+			// <isEncrypted>true</isEncrypted>
+			// </componentRoles>
+
+			DefaultConfiguration componentRolesConfig = new DefaultConfiguration(ServiceConstants.COMPONENT_ROLE_KEYS);
+
+			DefaultConfiguration componentRolesLocation = new DefaultConfiguration(
+					ServiceConstants.COMPONENT_LOCATION_KEY);
+
+			componentRolesLocation.setValue(this.getComponentRolesLocation());
+
+			DefaultConfiguration componentRolesIsEncrypted = new DefaultConfiguration(
+					ServiceConstants.COMPONENT_ISENCRYPTED_KEY);
+
+			componentRolesIsEncrypted.setValue(this.isComponentRolesEncrypted());
+
+			componentRolesConfig.addChild(componentRolesLocation);
+			componentRolesConfig.addChild(componentRolesIsEncrypted);
+
+			result.addChild(componentRolesConfig);
+
+			// add the following fragement
+			//
+			// <componentConfiguration>
+			// <location>../conf/componentRoles.xml</location>
+			// <isEncrypted>true</isEncrypted>
+			// </componentConfiguration>
+
+			DefaultConfiguration componentConfigurationConfig = new DefaultConfiguration(
+					ServiceConstants.COMPONENT_CONFIG_KEY);
+
+			DefaultConfiguration componentConfigurationLocation = new DefaultConfiguration(
+					ServiceConstants.COMPONENT_LOCATION_KEY);
+
+			componentConfigurationLocation.setValue(this.getComponentConfigurationLocation());
+
+			DefaultConfiguration componentConfigurationIsEncrypted = new DefaultConfiguration(
+					ServiceConstants.COMPONENT_ISENCRYPTED_KEY);
+
+			componentConfigurationIsEncrypted.setValue(this.isComponentConfigurationEncrypted());
+
+			componentConfigurationConfig.addChild(componentConfigurationLocation);
+			componentConfigurationConfig.addChild(componentConfigurationIsEncrypted);
+
+			result.addChild(componentConfigurationConfig);
+
+			// Add the following fragement
+			//
+			// <parameters>
+			// <location>../conf/parameters.properties</location>
+			// <isEncrypted>true</isEncrypted>
+			// </parameters>
+
+			DefaultConfiguration parameterConfigurationConfig = new DefaultConfiguration(
+					ServiceConstants.COMPONENT_PARAMETERS_KEY);
+
+			DefaultConfiguration parameterConfigurationLocation = new DefaultConfiguration(
+					ServiceConstants.COMPONENT_LOCATION_KEY);
+
+			parameterConfigurationLocation.setValue(this.getParametersLocation());
+
+			DefaultConfiguration parameterConfigurationIsEncrypted = new DefaultConfiguration(
+					ServiceConstants.COMPONENT_ISENCRYPTED_KEY);
+
+			parameterConfigurationIsEncrypted.setValue(this.isParametersEncrypted());
+
+			parameterConfigurationConfig.addChild(parameterConfigurationLocation);
+			parameterConfigurationConfig.addChild(parameterConfigurationIsEncrypted);
+
+			result.addChild(parameterConfigurationConfig);
+
+			// Add the following fragement
+			//
+			// <serviceManagers>
+			// <serviceManagers>springFrameworkService</serviceManager>
+			// </serviceManagers>
+
+			if (this.hasServiceManagerList()) {
+				DefaultConfiguration serviceManagerListConfig = new DefaultConfiguration(
+						ServiceConstants.SERVICEMANAGER_LIST_KEY);
+
+				for (int i = 0; i < this.serviceManagerList.length; i++) {
+					DefaultConfiguration serviceManagerConfig = new DefaultConfiguration(
+							ServiceConstants.SERVICEMANAGER_KEY);
+
+					serviceManagerConfig.setValue(this.serviceManagerList[i]);
+
+					serviceManagerListConfig.addChild(serviceManagerConfig);
+				}
+
+				result.addChild(serviceManagerListConfig);
+			}
+
+			return result;
+		}
+	}
+
+	/////////////////////////////////////////////////////////////////////////
+	// Generated Getters/Setters
+	/////////////////////////////////////////////////////////////////////////
+
+	/**
+	 * @return Returns the serviceContainerClazzName.
+	 */
+	private String getServiceContainerClazzName() {
+		return this.serviceContainerClazzName;
+	}
+
+	/**
+	 * @return Returns the componentConfigurationLocation.
+	 */
+	private String getComponentConfigurationLocation() {
+		return componentConfigurationLocation;
+	}
+
+	/**
+	 * @param componentConfigurationLocation The componentConfigurationLocation to
+	 *                                       set.
+	 */
+	public void setComponentConfigurationLocation(String componentConfigurationLocation) {
+		Validate.notNull(componentConfigurationLocation, "componentConfigurationLocation");
+		this.componentConfigurationLocation = componentConfigurationLocation;
+	}
+
+	/**
+	 * @return Returns the componentRolesLocation.
+	 */
+	private String getComponentRolesLocation() {
+		return componentRolesLocation;
+	}
+
+	/**
+	 * @param componentRolesLocation The componentRolesLocation to set.
+	 */
+	public void setComponentRolesLocation(String componentRolesLocation) {
+		this.componentRolesLocation = componentRolesLocation;
+	}
+
+	/**
+	 * @return Returns the context.
+	 */
+	private DefaultContext getContext() {
+		return context;
+	}
+
+	/**
+	 * @param context The context to set.
+	 */
+	public void setContext(Context context) {
+		if (context instanceof DefaultContext) {
+			this.context = (DefaultContext) context;
+		} else {
+			this.context = new DefaultContext(context);
+		}
+	}
+
+	/**
+	 * @return Returns the isComponentConfigurationEncrypted.
+	 */
+	private String isComponentConfigurationEncrypted() {
+		return isComponentConfigurationEncrypted;
+	}
+
+	/**
+	 * @param isComponentConfigurationEncrypted The
+	 *                                          isComponentConfigurationEncrypted to
+	 *                                          set.
+	 */
+	public void setComponentConfigurationEncrypted(String isComponentConfigurationEncrypted) {
+		this.isComponentConfigurationEncrypted = isComponentConfigurationEncrypted;
+	}
+
+	/**
+	 * @return Returns the isComponentRolesEncrypted.
+	 */
+	private String isComponentRolesEncrypted() {
+		return isComponentRolesEncrypted;
+	}
+
+	/**
+	 * @param isComponentRolesEncrypted The isComponentRolesEncrypted to set.
+	 */
+	public void setComponentRolesEncrypted(String isComponentRolesEncrypted) {
+		this.isComponentRolesEncrypted = isComponentRolesEncrypted;
+	}
+
+	/**
+	 * @return Returns the isParametersEncrypted.
+	 */
+	private String isParametersEncrypted() {
+		return isParametersEncrypted;
+	}
+
+	/**
+	 * @param isParametersEncrypted The isParametersEncrypted to set.
+	 */
+	public void setParametersEncrypted(String isParametersEncrypted) {
+		Validate.notEmpty(isParametersEncrypted, "isParametersEncrypted");
+		this.isParametersEncrypted = isParametersEncrypted;
+	}
+
+	/**
+	 * @return Returns the logger.
+	 */
+	public Logger getLogger() {
+		return logger;
+	}
+
+	/**
+	 * @param logger The logger to set.
+	 */
+	public void setLogger(Logger logger) {
+		this.logger = logger;
+	}
+
+	/**
+	 * @return Returns the parametersLocation.
+	 */
+	private String getParametersLocation() {
+		return parametersLocation;
+	}
+
+	/**
+	 * @param parametersLocation The parametersLocation to set.
+	 */
+	public void setParametersLocation(String parametersLocation) {
+		this.parametersLocation = parametersLocation;
+	}
+
+	/**
+	 * @return Returns the applicationRootDir.
+	 */
+	private File getApplicationRootDir() {
+		return new File(applicationRootDir);
+	}
+
+	/**
+	 * @param applicationRootDir The applicationRootDir to set.
+	 */
+	public void setApplicationRootDir(String applicationRootDir) {
+		Validate.notNull(applicationRootDir, "applicationRootDir");
+
+		if (applicationRootDir.equals(".")) {
+			this.applicationRootDir = new File("").getAbsolutePath();
+		} else {
+			this.applicationRootDir = new File(applicationRootDir).getAbsolutePath();
+		}
+	}
+
+	/**
+	 * @return Returns the tempRootDir.
+	 * @throws Exception 
+	 * @throws IOException 
+	 */
+	private File getTempRootDir() throws IOException, Exception {
+		return makeAbsoluteFile(this.getApplicationRootDir(), this.tempRootDir);
+	}
+
+	/**
+	 * @param tempRootDir The tempRootDir to set.
+	 */
+	public void setTempRootDir(String tempRootDir) {
+		Validate.notNull(tempRootDir, "tempRootDir");
+		this.tempRootDir = tempRootDir;
+	}
+
+	/**
+	 * @return Returns the classLoader.
+	 */
+	private ClassLoader getComponentClassLoader() {
+		return componentClassLoader;
+	}
+
+	/**
+	 * @param componentClassLoader The classLoader to set.
+	 */
+	public void setComponentClassLoader(ClassLoader componentClassLoader) {
+		Validate.notNull(componentClassLoader, "componentClassLoader");
+		this.componentClassLoader = componentClassLoader;
+	}
+
+	/**
+	 * @return Returns the containerFlavour.
+	 */
+	private String getContainerFlavour() {
+		return containerFlavour;
+	}
+
+	/**
+	 * @param containerFlavour The containerFlavour to set.
+	 */
+	public void setContainerFlavour(String containerFlavour) {
+		this.containerFlavour = containerFlavour;
+	}
+
+	/**
+	 * @return Returns the containerConfiguration.
+	 */
+	private Configuration getContainerConfiguration() {
+		return containerConfiguration;
+	}
+
+	/**
+	 * @param containerConfiguration The containerConfiguration to set.
+	 */
+	public void setContainerConfiguration(Configuration containerConfiguration) {
+		this.containerConfiguration = containerConfiguration;
+	}
+
+	/**
+	 * Get the parent service manager to find service managed by the parent
+	 * container.
+	 *
+	 * @return the parent container
+	 */
+
+	public ServiceManager getParentServiceManager() {
+		return parentServiceManager;
+	}
+
+	/**
+	 * Set the parent service manager to find service managed by the parent
+	 * container.
+	 *
+	 * @param parentServiceManager the parent container
+	 */
+	public void setParentServiceManager(ServiceManager parentServiceManager) {
+		this.parentServiceManager = parentServiceManager;
+	}
+
+	/**
+	 * Get a list of service manager managing their own set of services.
+	 *
+	 * @return a list of service implementing the ServiceManager interface
+	 */
+	public String[] getServiceManagerList() {
+		return serviceManagerList;
+	}
+
+	/**
+	 * Set a list of service manager managing their own set of services.
+	 *
+	 * @param serviceManagerList a list of service implementing the ServiceManager
+	 *                           interface
+	 */
+	public void setServiceManagerList(String[] serviceManagerList) {
+		this.serviceManagerList = serviceManagerList;
+	}
+
+	/**
+	 * @return true if there is a service manager defined
+	 */
+	public boolean hasServiceManagerList() {
+		if (this.serviceManagerList != null && this.serviceManagerList.length > 0)
+			return true;
+		return false;
+	}
+
+	/**
+	 * Loads a containerConfiguration file and set is as the Avalon configuration to
+	 * be used for Configurable.configure(). Take care that the implementation uses
+	 * an InputStreamLocator to find the containerConfiguration which uses the
+	 * previously set application root directory.
+	 *
+	 * @param location the location of the containerConfiguration
+	 * @throws IOException loading the configuration failed
+	 */
+	public void loadContainerConfiguration(String location) throws IOException {
+		this.loadContainerConfiguration(location, "false");
+	}
+
+	/**
+	 * Loads a containerConfiguration file and set is as the Avalon configuration to
+	 * be used for Configurable.configure(). Take care that the implementation uses
+	 * an InputStreamLocator to find the containerConfiguration which uses the
+	 * previously set application root directory.
+	 *
+	 * @param location    the location of the containerConfiguration
+	 * @param isEncrypted is the file encrypted
+	 * @throws IOException loading the configuration failed
+	 */
+	public void loadContainerConfiguration(String location, String isEncrypted) throws IOException {
+		Configuration result = null;
+
+		InputStreamLocator locator = new InputStreamLocator(this.getApplicationRootDir(), this.getLogger());
+
+		DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+		InputStream is = locator.locate(location);
+
+		if (is != null) {
+			try {
+				is = CryptoStreamFactory.getDecryptingInputStream(is, isEncrypted);
+				result = builder.build(is);
+				this.setContainerConfiguration(result);
+			} catch (Exception e) {
+				String msg = "Unable to parse the following file : " + location;
+				this.getLogger().error(msg, e);
+				throw new IOException(msg);
+			}
+		} else {
+			String msg = "Unable to locate the containerConfiguration file : " + location;
+			this.getLogger().error(msg);
+			throw new IOException(msg);
+		}
+	}
+
+	/**
+	 * Determines the absolute file.
+	 * 
+	 * @param baseDir  the base directory
+	 * @param fileName the filename
+	 * @return the absolute path
+	 */
+	private static File makeAbsoluteFile(File baseDir, String fileName) throws IOException, Exception {
+		if (baseDir.exists()) {
+			if (!StringUtils.isEmpty(fileName)) {
+				File result = new File(fileName);
+				if (!result.isAbsolute()) {
+					result = new File(baseDir, fileName);
+				}
+				return result;
+			} else {
+				throw new Exception("No filename specified");
+			}
+		} else {
+			throw new IOException("The directory does not exist");
+		}
+	}
 }

Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/util/ConfigurationUtil.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/util/ConfigurationUtil.java?rev=1848876&r1=1848875&r2=1848876&view=diff
==============================================================================
--- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/util/ConfigurationUtil.java (original)
+++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/util/ConfigurationUtil.java Thu Dec 13 18:17:39 2018
@@ -45,7 +45,7 @@ public class ConfigurationUtil
      */
     public static void expand(Logger logger, DefaultConfiguration defaultConfiguration, Map<?, ?> vars) throws ConfigurationException
     {
-        if((vars == null) || (vars.size() == 0))
+        if( vars == null || vars.size() == 0)
         {
             return;
         }

Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/util/InputStreamLocator.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/util/InputStreamLocator.java?rev=1848876&r1=1848875&r2=1848876&view=diff
==============================================================================
--- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/util/InputStreamLocator.java (original)
+++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/util/InputStreamLocator.java Thu Dec 13 18:17:39 2018
@@ -33,147 +33,120 @@ import org.apache.avalon.framework.logge
  * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
  */
 
-public class InputStreamLocator
-{
-    /** the root directory of our search */
-    private File rootDir;
-
-    /** the logger to be used */
-    private Logger logger;
-
-    /**
-     * Constructor
-     */
-    public InputStreamLocator()
-    {
-        this.rootDir = new File( new File("").getAbsolutePath() );
-        this.logger = new NullLogger();
-    }
-
-    /**
-     * Constructor
-     *
-     * @param rootDir the root directory to start the search     */
-    public InputStreamLocator( File rootDir )
-    {
-        this( rootDir, new NullLogger() );
-    }
-
-    /**
-     * Constructor
-     *
-     * @param rootDir the root directory to start the search
-     * @param logger the logger to be used
-     */
-    public InputStreamLocator( File rootDir, Logger logger )
-    {
-        this.rootDir    = rootDir;
-        this.logger     = logger;
-    }
-
-    /**
-     * Locate the file with the given position using the following steps
-     *
-     * @param location the location of the source to be loaded
-     * @return input stream of the source
-     * @throws IOException if source is not found
-     */
-    public InputStream locate( String location ) throws IOException
-    {
-        if( ( location == null ) || ( location.length() == 0 ) )
-        {
-            return null;
-        }
-
-        String baseName = null;
-        File file = null;
-        InputStream is = null;
-
-        // try to load a relative location with the given root dir
-        // e.g. "componentRoles.xml" located in the current working directory
-
-        if( is == null )
-        {
-            file = new File( this.rootDir, location );
-
-            this.getLogger().debug("Looking for " + location + " in the root directory");
-
-            if( file.exists() )
-            {
-                is = new FileInputStream( file );
-                this.getLogger().debug("Found " + location + " as " + file.getAbsolutePath() );
-            }
-        }
-
-        // try to load an absolute location as file
-        // e.g. "/foo/componentRoles.xml" from the root of the file system
-
-        if( is == null )
-        {
-            file = new File( location );
-
-            this.getLogger().debug("Looking for " + location + " as absolute file location");
-
-            if( file.isAbsolute() && file.exists() )
-            {
-                is = new FileInputStream( file );
-                this.getLogger().debug("Found " + location + " as " + file.getAbsolutePath() );
-            }
-        }
-
-        // try to load an absolute location through the classpath
-        // e.g. "/componentRoles.xml" located in the classpath
-
-        if( ( is == null ) && ( location.startsWith( "/" ) == true ) )
-        {
-            this.getLogger().debug("Looking for " + location + " using the class loader");
-            is =  getClass().getResourceAsStream( location );
-
-            if( is != null )
-            {
-                this.getLogger().debug("Successfully located " + location);
-            }
-        }
-
-        // try to load the last part of the file name using the classloader
-        // e.g. "conf/componentRoles.xml" as "/componentRoles.xml" located in
-        // the classpath.
-
-        if( ( is == null ) && ( location.startsWith( "/" ) == false ) )
-        {
-            baseName = '/' + new File(location).getName();
-            this.getLogger().debug("Looking for " + baseName + " using the class loader");
-            is =  getClass().getResourceAsStream( baseName );
-
-            if( is != null )
-            {
-                this.getLogger().debug("Successfully located " + baseName);
-            }
-        }
-
-        if( is == null )
-        {
-            this.getLogger().info("Unable to find any resource with the name '" + location + "'");
-        }
-
-        return is;
-    }
-
-    /**
-     * @return Returns the logger.
-     */
-    protected Logger getLogger()
-    {
-        return logger;
-    }
-
-    /**
-     * @return Returns the rootDir.
-     */
-    protected File getRootDir()
-    {
-        return rootDir;
-    }
-
+public class InputStreamLocator {
+	
+	/** the root directory of our search */
+	private File rootDir;
+
+	/** the logger to be used */
+	private Logger logger;
+
+	/**
+	 * Constructor
+	 */
+	public InputStreamLocator() {
+		this.rootDir = new File(new File("").getAbsolutePath());
+		this.logger = new NullLogger();
+	}
+
+	/**
+	 * Constructor
+	 *
+	 * @param rootDir the root directory to start the search
+	 */
+	public InputStreamLocator(File rootDir) {
+		this(rootDir, new NullLogger());
+	}
+
+	/**
+	 * Constructor
+	 *
+	 * @param rootDir the root directory to start the search
+	 * @param logger  the logger to be used
+	 */
+	public InputStreamLocator(File rootDir, Logger logger) {
+		this.rootDir = rootDir;
+		this.logger = logger;
+	}
+
+	/**
+	 * Locate the file with the given position using the following steps
+	 *
+	 * @param location the location of the source to be loaded
+	 * @return input stream of the source
+	 * @throws IOException if source is not found
+	 */
+	public InputStream locate(String location) throws IOException {
+		if (location == null || location.length() == 0) {
+			return null;
+		}
+
+		String baseName = null;
+		File file = null;
+		InputStream is = null;
+
+		// try to load a relative location with the given root dir
+		// e.g. "componentRoles.xml" located in the current working directory
+		if (is == null) {
+			file = new File(this.rootDir, location);
+
+			this.logger.debug("Looking for " + location + " in the root directory");
+
+			if (file.exists()) {
+				is = new FileInputStream(file);
+				this.logger.debug("Found " + location + " as " + file.getAbsolutePath());
+			}
+		}
+
+		// try to load an absolute location as file
+		// e.g. "/foo/componentRoles.xml" from the root of the file system
+		if (is == null) {
+			file = new File(location);
+
+			this.logger.debug("Looking for " + location + " as absolute file location");
+
+			if (file.isAbsolute() && file.exists()) {
+				is = new FileInputStream(file);
+				this.logger.debug("Found " + location + " as " + file.getAbsolutePath());
+			}
+		}
+
+		// try to load an absolute location through the classpath
+		// e.g. "/componentRoles.xml" located in the classpath
+		if (is == null && location.startsWith("/") == true) {
+			this.logger.debug("Looking for " + location + " using the class loader");
+			is = getClass().getResourceAsStream(location);
+
+			if (is != null) {
+				this.logger.debug("Successfully located " + location);
+			}
+		}
+
+		// try to load the last part of the file name using the classloader
+		// e.g. "conf/componentRoles.xml" as "/componentRoles.xml" located in
+		// the classpath.
+
+		if (is == null && location.startsWith("/") == false) {
+			baseName = '/' + new File(location).getName();
+			this.logger.debug("Looking for " + baseName + " using the class loader");
+			is = getClass().getResourceAsStream(baseName);
+			if (is != null) {
+				this.logger.debug("Successfully located " + baseName);
+			}
+		}
+
+		if (is == null) {
+			this.logger.info("Unable to find any resource with the name '" + location + "'");
+		}
+
+		return is;
+	}
+
+	/**
+	 * @return Returns the rootDir.
+	 */
+	protected File getRootDir() {
+		return rootDir;
+	}
 
 }

Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/jamon/JamonInterceptorServiceImpl.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/jamon/JamonInterceptorServiceImpl.java?rev=1848876&r1=1848875&r2=1848876&view=diff
==============================================================================
--- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/jamon/JamonInterceptorServiceImpl.java (original)
+++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/jamon/JamonInterceptorServiceImpl.java Thu Dec 13 18:17:39 2018
@@ -64,7 +64,7 @@ public class JamonInterceptorServiceImpl
 	private String performanceMonitorClassName;
 
 	/** the implementation class name for the performance monitor */
-	private Class performanceMonitorClass;
+	private Class<?> performanceMonitorClass;
 
 	/** the class name of the JAMon MonitorFactory */
 	private static final String MONITORFACTORY_CLASSNAME = "com.jamonapi.MonitorFactory";
@@ -240,7 +240,7 @@ public class JamonInterceptorServiceImpl
 
 		try {
 			Class[] signature = { String.class, Method.class, Boolean.class };
-			Object[] args = { serviceName, method, (isEnabled) ? Boolean.TRUE : Boolean.FALSE };
+			Object[] args = { serviceName, method, isEnabled ? Boolean.TRUE : Boolean.FALSE };
 			result = (JamonPerformanceMonitor) Clazz.newInstance(this.performanceMonitorClass, signature, args);
 			return result;
 		} catch (Exception e) {

Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/javasimon/JavaSimonInterceptorServiceImpl.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/javasimon/JavaSimonInterceptorServiceImpl.java?rev=1848876&r1=1848875&r2=1848876&view=diff
==============================================================================
--- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/javasimon/JavaSimonInterceptorServiceImpl.java (original)
+++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/javasimon/JavaSimonInterceptorServiceImpl.java Thu Dec 13 18:17:39 2018
@@ -44,287 +44,261 @@ import org.apache.fulcrum.yaafi.intercep
  * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
  */
 
-public class JavaSimonInterceptorServiceImpl
-    extends BaseInterceptorServiceImpl
-    implements JavaSimonInterceptorService, Reconfigurable, ThreadSafe, Disposable, Initializable
-{
+public class JavaSimonInterceptorServiceImpl extends BaseInterceptorServiceImpl
+		implements JavaSimonInterceptorService, Reconfigurable, ThreadSafe, Disposable, Initializable {
 	/** are the JavaSimon classes in the classpath */
 	private boolean isJavaSimonAvailable;
 
-    /** the file to hold the report */
-    private File reportFile;
+	/** the file to hold the report */
+	private File reportFile;
 
-    /** the time in ms between two reports */
-    private long reportTimeout;
+	/** the time in ms between two reports */
+	private long reportTimeout;
 
-    /** do we create a report during disposal of the service */
-    private boolean reportOnExit;
+	/** do we create a report during disposal of the service */
+	private boolean reportOnExit;
 
-    /** the time when the next report is due */
-    private long nextReportTimestamp;
-
-    /** the implementation class name for the performance monitor */
-    private String performanceMonitorClassName;
-
-    /** the implementation class name for the performance monitor */
-    private Class<?> performanceMonitorClass;
-
-    /** the class name of the JavaSimon factory */
-    private static final String MONITORFACTORY_CLASSNAME = "org.javasimon.SimonManager";
-
-    /** the class name of the JavaSimon MonitorFactory */
-    private static final String DEFAULT_PERFORMANCEMONITOR_CLASSNAME = "org.apache.fulcrum.yaafi.interceptor.javasimon.JavaSimon4PerformanceMonitorImpl";
-
-    /////////////////////////////////////////////////////////////////////////
-    // Avalon Service Lifecycle Implementation
-    /////////////////////////////////////////////////////////////////////////
-
-    /**
-     * Constructor
-     */
-    public JavaSimonInterceptorServiceImpl()
-    {
-        super();
-    }
-
-    /**
-     * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
-     */
-    public void configure(Configuration configuration) throws ConfigurationException
-    {
-        super.configure(configuration);
-        this.reportTimeout = configuration.getChild("reportTimeout").getValueAsLong(0);
-
-        // parse the performance monitor class name
-        this.performanceMonitorClassName = configuration.getChild("performanceMonitorClassName").getValue(DEFAULT_PERFORMANCEMONITOR_CLASSNAME);
-
-        // parse the report file name
-        String reportFileName = configuration.getChild("reportFile").getValue("./javasimon.html");
-        this.reportFile = this.makeAbsoluteFile( reportFileName );
-
-        // determine when to create the next report
-        this.nextReportTimestamp = System.currentTimeMillis() + this.reportTimeout;
-
-        // do we create a report on disposal
-        this.reportOnExit = configuration.getChild("reportOnExit").getValueAsBoolean(false);
-    }
-
-    /**
-     * @see Initializable#initialize()
-     */
-    public void initialize() throws Exception
-    {
-        ClassLoader classLoader = this.getClassLoader();
-
-        if (!Clazz.hasClazz(classLoader, MONITORFACTORY_CLASSNAME))
-        {
-            String msg = "The JavaSimonInterceptorService is disabled since the JavaSimon classes are not found in the classpath";
-            this.getLogger().warn(msg);
-            this.isJavaSimonAvailable = false;
-            return;
-        }
-
-        if (!Clazz.hasClazz(classLoader, this.performanceMonitorClassName))
-        {
-            String msg = "The JavaSimonInterceptorService is disabled since the performance monitor class is not found in the classpath";
-            this.getLogger().warn(msg);
-            this.isJavaSimonAvailable = false;
-            return;
-        }
-
-        // load the performance monitor class
-        this.performanceMonitorClass = Clazz.getClazz(this.getClassLoader(), this.performanceMonitorClassName);
-
-        // check if we can create an instance of the performance monitor class
-        JavaSimonPerformanceMonitor testMonitor = this.createJavaSimonPerformanceMonitor(null, null, true);
-        if(testMonitor == null)
-        {
-            String msg = "The JavaSimonInterceptorService is disabled since the performance monitor can't be instantiated";
-            this.getLogger().warn(msg);
-            this.isJavaSimonAvailable = false;
-            return;
-        }
-
-        this.getLogger().debug("The JavaSimonInterceptorService is enabled");
-        this.isJavaSimonAvailable = true;
-    }
-
-        /**
-     * @see Reconfigurable#reconfigure(Configuration)
-     */
-    public void reconfigure(Configuration configuration) throws ConfigurationException
-    {
-        super.reconfigure(configuration);
-        this.configure(configuration);
-    }
-
-    /**
-     * @see Disposable#dispose()
-     */
-    public void dispose()
-    {
-        if( this.reportOnExit )
-        {
-            this.run();
-        }
-
-        this.reportFile = null;
-    }
-
-    /////////////////////////////////////////////////////////////////////////
-    // Service interface implementation
-    /////////////////////////////////////////////////////////////////////////
-
-    /**
-     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onEntry(AvalonInterceptorContext)
-     */
-    public void onEntry(AvalonInterceptorContext interceptorContext)
-    {
-        if( this.isJavaSimonAvailable()  )
-        {
-            this.writeReport();
-
-            String serviceShortHand = interceptorContext.getServiceShorthand();
-            Method serviceMethod = interceptorContext.getMethod();
-            boolean isEnabled = this.isServiceMonitored(interceptorContext );
-            JavaSimonPerformanceMonitor monitor = this.createJavaSimonPerformanceMonitor(serviceShortHand, serviceMethod, isEnabled);
-            monitor.start();
-            interceptorContext.getRequestContext().put(this.getServiceName(), monitor);
-        }
-    }
-
-    /**
-     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onExit(AvalonInterceptorContext, Object)
-     */
-    public void onExit(AvalonInterceptorContext interceptorContext, Object result)
-    {
-        if( this.isJavaSimonAvailable() )
-        {
-            JavaSimonPerformanceMonitor monitor;
-            monitor = (JavaSimonPerformanceMonitor) interceptorContext.getRequestContext().remove(this.getServiceName());
-            monitor.stop();
-        }
-    }
-
-    /**
-     * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onError(AvalonInterceptorContext, Throwable)
-     */
-    public void onError(AvalonInterceptorContext interceptorContext,Throwable t)
-    {
-        if( this.isJavaSimonAvailable() )
-        {
-            JavaSimonPerformanceMonitor monitor;
-            monitor = (JavaSimonPerformanceMonitor) interceptorContext.getRequestContext().remove(this.getServiceName());
-            monitor.stop(t);
-        }
-    }
-
-    /**
-     * Writes the JavaSimon report to the file system.
-     *
-     * @see Runnable#run()
-     */
-    public void run()
-    {
-        this.writeReport(this.reportFile);
-    }
-
-    /////////////////////////////////////////////////////////////////////////
-    // Service Implementation
-    /////////////////////////////////////////////////////////////////////////
-
-    /**
-     * @return Returns the isJavaSimonAvailable.
-     */
-    protected final boolean isJavaSimonAvailable()
-    {
-        return this.isJavaSimonAvailable;
-    }
-
-    /**
-     * Factory method for creating an implementation of a JavaSimonPerformanceMonitor.
-     *
-     * @param serviceName the service name
-     * @param method the method
-     * @param isEnabled is the monitor enabled
-     * @return the instance or <b>null</b> if the creation failed
-     */
-    @SuppressWarnings("rawtypes")
-	protected JavaSimonPerformanceMonitor createJavaSimonPerformanceMonitor(String serviceName, Method method, boolean isEnabled)
-    {
-        JavaSimonPerformanceMonitor result = null;
-
-        try
-        {
-            Class[] signature = { String.class, Method.class, Boolean.class };
-            Object[] args = { serviceName, method, (isEnabled) ? Boolean.TRUE : Boolean.FALSE};
-            result = (JavaSimonPerformanceMonitor) Clazz.newInstance(this.performanceMonitorClass, signature, args);
-        }
-        catch(Exception e)
-        {
-            String msg = "Failed to create a performance monitor instance : " + this.performanceMonitorClassName;
-            this.getLogger().error(msg, e);
-        }
-
-        return result;
-    }
-
-    /**
-     * Write a report file
-     */
-    protected void writeReport()
-    {
-        if( this.reportTimeout > 0 )
-        {
-            long currTimestamp = System.currentTimeMillis();
-
-            if( currTimestamp > this.nextReportTimestamp )
-            {
-                this.nextReportTimestamp = currTimestamp + this.reportTimeout;
-                this.writeReport(this.reportFile);
-            }
-        }
-    }
-
-    /**
-     * Write the HTML report to the given destination.
-     *
-     * @param reportFile the report destination
-     */
-    protected void writeReport( File reportFile )
-    {
-        PrintWriter printWriter = null;
-
-        if( this.isJavaSimonAvailable() )
-        {
-            try
-            {
-                if( this.getLogger().isDebugEnabled() )
-                {
-                    this.getLogger().debug( "Writing JavaSimon report to " + reportFile.getAbsolutePath() );
-                }
-
-                // Update to eliminate reliance on default encoding (DM_DEFAULT_ENCODING)
-                Writer w = new OutputStreamWriter(new FileOutputStream(reportFile), "UTF-8");
-                printWriter = new PrintWriter( w );
-                
-                // JavaSimonPerformanceMonitor monitor = this.createJavaSimonPerformanceMonitor(null, null, true);
-                String report = "Not implemented yet ...";
-                printWriter.write( report );
-                printWriter.close();
-            }
-            catch( Throwable t )
-            {
-                String msg = "Generating the JavaSimon report failed for " + reportFile.getAbsolutePath();
-                this.getLogger().error(msg,t);
-            }
-            finally
-            {
-                if( printWriter != null )
-                {
-                    printWriter.close();
-                }
-            }
-        }
-    }
+	/** the time when the next report is due */
+	private long nextReportTimestamp;
+
+	/** the implementation class name for the performance monitor */
+	private String performanceMonitorClassName;
+
+	/** the implementation class name for the performance monitor */
+	private Class<?> performanceMonitorClass;
+
+	/** the class name of the JavaSimon factory */
+	private static final String MONITORFACTORY_CLASSNAME = "org.javasimon.SimonManager";
+
+	/** the class name of the JavaSimon MonitorFactory */
+	private static final String DEFAULT_PERFORMANCEMONITOR_CLASSNAME = "org.apache.fulcrum.yaafi.interceptor.javasimon.JavaSimon4PerformanceMonitorImpl";
+
+	/////////////////////////////////////////////////////////////////////////
+	// Avalon Service Lifecycle Implementation
+	/////////////////////////////////////////////////////////////////////////
+
+	/**
+	 * Constructor
+	 */
+	public JavaSimonInterceptorServiceImpl() {
+		super();
+	}
+
+	/**
+	 * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
+	 */
+	public void configure(Configuration configuration) throws ConfigurationException {
+		super.configure(configuration);
+		this.reportTimeout = configuration.getChild("reportTimeout").getValueAsLong(0);
+
+		// parse the performance monitor class name
+		this.performanceMonitorClassName = configuration.getChild("performanceMonitorClassName")
+				.getValue(DEFAULT_PERFORMANCEMONITOR_CLASSNAME);
+
+		// parse the report file name
+		String reportFileName = configuration.getChild("reportFile").getValue("./javasimon.html");
+		this.reportFile = this.makeAbsoluteFile(reportFileName);
+
+		// determine when to create the next report
+		this.nextReportTimestamp = System.currentTimeMillis() + this.reportTimeout;
+
+		// do we create a report on disposal
+		this.reportOnExit = configuration.getChild("reportOnExit").getValueAsBoolean(false);
+	}
+
+	/**
+	 * @see Initializable#initialize()
+	 */
+	public void initialize() throws Exception {
+		ClassLoader classLoader = this.getClassLoader();
+
+		if (!Clazz.hasClazz(classLoader, MONITORFACTORY_CLASSNAME)) {
+			String msg = "The JavaSimonInterceptorService is disabled since the JavaSimon classes are not found in the classpath";
+			this.getLogger().warn(msg);
+			this.isJavaSimonAvailable = false;
+			return;
+		}
+
+		if (!Clazz.hasClazz(classLoader, this.performanceMonitorClassName)) {
+			String msg = "The JavaSimonInterceptorService is disabled since the performance monitor class is not found in the classpath";
+			this.getLogger().warn(msg);
+			this.isJavaSimonAvailable = false;
+			return;
+		}
+
+		// load the performance monitor class
+		this.performanceMonitorClass = Clazz.getClazz(this.getClassLoader(), this.performanceMonitorClassName);
+
+		// check if we can create an instance of the performance monitor class
+		JavaSimonPerformanceMonitor testMonitor = this.createJavaSimonPerformanceMonitor(null, null, true);
+		if (testMonitor == null) {
+			String msg = "The JavaSimonInterceptorService is disabled since the performance monitor can't be instantiated";
+			this.getLogger().warn(msg);
+			this.isJavaSimonAvailable = false;
+			return;
+		}
+
+		this.getLogger().debug("The JavaSimonInterceptorService is enabled");
+		this.isJavaSimonAvailable = true;
+	}
+
+	/**
+	 * @see Reconfigurable#reconfigure(Configuration)
+	 */
+	public void reconfigure(Configuration configuration) throws ConfigurationException {
+		super.reconfigure(configuration);
+		this.configure(configuration);
+	}
+
+	/**
+	 * @see Disposable#dispose()
+	 */
+	public void dispose() {
+		if (this.reportOnExit) {
+			this.run();
+		}
+
+		this.reportFile = null;
+	}
+
+	/////////////////////////////////////////////////////////////////////////
+	// Service interface implementation
+	/////////////////////////////////////////////////////////////////////////
+
+	/**
+	 * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onEntry(AvalonInterceptorContext)
+	 */
+	public void onEntry(AvalonInterceptorContext interceptorContext) {
+		if (this.isJavaSimonAvailable()) {
+			this.writeReport();
+
+			String serviceShortHand = interceptorContext.getServiceShorthand();
+			Method serviceMethod = interceptorContext.getMethod();
+			boolean isEnabled = this.isServiceMonitored(interceptorContext);
+			JavaSimonPerformanceMonitor monitor = this.createJavaSimonPerformanceMonitor(serviceShortHand,
+					serviceMethod, isEnabled);
+			monitor.start();
+			interceptorContext.getRequestContext().put(this.getServiceName(), monitor);
+		}
+	}
+
+	/**
+	 * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onExit(AvalonInterceptorContext,
+	 *      Object)
+	 */
+	public void onExit(AvalonInterceptorContext interceptorContext, Object result) {
+		if (this.isJavaSimonAvailable()) {
+			JavaSimonPerformanceMonitor monitor;
+			monitor = (JavaSimonPerformanceMonitor) interceptorContext.getRequestContext()
+					.remove(this.getServiceName());
+			monitor.stop();
+		}
+	}
+
+	/**
+	 * @see org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService#onError(AvalonInterceptorContext,
+	 *      Throwable)
+	 */
+	public void onError(AvalonInterceptorContext interceptorContext, Throwable t) {
+		if (this.isJavaSimonAvailable()) {
+			JavaSimonPerformanceMonitor monitor;
+			monitor = (JavaSimonPerformanceMonitor) interceptorContext.getRequestContext()
+					.remove(this.getServiceName());
+			monitor.stop(t);
+		}
+	}
+
+	/**
+	 * Writes the JavaSimon report to the file system.
+	 *
+	 * @see Runnable#run()
+	 */
+	public void run() {
+		this.writeReport(this.reportFile);
+	}
+
+	/////////////////////////////////////////////////////////////////////////
+	// Service Implementation
+	/////////////////////////////////////////////////////////////////////////
+
+	/**
+	 * @return Returns the isJavaSimonAvailable.
+	 */
+	protected final boolean isJavaSimonAvailable() {
+		return this.isJavaSimonAvailable;
+	}
+
+	/**
+	 * Factory method for creating an implementation of a
+	 * JavaSimonPerformanceMonitor.
+	 *
+	 * @param serviceName the service name
+	 * @param method      the method
+	 * @param isEnabled   is the monitor enabled
+	 * @return the instance or <b>null</b> if the creation failed
+	 */
+	@SuppressWarnings("rawtypes")
+	protected JavaSimonPerformanceMonitor createJavaSimonPerformanceMonitor(String serviceName, Method method,
+			boolean isEnabled) {
+		JavaSimonPerformanceMonitor result = null;
+
+		try {
+			Class[] signature = { String.class, Method.class, Boolean.class };
+			Object[] args = { serviceName, method, isEnabled ? Boolean.TRUE : Boolean.FALSE };
+			result = (JavaSimonPerformanceMonitor) Clazz.newInstance(this.performanceMonitorClass, signature, args);
+		} catch (Exception e) {
+			String msg = "Failed to create a performance monitor instance : " + this.performanceMonitorClassName;
+			this.getLogger().error(msg, e);
+		}
+
+		return result;
+	}
+
+	/**
+	 * Write a report file
+	 */
+	protected void writeReport() {
+		if (this.reportTimeout > 0) {
+			long currTimestamp = System.currentTimeMillis();
+
+			if (currTimestamp > this.nextReportTimestamp) {
+				this.nextReportTimestamp = currTimestamp + this.reportTimeout;
+				this.writeReport(this.reportFile);
+			}
+		}
+	}
+
+	/**
+	 * Write the HTML report to the given destination.
+	 *
+	 * @param reportFile the report destination
+	 */
+	protected void writeReport(File reportFile) {
+		PrintWriter printWriter = null;
+
+		if (this.isJavaSimonAvailable()) {
+			try {
+				if (this.getLogger().isDebugEnabled()) {
+					this.getLogger().debug("Writing JavaSimon report to " + reportFile.getAbsolutePath());
+				}
+
+				// Update to eliminate reliance on default encoding (DM_DEFAULT_ENCODING)
+				Writer w = new OutputStreamWriter(new FileOutputStream(reportFile), "UTF-8");
+				printWriter = new PrintWriter(w);
+
+				// JavaSimonPerformanceMonitor monitor =
+				// this.createJavaSimonPerformanceMonitor(null, null, true);
+				String report = "Not implemented yet ...";
+				printWriter.write(report);
+				printWriter.close();
+			} catch (Throwable t) {
+				String msg = "Generating the JavaSimon report failed for " + reportFile.getAbsolutePath();
+				this.getLogger().error(msg, t);
+			} finally {
+				if (printWriter != null) {
+					printWriter.close();
+				}
+			}
+		}
+	}
 }