You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jm...@apache.org on 2002/11/04 06:36:50 UTC

cvs commit: jakarta-turbine-fulcrum/src/test/org/apache/fulcrum/security AccessControlListTest.java

jmcnally    2002/11/03 21:36:50

  Modified:    .        project.properties project.xml
               src/java/org/apache/fulcrum BaseServiceBroker.java
                        Fulcrum.java ServiceBroker.java
               src/java/org/apache/fulcrum/bsf BSFService.java
                        TurbineBSFService.java
               src/java/org/apache/fulcrum/cache GlobalCacheService.java
                        TurbineGlobalCacheService.java
               src/java/org/apache/fulcrum/crypto CryptoService.java
                        TurbineCryptoService.java
               src/java/org/apache/fulcrum/dvsl DefaultDvslService.java
                        DvslService.java
               src/java/org/apache/fulcrum/factory FactoryService.java
                        TurbineFactoryService.java
               src/java/org/apache/fulcrum/intake IntakeService.java
                        TurbineIntakeService.java
               src/java/org/apache/fulcrum/jsp JspService.java
                        TurbineJspService.java
               src/java/org/apache/fulcrum/localization
                        LocalizationService.java
                        TurbineLocalizationService.java
               src/java/org/apache/fulcrum/mimetype MimeTypeService.java
                        TurbineMimeTypeService.java
               src/java/org/apache/fulcrum/naming NamingService.java
                        TurbineNamingService.java
               src/java/org/apache/fulcrum/pool PoolService.java
                        TurbinePoolService.java
               src/java/org/apache/fulcrum/security
                        BaseSecurityService.java SecurityService.java
               src/java/org/apache/fulcrum/security/impl/db
                        DBSecurityService.java
               src/java/org/apache/fulcrum/security/impl/db/entity
                        TurbineUserPeer.java
               src/java/org/apache/fulcrum/template
                        BaseTemplateEngineService.java
                        TemplateEngineService.java TemplateService.java
                        TurbineTemplateService.java
               src/java/org/apache/fulcrum/velocity
                        TurbineVelocityService.java VelocityService.java
               src/test/org/apache/fulcrum/crypto CryptoDefaultTest.java
                        CryptoTest.java
               src/test/org/apache/fulcrum/localization
                        LocalizationTest.java
               src/test/org/apache/fulcrum/security
                        AccessControlListTest.java
  Added:       .        sample-avalon-conf.xml
               src/java/org/apache/fulcrum BaseFulcrumComponent.java
                        FulcrumContainer.java HasApplicationRoot.java
                        avalon-roles.xml
  Log:
  initial conversion to avalon components.
  
  the components will still use the old configuration file which uses properties
  as well as the standard xml configuration.
  
  modified TurbineServices so that if it is used along with FulcrumContainer,
  an application will have very little code to modify for this first cut.
  
  the only service functionality that was altered was the cache service which
  was modified so the housekeeping thread will be stopped during disposal.
  
  Revision  Changes    Path
  1.6       +1 -0      jakarta-turbine-fulcrum/project.properties
  
  Index: project.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/project.properties,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- project.properties	27 Sep 2002 05:31:24 -0000	1.5
  +++ project.properties	4 Nov 2002 05:36:47 -0000	1.6
  @@ -9,6 +9,7 @@
   maven.delegatorBuildFile = build.xml
   maven.prepareSourceDirectory = target/src
   maven.prepareSourceTarget = om
  +maven.jarResources.basedir = ${basedir}/target/src
   
   src.dir = src
   build.src = src/java
  
  
  
  1.53      +36 -0     jakarta-turbine-fulcrum/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/project.xml,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- project.xml	16 Oct 2002 11:51:26 -0000	1.52
  +++ project.xml	4 Nov 2002 05:36:47 -0000	1.53
  @@ -96,6 +96,31 @@
         <version>1.0.2</version>
         <url>http://java.sun.com/products/javabeans/glasgow/jaf.html</url>
       </dependency>
  +     <dependency>
  +      <id>avalon-framework</id>
  +      <version>4.0</version>
  +      <url>http://jakarta.apache.org/avalon</url>
  +    </dependency>
  +    <dependency>
  +      <id>excalibur-collections</id>
  +      <version>1.0</version>
  +      <url>http://jakarta.apache.org/avalon</url>
  +    </dependency>
  +    <dependency>
  +      <id>excalibur-component</id>
  +      <version>1.0</version>
  +      <url>http://jakarta.apache.org/avalon</url>
  +    </dependency>
  +    <dependency>
  +      <id>excalibur-logger</id>
  +      <version>1.0</version>
  +      <url>http://jakarta.apache.org/avalon</url>
  +    </dependency>
  +    <dependency>
  +      <id>excalibur-pool</id>
  +      <version>1.0</version>
  +      <url>http://jakarta.apache.org/avalon</url>
  +    </dependency>
       <dependency>
         <id>bsf</id>
         <version>2.2</version>
  @@ -171,6 +196,11 @@
         <url>http://java.sun.com/products/javamail/</url>
       </dependency>
       <dependency>
  +      <id>logkit</id>
  +      <version>1.0.1</version>
  +      <url>http://jakarta.apache.org/avalon</url>
  +    </dependency>
  +    <dependency>
         <id>regexp</id>
         <version>1.3-dev</version>
         <url>http://jakarta.apache.org/regexp/</url>
  @@ -240,6 +270,12 @@
           <exclude>**/XmlRpcTest.java</exclude>
         </excludes>
       </unitTest>
  +
  +    <resources>
  +      <includes>
  +        <include>**/avalon-roles.xml</include>
  +      </includes>
  +    </resources>
   
       <jars/>
     </build>
  
  
  
  1.1                  jakarta-turbine-fulcrum/sample-avalon-conf.xml
  
  Index: sample-avalon-conf.xml
  ===================================================================
  <fulcrum-services>
  
  <!-- -------------------------------------------------------------------
   
   B S F  S E R V I C E
  
   ------------------------------------------------------------------- -->
  <bsf use-property-file="true"
       scriptsDirectory="WEB-INF/scripts" defaultExtension="py"/>
  
  <!-- -------------------------------------------------------------------
   
   C A C H E  S E R V I C E
  
   ------------------------------------------------------------------- -->
  <cache use-property-file="true"/>
  
  <!-- -------------------------------------------------------------------
   
   C R Y P T O  S E R V I C E
  
   ------------------------------------------------------------------- -->
  <crypto use-property-file="true"/>
     <algorithm>
         <sha>com.foo.ShaProvider</sha>
         <base64>org.bar.Base64Provider</base64>   
     </algorithm>
  </crypto>
  
  <!-- -------------------------------------------------------------------
   
   D V S L  S E R V I C E
  
   ------------------------------------------------------------------- -->
  <dvsl/>
  
  <!-- -------------------------------------------------------------------
   
   I N T A K E  S E R V I C E
  
   ------------------------------------------------------------------- -->
  <intake use-property-file="true"
      xml-path="WEB-INF/conf/intake.xml" 
      serialize-path="WEB-INF/appData.ser"/>
  
  <!-- -------------------------------------------------------------------
   
    F A C T O R Y  S E R V I C E
  
   ------------------------------------------------------------------- -->
  <factory use-property-file="true">
  
      <!-- (very optional)
      <classloader>org.foo.bar.MyClassLoader</classloader>
      <classloader>org.ack.joe.YourClassLoader</classloader>
      -->
  
      <object-factory>
  
      <!-- Default factory to use when no custom factory is specified. -->
      <!-- <default>org.foo.bar.DefaultFactory</default> -->
      
      <!--    
      Customized factories to be used instead of the default factory.
      E.g. to instantiate XML parsers, SSL sockets, etc., which require
      specific instantiation not supported by the default factory.
      The property name is prefixed with "factory" followed by the
      name of the production class. The value is the class name of
      the factory implementing the Factory interface. The factory
      will be instantiated by using the service itself.
    
      Examples:
   
      <javax.xml.parsers.DocumentBuilder>
          org.foo.xml.DomBuilderFactory
      </javax.xml.parsers.DocumentBuilder>
      <javax.xml.parsers.SAXParser>
          org.foo.xml.SaxParserFactory
      </javax.xml.parsers.SAXParser>
      <java.net.ServerSocket>
          org.foo.net.SslServerSocketFactory
      <java.net.ServerSocket>
      -->
  
      </object-factory>
  </factory>
  
  <!-- -------------------------------------------------------------------
   
   L O C A L I Z A T I O N  S E R V I C E
  
   ------------------------------------------------------------------- -->
  <localization use-property-file="true"/>
  
  <!-- -------------------------------------------------------------------
   
   M I M E T Y P E  S E R V I C E
  
   ------------------------------------------------------------------- -->
  <mimetype use-property-file="true"/>
  
  <!-- -------------------------------------------------------------------
   
   N A M I N G  S E R V I C E
  
   ------------------------------------------------------------------- -->
  <jndi use-property-file="true"/>
  
  <!-- -------------------------------------------------------------------
   
    P O O L  S E R V I C E
  
   ------------------------------------------------------------------- -->
  <pool use-property-file="true">
      <capacity>
          <!-- 
              Default capacity of pools of the Object pooling service. 
              Default: 128 
          -->
          <default>128</default>
  
  
          <!--
              Class specific capacities used instead of the default if specified.
          -->
          <services.PoolService.pool.capacity.org.apache.turbine.services.rundata.DefaultTurbineRunData>512</services.PoolService.pool.capacity.org.apache.turbine.services.rundata.DefaultTurbineRunData>
      </capacity>
  </pool>
  
  <!-- -------------------------------------------------------------------
   
   S E C U R I T Y  S E R V I C E
  
   ------------------------------------------------------------------- -->
  <security use-property-file="true"/>
  
  <!-- -------------------------------------------------------------------
   
   T E M P L A T E  S E R V I C E
  
   ------------------------------------------------------------------- -->
  <template use-property-file="true"/>
  
  <!-- -------------------------------------------------------------------
   
   V E L O C I T Y  S E R V I C E
  
   ------------------------------------------------------------------- -->
  <velocity use-property-file="true"/>
  
  <!-- -------------------------------------------------------------------
   
   J S P  S E R V I C E
  
   ------------------------------------------------------------------- -->
  <jsp use-property-file="true"/>
  
  </fulcrum-services>
  
  
  
  
  1.7       +68 -3     jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/BaseServiceBroker.java
  
  Index: BaseServiceBroker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/BaseServiceBroker.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BaseServiceBroker.java	14 Aug 2002 14:13:28 -0000	1.6
  +++ BaseServiceBroker.java	4 Nov 2002 05:36:47 -0000	1.7
  @@ -60,11 +60,13 @@
   import java.util.ArrayList;
   import java.util.Date;
   import java.util.Enumeration;
  +import java.util.Map;
   import java.util.Hashtable;
   import java.util.Iterator;
   import java.util.List;
   import java.util.Properties;
   import java.util.Stack;
  +import java.lang.reflect.Field;
   
   import org.apache.fulcrum.ServiceException;
   import org.apache.commons.configuration.BaseConfiguration;
  @@ -73,6 +75,9 @@
   import org.apache.log4j.Category;
   import org.apache.log4j.helpers.NullEnumeration;
   
  +import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.avalon.framework.component.Component;
  +
   /**
    * A generic implementation of a <code>ServiceBroker</code> which
    * provides:
  @@ -104,6 +109,13 @@
       protected Hashtable services = new Hashtable();
   
       /**
  +     * A repository of avalon components.
  +     */
  +    private Map avalonComponents = new Hashtable();
  +
  +    private ComponentManager avalonManager;
  +
  +    /**
        * Configuration for the services broker.
        * The configuration should be set by the application
        * in which the services framework is running.
  @@ -238,6 +250,11 @@
           return category;
       }
   
  +    public void setAvalonManager(ComponentManager manager)
  +    {
  +        avalonManager = manager;
  +    }
  +
       /**
        * Initialize this service manager.
        */
  @@ -523,6 +540,14 @@
       {
           notice("Shutting down all services!");
   
  +        // release the avalon components
  +        Iterator components = avalonComponents.values().iterator();
  +        while (components.hasNext()) 
  +        {
  +            avalonManager.release((Component)components.next());
  +        }
  +        
  +
           Iterator serviceNames = getServiceNames();
           String serviceName = null;
   
  @@ -559,10 +584,44 @@
        * @exception InstantiationException, if the service is unknown or
        * can't be initialized.
        */
  -    public Service getService(String name) throws InstantiationException
  +    public synchronized Object getService(String name) 
  +        throws InstantiationException
  +    {
  +        // check if the name is an actual service
  +        Object obj = services.get(name);
  +        if (obj == null && avalonManager != null) 
  +        {
  +            // check if it is an avalon component
  +            obj = avalonComponents.get(name);
  +            if (obj == null) 
  +            {
  +                try
  +                {
  +                    Class componentClass = Class.forName(name);
  +                    Field roleField = componentClass.getField("ROLE");
  +                    String role = (String)roleField.get(null);
  +                    obj = avalonManager.lookup(role);
  +                    avalonComponents.put(name, obj);
  +                }
  +                catch (Exception e)
  +                {
  +                    obj = getOldService(name);                
  +                }
  +            }            
  +        }
  +        else 
  +        {
  +            obj = getOldService(name);
  +        }
  +            
  +        return obj;
  +    }
  +
  +    private Service getOldService(String name)
  +        throws InstantiationException
       {
           Service service;
  -        try
  +        try 
           {
               service = getServiceInstance(name);
               if (!service.isInitialized())
  @@ -588,6 +647,7 @@
                   throw new InitializationException(
                       "init() failed to initialize service " + name);
               }
  +        
               return service;
           }
           catch (InitializationException e)
  @@ -795,5 +855,10 @@
       public String getRealPath(String path)
       {
           return new File(getApplicationRoot(), path).getAbsolutePath();
  +    }
  +
  +    public ComponentManager getAvalonComponentManager()
  +    {
  +        return avalonManager;
       }
   }
  
  
  
  1.3       +2 -2      jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/Fulcrum.java
  
  Index: Fulcrum.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/Fulcrum.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Fulcrum.java	24 Jul 2002 11:57:28 -0000	1.2
  +++ Fulcrum.java	4 Nov 2002 05:36:47 -0000	1.3
  @@ -106,7 +106,7 @@
        *
        * @param name The name of the service to retrieve.
        */
  -    public static Service getService(String name)
  +    public static Object getService(String name)
       {
           return ts.getService(name);
       }
  
  
  
  1.2       +2 -2      jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/ServiceBroker.java
  
  Index: ServiceBroker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/ServiceBroker.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServiceBroker.java	30 May 2002 02:27:10 -0000	1.1
  +++ ServiceBroker.java	4 Nov 2002 05:36:47 -0000	1.2
  @@ -132,7 +132,7 @@
        * @exception InstantiationException, if the service is unknown or
        * can't be initialized.
        */
  -    public Service getService( String name )
  +    public Object getService( String name )
           throws InstantiationException;
   
       /**
  
  
  
  1.1                  jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/BaseFulcrumComponent.java
  
  Index: BaseFulcrumComponent.java
  ===================================================================
  package org.apache.fulcrum;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import org.apache.commons.configuration.Configuration;
  // also uses org.apache.avalon.framework.configuration.Configuration
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.parameters.Parameters;
  
  
  /**
   * This class is a generic implementation of <code>Service</code>.
   *
   * @author <a href="mailto:jmcnally@apache.org">John McNally</a>
   * @version $Id: BaseFulcrumComponent.java,v 1.1 2002/11/04 05:36:47 jmcnally Exp $
   */
  public abstract class BaseFulcrumComponent 
      extends AbstractLogEnabled
      implements Contextualizable
  {
      public static final String USE_PROPERTY_FILE = "use-property-file";
  
      /**
       * Initialization status of this class.
       */
      protected boolean isInitialized = false;
  
      private Configuration oldPropConf;
  
      public void contextualize(Context context)
          throws ContextException
      {
          if (context != null) 
          {
              try 
              {
                  oldPropConf = (Configuration)context
                      .get(FulcrumContainer.PROP_CONF);
              }
              catch (ContextException e)
              {
                  // ignored, oldPropConf can be null
              }
              
          }
      }
  
      protected boolean useOldConfiguration(Parameters parameters)
      {
          return parameters.getParameterAsBoolean(USE_PROPERTY_FILE, false);
              // && getConfiguration() != null;
      }
      
      protected boolean useOldConfiguration(
          org.apache.avalon.framework.configuration.Configuration  conf)
      {
          return conf.getAttributeAsBoolean(USE_PROPERTY_FILE, false);
      }
      
      /**
       * Returns the configuration for the specified service.
       *
       * @param name The name of the service.
       */
      protected Configuration getConfiguration()
      {
          return getConfiguration(getName());
      }
  
      protected abstract String getName();
  
      /**
       * Returns the configuration for the specified service.
       *
       * @param name The name of the service.
       */
      private Configuration getConfiguration( String name )
      {
          Configuration subset = null;
          if (oldPropConf != null) 
          {
              subset = oldPropConf.subset("services." + name);
          }
          System.out.println("Getting conf for " + name + ": " + subset);
          return subset;
      }
  
  
      /**
       * Returns initialization status.
       *
       * @return True if the service is initialized.
       * @see org.apache.fulcrum.Service#isInitialized()
       * @deprecated use isInitialized() which uses proper bean semantics.
       */
      public boolean getInit()
      {
          return isInitialized();
      }
  
      /**
       * Returns either <code>Initialized</code> or
       * <code>Uninitialized</code>, depending upon {@link
       * org.apache.fulcrum.Service} innitialization state.
       *
       * @see org.apache.fulcrum.Service#getStatus()
       */
      public String getStatus() throws ServiceException
      {
          return (isInitialized() ? "Initialized" : "Uninitialized");
      }
  
      /**
       * @see org.apache.fulcrum.Service#isInitialized()
       */
      public boolean isInitialized()
      {
          return isInitialized;
      }
  
      /**
       * Sets initailization status.
       *
       * @param value The new initialization status.
       */
      protected void setInit(boolean value)
      {
          this.isInitialized = value;
      }
  }
  
  
  
  
  
  1.1                  jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/FulcrumContainer.java
  
  Index: FulcrumContainer.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.fulcrum;
  
  import java.io.StringBufferInputStream;
  import java.io.InputStream;
  
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.framework.component.Component;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  import org.apache.avalon.excalibur.component.ExcaliburComponentManager;
  import org.apache.avalon.excalibur.component.DefaultRoleManager;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.DefaultContext;
  import org.apache.avalon.framework.context.Contextualizable;
  //import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.parameters.Parameterizable;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.avalon.framework.parameters.ParameterException;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.thread.ThreadSafe;
  import org.apache.log.Hierarchy;
  
  public class FulcrumContainer
      extends AbstractLogEnabled
      implements Component, Contextualizable, Parameterizable,
                 Initializable, Disposable 
  {
      public static final String CONF_PATH = "fulcrum-configuration-path";
      public static final String CONF_XML = "fulcrum-configuration-xml";
      public static final String APP_ROOT = "application-root";
      public static final String PROP_CONF = "old.style.property.configuration";
  
      ExcaliburComponentManager manager = new ExcaliburComponentManager();
      private String confPath;
      private InputStream confStream;
      private String appRoot;
      private Context context;
      
      /**
       * Any values set through the Context 
       *
       * @param parameters a <code>Parameters</code> value
       */
      public void parameterize(Parameters parameters)
          throws ParameterException
      {
          if (confPath == null) 
          {
              confPath = parameters.getParameter(CONF_PATH);            
          }
          if (appRoot == null) 
          {
              appRoot = parameters.getParameter(APP_ROOT);
          }
      }
  
      public void contextualize(Context context)
          throws ContextException
      {
          if (context == null) 
          {
              this.context = new DefaultContext();
          }
          else 
          {
              this.context = context;
              // allow context info to override parameters
              try 
              {
                  String contextConfPath = (String) context.get(CONF_PATH);
                  if ( contextConfPath != null ) 
                  {
                      confPath = contextConfPath;
                  }
              }
              catch (ContextException e)
              {
                  String contextConf = (String) context.get(CONF_XML);
                  if ( contextConf != null ) 
                  {
                      confStream = new StringBufferInputStream(contextConf);
                  }                
              }
              
              String contextAppRoot = (String) context.get(APP_ROOT);
              if ( contextAppRoot != null ) 
              {
                  appRoot = contextAppRoot;
              }
          }
      }
  
      public void initialize()
          throws Exception
      {
          DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
          Configuration sysConfig = null;
          if (confStream == null && confPath != null) 
          {
              sysConfig = builder.buildFromFile(confPath);            
          }
          else if (confStream != null) 
          {
              sysConfig = builder.build(confStream);            
          }
          else 
          {
              throw new IllegalStateException("component was not configured.");
          }
          
  
          Configuration roleConfig = builder.build(
              this.getClass().getResourceAsStream("avalon-roles.xml"));
  
          DefaultRoleManager roles = new DefaultRoleManager();
          roles.setLogger( Hierarchy.getDefaultHierarchy()
                           .getLoggerFor("fulcrum.roles") );
          roles.configure(roleConfig);
  
          this.manager.setLogger( Hierarchy.getDefaultHierarchy()
                                  .getLoggerFor("fulcrum") );        
          this.manager.contextualize( context );
          this.manager.setRoleManager( roles );
          this.manager.configure( sysConfig );
          this.manager.initialize();
  
          ((BaseServiceBroker)TurbineServices.getInstance())
              .setAvalonManager(manager);
      }
  
      public void dispose()
      {
          this.manager.dispose();
      }
  }
            
  
  
  
  1.1                  jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/HasApplicationRoot.java
  
  Index: HasApplicationRoot.java
  ===================================================================
  package org.apache.fulcrum;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import java.io.File;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  
  /**
   * This class is a generic implementation of <code>Service</code>.
   *
   * @author <a href="mailto:jmcnally@apache.org">John McNally</a>
   * @version $Id: HasApplicationRoot.java,v 1.1 2002/11/04 05:36:47 jmcnally Exp $
   */
  public abstract class HasApplicationRoot
      extends BaseFulcrumComponent 
  {
      private String applicationRoot;
  
      public void contextualize(Context context)
          throws ContextException
      {
          super.contextualize(context);
          if (context != null) 
          {
              applicationRoot = (String) context.get(FulcrumContainer.APP_ROOT);
          }
      }
  
      /**
       * @see org.apache.fulcrum.ServiceBroker#getRealPath(String)
       */
      public String getRealPath(String path)
      {
          String absolutePath = null;
          if (applicationRoot == null) 
          {
              absolutePath = new File(path).getAbsolutePath();
          }
          else 
          {
              absolutePath = new File(applicationRoot, path).getAbsolutePath();
          }
          
          return absolutePath;
      }
  }
  
  
  
  1.1                  jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/avalon-roles.xml
  
  Index: avalon-roles.xml
  ===================================================================
  <role-list>
    <role
      name="org.apache.fulcrum.bsf.BSFService"
      shorthand="bsf"
      default-class="org.apache.fulcrum.bsf.TurbineBSFService"/>
  
    <role
      name="org.apache.fulcrum.cache.GlobalCacheService"
      shorthand="cache"
      default-class="org.apache.fulcrum.cache.TurbineGlobalCacheService"/>
  
    <role
      name="org.apache.fulcrum.crypto.CryptoService"
      shorthand="crypto"
      default-class="org.apache.fulcrum.crypto.TurbineCryptoService"/>
  
    <role
      name="org.apache.fulcrum.dvsl.DvslService"
      shorthand="dvsl"
      default-class="org.apache.fulcrum.dvsl.DefaultDvslService"/>
  
    <role
      name="org.apache.fulcrum.factory.FactoryService"
      shorthand="factory"
      default-class="org.apache.fulcrum.factory.TurbineFactoryService"/>
  
    <role
      name="org.apache.fulcrum.intake.IntakeService"
      shorthand="intake"
      default-class="org.apache.fulcrum.intake.TurbineIntakeService"/>
  
    <role
      name="org.apache.fulcrum.localization.LocalizationService"
      shorthand="localization"
      default-class="org.apache.fulcrum.localization.TurbineLocalizationService"/>
  
    <role
      name="org.apache.fulcrum.mimetype.MimeTypeService"
      shorthand="mimetype"
      default-class="org.apache.fulcrum.mimetype.TurbineMimeTypeService"/>
  
    <role
      name="org.apache.fulcrum.naming.NamingService"
      shorthand="jndi"
      default-class="org.apache.fulcrum.naming.TurbineNamingService"/>
  
    <role
      name="org.apache.fulcrum.pool.PoolService"
      shorthand="pool"
      default-class="org.apache.fulcrum.pool.TurbinePoolService"/>
  
    <role
      name="org.apache.fulcrum.security.SecurityService"
      shorthand="security"
      default-class="org.apache.fulcrum.security.impl.db.DBSecurityService"/>
  
    <role
      name="org.apache.fulcrum.template.TemplateService"
      shorthand="template"
      default-class="org.apache.fulcrum.template.TurbineTemplateService"/>
    <role
      name="org.apache.fulcrum.velocity.VelocityService"
      shorthand="velocity"
      default-class="org.apache.fulcrum.velocity.TurbineVelocityService"/>
    <role
      name="org.apache.fulcrum.jsp.JspService"
      shorthand="jsp"
      default-class="org.apache.fulcrum.jsp.TurbineJspService"/>
  
  </role-list>
  
            
  
  
  1.2       +10 -3     jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/bsf/BSFService.java
  
  Index: BSFService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/bsf/BSFService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BSFService.java	30 May 2002 02:27:10 -0000	1.1
  +++ BSFService.java	4 Nov 2002 05:36:48 -0000	1.2
  @@ -54,16 +54,23 @@
    * <http://www.apache.org/>.
    */
   
  -import org.apache.fulcrum.Service;
  +import org.apache.avalon.framework.component.Component;
   
   /**
    *
    * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
    */
   public interface BSFService
  -    extends Service
  +    extends Component
   {
  -    public static final String SERVICE_NAME = "BSFService";
  +    /** Avalon role - used to id the component within the manager */
  +    String ROLE = BSFService.class.getName();
  +
  +    /** 
  +     * Old style TurbineServices role, now equal to ROLE.
  +     * @deprecated TurbineServices is deprecated in favor of avalon. 
  +     */
  +    String SERVICE_NAME = ROLE;
   
       /**
        * Execute a script supported by the BSF.
  
  
  
  1.2       +77 -37    jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/bsf/TurbineBSFService.java
  
  Index: TurbineBSFService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/bsf/TurbineBSFService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TurbineBSFService.java	30 May 2002 02:27:11 -0000	1.1
  +++ TurbineBSFService.java	4 Nov 2002 05:36:48 -0000	1.2
  @@ -61,18 +61,36 @@
   import java.io.StringWriter;
   import com.ibm.bsf.BSFManager;
   import com.ibm.bsf.BSFException;
  -import org.apache.fulcrum.BaseService;
   import org.apache.fulcrum.InitializationException;
  +import org.apache.fulcrum.HasApplicationRoot;
  +
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.thread.ThreadSafe;
   
   /**
    *
    * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
    */
   public class TurbineBSFService
  -    extends BaseService
  -    implements BSFService
  +    extends HasApplicationRoot
  +    implements BSFService, Configurable, Initializable, ThreadSafe
   {
       /**
  +     * Tag for scripts directory in the service
  +     * configuration.
  +     */
  +    protected static final String SCRIPTS_DIRECTORY = "scriptsDirectory";
  +
  +    /**
  +     * Tag for default extension in the service
  +     * configuration.
  +     */
  +    protected static final String DEFAULT_EXTENSION = "defaultExtension";
  +
  +    /**
        * BSF manager that is responsible for executing scripts.
        * This may eventually be a pool of managers and
        * utilize the pool service.
  @@ -85,46 +103,14 @@
       protected String scriptsDirectory;
   
       /**
  -     * Tag for scripts directory in the service
  -     * configuration.
  -     */
  -    protected static final String SCRIPTS_DIRECTORY = "scriptsDirectory";
  -
  -    /**
        * Default extension for scripts if an extension is not
        * provided.
        */
       protected String defaultExtension;
   
  -    /**
  -     * Tag for default extension in the service
  -     * configuration.
  -     */
  -    protected static final String DEFAULT_EXTENSION = "defaultExtension";
   
  -    /**
  -     * Initialize the TurbineBSF Service.
  -     */
  -    public void init()
  -        throws InitializationException
  +    public TurbineBSFService()
       {
  -        scriptsDirectory = getConfiguration().getString(SCRIPTS_DIRECTORY);
  -
  -        if (scriptsDirectory == null)
  -        {
  -            throw new InitializationException(
  -                "You must provide a scripts directory in " +
  -                    "order to executes scripts!");
  -        }
  -
  -        defaultExtension = getConfiguration().getString(DEFAULT_EXTENSION);
  -        initBSFManagers();
  -        setInit(true);
  -    }
  -
  -    private void initBSFManagers()
  -    {
  -        manager = new BSFManager();
       }
   
       /**
  @@ -142,7 +128,7 @@
   
           script = getRealPath(scriptsDirectory + "/" + script);
   
  -        getCategory().debug("[BSFService] Script to execute: " + script);
  +        getLogger().debug("[BSFService] Script to execute: " + script);
   
           try
           {
  @@ -188,5 +174,59 @@
           }
   
           return sw.toString();
  +    }
  +
  +    // ---------------- Avalon Lifecycle Methods ---------------------
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void configure(Configuration conf)
  +        throws ConfigurationException
  +    {
  +        if (useOldConfiguration(conf))
  +        {
  +            scriptsDirectory = getConfiguration().getString(SCRIPTS_DIRECTORY);
  +
  +            if (scriptsDirectory == null)
  +            {
  +                throw new ConfigurationException(
  +                    "You must provide a scripts directory in " +
  +                    "order to executes scripts!");
  +            }
  +            
  +            defaultExtension = getConfiguration().getString(DEFAULT_EXTENSION);
  +        }
  +        else
  +        {
  +            scriptsDirectory = conf.getAttribute(SCRIPTS_DIRECTORY, null);
  +            if (scriptsDirectory == null)
  +            {
  +                throw new ConfigurationException(
  +                    "You must provide a scripts directory in " +
  +                    "order to executes scripts!");
  +            }
  +
  +            defaultExtension = conf.getAttribute(DEFAULT_EXTENSION, "bsf");
  +        }
  +    }
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void initialize()
  +    {
  +        manager = new BSFManager();
  +        setInit(true);
  +    }
  +
  +
  +    /**
  +     * The name used to specify this component in TurbineResources.properties 
  +     * @deprecated part of the pre-avalon compatibility layer
  +     */
  +    protected String getName()
  +    {
  +        return "BSFService";
       }
   }
  
  
  
  1.2       +11 -4     jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/cache/GlobalCacheService.java
  
  Index: GlobalCacheService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/cache/GlobalCacheService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GlobalCacheService.java	30 May 2002 02:27:11 -0000	1.1
  +++ GlobalCacheService.java	4 Nov 2002 05:36:48 -0000	1.2
  @@ -55,7 +55,7 @@
    */
   
   import java.io.IOException;
  -import org.apache.fulcrum.Service;
  +import org.apache.avalon.framework.component.Component;
   
   /**
    * GlobalCacheService interface.
  @@ -64,9 +64,16 @@
    * @version $Id$
    */
   public interface GlobalCacheService
  -    extends Service
  +    extends Component
   {
  -    public static final String SERVICE_NAME = "GlobalCacheService";
  +    /** Avalon role - used to id the component within the manager */
  +    String ROLE = GlobalCacheService.class.getName();
  +
  +    /** 
  +     * Old style TurbineServices role, now equal to ROLE.
  +     * @deprecated TurbineServices is deprecated in favor of avalon. 
  +     */
  +    String SERVICE_NAME = ROLE;
   
       /**
        * Gets a cached object given its id (a String).
  
  
  
  1.2       +89 -45    jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/cache/TurbineGlobalCacheService.java
  
  Index: TurbineGlobalCacheService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/cache/TurbineGlobalCacheService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TurbineGlobalCacheService.java	30 May 2002 02:27:11 -0000	1.1
  +++ TurbineGlobalCacheService.java	4 Nov 2002 05:36:48 -0000	1.2
  @@ -61,7 +61,14 @@
   import java.util.Hashtable;
   import java.util.Vector;
   import org.apache.fulcrum.InitializationException;
  -import org.apache.fulcrum.BaseService;
  +import org.apache.fulcrum.BaseFulcrumComponent;
  +
  +import org.apache.avalon.framework.activity.Disposable;
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.thread.ThreadSafe;
   
   /**
    * This Service functions as a Global Cache.  A global cache is a good
  @@ -79,62 +86,34 @@
    * @version $Id$
    */
   public class TurbineGlobalCacheService
  -    extends BaseService
  -    implements GlobalCacheService,
  -               Runnable
  +    extends BaseFulcrumComponent
  +    implements GlobalCacheService, Runnable, Configurable, Initializable, 
  +               Disposable, ThreadSafe 
   {
  -    /** The cache. **/
  -    protected Hashtable cache = null;
  -
       /**
        * Default cacheCheckFrequency value.
        */
       private final static long DEFAULT_CACHE_CHECK_FREQUENCY = 5000;
   
  +    /** The cache. **/
  +    protected Hashtable cache = null;
  +
       /**
        * cacheCheckFrequency (default - 5 seconds)
        */
       private long cacheCheckFrequency;
   
  -    /**
  -     * Constructor.
  -     */
  +    /** thread for removing stale items from the cache */
  +    private Thread housekeeping;
  +    /** flag to stop the housekeeping thread when the component is disposed. */
  +    private boolean continueThread;
  +    private boolean disposed;
  +
       public TurbineGlobalCacheService()
       {
       }
   
       /**
  -     * Called the first time the Service is used.
  -     */
  -    public void init()
  -        throws InitializationException
  -    {
  -        cacheCheckFrequency = getConfiguration().getLong(
  -            "cacheCheckFrequency", DEFAULT_CACHE_CHECK_FREQUENCY);
  -
  -        try
  -        {
  -            cache = new Hashtable(20);
  -
  -            // Start housekeeping thread.
  -            Thread housekeeping = new Thread(this);
  -            // Indicate that this is a system thread. JVM will quit only when there
  -            // are no more active user threads. Settings threads spawned internally
  -            // by Turbine as daemons allows commandline applications using Turbine
  -            // to terminate in an orderly manner.
  -            housekeeping.setDaemon(true);
  -            housekeeping.start();
  -
  -            setInit(true);
  -        }
  -        catch (Exception e)
  -        {
  -            throw new InitializationException(
  -                "TurbineGlobalCacheService failed to initialize", e);
  -        }
  -    }
  -
  -    /**
        * Returns an item from the cache.
        *
        * @param id The key of the stored object.
  @@ -206,19 +185,18 @@
        */
       public void run()
       {
  -        while(true)
  +        while(continueThread)
           {
               // Sleep for amount of time set in cacheCheckFrequency -
               // default = 5 seconds.
               try
               {
  +                clearCache();
                   Thread.sleep(cacheCheckFrequency);
               }
               catch(InterruptedException exc)
               {
               }
  -
  -            clearCache();
           }
       }
   
  @@ -291,5 +269,71 @@
           //
           int objectsize = baos.toByteArray().length - 4;
           return objectsize;
  +    }
  +
  +
  +    // ---------------- Avalon Lifecycle Methods ---------------------
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void configure(Configuration conf)
  +        throws ConfigurationException
  +    {
  +        if (useOldConfiguration(conf))
  +        {
  +            cacheCheckFrequency = getConfiguration().getLong(
  +                "cacheCheckFrequency", DEFAULT_CACHE_CHECK_FREQUENCY);
  +        }
  +        else
  +        {
  +            cacheCheckFrequency = conf.getAttributeAsLong(
  +                "cacheCheckFrequency", DEFAULT_CACHE_CHECK_FREQUENCY);
  +        }
  +    }
  +
  +    public void initialize()
  +        throws InitializationException
  +    {
  +        try
  +        {
  +            cache = new Hashtable(20);
  +
  +            // Start housekeeping thread.
  +            continueThread = true;
  +            housekeeping = new Thread(this);
  +            // Indicate that this is a system thread. JVM will quit only when 
  +            // there are no more active user threads. Settings threads spawned
  +            // internally by Turbine as daemons allows commandline applications
  +            // using Turbine to terminate in an orderly manner.
  +            housekeeping.setDaemon(true);
  +            housekeeping.start();
  +
  +            setInit(true);
  +        }
  +        catch (Exception e)
  +        {
  +            throw new InitializationException(
  +                "TurbineGlobalCacheService failed to initialize", e);
  +        }
  +    }
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void dispose()
  +    {
  +        continueThread = false;
  +        housekeeping.interrupt();
  +        disposed = true;
  +    }
  +
  +    /**
  +     * The name used to specify this component in TurbineResources.properties 
  +     * @deprecated part of the pre-avalon compatibility layer
  +     */
  +    protected String getName()
  +    {
  +        return "GlobalCacheService";
       }
   }
  
  
  
  1.2       +11 -7     jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/crypto/CryptoService.java
  
  Index: CryptoService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/crypto/CryptoService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CryptoService.java	1 Jul 2002 16:33:37 -0000	1.1
  +++ CryptoService.java	4 Nov 2002 05:36:48 -0000	1.2
  @@ -55,7 +55,7 @@
    */
   
   import java.security.NoSuchAlgorithmException;
  -import org.apache.fulcrum.Service;
  +import org.apache.avalon.framework.component.Component;
   
   /**
    * The Crypto Service manages the availability of various crypto 
  @@ -70,12 +70,17 @@
    * @version $Id$
    *
    */
  -
   public interface CryptoService 
  -    extends Service
  +    extends Component
   {
  -    /** The name of the service */
  -    public static final String SERVICE_NAME = "CryptoService";
  +    /** Avalon role - used to id the component within the manager */
  +    String ROLE = CryptoService.class.getName();
  +
  +    /** 
  +     * Old style TurbineServices role, now equal to ROLE.
  +     * @deprecated TurbineServices is deprecated in favor of avalon. 
  +     */
  +    String SERVICE_NAME = ROLE;
   
       /**
        * Returns a CryptoAlgorithm Object which represents the requested
  @@ -88,7 +93,6 @@
        * @throws NoSuchAlgorithmException  Requested algorithm is not available
        *
        */
  -
       CryptoAlgorithm getCryptoAlgorithm(String algorithm)
           throws NoSuchAlgorithmException;
   }
  
  
  
  1.3       +119 -59   jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/crypto/TurbineCryptoService.java
  
  Index: TurbineCryptoService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/crypto/TurbineCryptoService.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TurbineCryptoService.java	14 Aug 2002 14:15:41 -0000	1.2
  +++ TurbineCryptoService.java	4 Nov 2002 05:36:48 -0000	1.3
  @@ -61,10 +61,16 @@
   
   import org.apache.fulcrum.InitializationException;
   import org.apache.fulcrum.factory.FactoryService;
  -import org.apache.fulcrum.BaseService;
  -import org.apache.fulcrum.TurbineServices;
  +import org.apache.fulcrum.BaseFulcrumComponent;
   
  -import org.apache.commons.configuration.Configuration;
  +import org.apache.avalon.framework.activity.Disposable;
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.avalon.framework.component.Composable;
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.thread.ThreadSafe;
   
   /**
    * An implementation of CryptoService that uses either supplied crypto
  @@ -77,9 +83,10 @@
    */
   
   public class TurbineCryptoService 
  -    extends BaseService
  -    implements CryptoService
  -{
  +    extends BaseFulcrumComponent
  +    implements CryptoService, Configurable, Initializable, 
  +               Disposable, Composable, ThreadSafe 
  +{ 
       /** Key Prefix for our algorithms */
       private static final String ALGORITHM = "algorithm"; 
   
  @@ -90,63 +97,15 @@
       private static final String DEFAULT_CLASS = 
           "org.apache.fulcrum.crypto.provider.JavaCrypt";
   
  +    private boolean disposed = false; 
  +    private ComponentManager manager = null; 
  +
       /** Names of the registered algorithms and the wanted classes */
       private Hashtable algos = null;
   
       /** A factory to construct CryptoAlgorithm objects  */
       private FactoryService factoryService = null;
   
  -
  -    /**
  -     * There is not much to initialize here. This runs
  -     * as early init method.
  -     *
  -     * @throws InitializationException Something went wrong in the init
  -     *         stage
  -     */ 
  -
  -    public void init()
  -        throws InitializationException
  -    {
  -        this.algos = new Hashtable();
  -
  -        /*
  -         * Set up default (Can be overridden by default key
  -         * from the properties
  -         */
  -
  -        algos.put(DEFAULT_KEY, DEFAULT_CLASS);
  -
  -        /* get the parts of the configuration relevant to us. */
  -
  -        Configuration conf = getConfiguration().subset(ALGORITHM);
  -
  -        if (conf != null)
  -        {
  -            for (Iterator it = conf.getKeys() ;it.hasNext(); )
  -            {
  -                String key = (String) it.next();
  -                String val = conf.getString(key);
  -                // Log.debug("Registered " + val 
  -                //            + " for Crypto Algorithm " + key);
  -                algos.put(key, val);
  -            }
  -        }
  -
  -        try 
  -        {
  -            factoryService = (FactoryService) TurbineServices.getInstance().
  -                getService(FactoryService.SERVICE_NAME);
  -        }
  -        catch (Exception e)
  -        {
  -            throw new InitializationException(
  -                                              "TurbineCryptoService.init: Failed to get a Factory object", e);
  -        }
  -
  -        setInit(true);
  -    }
  -
       /**
        * Returns a CryptoAlgorithm Object which represents the requested
        * crypto algorithm.
  @@ -158,7 +117,6 @@
        * @throws NoSuchAlgorithmException  Requested algorithm is not available
        *
        */
  -
       public CryptoAlgorithm getCryptoAlgorithm(String algo)
           throws NoSuchAlgorithmException
       {
  @@ -191,5 +149,107 @@
           ca.setCipher(algo);
   
           return ca;
  +    }
  +
  +    // ---------------- Avalon Lifecycle Methods ---------------------
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void configure(Configuration conf)
  +        throws ConfigurationException
  +    {
  +        this.algos = new Hashtable();
  +        // Set up default (Can be overridden by default key
  +        // from the properties
  +        algos.put(DEFAULT_KEY, DEFAULT_CLASS);
  +                    
  +        if (useOldConfiguration(conf))
  +        {
  +            // get the parts of the configuration relevant to us.
  +            org.apache.commons.configuration.Configuration algoConf = 
  +                getConfiguration().subset(ALGORITHM);
  +            if (algoConf != null)
  +            {
  +                for (Iterator it = algoConf.getKeys() ;it.hasNext(); )
  +                {
  +                    String key = (String) it.next();
  +                    String val = algoConf.getString(key);
  +                    // Log.debug("Registered " + val 
  +                    //            + " for Crypto Algorithm " + key);
  +                    algos.put(key, val);
  +                }
  +            }
  +        }
  +        else
  +        {
  +            final Configuration algorithms = conf.getChild(ALGORITHM, false);
  +            if (algorithms != null)
  +            {
  +                Configuration[] nameVal = algorithms.getChildren();
  +                for (int i=0; i < nameVal.length; i++)
  +                {
  +                    String key = nameVal[i].getName();
  +                    String val = nameVal[i].getValue();
  +                    // getLogger.debug("Registered " + val 
  +                    //            + " for Crypto Algorithm " + key);
  +                    algos.put(key, val);
  +                }
  +            }
  +        }
  +    }
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void compose(ComponentManager manager)
  +    {
  +        this.manager = manager;
  +    }
  +
  +    /**
  +     * Avalon component lifecycle method
  +     * Get the factory service from the manager here
  +     *
  +     * @throws InitializationException Something went wrong in the init
  +     *         stage
  +     */ 
  +    public void initialize()
  +        throws InitializationException
  +    {
  +        try 
  +        {
  +            factoryService = 
  +                (FactoryService)manager.lookup(FactoryService.ROLE);
  +            setInit(true);
  +        }
  +        catch (Exception e)
  +        {
  +            throw new InitializationException(
  +                "TurbineCryptoService.init: Failed to get a Factory object",e);
  +        }
  +    }
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void dispose()
  +    {
  +        if (factoryService != null) 
  +        { 
  +            manager.release(factoryService); 
  +        } 
  +        factoryService = null;
  +        manager = null;
  +        disposed = true;
  +    }
  +
  +    /**
  +     * The name used to specify this component in TurbineResources.properties 
  +     * @deprecated part of the pre-avalon compatibility layer
  +     */
  +    protected String getName()
  +    {
  +        return "CryptoService";
       }
   }
  
  
  
  1.2       +25 -13    jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/dvsl/DefaultDvslService.java
  
  Index: DefaultDvslService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/dvsl/DefaultDvslService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultDvslService.java	30 May 2002 02:27:15 -0000	1.1
  +++ DefaultDvslService.java	4 Nov 2002 05:36:48 -0000	1.2
  @@ -60,11 +60,13 @@
   import java.util.Map;
   import java.util.Properties;
   
  -import org.apache.fulcrum.BaseService;
  -import org.apache.fulcrum.InitializationException;
  +import org.apache.fulcrum.BaseFulcrumComponent;
   
   import org.apache.tools.dvsl.DVSL;
   
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.thread.ThreadSafe;
  +
   /**
    *  Implementation of the Fulcrum Dvsl Service. It transforms xml with a given
    *  dvsl file.
  @@ -72,21 +74,12 @@
    * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
    */
   public class DefaultDvslService
  -    extends BaseService
  -    implements DvslService
  -
  +    extends BaseFulcrumComponent
  +    implements DvslService, Initializable, ThreadSafe
   {
       protected Map servicePool = new HashMap();
   
       /**
  -     * Initialize the DVSL Service.
  -     */
  -    public void init()
  -        throws InitializationException
  -    {
  -    }
  -
  -    /**
        *  register a stylesheet
        */
       public void register( String styleName,  Reader stylesheet, Properties toolbox )
  @@ -128,5 +121,24 @@
           DVSL dvsl = (DVSL) servicePool.get( styleName );
   
           dvsl.transform( in, out );
  +    }
  +
  +    // ---------------- Avalon Lifecycle Methods ---------------------
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void initialize()
  +    {
  +        setInit(true);
  +    }
  +
  +    /**
  +     * The name used to specify this component in TurbineResources.properties 
  +     * @deprecated part of the pre-avalon compatibility layer
  +     */
  +    protected String getName()
  +    {
  +        return "DVSLService";
       }
   }
  
  
  
  1.2       +10 -3     jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/dvsl/DvslService.java
  
  Index: DvslService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/dvsl/DvslService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DvslService.java	30 May 2002 02:27:15 -0000	1.1
  +++ DvslService.java	4 Nov 2002 05:36:48 -0000	1.2
  @@ -59,7 +59,7 @@
   
   import java.util.Properties;
   
  -import org.apache.fulcrum.Service;
  +import org.apache.avalon.framework.component.Component;
   
   /**
    * The Fulcrum DVSL Service is used to transform XML with a DVSL stylesheet.
  @@ -69,9 +69,16 @@
    * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
    */
   public interface DvslService
  -    extends Service
  +    extends Component
   {
  -    public static final String SERVICE_NAME = "DVSLService";
  +    /** Avalon role - used to id the component within the manager */
  +    String ROLE = DvslService.class.getName();
  +
  +    /** 
  +     * Old style TurbineServices role, now equal to ROLE.
  +     * @deprecated TurbineServices is deprecated in favor of avalon. 
  +     */
  +    String SERVICE_NAME = ROLE;
   
       /**
        *  Registers a stylesheet by name
  
  
  
  1.2       +11 -5     jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/factory/FactoryService.java
  
  Index: FactoryService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/factory/FactoryService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FactoryService.java	30 May 2002 02:27:16 -0000	1.1
  +++ FactoryService.java	4 Nov 2002 05:36:48 -0000	1.2
  @@ -55,7 +55,7 @@
    */
   
   import org.apache.fulcrum.ServiceException;
  -import org.apache.fulcrum.Service;
  +import org.apache.avalon.framework.component.Component;
   
   /**
    * The Factory Service instantiates objects using either default
  @@ -66,12 +66,18 @@
    * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
    * @version $Id$
    */
  -public interface FactoryService extends Service
  +public interface FactoryService
  +    extends Component
   {
       /**
  -     * The key under which this service is stored in TurbineServices.
  +     * The key under which this component is known by an avalon container.
        */
  -    public static final String SERVICE_NAME = "FactoryService";
  +    String ROLE = FactoryService.class.getName();
  +
  +    /**
  +     * The key under which this component is stored in TurbineServices.
  +     */
  +    public static final String SERVICE_NAME = ROLE;
   
       /**
        * Gets an instance of a named class.
  
  
  
  1.2       +132 -57   jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/factory/TurbineFactoryService.java
  
  Index: TurbineFactoryService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/factory/TurbineFactoryService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TurbineFactoryService.java	30 May 2002 02:27:16 -0000	1.1
  +++ TurbineFactoryService.java	4 Nov 2002 05:36:48 -0000	1.2
  @@ -64,8 +64,18 @@
   import java.io.ObjectOutputStream;
   import org.apache.fulcrum.ServiceException;
   import org.apache.fulcrum.pool.ObjectInputStreamForContext;
  -import org.apache.fulcrum.BaseService;
   import org.apache.fulcrum.InitializationException;
  +import org.apache.fulcrum.BaseFulcrumComponent;
  +
  +import org.apache.avalon.framework.activity.Disposable;
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.component.Component;
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.framework.thread.ThreadSafe;
  +//import org.apache.avalon.framework.;
   
   /**
    * The Factory Service instantiates objects using specified
  @@ -76,18 +86,22 @@
    * @version $Id$
    */
   public class TurbineFactoryService
  -    extends BaseService
  -    implements FactoryService
  -{
  +    extends BaseFulcrumComponent
  +    implements FactoryService, Configurable, Initializable, 
  +               Component, ThreadSafe 
  +{ 
  +    protected boolean initialized = false; 
  +    //private boolean disposed = false; 
  +
       /**
        * The property specifying a set of additional class loaders.
        */
  -    public static final String CLASS_LOADERS = "class.loaders";
  +    private static final String CLASS_LOADER = "classloader";
   
       /**
        * The property prefix specifying additional object factories.
        */
  -    public static final String OBJECT_FACTORY = "factory.";
  +    private static final String OBJECT_FACTORY = "object-factory";
   
       /**
        * The name of the default factory.
  @@ -112,6 +126,11 @@
       }
   
       /**
  +     * temporary storage of class names between configure and initialize
  +     */
  +    private String[] loaderNames;
  +
  +    /**
        * Additional class loaders.
        */
       private ArrayList classLoaders = new ArrayList();
  @@ -138,56 +157,6 @@
       public TurbineFactoryService()
       {
       }
  -
  -    /**
  -     * Initializes the service by loading default class loaders
  -     * and customized object factories.
  -     *
  -     * @throws InitializationException if initialization fails.
  -     */
  -    public void init()
  -        throws InitializationException
  -    {
  -        if (getConfiguration() != null)
  -        {
  -            Vector loaders = getConfiguration().getVector(CLASS_LOADERS);
  -            if (loaders != null)
  -            {
  -                for (int i = 0; i < loaders.size(); i++)
  -                {
  -                    try
  -                    {
  -                        classLoaders.add(
  -                            loadClass((String) loaders.get(i)).newInstance());
  -                    }
  -                    catch (Exception x)
  -                    {
  -                        throw new InitializationException(
  -                            "No such class loader '" +
  -                                (String) loaders.get(i) +
  -                                    "' for TurbinbeFactoryService",x);
  -                    }
  -                }
  -            }
  -
  -            String key,factory;
  -
  -            for (Iterator i = getConfiguration().getKeys(OBJECT_FACTORY); i.hasNext();)
  -            {
  -                key = (String) i.next();
  -                factory = getConfiguration().getString(key);
  -
  -                /*
  -                 * Store the factory to the table as a string and
  -                 * instantiate it by using the service when needed.
  -                 */
  -                objectFactories.put(
  -                    key.substring(OBJECT_FACTORY.length()),factory);
  -            }
  -        }
  -        setInit(true);
  -    }
  -
       /**
        * Gets an instance of a named class.
        *
  @@ -635,5 +604,111 @@
           {
               return null;
           }
  +    }
  +
  +
  +    // ---------------- Avalon Lifecycle Methods ---------------------
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void configure(Configuration conf)
  +        throws ConfigurationException
  +    {
  +        if (useOldConfiguration(conf))
  +        {
  +            Vector loaders = getConfiguration().getVector("class.loaders");
  +            if (loaders != null)
  +            {
  +                loaderNames = new String[loaders.size()];
  +                for (int i = 0; i < loaders.size(); i++)
  +                {
  +                    loaderNames[i] = (String)loaders.get(i);
  +                }
  +            }
  +
  +            String key,factory;
  +            for (Iterator i = getConfiguration().getKeys("factory."); 
  +                 i.hasNext();)
  +            {
  +                key = (String) i.next();
  +                factory = getConfiguration().getString(key);
  +
  +                /*
  +                 * Store the factory to the table as a string and
  +                 * instantiate it by using the service when needed.
  +                 */
  +                objectFactories.put(key.substring(8),factory);
  +            }
  +        }
  +        else
  +        {
  +            final Configuration[] loaders = conf.getChildren(CLASS_LOADER);
  +            if (loaders != null)
  +            {
  +                loaderNames = new String[loaders.length];
  +                for (int i = 0; i < loaders.length; i++)
  +                {
  +                    loaderNames[i] = loaders[i].getValue();
  +                }
  +            }
  +
  +            final Configuration factories = 
  +                conf.getChild(OBJECT_FACTORY, false);
  +            if (factories != null)
  +            {
  +                Configuration[] nameVal = factories.getChildren();
  +                for (int i=0; i < nameVal.length; i++)
  +                {
  +                    String key = nameVal[i].getName();
  +                    String factory = nameVal[i].getValue();
  +                    
  +                    // Store the factory to the table as a string and
  +                    // instantiate it by using the service when needed.
  +                    objectFactories.put(key,factory);
  +                }
  +            }
  +        }
  +    }
  +
  +    /**
  +     * Avalon component lifecycle method
  +     * Initializes the service by loading default class loaders
  +     * and customized object factories.
  +     *
  +     * @throws InitializationException if initialization fails.
  +     */
  +    public void initialize()
  +        throws InitializationException
  +    {
  +        if (loaderNames != null)
  +        {
  +            for (int i = 0; i < loaderNames.length; i++)
  +            {
  +                try
  +                {
  +                    classLoaders.add(
  +                        loadClass(loaderNames[i]).newInstance());
  +                }
  +                catch (Exception x)
  +                {
  +                    throw new InitializationException(
  +                        "No such class loader '" + loaderNames[i] +
  +                        "' for TurbineFactoryService",x);
  +                }
  +            }
  +            loaderNames = null;
  +        }
  +
  +        setInit(true);
  +    }
  +
  +    /**
  +     * The name used to specify this component in TurbineResources.properties 
  +     * @deprecated part of the pre-avalon compatibility layer
  +     */
  +    protected String getName()
  +    {
  +        return "FactoryService";
       }
   }
  
  
  
  1.2       +12 -35    jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/intake/IntakeService.java
  
  Index: IntakeService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/intake/IntakeService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IntakeService.java	30 May 2002 02:27:17 -0000	1.1
  +++ IntakeService.java	4 Nov 2002 05:36:48 -0000	1.2
  @@ -55,6 +55,7 @@
    */
   
   import java.lang.reflect.Method;
  +import org.apache.avalon.framework.component.Component;
   import org.apache.fulcrum.ServiceException;
   import org.apache.fulcrum.pool.Recyclable;
   import org.apache.fulcrum.util.parser.ValueParser;
  @@ -75,17 +76,21 @@
    * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
    * @version $Id$
    */
  -public interface IntakeService
  +public interface IntakeService extends Component
   {
  -    /**
  -     * The key under which this service is stored in TurbineServices.
  +    /** Avalon role - used to id the component within the manager */
  +    String ROLE = IntakeService.class.getName();
  +
  +    /** 
  +     * Old style TurbineServices role, now equal to ROLE.
  +     * @deprecated TurbineServices is deprecated in favor of avalon. 
        */
  -    public static final String SERVICE_NAME = "IntakeService";
  +    String SERVICE_NAME = ROLE;
   
       /**
        * The property specifying the location of the xml specification.
        */
  -    public static final String XML_PATH = "xml.path";
  +    public static final String XML_PATH = "xml-path";
   
       /**
        * The default location of the xml specification.
  @@ -96,7 +101,7 @@
        * The property specifying the location where a serialized version of 
        * the xml specification can be written for faster restarts..
        */
  -    public static final String SERIAL_XML = "serialize.path";
  +    public static final String SERIAL_XML = "serialize-path";
   
       /**
        * The default location where a serialized version of 
  @@ -119,34 +124,6 @@
        */
       public Group getGroup(String groupName)
           throws ServiceException;
  -
  -    /**
  -     * Gets an instance of a named group either from the pool
  -     * or by calling the Factory Service if the pool is empty and
  -     * then initialize it using the ValueParser looking for
  -     * a NEW id.
  -     *
  -     * @param groupName the name of the group.
  -     * @param pp the request parameters that may contain matching keys
  -     * @return a Group instance.
  -     * @throws ServiceException if recycling fails.
  -     * /
  -    public Group getGroup(String groupName, ValueParser pp)
  -        throws Exception;
  -
  -    /**
  -     * Gets an instance of a named group either from the pool
  -     * or by calling the Factory Service if the pool is empty and
  -     * then initialize it using the ValueParser looking for id.
  -     *
  -     * @param groupName the name of the group.
  -     * @param pp the request parameters that may contain matching keys
  -     * @return a Group instance.
  -     * @throws ServiceException if recycling fails.
  -     * /
  -    public Group getGroup(String groupName, ValueParser pp, String id)
  -        throws Exception;
  -    */
   
       /**
        * Puts a group back to the pool.
  
  
  
  1.2       +257 -206  jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/intake/TurbineIntakeService.java
  
  Index: TurbineIntakeService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/intake/TurbineIntakeService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TurbineIntakeService.java	30 May 2002 02:27:17 -0000	1.1
  +++ TurbineIntakeService.java	4 Nov 2002 05:36:48 -0000	1.2
  @@ -82,9 +82,16 @@
   import org.apache.fulcrum.ServiceException;
   import org.apache.fulcrum.pool.BoundedBuffer;
   import org.apache.fulcrum.pool.Recyclable;
  -import org.apache.fulcrum.BaseService;
  +import org.apache.fulcrum.HasApplicationRoot;
   import org.apache.fulcrum.InitializationException;
   
  +import org.apache.avalon.framework.activity.Disposable;
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.thread.ThreadSafe;
  +
   /**
    * This service provides access to input processing objects based
    * on an XML specification.
  @@ -93,9 +100,12 @@
    * @version $Id$
    */
   public class TurbineIntakeService
  -    extends BaseService
  -    implements IntakeService
  -{
  +    extends HasApplicationRoot
  +    implements IntakeService, Configurable, Initializable, 
  +               Disposable, ThreadSafe 
  +{ 
  +    private boolean disposed = false; 
  +
       /** Array of group names. */
       private String[] groupNames;
   
  @@ -120,208 +130,25 @@
       /** pools Group objects */
       KeyedObjectPool keyedPool;
   
  +    /** the location of the xml descriptor */
  +    private String xmlPath;
  +
  +    /** location to store a serialized version of the xml descriptor */
  +    private String appDataPath;
  +
       // a couple integers for a switch statement
       private static final int GETTER = 0;
       private static final int SETTER = 1;
   
  -    /**
  -     * Constructor.
  +    /** 
  +     * Constructor. All Components need a public no argument constructor 
  +     * to be a legal Component. 
        */
       public TurbineIntakeService()
       {
       }
   
       /**
  -     * Called the first time the Service is used.
  -     *
  -     * @param config A ServletConfig.
  -     */
  -    public void init()
  -        throws InitializationException
  -    {
  -        String xmlPath = getConfiguration()
  -            .getString(XML_PATH, XML_PATH_DEFAULT);
  -        String appDataPath = getConfiguration()
  -            .getString(SERIAL_XML, SERIAL_XML_DEFAULT);
  -        
  -        String SERIALIZED_ERROR_MSG = 
  -            "Intake initialization could not be serialized " +
  -            "because writing to " + appDataPath + " was not " +
  -            "allowed.  This will require that the xml file be " +
  -            "parsed when restarting the application.";
  -
  -        if ( xmlPath == null )
  -        {
  -            String pathError =
  -                "Path to intake.xml was not specified.  Check that the" +
  -                " property exists in TR.props and was loaded.";
  -            getCategory().error(pathError);
  -            throw new InitializationException(pathError);
  -        }
  -
  -        File serialAppData = null;
  -        File xmlFile = null;
  -        xmlFile = new File(xmlPath);
  -        if ( !xmlFile.canRead() ) 
  -        {
  -            // If possible, transform paths to be webapp root relative.
  -            xmlPath = getRealPath(xmlPath);
  -            xmlFile = new File(xmlPath);
  -            if ( !xmlFile.canRead() ) 
  -            {
  -                String pathError =
  -                    "Could not read input file.  Even tried relative to"
  -                    + " webapp root.";
  -                getCategory().error(pathError);
  -                throw new InitializationException(pathError);
  -            }
  -        }
  -
  -        serialAppData = new File(appDataPath);
  -        try
  -        {
  -            serialAppData.createNewFile();
  -            serialAppData.delete();
  -        }
  -        catch (Exception e)
  -        {
  -            // If possible, transform paths to be webapp root relative.
  -            appDataPath = getRealPath(appDataPath);
  -            serialAppData = new File(appDataPath);
  -            try
  -            {
  -                serialAppData.createNewFile();
  -                serialAppData.delete();
  -            }
  -            catch (Exception ee)
  -            {
  -                getCategory().info(SERIALIZED_ERROR_MSG);
  -            }
  -        }
  -
  -        try
  -        {
  -            if ( serialAppData.exists()
  -                 && serialAppData.lastModified() > xmlFile.lastModified() )
  -            {
  -                InputStream in = null;
  -                try
  -                {
  -                    in = new FileInputStream(serialAppData);
  -                    ObjectInputStream p = new ObjectInputStream(in);
  -                    appData = (AppData)p.readObject();
  -                }
  -                catch (Exception e)
  -                {
  -                    // We got a corrupt file for some reason
  -                    writeAppData(xmlPath, appDataPath, serialAppData);
  -                }
  -                finally
  -                {
  -                    if (in != null)
  -                    {
  -                        in.close();
  -                    }
  -                }
  -            }
  -            else
  -            {
  -                writeAppData(xmlPath, appDataPath, serialAppData);
  -            }
  -
  -            groupNames = new String[appData.getGroups().size()];
  -            groupKeyMap = new HashMap();
  -            groupNameMap = new HashMap();
  -            getterMap = new HashMap();
  -            setterMap = new HashMap();
  -            // omTool = new OMTool();
  -            String pkg = appData.getBasePackage();
  -
  -            int maxPooledGroups = 0;
  -            List glist = appData.getGroups();
  -            for ( int i=glist.size()-1; i>=0; i-- )
  -            {
  -                XmlGroup g = (XmlGroup)glist.get(i);
  -                String groupName = g.getName();
  -                groupNames[i] = groupName;
  -                groupKeyMap.put(groupName, g.getKey());
  -                groupNameMap.put(g.getKey(), groupName);
  -                maxPooledGroups = 
  -                    Math.max(maxPooledGroups, 
  -                             Integer.parseInt(g.getPoolCapacity()));
  -                List classNames = g.getMapToObjects();
  -                Iterator iter2 = classNames.iterator();
  -                while (iter2.hasNext())
  -                {
  -                    String className = (String)iter2.next();
  -                    if ( !getterMap.containsKey(className) )
  -                    {
  -                        getterMap.put(className, new HashMap());
  -                        setterMap.put(className, new HashMap());
  -                    }
  -                }
  -            }
  -
  -            KeyedPoolableObjectFactory factory = 
  -                new Group.GroupFactory(appData);
  -            keyedPool = new StackKeyedObjectPool(factory, maxPooledGroups);
  -
  -            setInit(true);
  -        }
  -        catch (Exception e)
  -        {
  -            throw new InitializationException(
  -                "TurbineIntakeService failed to initialize", e);
  -        }
  -    }
  -
  -    /**
  -     * This method writes the appData file into Objects and stores
  -     * the information into this classes appData property
  -     */
  -    private void writeAppData(String xmlPath, String appDataPath, File serialAppData)
  -        throws Exception
  -    {
  -        XmlToAppData xmlApp = new XmlToAppData();
  -        appData = xmlApp.parseFile(xmlPath);
  -        OutputStream out = null;
  -        InputStream in = null;
  -        try
  -        {
  -            // write the appData file out
  -            out = new FileOutputStream(serialAppData);
  -            ObjectOutputStream p = new ObjectOutputStream(out);
  -            p.writeObject(appData);
  -            p.flush();
  -
  -            // read the file back in. for some reason on OSX 10.1
  -            // this is necessary.
  -            in = new FileInputStream(serialAppData);
  -            ObjectInputStream pin = new ObjectInputStream(in);
  -            appData = (AppData)pin.readObject();
  -        }
  -        catch (Exception e)
  -        {
  -            getCategory().info(
  -                "Intake initialization could not be serialized " +
  -                "because writing to " + appDataPath + " was not " +
  -                "allowed.  This will require that the xml file be " +
  -                "parsed when restarting the application.");
  -        }
  -        finally
  -        {
  -            if (out != null)
  -            {
  -                out.close();
  -            }
  -            if (in != null)
  -            {
  -                in.close();
  -            }
  -        }
  -    }
  -
  -    /**
        * Gets an instance of a named group either from the pool
        * or by calling the Factory Service if the pool is empty.
        *
  @@ -369,11 +196,6 @@
               {
                   new ServiceException(e);
               }
  -            //return true;
  -        }
  -        else
  -        {
  -            //return false;
           }
       }
   
  @@ -446,14 +268,14 @@
                       ((Map)setterMap.get(className)).put(propName, setter);
                       if ( setter == null ) 
                       {
  -                        getCategory().error("Intake: setter for '" + propName
  +                        getLogger().error("Intake: setter for '" + propName
                                               + "' in class '" + className
                                               + "' could not be found.");
                       }
                   }
                   catch (Exception e)
                   {
  -                    getCategory().error(e);
  +                    getLogger().error("", e);
                   }
               }
               // we have already completed the reflection on the getter, so
  @@ -501,14 +323,14 @@
                       ((Map)getterMap.get(className)).put(propName, getter);
                       if ( getter == null ) 
                       {
  -                        getCategory().error("Intake: getter for '" + propName
  +                        getLogger().error("Intake: getter for '" + propName
                                               + "' in class '" + className
                                               + "' could not be found.");
                       }
                   }
                   catch (Exception e)
                   {
  -                    getCategory().error(e);
  +                    getLogger().error("", e);
                   }
               }
               // we have already completed the reflection on the setter, so
  @@ -529,4 +351,233 @@
           return getter;
       }
   
  +
  +    // ---------------- Avalon Lifecycle Methods ---------------------
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void configure(Configuration conf)
  +        throws ConfigurationException
  +    {
  +        if (useOldConfiguration(conf))
  +        {
  +            xmlPath = getConfiguration()
  +                .getString(XML_PATH, XML_PATH_DEFAULT);
  +            appDataPath = getConfiguration()
  +                .getString(SERIAL_XML, SERIAL_XML_DEFAULT);
  +        }
  +        else
  +        {
  +            xmlPath = conf.getAttribute(XML_PATH, XML_PATH_DEFAULT);
  +            appDataPath = conf.getAttribute(SERIAL_XML, SERIAL_XML_DEFAULT);
  +        }
  +    }
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void initialize()
  +        throws InitializationException
  +    {
  +        if ( xmlPath == null )
  +        {
  +            String pathError =
  +                "Path to intake.xml was not specified.  Check that the" +
  +                " property exists in TR.props and was loaded.";
  +            getLogger().error(pathError);
  +            throw new InitializationException(pathError);
  +        }
  +
  +        File serialAppData = null;
  +        File xmlFile = null;
  +        xmlFile = new File(xmlPath);
  +        if ( !xmlFile.canRead() ) 
  +        {
  +            // If possible, transform paths to be webapp root relative.
  +            xmlPath = getRealPath(xmlPath);
  +            xmlFile = new File(xmlPath);
  +            if ( !xmlFile.canRead() ) 
  +            {
  +                String pathError =
  +                    "Could not read input file.  Even tried relative to"
  +                    + " webapp root.";
  +                getLogger().error(pathError);
  +                throw new InitializationException(pathError);
  +            }
  +        }
  +
  +        serialAppData = new File(appDataPath);
  +        try
  +        {
  +            serialAppData.createNewFile();
  +            serialAppData.delete();
  +        }
  +        catch (Exception e)
  +        {
  +            // If possible, transform paths to be webapp root relative.
  +            appDataPath = getRealPath(appDataPath);
  +            serialAppData = new File(appDataPath);
  +            try
  +            {
  +                serialAppData.createNewFile();
  +                serialAppData.delete();
  +            }
  +            catch (Exception ee)
  +            {
  +                String SERIALIZED_ERROR_MSG = 
  +                    "Intake initialization could not be serialized " +
  +                    "because writing to " + appDataPath + " was not " +
  +                    "allowed.  This will require that the xml file be " +
  +                    "parsed when restarting the application.";
  +
  +                getLogger().info(SERIALIZED_ERROR_MSG);
  +            }
  +        }
  +
  +        try
  +        {
  +            if ( serialAppData.exists()
  +                 && serialAppData.lastModified() > xmlFile.lastModified() )
  +            {
  +                InputStream in = null;
  +                try
  +                {
  +                    in = new FileInputStream(serialAppData);
  +                    ObjectInputStream p = new ObjectInputStream(in);
  +                    appData = (AppData)p.readObject();
  +                }
  +                catch (Exception e)
  +                {
  +                    // We got a corrupt file for some reason
  +                    writeAppData(xmlPath, appDataPath, serialAppData);
  +                }
  +                finally
  +                {
  +                    if (in != null)
  +                    {
  +                        in.close();
  +                    }
  +                }
  +            }
  +            else
  +            {
  +                writeAppData(xmlPath, appDataPath, serialAppData);
  +            }
  +
  +            groupNames = new String[appData.getGroups().size()];
  +            groupKeyMap = new HashMap();
  +            groupNameMap = new HashMap();
  +            getterMap = new HashMap();
  +            setterMap = new HashMap();
  +            // omTool = new OMTool();
  +            String pkg = appData.getBasePackage();
  +
  +            int maxPooledGroups = 0;
  +            List glist = appData.getGroups();
  +            for ( int i=glist.size()-1; i>=0; i-- )
  +            {
  +                XmlGroup g = (XmlGroup)glist.get(i);
  +                String groupName = g.getName();
  +                groupNames[i] = groupName;
  +                groupKeyMap.put(groupName, g.getKey());
  +                groupNameMap.put(g.getKey(), groupName);
  +                maxPooledGroups = 
  +                    Math.max(maxPooledGroups, 
  +                             Integer.parseInt(g.getPoolCapacity()));
  +                List classNames = g.getMapToObjects();
  +                Iterator iter2 = classNames.iterator();
  +                while (iter2.hasNext())
  +                {
  +                    String className = (String)iter2.next();
  +                    if ( !getterMap.containsKey(className) )
  +                    {
  +                        getterMap.put(className, new HashMap());
  +                        setterMap.put(className, new HashMap());
  +                    }
  +                }
  +            }
  +
  +            KeyedPoolableObjectFactory factory = 
  +                new Group.GroupFactory(appData);
  +            keyedPool = new StackKeyedObjectPool(factory, maxPooledGroups);
  +
  +            setInit(true);
  +        }
  +        catch (Exception e)
  +        {
  +            throw new InitializationException(
  +                "TurbineIntakeService failed to initialize", e);
  +        }
  +    }
  +
  +    /**
  +     * This method writes the appData file into Objects and stores
  +     * the information into this classes appData property
  +     */
  +    private void writeAppData(String xmlPath, String appDataPath, File serialAppData)
  +        throws Exception
  +    {
  +        XmlToAppData xmlApp = new XmlToAppData();
  +        appData = xmlApp.parseFile(xmlPath);
  +        OutputStream out = null;
  +        InputStream in = null;
  +        try
  +        {
  +            // write the appData file out
  +            out = new FileOutputStream(serialAppData);
  +            ObjectOutputStream p = new ObjectOutputStream(out);
  +            p.writeObject(appData);
  +            p.flush();
  +
  +            // read the file back in. for some reason on OSX 10.1
  +            // this is necessary.
  +            in = new FileInputStream(serialAppData);
  +            ObjectInputStream pin = new ObjectInputStream(in);
  +            appData = (AppData)pin.readObject();
  +        }
  +        catch (Exception e)
  +        {
  +            getLogger().info(
  +                "Intake initialization could not be serialized " +
  +                "because writing to " + appDataPath + " was not " +
  +                "allowed.  This will require that the xml file be " +
  +                "parsed when restarting the application.");
  +        }
  +        finally
  +        {
  +            if (out != null)
  +            {
  +                out.close();
  +            }
  +            if (in != null)
  +            {
  +                in.close();
  +            }
  +        }
  +    }
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void dispose()
  +    {
  +        groupNames = null;
  +        groupNameMap = null;
  +        groupKeyMap = null;
  +        getterMap = null;
  +        setterMap = null;
  +        appData = null;
  +        keyedPool = null;
  +        disposed = true;
  +    }
  +
  +    /**
  +     * The name used to specify this component in TurbineResources.properties 
  +     * @deprecated part of the pre-avalon compatibility layer
  +     */
  +    protected String getName()
  +    {
  +        return "IntakeService";
  +    }
   }
  
  
  
  1.3       +5 -5      jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/jsp/JspService.java
  
  Index: JspService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/jsp/JspService.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JspService.java	17 Jul 2002 12:55:20 -0000	1.2
  +++ JspService.java	4 Nov 2002 05:36:48 -0000	1.3
  @@ -54,9 +54,8 @@
    * <http://www.apache.org/>.
    */
   
  -import org.apache.fulcrum.Service;
  -//import org.apache.turbine.RunData;
   import org.apache.fulcrum.ServiceException;
  +import org.apache.avalon.framework.component.Component;
   
   /**
    * Implementations of the JspService interface.
  @@ -64,10 +63,11 @@
    * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
    */
   public interface JspService
  -    extends Service
  +    extends Component
   {
  -    /** The name used to specify this service in TurbineResources.properties */
  -    public static final String SERVICE_NAME = "JspService";
  +    String ROLE = JspService.class.getName();
  +    String SERVICE_NAME = ROLE;
  +
       /** The key used to store an instance of RunData in the request */
       public static final String RUNDATA = "rundata";
       /** The key used to store an instance of JspLink in the request */
  
  
  
  1.2       +74 -55    jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/jsp/TurbineJspService.java
  
  Index: TurbineJspService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/jsp/TurbineJspService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TurbineJspService.java	30 May 2002 02:27:22 -0000	1.1
  +++ TurbineJspService.java	4 Nov 2002 05:36:48 -0000	1.2
  @@ -58,6 +58,8 @@
   import java.io.IOException;
   import java.io.OutputStream;
   import java.io.Writer;
  +import java.util.List;
  +import java.util.ArrayList;
   import javax.servlet.ServletConfig;
   import javax.servlet.ServletContext;
   import javax.servlet.RequestDispatcher;
  @@ -70,6 +72,9 @@
   import org.apache.fulcrum.template.TurbineTemplate;
   import org.apache.fulcrum.template.TemplateContext;
   
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
  +
   /**
    * This is a Service that can process JSP templates from within a Turbine
    * screen.
  @@ -82,6 +87,9 @@
       extends BaseTemplateEngineService
       implements JspService
   {
  +    /** paths as given in the configuration file */
  +    private String[] rawPaths;
  +
       /** The base path[s] prepended to filenames given in arguments */
       private String[] templatePaths;
   
  @@ -92,25 +100,6 @@
       private int bufferSize;
   
       /**
  -     * Performs early initialization of this Turbine service.
  -     */
  -    public void init()
  -        throws InitializationException
  -    {
  -        try
  -        {
  -            initJsp();
  -            registerConfiguration("jsp");
  -            setInit(true);
  -        }
  -        catch (Exception e)
  -        {
  -            throw new InitializationException(
  -                "TurbineJspService failed to initialize", e);
  -        }
  -    }
  -
  -    /**
        * Adds some convenience objects to the request.  For example an instance
        * of JspLink which can be used to generate links to other templates.
        *
  @@ -247,42 +236,6 @@
           // TODO: Implement me!
       }
   
  -    /**
  -     * This method sets up the template cache.
  -     */
  -    private void initJsp() throws Exception
  -    {
  -        /*
  -         * Use the turbine template service to translate
  -         * the template paths.
  -         */
  -        templatePaths = TurbineTemplate.translateTemplatePaths(
  -        getConfiguration().getStringArray("templates"));
  -
  -        /*
  -         * Set relative paths from config.
  -         * Needed for javax.servlet.RequestDispatcher
  -         */
  -        relativeTemplatePaths = getConfiguration().getStringArray("templates");
  -
  -        /*
  -         * Make sure that the relative paths begin with /
  -         */
  -        for (int i = 0; i < relativeTemplatePaths.length; i++)
  -        {
  -            if (!relativeTemplatePaths[i].startsWith("/"))
  -            {
  -                relativeTemplatePaths[i] = "/" + relativeTemplatePaths[i];
  -            }
  -        }
  -
  -        bufferSize = getConfiguration().getInt("buffer.size", 8192);
  -
  -        /*
  -         * Register with the template service.
  -         */
  -        registerConfiguration("jsp");
  -    }
   
       /**
        * Determine whether a given template exists. This service
  @@ -357,4 +310,70 @@
           // do nothing
       }
       */
  +
  +    // ---------------- Avalon Lifecycle Methods ---------------------
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void configure(Configuration conf)
  +        throws ConfigurationException
  +    {
  +        if (conf.getAttributeAsBoolean(USE_PROPERTY_FILE, false)) 
  +        {
  +            rawPaths = getConfiguration().getStringArray("templates");
  +            bufferSize = getConfiguration().getInt("buffer.size", 8192);
  +        }
  +        else
  +        {
  +            List pathList = new ArrayList();
  +            final Configuration[] paths = conf.getChildren("template-path");
  +            if (paths != null)
  +            {
  +                for (int i=0; i < paths.length; i++)
  +                {
  +                    pathList.add(paths[i].getValue());
  +                }
  +            }
  +            rawPaths = (String[])pathList.toArray(new String[pathList.size()]);
  +
  +            bufferSize = conf.getAttributeAsInteger("buffer-size", 8192); 
  +        }        
  +
  +        // Register with the template service.
  +        registerConfiguration(conf, "jsp");
  +
  +        // Use the turbine template service to translate the template paths.
  +        templatePaths = TurbineTemplate.translateTemplatePaths(rawPaths);
  +        
  +        // Set relative paths from config.
  +        // Needed for javax.servlet.RequestDispatcher
  +        relativeTemplatePaths = rawPaths;
  +        // Make sure that the relative paths begin with /
  +        for (int i = 0; i < relativeTemplatePaths.length; i++)
  +        {
  +            if (!relativeTemplatePaths[i].startsWith("/"))
  +            {
  +                relativeTemplatePaths[i] = "/" + relativeTemplatePaths[i];
  +            }
  +        }
  +    }
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void initialize()
  +        throws InitializationException
  +    {
  +        setInit(true);
  +    }
  +
  +    /** 
  +     * The name used to specify this component in TurbineResources.properties 
  +     * @deprecated part of the pre-avalon compatibility layer
  +     */
  +    protected String getName()
  +    {
  +        return "JspService";
  +    }
   }
  
  
  
  1.2       +23 -25    jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/localization/LocalizationService.java
  
  Index: LocalizationService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/localization/LocalizationService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LocalizationService.java	30 May 2002 02:27:23 -0000	1.1
  +++ LocalizationService.java	4 Nov 2002 05:36:48 -0000	1.2
  @@ -58,7 +58,7 @@
   import java.util.ResourceBundle;
   import javax.servlet.http.HttpServletRequest;
   
  -import org.apache.fulcrum.Service;
  +import org.apache.avalon.framework.component.Component;
   
   /**
    * <p>Provides localization functionality using the interface provided
  @@ -77,36 +77,34 @@
    * @version $Id$
    */
   public interface LocalizationService
  -    extends Service
  +    extends Component
   {
  -    /**
  -     * The name of this service.
  -     */
  -    public static final String SERVICE_NAME = "LocalizationService";
  +    String ROLE = LocalizationService.class.getName();
  +    String SERVICE_NAME = ROLE;
   
       /**
        * A constant for the HTTP <code>Accept-Language</code> header.
        */
  -    public static final String ACCEPT_LANGUAGE = "Accept-Language";
  +    String ACCEPT_LANGUAGE = "Accept-Language";
   
       /**
        * Retrieves the default language (as specified in the config
        * file).
        */
  -    public String getDefaultLanguage();
  +    String getDefaultLanguage();
   
       /**
        * Retrieves the default country (as specified in the config
        * file).
        */
  -    public String getDefaultCountry();
  +    String getDefaultCountry();
   
       /**
        * Retrieves the name of the default bundle (as specified in the
        * config file), or the first in the list if there are more than
        * one.
        */
  -    public String getDefaultBundleName();
  +    String getDefaultBundleName();
   
       /**
        * Retrieves the list of names of bundles to search by default for
  @@ -115,14 +113,14 @@
        *
        * @return The list of configured bundle names.
        */
  -    public String[] getBundleNames();
  +    String[] getBundleNames();
   
       /**
        * Convenience method to get the default <code>ResourceBundle</code>.
        *
        * @return A localized <code>ResourceBundle</code>.
        */
  -    public ResourceBundle getBundle();
  +    ResourceBundle getBundle();
   
       /**
        * Returns a ResourceBundle given the bundle name and the default
  @@ -131,7 +129,7 @@
        * @param bundleName Name of bundle.
        * @return A localized ResourceBundle.
        */
  -    public ResourceBundle getBundle(String bundleName);
  +    ResourceBundle getBundle(String bundleName);
   
       /**
        * Convenience method to get a ResourceBundle based on name and
  @@ -141,7 +139,7 @@
        * @param languageHeader A String with the language header.
        * @return A localized ResourceBundle.
        */
  -    public ResourceBundle getBundle(String bundleName, String languageHeader);
  +    ResourceBundle getBundle(String bundleName, String languageHeader);
   
       /**
        * Convenience method to get a ResourceBundle based on HTTP
  @@ -151,7 +149,7 @@
        * <code>Accept-Language</code> of.
        * @return A localized ResourceBundle.
        */
  -    public ResourceBundle getBundle(HttpServletRequest req);
  +    ResourceBundle getBundle(HttpServletRequest req);
   
       /**
        * Convenience method to get a <code>ResourceBundle</code> based
  @@ -163,7 +161,7 @@
        * <code>Accept-Language</code> of.
        * @return A localized ResourceBundle.
        */
  -    public ResourceBundle getBundle(String bundleName, HttpServletRequest req);
  +    ResourceBundle getBundle(String bundleName, HttpServletRequest req);
   
       /**
        * Convenience method to get a ResourceBundle based on name and
  @@ -173,7 +171,7 @@
        * @param locale A Locale.
        * @return A localized ResourceBundle.
        */
  -    public ResourceBundle getBundle(String bundleName, Locale locale);
  +    ResourceBundle getBundle(String bundleName, Locale locale);
   
       /**
        * Attempts to pull the <code>Accept-Language</code> header out of
  @@ -185,7 +183,7 @@
        * <code>Accept-Language</code> of.
        * @return The parsed locale.
        */
  -    public Locale getLocale(HttpServletRequest req);
  +    Locale getLocale(HttpServletRequest req);
   
       /**
        * Parses the <code>Accept-Language</code> header and attempts to
  @@ -197,7 +195,7 @@
        * @return The parsed locale, or a locale corresponding to the
        * language and country defaults.
        */
  -    public Locale getLocale(String languageHeader);
  +    Locale getLocale(String languageHeader);
   
       /**
        * Tries very hard to return a value, looking first in the
  @@ -209,14 +207,14 @@
        * @param key Name of the text to retrieve.
        * @return Localized text.
        */
  -    public String getString(String bundleName, Locale locale, String key);
  +    String getString(String bundleName, Locale locale, String key);
   
       /**
        * This method sets the name of the defaultBundle.
        *
        * @param defaultBundle Name of default bundle.
        */
  -    public void setBundle(String defaultBundle);
  +    void setBundle(String defaultBundle);
   
       /**
        * Formats a localized value using the provided object.
  @@ -228,7 +226,7 @@
        * @return Formatted localized text.
        * @see #format(String, Locale, String, Object[])
        */
  -    public String format(String bundleName, Locale locale,
  +    String format(String bundleName, Locale locale,
                            String key, Object arg1);
   
       /**
  @@ -242,7 +240,7 @@
        * @return Formatted localized text.
        * @see #format(String, Locale, String, Object[])
        */
  -    public String format(String bundleName, Locale locale,
  +    String format(String bundleName, Locale locale,
                            String key, Object arg1, Object arg2);
   
       /**
  @@ -255,6 +253,6 @@
        *             formatting the localized text.
        * @return Formatted localized text.
        */
  -    public String format(String bundleName, Locale locale,
  +    String format(String bundleName, Locale locale,
                            String key, Object[] args);
   }
  
  
  
  1.4       +65 -19    jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/localization/TurbineLocalizationService.java
  
  Index: TurbineLocalizationService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/localization/TurbineLocalizationService.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TurbineLocalizationService.java	17 Jul 2002 12:56:07 -0000	1.3
  +++ TurbineLocalizationService.java	4 Nov 2002 05:36:48 -0000	1.4
  @@ -68,6 +68,15 @@
   import org.apache.log4j.Category;
   import org.apache.fulcrum.BaseService;
   import org.apache.fulcrum.InitializationException;
  +import org.apache.fulcrum.BaseFulcrumComponent;
  +
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.component.Component;
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.thread.ThreadSafe;
  +
   
   /**
    * <p>This class is the single point of access to all localization
  @@ -99,9 +108,10 @@
    * @author <a href="mailto:leonardr@collab.net">Leonard Richardson</a>
    * @version $Id$
    */
  +
   public class TurbineLocalizationService
  -    extends BaseService
  -    implements LocalizationService
  +    extends BaseFulcrumComponent
  +    implements LocalizationService, Configurable, Initializable, ThreadSafe
   {
       /**
        * The value to pass to <code>MessageFormat</code> if a
  @@ -121,6 +131,11 @@
       private String[] bundleNames = null;
   
       /**
  +     * The default bundle name to use if not specified.
  +     */
  +    private String defaultBundleName = null;
  +
  +    /**
        * The name of the default locale to use (includes language and
        * country).
        */
  @@ -145,23 +160,48 @@
           bundles = new HashMap();
       }
   
  +
  +    public void configure(Configuration conf)
  +        throws ConfigurationException
  +    {
  +        Locale jvmDefault = Locale.getDefault();
  +        if (useOldConfiguration(conf))
  +        {
  +            System.out.println("Using old conf");
  +             defaultLanguage = getConfiguration().getString(
  +                 "locale.default.language",
  +                 jvmDefault.getLanguage()).trim();
  +
  +             defaultCountry = getConfiguration().getString(
  +                 "locale.default.country",
  +                 jvmDefault.getCountry()).trim();
  +
  +             bundleNames =
  +                 getConfiguration().getStringArray("locale.default.bundles");
  +             defaultBundleName = 
  +                 getConfiguration().getString("locale.default.bundle");
  +        }
  +        else
  +        {
  +            System.out.println("Using parameters");
  +            defaultLanguage = conf.getAttribute(
  +                "locale-default-language", jvmDefault.getLanguage()).trim();
  +            defaultCountry = conf.getAttribute(
  +                "locale-default-country", jvmDefault.getCountry()).trim();
  +            // FIXME! need to add bundle names
  +        }
  +        System.out.println("initialized lang="
  +                           + defaultLanguage + " country=" + defaultCountry);
  +    }
  +
       /**
        * Called the first time the Service is used.
        */
  -    public void init()
  +    public void initialize()
           throws InitializationException
       {
           initBundleNames(null);
  -
  -        Locale jvmDefault = Locale.getDefault();
  -        defaultLanguage = getConfiguration()
  -            .getString("locale.default.language",
  -                       jvmDefault.getLanguage()).trim();
  -        defaultCountry = getConfiguration()
  -            .getString("locale.default.country",
  -                       jvmDefault.getCountry()).trim();
           defaultLocale = new Locale(defaultLanguage, defaultCountry);
  -
           setInit(true);
       }
   
  @@ -173,21 +213,18 @@
       protected void initBundleNames(String[] ignored)
       {
           //System.err.println("cfg=" + getConfiguration());
  -        bundleNames =
  -            getConfiguration().getStringArray("locale.default.bundles");
  -        String name = getConfiguration().getString("locale.default.bundle");
  -        if (name != null && name.length() > 0)
  +        if (defaultBundleName != null && defaultBundleName.length() > 0)
           {
               // Using old-style single bundle name property.
               if (bundleNames == null || bundleNames.length <= 0)
               {
  -                bundleNames = new String[] { name };
  +                bundleNames = new String[] { defaultBundleName };
               }
               else
               {
                   // Prepend "default" bundle name.
                   String[] array = new String[bundleNames.length + 1];
  -                array[0] = name;
  +                array[0] = defaultBundleName;
                   System.arraycopy(bundleNames, 0, array, 1, bundleNames.length);
                   bundleNames = array;
               }
  @@ -629,5 +666,14 @@
           messageFormat.applyPattern(value);
   
           return messageFormat.format(args);
  +    }
  +
  +    /** 
  +     * The name used to specify this component in TurbineResources.properties 
  +     * @deprecated part of the pre-avalon compatibility layer
  +     */
  +    protected String getName()
  +    {
  +        return "LocalizationService";
       }
   }
  
  
  
  1.2       +12 -7     jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/mimetype/MimeTypeService.java
  
  Index: MimeTypeService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/mimetype/MimeTypeService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MimeTypeService.java	30 May 2002 02:27:23 -0000	1.1
  +++ MimeTypeService.java	4 Nov 2002 05:36:49 -0000	1.2
  @@ -57,7 +57,7 @@
   import java.io.File;
   import java.util.Locale;
   
  -import org.apache.fulcrum.Service;
  +import org.apache.avalon.framework.component.Component;
   import org.apache.fulcrum.mimetype.util.MimeType;
   
   /**
  @@ -70,12 +70,17 @@
    * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
    * @version $Id$
    */
  -public interface MimeTypeService extends Service
  +public interface MimeTypeService 
  +    extends Component
   {
  -    /**
  -     * The name of the service.
  +    /** Avalon role - used to id the component within the manager */
  +    String ROLE = MimeTypeService.class.getName();
  +
  +    /** 
  +     * Old style TurbineServices role, now equal to ROLE.
  +     * @deprecated TurbineServices is deprecated in favor of avalon. 
        */
  -    public static final String SERVICE_NAME = "MimeTypeService";
  +    String SERVICE_NAME = ROLE;
   
       /**
        * Sets a MIME content type mapping to extensions to the map.
  @@ -211,4 +216,4 @@
        */
       public String getCharSet(String key,
                                String def);
  -}
  \ No newline at end of file
  +}
  
  
  
  1.2       +97 -64    jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/mimetype/TurbineMimeTypeService.java
  
  Index: TurbineMimeTypeService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/mimetype/TurbineMimeTypeService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TurbineMimeTypeService.java	30 May 2002 02:27:24 -0000	1.1
  +++ TurbineMimeTypeService.java	4 Nov 2002 05:36:49 -0000	1.2
  @@ -63,6 +63,13 @@
   import org.apache.fulcrum.mimetype.util.MimeType;
   import org.apache.fulcrum.mimetype.util.MimeTypeMap;
   import org.apache.fulcrum.mimetype.util.CharSetMap;
  +import org.apache.fulcrum.HasApplicationRoot;
  +
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.thread.ThreadSafe;
   
   /**
    * The MimeType Service maintains mappings between MIME types and
  @@ -85,19 +92,24 @@
    * @version $Id$
    */
   public class TurbineMimeTypeService
  -    extends BaseService
  -    implements MimeTypeService
  +    extends HasApplicationRoot
  +    implements MimeTypeService, Configurable, Initializable, ThreadSafe
   {
       /**
        * The MIME type file property.
        */
  -    public static final String MIME_TYPES = "mime.types";
  +    public static final String MIME_TYPES = "mimetypes";
   
       /**
        * The charset file property.
        */
       public static final String CHARSETS = "charsets";
   
  +    // path to a mimetypes-file_extension mapping file
  +    private String mimetypePath;
  +    // path to a charset-language mapping file
  +    private String charsetPath;
  +
       /**
        * The MIME type map used by the service.
        */
  @@ -116,66 +128,6 @@
       }
   
       /**
  -     * Initializes the service.
  -     *
  -     * @throws InitializationException if initialization fails.
  -     */
  -    public void init()
  -        throws InitializationException
  -    {
  -        String path = null;
  -
  -        if (getConfiguration() != null)
  -        {
  -            path = getConfiguration().getString(MIME_TYPES);
  -            if (path != null)
  -            {
  -                path = getRealPath(path);
  -            }
  -        }
  -        if (path != null)
  -        {
  -            try
  -            {
  -                mimeTypeMap = new MimeTypeMap(path);
  -            }
  -            catch (IOException x)
  -            {
  -                throw new InitializationException(path,x);
  -            }
  -        }
  -        else
  -        {
  -            mimeTypeMap = new MimeTypeMap();
  -        }
  -
  -        if (getConfiguration() != null)
  -        {
  -            path = getConfiguration().getString(CHARSETS);
  -            if (path != null)
  -            {
  -                path = getRealPath(path);
  -            }
  -        }
  -        if (path != null)
  -        {
  -            try
  -            {
  -                charSetMap = new CharSetMap(path);
  -            }
  -            catch (IOException x)
  -            {
  -                throw new InitializationException(path,x);
  -            }
  -        }
  -        else
  -        {
  -            charSetMap = new CharSetMap();
  -        }
  -        setInit(true);
  -    }
  -
  -    /**
        * Sets a MIME content type mapping to extensions to the map.
        * The extension is specified by a MIME type name followed
        * by a list of file name extensions separated by a whitespace.
  @@ -350,5 +302,86 @@
                                String def)
       {
           return charSetMap.getCharSet(key,def);
  +    }
  +
  +    // ---------------- Avalon Lifecycle Methods ---------------------
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void configure(Configuration conf)
  +        throws ConfigurationException
  +    {
  +        if (useOldConfiguration(conf))
  +        {
  +            mimetypePath = getConfiguration().getString("mime.types");
  +            charsetPath = getConfiguration().getString(CHARSETS);
  +        }
  +        else
  +        {
  +            mimetypePath = conf.getAttribute(MIME_TYPES, null);
  +            charsetPath = conf.getAttribute(CHARSETS, null);
  +        }
  +
  +        if (mimetypePath != null)
  +        {
  +            mimetypePath = getRealPath(mimetypePath);
  +        }
  +
  +        if (charsetPath != null)
  +        {
  +            charsetPath = getRealPath(charsetPath);
  +        }
  +    }
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void initialize()
  +        throws InitializationException
  +    {
  +        if (mimetypePath != null)
  +        {
  +            try
  +            {
  +                mimeTypeMap = new MimeTypeMap(mimetypePath);
  +            }
  +            catch (IOException x)
  +            {
  +                throw new InitializationException(mimetypePath,x);
  +            }
  +        }
  +        else
  +        {
  +            mimeTypeMap = new MimeTypeMap();
  +        }
  +
  +        if (charsetPath != null)
  +        {
  +            try
  +            {
  +                charSetMap = new CharSetMap(charsetPath);
  +            }
  +            catch (IOException x)
  +            {
  +                throw new InitializationException(charsetPath,x);
  +            }
  +        }
  +        else
  +        {
  +            charSetMap = new CharSetMap();
  +        }
  +
  +        setInit(true);
  +    }
  +
  +
  +    /**
  +     * The name used to specify this component in TurbineResources.properties 
  +     * @deprecated part of the pre-avalon compatibility layer
  +     */
  +    protected String getName()
  +    {
  +        return "MimeTypeService";
       }
   }
  
  
  
  1.2       +11 -4     jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/naming/NamingService.java
  
  Index: NamingService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/naming/NamingService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NamingService.java	30 May 2002 02:27:25 -0000	1.1
  +++ NamingService.java	4 Nov 2002 05:36:49 -0000	1.2
  @@ -55,7 +55,7 @@
    */
   
   import javax.naming.Context;
  -import org.apache.fulcrum.Service;
  +import org.apache.avalon.framework.component.Component;
   
   /**
    * Implementations of the NamingService interface provide JNDI naming
  @@ -65,9 +65,16 @@
    * @version $Id$
    */
   public interface NamingService
  -    extends Service
  +    extends Component
   {
  -    public static final String SERVICE_NAME = "NamingService";
  +    /** Avalon role - used to id the component within the manager */
  +    String ROLE = NamingService.class.getName();
  +
  +    /** 
  +     * Old style TurbineServices role, now equal to ROLE.
  +     * @deprecated TurbineServices is deprecated in favor of avalon. 
  +     */
  +    String SERVICE_NAME = ROLE;
   
       /**
        * Return the Context with the specified name.
  
  
  
  1.2       +142 -67   jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/naming/TurbineNamingService.java
  
  Index: TurbineNamingService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/naming/TurbineNamingService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TurbineNamingService.java	30 May 2002 02:27:26 -0000	1.1
  +++ TurbineNamingService.java	4 Nov 2002 05:36:49 -0000	1.2
  @@ -60,8 +60,15 @@
   import java.util.Properties;
   import javax.naming.Context;
   import javax.naming.InitialContext;
  -import org.apache.fulcrum.BaseService;
   import org.apache.fulcrum.InitializationException;
  +import org.apache.fulcrum.BaseFulcrumComponent;
  +
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.parameters.Parameters;
  +import org.apache.avalon.framework.thread.ThreadSafe;
   
   /**
    * This class is the default implementation of NamingService, which
  @@ -72,8 +79,8 @@
    * @version $Id$
    */
   public class TurbineNamingService
  -    extends BaseService
  -    implements NamingService
  +    extends BaseFulcrumComponent
  +    implements NamingService, Configurable, Initializable, ThreadSafe
   {
       /**
        * A global HashTable of Property objects which are initialised using
  @@ -84,69 +91,6 @@
       private Hashtable initialContexts = new Hashtable();
   
       /**
  -     * Called the first time the Service is used.<br>
  -     *
  -     */
  -    public void init()
  -        throws InitializationException
  -    {
  -        // Context properties are specified in lines in the properties
  -        // file that begin with "context.contextname.", allowing
  -        // multiple named contexts to be used.  Everything after the
  -        // "contextname."  is the name of the property that will be
  -        // used by the InitialContext class to create a new context
  -        // instance.
  -        try
  -        {
  -            //!! "context" should be a constant.
  -            Iterator contextKeys = getConfiguration().getKeys("context");
  -            contextPropsList = new Hashtable();
  -
  -            while (contextKeys.hasNext())
  -            {
  -                String key = (String) contextKeys.next();
  -                int start = key.indexOf(".") + 1;
  -                int end = key.indexOf(".", start);
  -                String contextName = key.substring(start, end);
  -                Properties contextProps = null;
  -
  -                if (contextPropsList.containsKey(contextName))
  -                {
  -                    contextProps = (Properties)
  -                        contextPropsList.get(contextName);
  -                }
  -                else
  -                {
  -                    contextProps = new Properties();
  -                }
  -
  -                contextProps.put(
  -                    key.substring(end + 1), getConfiguration().getString(key));
  -
  -                contextPropsList.put(contextName, contextProps);
  -            }
  -
  -            Enumeration contextPropsKeys = contextPropsList.keys();
  -            while (contextPropsKeys.hasMoreElements())
  -            {
  -                String key = (String) contextPropsKeys.nextElement();
  -                Properties contextProps = (Properties) contextPropsList.get(key);
  -                InitialContext context = new InitialContext(contextProps);
  -                initialContexts.put(key, context);
  -            }
  -
  -            setInit(true);
  -        }
  -        catch (Exception e)
  -        {
  -            getCategory().error("Failed to initialize JDNI contexts!", e);
  -
  -            throw new InitializationException(
  -                "Failed to initialize JDNI contexts!");
  -        }
  -    }
  -
  -    /**
         * Return the Context with the specified name.  The Context is
         * constructed using the properties for the context with the
         * specified name; ie. those properties that start with
  @@ -180,5 +124,136 @@
           {
               return null;
           }
  +    }
  +
  +    // ---------------- Avalon Lifecycle Methods ---------------------
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void configure(Configuration conf)
  +        throws ConfigurationException
  +    {
  +        if (useOldConfiguration(conf))
  +        {
  +            // Context properties are specified in lines in the properties
  +            // file that begin with "context.contextname.", allowing
  +            // multiple named contexts to be used.  Everything after the
  +            // "contextname."  is the name of the property that will be
  +            // used by the InitialContext class to create a new context
  +            // instance.
  +            try
  +            {
  +                //!! "context" should be a constant.
  +                Iterator contextKeys = getConfiguration().getKeys("context");
  +                contextPropsList = new Hashtable();
  +                
  +                while (contextKeys.hasNext())
  +                {
  +                    String key = (String) contextKeys.next();
  +                    int start = key.indexOf(".") + 1;
  +                    int end = key.indexOf(".", start);
  +                    String contextName = key.substring(start, end);
  +                    Properties contextProps = null;
  +                    
  +                    if (contextPropsList.containsKey(contextName))
  +                    {
  +                        contextProps = (Properties)
  +                            contextPropsList.get(contextName);
  +                    }
  +                    else
  +                    {
  +                        contextProps = new Properties();
  +                    }
  +                    
  +                    contextProps.put(key.substring(end + 1), 
  +                                     getConfiguration().getString(key));
  +                    contextPropsList.put(contextName, contextProps);
  +                }
  +            }
  +            catch (Exception e)
  +            {
  +                getLogger().error("Failed to configure JDNI contexts!", e);
  +                throw new ConfigurationException(
  +                    "Failed to configure JDNI contexts!");
  +            }
  +        }
  +        else
  +        {
  +            Configuration[] keys = conf.getChildren();
  +            if (keys != null) 
  +            {
  +                for (int i=0; i<keys.length; i++) 
  +                {
  +                    String contextName = keys[i].getName();
  +                    Properties contextProps = toProperties( 
  +                        Parameters.fromConfiguration(keys[i]) );
  +
  +                    contextPropsList.put(contextName, contextProps);
  +                }
  +            }
  +        }
  +    }
  +
  +    /**
  +     * Note: this is copied from avalon's Parameter class, which does not
  +     * appear to have the method in the version I'm compiling against.
  +     * Creates a <code>java.util.Properties</code> object from an Avalon
  +     * Parameters object.
  +     *
  +     * @param params a <code>Parameters</code> instance
  +     * @return a <code>Properties</code> instance
  +     */
  +    private static Properties toProperties( final Parameters params )
  +    {
  +        final Properties properties = new Properties();
  +        final String[] names = params.getNames();
  +
  +        for ( int i = 0; i < names.length; ++i )
  +        {
  +            // "" is the default value, since getNames() proves it will exist
  +            properties.setProperty( names[i], params.getParameter( names[i], "" ) );
  +        }
  +
  +        return properties;
  +    }
  +
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void initialize()
  +        throws InitializationException
  +    {
  +        try 
  +        {
  +            Enumeration contextPropsKeys = contextPropsList.keys();
  +            while (contextPropsKeys.hasMoreElements())
  +            {
  +                String key = (String) contextPropsKeys.nextElement();
  +                Properties contextProps = 
  +                    (Properties)contextPropsList.get(key);
  +                InitialContext context = new InitialContext(contextProps);
  +                initialContexts.put(key, context);
  +            }
  +
  +            setInit(true);
  +        }
  +        catch (Exception e)
  +        {
  +            getLogger().error("Failed to initialize JDNI contexts!", e);
  +
  +            throw new InitializationException(
  +                "Failed to initialize JDNI contexts!");
  +        }
  +    }
  +
  +    /**
  +     * The name used to specify this component in TurbineResources.properties 
  +     * @deprecated part of the pre-avalon compatibility layer
  +     */
  +    protected String getName()
  +    {
  +        return "NamingService";
       }
   }
  
  
  
  1.2       +13 -5     jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/pool/PoolService.java
  
  Index: PoolService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/pool/PoolService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PoolService.java	30 May 2002 02:27:26 -0000	1.1
  +++ PoolService.java	4 Nov 2002 05:36:49 -0000	1.2
  @@ -56,6 +56,9 @@
   
   import org.apache.fulcrum.ServiceException;
   import org.apache.fulcrum.factory.FactoryService;
  +import org.apache.avalon.framework.component.Component;
  +
  +
   
   /**
    * The Pool Service extends the Factory Service by adding support
  @@ -72,12 +75,17 @@
    * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
    * @version $Id$
    */
  -public interface PoolService extends FactoryService
  +public interface PoolService 
  +    extends FactoryService
   {
  -    /**
  -     * The key under which this service is stored in TurbineServices.
  +    /** Avalon role - used to id the component within the manager */
  +    String ROLE = PoolService.class.getName();
  +
  +    /** 
  +     * Old style TurbineServices role, now equal to ROLE.
  +     * @deprecated TurbineServices is deprecated in favor of avalon. 
        */
  -    public static final String SERVICE_NAME = "PoolService";
  +    String SERVICE_NAME = ROLE;
   
       /**
        * The default pool capacity.
  
  
  
  1.2       +142 -49   jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/pool/TurbinePoolService.java
  
  Index: TurbinePoolService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/pool/TurbinePoolService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TurbinePoolService.java	30 May 2002 02:27:27 -0000	1.1
  +++ TurbinePoolService.java	4 Nov 2002 05:36:49 -0000	1.2
  @@ -55,16 +55,28 @@
    */
   
   import java.util.HashMap;
  +import java.util.Map;
   import java.util.ArrayList;
   import java.util.Iterator;
   import java.lang.reflect.Method;
   import org.apache.fulcrum.ServiceException;
  -import org.apache.fulcrum.TurbineServices;
  -import org.apache.fulcrum.BaseService;
   import org.apache.fulcrum.InitializationException;
   import org.apache.fulcrum.factory.FactoryService;
   import org.apache.fulcrum.factory.TurbineFactoryService;
   
  +import org.apache.avalon.framework.activity.Disposable;
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.avalon.framework.component.Component;
  +import org.apache.avalon.framework.component.Composable;
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
  +//import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +//import org.apache.avalon.framework.thread.ThreadSafe;
  +//import org.apache.avalon.framework.;
  +
  +
   /**
    * The Pool Service extends the Factory Service by adding support
    * for pooling instantiated objects. When a new instance is
  @@ -81,12 +93,12 @@
    */
   public class TurbinePoolService
       extends TurbineFactoryService
  -    implements PoolService
  +    implements PoolService, Composable, Disposable
   {
       /**
        * The property specifying the pool capacity.
        */
  -    public static final String POOL_CAPACITY = "pool.capacity";
  +    public static final String POOL_CAPACITY = "capacity";
   
       /**
        * An inner class for class specific pools.
  @@ -337,6 +349,11 @@
        */
       private HashMap poolRepository = new HashMap();
   
  +    private Map capacityMap;
  +    private FactoryService factoryService;
  +    private ComponentManager manager;
  +    private boolean disposed;
  +
       /**
        * Constructs a Pool Service.
        */
  @@ -345,37 +362,6 @@
       }
   
       /**
  -     * Initializes the service by setting the pool capacity.
  -     *
  -     * @param config initialization configuration.
  -     * @throws InitializationException if initialization fails.
  -     */
  -    public void init()
  -        throws InitializationException
  -    {
  -        if (getConfiguration() != null)
  -        {
  -            try
  -            {
  -                int capacity =
  -                    getConfiguration().getInt(POOL_CAPACITY,DEFAULT_POOL_CAPACITY);
  -
  -                if (capacity <= 0)
  -                {
  -                    throw new IllegalArgumentException("Capacity must be >0");
  -                }
  -                poolCapacity = capacity;
  -            }
  -            catch (Exception x)
  -            {
  -                throw new InitializationException(
  -                    "Failed to initialize TurbinePoolService",x);
  -            }
  -        }
  -        setInit(true);
  -    }
  -
  -    /**
        * Gets an instance of a named class either from the pool
        * or by calling the Factory Service if the pool is empty.
        *
  @@ -556,19 +542,12 @@
               /* Check class specific capacity. */
               int capacity = poolCapacity;
   
  -            if (getConfiguration() != null)
  +            if (capacityMap != null)
               {
  -                try
  -                {
  -                    capacity = getConfiguration().getInt(
  -                        POOL_CAPACITY + '.' + className,poolCapacity);
  -                    if (capacity <= 0)
  -                    {
  -                        capacity = poolCapacity;
  -                    }
  -                }
  -                catch (Exception x)
  +                Integer cap = (Integer)capacityMap.get(className);
  +                if (cap != null) 
                   {
  +                    capacity = cap.intValue();
                   }
               }
               return capacity;
  @@ -656,7 +635,121 @@
        */
       private FactoryService getFactory()
       {
  -        return (FactoryService) TurbineServices.
  -            getInstance().getService(FactoryService.SERVICE_NAME);
  +        return factoryService;
  +    }
  +
  +
  +    // ---------------- Avalon Lifecycle Methods ---------------------
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void configure(Configuration conf)
  +    {
  +        if (useOldConfiguration(conf))
  +        {
  +            int capacity = getConfiguration()
  +                .getInt("pool.capacity", DEFAULT_POOL_CAPACITY);
  +            if (capacity <= 0)
  +            {
  +                throw new IllegalArgumentException("Capacity must be >0");
  +            }
  +            poolCapacity = capacity;
  +
  +            // FIXME! class specific capacities need to be reimplemented.
  +            //capacity = getConfiguration().getInt(
  +            //    "pool.capacity." + className, poolCapacity);
  +        }
  +        else
  +        {
  +            final Configuration capacities = 
  +                conf.getChild(POOL_CAPACITY, false);
  +            if (capacities != null)
  +            {
  +                Configuration defaultConf = capacities.getChild("default"); 
  +                int capacity =
  +                    defaultConf.getValueAsInteger(DEFAULT_POOL_CAPACITY);
  +                
  +                if (capacity <= 0)
  +                {
  +                    throw new IllegalArgumentException("Capacity must be >0");
  +                }
  +                poolCapacity = capacity;
  +                
  +                Configuration[] nameVal = capacities.getChildren();
  +                for (int i=0; i < nameVal.length; i++)
  +                {
  +                    String key = nameVal[i].getName();
  +                    if (!"default".equals(key)) 
  +                    {
  +                        capacity= nameVal[i].getValueAsInteger(poolCapacity);
  +                        if (capacity < 0) 
  +                        {
  +                            capacity = poolCapacity;
  +                        }
  +                        
  +                        if (capacityMap == null) 
  +                        {
  +                            capacityMap = new HashMap();
  +                        }
  +                        capacityMap.put(key, new Integer(capacity));
  +                    }                
  +                }
  +            }
  +        }
  +    }
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void compose(ComponentManager manager)
  +    {
  +        this.manager = manager;
  +    }
  +
  +    /**
  +     * Avalon component lifecycle method
  +     * Initializes the service by loading default class loaders
  +     * and customized object factories.
  +     *
  +     * @throws InitializationException if initialization fails.
  +     */
  +    public void initialize()
  +        throws InitializationException
  +    {
  +        try 
  +        {
  +            factoryService = 
  +                (FactoryService)manager.lookup(FactoryService.ROLE);
  +            setInit(true);
  +        }
  +        catch (Exception e)
  +        {
  +            throw new InitializationException(
  +                "TurbineCryptoService.init: Failed to get a Factory object",e);
  +        }
  +    }
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void dispose()
  +    {
  +        if (factoryService != null) 
  +        { 
  +            manager.release(factoryService); 
  +        } 
  +        factoryService = null;
  +        manager = null;
  +        disposed = true;
  +    }
  +
  +    /**
  +     * The name used to specify this component in TurbineResources.properties
  +     * @deprecated part of the pre-avalon compatibility layer
  +     */
  +    protected String getName()
  +    {
  +        return "PoolService";
       }
   }
  
  
  
  1.5       +246 -103  jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/security/BaseSecurityService.java
  
  Index: BaseSecurityService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/security/BaseSecurityService.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BaseSecurityService.java	15 Jul 2002 13:32:29 -0000	1.4
  +++ BaseSecurityService.java	4 Nov 2002 05:36:49 -0000	1.5
  @@ -56,9 +56,9 @@
   
   import java.util.Map;
   
  -import org.apache.fulcrum.BaseService;
   import org.apache.fulcrum.InitializationException;
   import org.apache.fulcrum.TurbineServices;
  +import org.apache.fulcrum.BaseFulcrumComponent;
   
   import org.apache.fulcrum.factory.FactoryService;
   
  @@ -76,6 +76,8 @@
   import org.apache.fulcrum.security.util.RoleSet;
   import org.apache.fulcrum.security.util.UnknownEntityException;
   
  +import org.apache.fulcrum.security.impl.db.entity.TurbineUserPeer;
  +
   import org.apache.torque.util.Criteria;
   
   // Classes needed for password encryption
  @@ -83,6 +85,15 @@
   
   import org.apache.commons.codec.base64.Base64;
   
  +import org.apache.avalon.framework.activity.Disposable;
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.component.Composable;
  +import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.thread.ThreadSafe;
  +
   /**
    * This is a common subset of SecurityService implementation.
    *
  @@ -103,10 +114,16 @@
    * @author <a href="mailto:marco@intermeta.de">Marco Kn&uuml;ttel</a>
    * @version $Id$
    */
  +
  +
   public abstract class BaseSecurityService
  -    extends BaseService
  -    implements SecurityService
  +    extends BaseFulcrumComponent
  +    implements SecurityService, Configurable, Initializable, Composable, 
  +               ThreadSafe
   {
  +    private boolean disposed = false; 
  +    private ComponentManager manager = null; 
  +
       // management of Groups/Role/Permissions
   
       /** Holds a list of all groups in the systems, for speeding up the access */
  @@ -121,6 +138,14 @@
       /** The number of threads concurrently reading security information */
       private int readerCount = 0;
   
  +    // temporary storage of the classnames prior to initialization
  +    String userManagerClassName;
  +    String userClassName;
  +    String groupClassName;
  +    String permissionClassName;
  +    String roleClassName;
  +    String aclClassName;
  +
       /** The instance of UserManager the SecurityService uses */
       protected UserManager userManager = null;
   
  @@ -190,8 +215,8 @@
               }
               catch (Exception e)
               {
  -                getCategory().error("Unable to encrypt password");
  -                getCategory().error(e);
  +                getLogger().error("Unable to encrypt password");
  +                getLogger().error("", e);
   
                   return null;
               }
  @@ -203,101 +228,6 @@
       }
   
       /**
  -     * Initializes the SecurityService, locating the apropriate UserManager
  -     *
  -     * @throws InitializationException A Problem occured while initializing the User Manager.
  -     */
  -    public void init()
  -        throws InitializationException
  -    {
  -        String userManagerClassName = getConfiguration().getString(
  -            SecurityService.USER_MANAGER_KEY,
  -            SecurityService.USER_MANAGER_DEFAULT);
  -
  -        String userClassName = getConfiguration().getString(
  -            SecurityService.USER_CLASS_KEY,
  -            SecurityService.USER_CLASS_DEFAULT);
  -
  -        String groupClassName = getConfiguration().getString(
  -            SecurityService.GROUP_CLASS_KEY, 
  -            SecurityService.GROUP_CLASS_DEFAULT);
  -
  -        String permissionClassName = getConfiguration().getString(
  -            SecurityService.PERMISSION_CLASS_KEY, 
  -            SecurityService.PERMISSION_CLASS_DEFAULT);
  -
  -        String roleClassName = getConfiguration().getString(
  -            SecurityService.ROLE_CLASS_KEY, 
  -            SecurityService.ROLE_CLASS_DEFAULT);
  -
  -        String aclClassName = getConfiguration().getString(
  -            SecurityService.ACL_CLASS_KEY, 
  -            SecurityService.ACL_CLASS_DEFAULT);
  -
  -        try
  -        {
  -            userClass = Class.forName(userClassName);
  -            groupClass      = Class.forName(groupClassName);
  -            permissionClass = Class.forName(permissionClassName);
  -            roleClass       = Class.forName(roleClassName);
  -            aclClass        = Class.forName(aclClassName);
  -        }
  -        catch (Exception e)
  -        {
  -            if (userClass == null)
  -            {
  -                throw new InitializationException(
  -                      "Failed to create a Class object for User implementation", e);
  -            }
  -            if (groupClass == null)
  -            {
  -                throw new InitializationException(
  -                      "Failed to create a Class object for Group implementation", e);
  -            }
  -            if (permissionClass == null)
  -            {
  -                throw new InitializationException(
  -                      "Failed to create a Class object for Permission implementation", e);
  -            }
  -            if (roleClass == null)
  -            {
  -            throw new InitializationException(
  -                      "Failed to create a Class object for Role implementation", e);
  -            }
  -            if (aclClass == null)
  -            {
  -                throw new InitializationException(
  -                      "Failed to create a Class object for ACL implementation", e);
  -            }
  -        }
  -
  -        try
  -        {
  -            userManager =  (UserManager) Class.
  -                forName(userManagerClassName).newInstance();
  -        }
  -        catch (Exception e)
  -        {
  -            throw new InitializationException(
  -                "BaseSecurityService.init: Failed to instantiate UserManager", e);
  -        }
  -
  -        try 
  -        {
  -            aclFactoryService = (FactoryService) TurbineServices.getInstance().
  -                getService(FactoryService.SERVICE_NAME);
  -        }
  -        catch (Exception e)
  -        {
  -            throw new InitializationException(
  -                "BaseSecurityService.init: Failed to get the Factory Service object", e);
  -        }
  -
  -
  -        setInit(true);
  -    }
  -
  -    /**
        * Return a Class object representing the system's chosen implementation of
        * of User interface.
        *
  @@ -872,8 +802,8 @@
                       }
                       catch (DataBackendException e)
                       {
  -                        getCategory().error("Failed to retrieve global group object");
  -                        getCategory().error(e);
  +                        getLogger().error("Failed to retrieve global group object");
  +                        getLogger().error("", e);
                       }
                   }
               }
  @@ -994,5 +924,218 @@
           throws DataBackendException
       {
           return getPermissions(new Criteria());
  +    }
  +
  +    // ---------------- Avalon Lifecycle Methods ---------------------
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void configure(Configuration conf)
  +        throws ConfigurationException
  +    {
  +        if (useOldConfiguration(conf))
  +        {
  +            userManagerClassName = getConfiguration().getString(
  +                SecurityService.USER_MANAGER_KEY,
  +                SecurityService.USER_MANAGER_DEFAULT);
  +
  +            userClassName = getConfiguration().getString(
  +                SecurityService.USER_CLASS_KEY,
  +                SecurityService.USER_CLASS_DEFAULT);
  +
  +            groupClassName = getConfiguration().getString(
  +                SecurityService.GROUP_CLASS_KEY, 
  +                SecurityService.GROUP_CLASS_DEFAULT);
  +
  +            permissionClassName = getConfiguration().getString(
  +                SecurityService.PERMISSION_CLASS_KEY, 
  +                SecurityService.PERMISSION_CLASS_DEFAULT);
  +
  +            roleClassName = getConfiguration().getString(
  +                SecurityService.ROLE_CLASS_KEY, 
  +                SecurityService.ROLE_CLASS_DEFAULT);
  +
  +            aclClassName = getConfiguration().getString(
  +                SecurityService.ACL_CLASS_KEY, 
  +                SecurityService.ACL_CLASS_DEFAULT);
  +        }
  +        else
  +        {
  +            userManagerClassName = conf.getAttribute(
  +                SecurityService.USER_MANAGER_KEY,
  +                SecurityService.USER_MANAGER_DEFAULT);
  +
  +            userClassName = conf.getAttribute(
  +                SecurityService.USER_CLASS_KEY,
  +                SecurityService.USER_CLASS_DEFAULT);
  +
  +            groupClassName = conf.getAttribute(
  +                SecurityService.GROUP_CLASS_KEY, 
  +                SecurityService.GROUP_CLASS_DEFAULT);
  +
  +            permissionClassName = conf.getAttribute(
  +                SecurityService.PERMISSION_CLASS_KEY, 
  +                SecurityService.PERMISSION_CLASS_DEFAULT);
  +
  +            roleClassName = conf.getAttribute(
  +                SecurityService.ROLE_CLASS_KEY, 
  +                SecurityService.ROLE_CLASS_DEFAULT);
  +
  +            aclClassName = conf.getAttribute(
  +                SecurityService.ACL_CLASS_KEY, 
  +                SecurityService.ACL_CLASS_DEFAULT);
  +        }
  +    }
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void compose(ComponentManager manager)
  +    {
  +        this.manager = manager;
  +    }
  +
  +    /**
  +     * Avalon component lifecycle method
  +     * Initializes the SecurityService, locating the apropriate UserManager
  +     *
  +     * @throws InitializationException A Problem occured while initializing 
  +     * the User Manager.
  +     */
  +    public void initialize()
  +        throws InitializationException
  +    {        
  +        if (getConfiguration() != null && userManagerClassName == null) 
  +        {
  +            userManagerClassName = getConfiguration().getString(
  +                SecurityService.USER_MANAGER_KEY,
  +                SecurityService.USER_MANAGER_DEFAULT);
  +        }
  +        if (getConfiguration() != null && userClassName == null) 
  +        {
  +            userClassName = getConfiguration().getString(
  +                SecurityService.USER_CLASS_KEY,
  +                SecurityService.USER_CLASS_DEFAULT);
  +        }
  +        if (getConfiguration() != null && groupClassName == null) 
  +        {
  +            groupClassName = getConfiguration().getString(
  +                SecurityService.GROUP_CLASS_KEY, 
  +                SecurityService.GROUP_CLASS_DEFAULT);
  +        }
  +        if (getConfiguration() != null && permissionClassName == null) 
  +        {
  +            permissionClassName = getConfiguration().getString(
  +                SecurityService.PERMISSION_CLASS_KEY, 
  +                SecurityService.PERMISSION_CLASS_DEFAULT);
  +        }
  +        if (getConfiguration() != null && roleClassName == null) 
  +        {
  +            roleClassName = getConfiguration().getString(
  +                SecurityService.ROLE_CLASS_KEY, 
  +                SecurityService.ROLE_CLASS_DEFAULT);
  +        }
  +        if (getConfiguration() != null && aclClassName == null) 
  +        {
  +            aclClassName = getConfiguration().getString(
  +                SecurityService.ACL_CLASS_KEY, 
  +                SecurityService.ACL_CLASS_DEFAULT);
  +        }
  +
  +        try
  +        {
  +            userClass = Class.forName(userClassName);
  +            groupClass      = Class.forName(groupClassName);
  +            permissionClass = Class.forName(permissionClassName);
  +            roleClass       = Class.forName(roleClassName);
  +            aclClass        = Class.forName(aclClassName);
  +        }
  +        catch (Exception e)
  +        {
  +            if (userClass == null)
  +            {
  +                throw new InitializationException(
  +                      "Failed to create a Class object for User implementation", e);
  +            }
  +            if (groupClass == null)
  +            {
  +                throw new InitializationException(
  +                      "Failed to create a Class object for Group implementation", e);
  +            }
  +            if (permissionClass == null)
  +            {
  +                throw new InitializationException(
  +                      "Failed to create a Class object for Permission implementation", e);
  +            }
  +            if (roleClass == null)
  +            {
  +            throw new InitializationException(
  +                      "Failed to create a Class object for Role implementation", e);
  +            }
  +            if (aclClass == null)
  +            {
  +                throw new InitializationException(
  +                      "Failed to create a Class object for ACL implementation", e);
  +            }
  +        }
  +
  +        // Let the peer know which class to create.  Why only user?
  +        TurbineUserPeer.setUserClass(userClass);
  +
  +        try
  +        {
  +            userManager =  (UserManager) Class.
  +                forName(userManagerClassName).newInstance();
  +        }
  +        catch (Exception e)
  +        {
  +            throw new InitializationException(
  +                "BaseSecurityService.init: Failed to instantiate UserManager", e);
  +        }
  +
  +        try 
  +        {
  +            aclFactoryService = 
  +                (FactoryService)manager.lookup(FactoryService.ROLE);
  +        }
  +        catch (Exception e)
  +        {
  +            throw new InitializationException(
  +                "BaseSecurityService.init: Failed to get the Factory Service object", e);
  +        }
  +
  +        userManagerClassName = null;
  +        userClassName = null;
  +        groupClassName = null;
  +        permissionClassName = null;
  +        roleClassName = null;
  +        aclClassName = null;
  +
  +        setInit(true);
  +    }
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void dispose()
  +
  +    {
  +        if (aclFactoryService != null) 
  +        { 
  +            manager.release(aclFactoryService); 
  +        } 
  +        aclFactoryService = null;
  +        manager = null;
  +        setInit(false);
  +    }
  +
  +    /**
  +     * The name used to specify this component in TurbineResources.properties 
  +     * @deprecated part of the pre-avalon compatibility layer
  +     */
  +    protected String getName()
  +    {
  +        return "SecurityService";
       }
   }
  
  
  
  1.4       +6 -5      jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/security/SecurityService.java
  
  Index: SecurityService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/security/SecurityService.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SecurityService.java	9 Jul 2002 13:58:18 -0000	1.3
  +++ SecurityService.java	4 Nov 2002 05:36:49 -0000	1.4
  @@ -56,8 +56,6 @@
   
   import java.util.Map;
   
  -import org.apache.fulcrum.Service;
  -
   import org.apache.fulcrum.security.entity.Group;
   import org.apache.fulcrum.security.entity.Permission;
   import org.apache.fulcrum.security.entity.Role;
  @@ -74,6 +72,8 @@
   
   import org.apache.torque.util.Criteria;
   
  +import org.apache.avalon.framework.component.Component;
  +
   /**
    * The Security Service manages Users, Groups Roles and Permissions in the
    * system.
  @@ -93,10 +93,11 @@
    * @version $Id$
    */
   public interface SecurityService
  -    extends Service
  +    extends Component
   {
  +    String ROLE = SecurityService.class.getName();
       /** The name of the service */
  -    public static final String SERVICE_NAME = "SecurityService";
  +    public static final String SERVICE_NAME = ROLE;
   
       /** the key within services's properties for user implementation classname (user.class) */
       public static final String USER_CLASS_KEY = "user.class";
  
  
  
  1.3       +6 -1      jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/security/impl/db/DBSecurityService.java
  
  Index: DBSecurityService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/security/impl/db/DBSecurityService.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DBSecurityService.java	8 Jul 2002 23:24:08 -0000	1.2
  +++ DBSecurityService.java	4 Nov 2002 05:36:49 -0000	1.3
  @@ -152,6 +152,7 @@
       public AccessControlList getACL( User user )
           throws DataBackendException, UnknownEntityException
       {
  +System.out.println("getting ACL for " + user.getUserName());
           if (!TurbineSecurity.accountExists(user))
           {
               throw new UnknownEntityException("The account '" +
  @@ -167,6 +168,7 @@
   
               // construct the snapshot:
   
  +System.out.println("Total groups= " + getAllGroups().size());
               // foreach group in the system
               Iterator groupsIterator = getAllGroups().elements();
               while(groupsIterator.hasNext())
  @@ -191,6 +193,9 @@
                   // put the Set into permissions(group)
                   permissions.put(group, groupPermissions);
               }
  +
  +System.out.println("permissions: " + permissions.size());
  +
               return getAclInstance(roles, permissions);
           }
           catch(Exception e)
  
  
  
  1.4       +6 -19     jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/security/impl/db/entity/TurbineUserPeer.java
  
  Index: TurbineUserPeer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/security/impl/db/entity/TurbineUserPeer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TurbineUserPeer.java	8 Jul 2002 23:24:08 -0000	1.3
  +++ TurbineUserPeer.java	4 Nov 2002 05:36:49 -0000	1.4
  @@ -81,33 +81,20 @@
   
       public static Class userClass = null;
   
  +    public static void setUserClass(Class userClz)
  +    {
  +        userClass = userClz;
  +    }
  +
       /**
        * The class that the Peer will make instances of.
        * If the BO is abstract then you must implement this method
        * in the BO.
        *
  -     * !! This is duplicated. This method is available in
  -     * the DBSecurityService???
        */
       public static Class getOMClass()
           throws TorqueException
       {
  -        if ( userClass == null )
  -        {
  -            String className = TurbineSecurity.getService()
  -                .getConfiguration().getString("user.class",
  -                    "org.apache.fulcrum.security.impl.db.entity.TurbineUser");
  -
  -            try
  -            {
  -                userClass = Class.forName(className);
  -            }
  -            catch (Exception e)
  -            {
  -                throw new TorqueException(e);
  -            }
  -        }
  -
           return userClass;
       }
   
  
  
  
  1.2       +142 -49   jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/template/BaseTemplateEngineService.java
  
  Index: BaseTemplateEngineService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/template/BaseTemplateEngineService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseTemplateEngineService.java	30 May 2002 02:27:36 -0000	1.1
  +++ BaseTemplateEngineService.java	4 Nov 2002 05:36:49 -0000	1.2
  @@ -58,8 +58,22 @@
   import java.io.Writer;
   import java.util.Iterator;
   import java.util.Hashtable;
  -import org.apache.fulcrum.BaseService;
  +import java.util.List;
  +import java.util.ArrayList;
   import org.apache.fulcrum.ServiceException;
  +import org.apache.fulcrum.ServiceRuntimeException;
  +import org.apache.fulcrum.HasApplicationRoot;
  +
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.thread.ThreadSafe;
  +import org.apache.avalon.framework.activity.Disposable;
  +import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.avalon.framework.component.ComponentException;
  +import org.apache.avalon.framework.component.Composable;
  +
   
   /**
    * The base implementation of Turbine {@link
  @@ -70,9 +84,13 @@
    * @version $Id$
    */
   public abstract class BaseTemplateEngineService
  -    extends BaseService
  -    implements TemplateEngineService
  +    extends HasApplicationRoot
  +    implements TemplateEngineService, Configurable, Initializable, ThreadSafe,
  +               Disposable, Composable
   {
  +    private boolean disposed = false; 
  +    private ComponentManager manager = null; 
  +
       /**
        * A Map containing the configuration for the template
        * engine service. The configuration contains:
  @@ -87,15 +105,6 @@
       private Hashtable configuration = new Hashtable();
   
       /**
  -     * @see org.apache.fulcrum.template.TemplateEngineService#registerConfiguration
  -     */
  -    public void registerConfiguration(String defaultExt)
  -    {
  -        initConfiguration(defaultExt);
  -        TurbineTemplate.registerTemplateEngineService(this);
  -    }
  -
  -    /**
        * @see org.apache.fulcrum.template.TemplateEngineService#getTemplateEngineServiceConfiguration
        */
       public Hashtable getTemplateEngineServiceConfiguration()
  @@ -112,6 +121,56 @@
       }
   
       /**
  +     * @see org.apache.fulcrum.template.TemplateEngineService#templateExists
  +     */
  +    public abstract boolean templateExists(String template);
  +
  +    public abstract String handleRequest(TemplateContext context,
  +                                         String template)
  +        throws ServiceException;
  +
  +    public abstract void handleRequest(TemplateContext context,
  +                                       String template, OutputStream os)
  +        throws ServiceException;
  +
  +    /**
  +     * @see org.apache.fulcrum.template.TemplateEngineService
  +     */
  +    public abstract void handleRequest(TemplateContext context, 
  +                                       String template, Writer writer)
  +        throws ServiceException;
  +
  +    // ---------------- Avalon Lifecycle Methods ---------------------
  +
  +    /**
  +     * Used by subclasses in their configure method
  +     */
  +    protected void registerConfiguration(Configuration conf, String defaultExt)
  +        throws ConfigurationException
  +    {
  +        initConfiguration(conf, defaultExt);
  +        
  +        TemplateService component = null;
  +        try 
  +        { 
  +            component = (TemplateService)manager
  +                .lookup(TemplateService.ROLE); 
  +            component.registerTemplateEngineService(this);
  +        } 
  +        catch (ComponentException ce) 
  +        { 
  +            throw new ServiceRuntimeException(ce.getMessage()); 
  +        } 
  +        finally 
  +        { 
  +            if (component != null) 
  +            { 
  +                manager.release(component); 
  +            } 
  +        } 
  +    }
  +
  +    /**
        * Note engine file extension associations.  First attempts to
        * pull a list of custom extensions from the property file value
        * keyed by <code>template.extension</code>.  If none are defined,
  @@ -122,50 +181,84 @@
        * @param defaultExt The default used when the default defined in the
        *                   properties file is missing or misconfigured.
        */
  -    protected void initConfiguration(String defaultExt)
  +    private void initConfiguration(Configuration conf, String defaultExt)
  +        throws ConfigurationException
       {
  -        /*
  -         * Should modify the configuration class to take defaults
  -         * here, should have to do this.
  -         */
  -        String[] fileExtensionAssociations =
  -            getConfiguration().getStringArray(TEMPLATE_EXTENSIONS);
  -
  -        if (fileExtensionAssociations == null ||
  -            fileExtensionAssociations.length == 0)
  +        if (conf.getAttributeAsBoolean(USE_PROPERTY_FILE, false)) 
           {
  -            fileExtensionAssociations = new String[1];
  -            fileExtensionAssociations[0] = getConfiguration().getString(
  -                DEFAULT_TEMPLATE_EXTENSION, defaultExt);
  -        }
  -
  -        configuration.put(TEMPLATE_EXTENSIONS, fileExtensionAssociations);
  -
  -        configuration.put(DEFAULT_PAGE_TEMPLATE,
  -            getConfiguration().getString(DEFAULT_PAGE_TEMPLATE));
  -
  -        configuration.put(DEFAULT_LAYOUT_TEMPLATE,
  -            getConfiguration().getString(DEFAULT_LAYOUT_TEMPLATE));
  +            /*
  +             * Should modify the configuration class to take defaults
  +             * here, should have to do this.
  +             */
  +            String[] fileExtensionAssociations =
  +                getConfiguration().getStringArray(TEMPLATE_EXTENSIONS);
  +
  +            if (fileExtensionAssociations == null ||
  +                fileExtensionAssociations.length == 0)
  +            {
  +                fileExtensionAssociations = new String[1];
  +                fileExtensionAssociations[0] = getConfiguration().getString(
  +                    DEFAULT_TEMPLATE_EXTENSION, defaultExt);
  +            }
  +
  +            configuration.put(TEMPLATE_EXTENSIONS, fileExtensionAssociations);
  +            
  +            configuration.put(DEFAULT_PAGE_TEMPLATE,
  +                getConfiguration().getString(DEFAULT_PAGE_TEMPLATE));
  +
  +            configuration.put(DEFAULT_LAYOUT_TEMPLATE,
  +                getConfiguration().getString(DEFAULT_LAYOUT_TEMPLATE));
  +        }        
  +        else 
  +        {
  +            List extensionList = new ArrayList();
  +            final Configuration[] extensions = 
  +                conf.getChildren("template-extension");
  +            if (extensions != null)
  +            {
  +                for (int i=0; i < extensions.length; i++)
  +                {
  +                    extensionList.add(extensions[i].getValue());
  +                }
  +            }
  +
  +            String[] fileExtensionAssociations = (String[])
  +                extensionList.toArray(new String[extensionList.size()]);
  +
  +            if (fileExtensionAssociations == null ||
  +                fileExtensionAssociations.length == 0)
  +            {
  +                Configuration defaultConf = 
  +                    conf.getChild("default-template-extension", true);
  +                fileExtensionAssociations = new String[1];
  +                fileExtensionAssociations[0] = 
  +                    defaultConf.getValue(defaultExt);                    
  +            }
  +
  +            configuration.put(TEMPLATE_EXTENSIONS, fileExtensionAssociations);
  +            
  +            configuration.put(DEFAULT_PAGE_TEMPLATE,
  +                conf.getChild("default-page-template", true).getValue());
   
  +            configuration.put(DEFAULT_LAYOUT_TEMPLATE,
  +                conf.getChild("default-layout-template", true).getValue());
  +        }
       }
   
       /**
  -     * @see org.apache.fulcrum.template.TemplateEngineService#templateExists
  +     * Avalon component lifecycle method
        */
  -    public abstract boolean templateExists(String template);
  -
  -    public abstract String handleRequest(TemplateContext context,
  -                                         String template)
  -        throws ServiceException;
  -
  -    public abstract void handleRequest(TemplateContext context,
  -                                       String template, OutputStream os)
  -        throws ServiceException;
  +    public void compose(ComponentManager manager)
  +    {
  +        this.manager = manager;
  +    }
   
       /**
  -     * @see org.apache.fulcrum.template.TemplateEngineService
  +     * Avalon component lifecycle method
        */
  -    public abstract void handleRequest(TemplateContext context, 
  -                                       String template, Writer writer)
  -        throws ServiceException;
  +    public void dispose()
  +    {
  +        manager = null;
  +        disposed = true;
  +    }
   }
  
  
  
  1.2       +3 -3      jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/template/TemplateEngineService.java
  
  Index: TemplateEngineService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/template/TemplateEngineService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TemplateEngineService.java	30 May 2002 02:27:36 -0000	1.1
  +++ TemplateEngineService.java	4 Nov 2002 05:36:49 -0000	1.2
  @@ -78,7 +78,7 @@
        * Return the configuration of the template engine in
        * the form of a Hashtable.
        */
  -    public Hashtable getTemplateEngineServiceConfiguration();
  +    //public Hashtable getTemplateEngineServiceConfiguration();
   
       /**
        * Initializes file extension associations and registers with the
  @@ -87,7 +87,7 @@
        * @param defaultExt The default file extension association to use
        *                   in case of properties file misconfiguration.
        */
  -    public void registerConfiguration(String defaultExt);
  +    //public void registerConfiguration(String defaultExt);
   
       /**
        * Supplies the file extension to key this engine in {@link
  
  
  
  1.2       +6 -7      jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/template/TemplateService.java
  
  Index: TemplateService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/template/TemplateService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TemplateService.java	30 May 2002 02:27:36 -0000	1.1
  +++ TemplateService.java	4 Nov 2002 05:36:49 -0000	1.2
  @@ -56,9 +56,10 @@
   
   import java.io.OutputStream;
   import java.io.Writer;
  -import org.apache.fulcrum.Service;
   import org.apache.fulcrum.ServiceException;
   
  +import org.apache.avalon.framework.component.Component;
  +
   /**
    * This service provides a method for mapping templates to their
    * appropriate Screens or Navigations.  It also allows templates to
  @@ -73,12 +74,10 @@
    * @version $Id$
    */
   public interface TemplateService
  -    extends Service
  +    extends Component
   {
  -    /**
  -     * The key under which this service is stored in TurbineServices.
  -     */
  -    public static final String SERVICE_NAME = "TemplateService";
  +    String ROLE = TemplateService.class.getName();
  +    String SERVICE_NAME = ROLE;
   
       /**
        * The key to the template context.
  
  
  
  1.2       +27 -15    jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/template/TurbineTemplateService.java
  
  Index: TurbineTemplateService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/template/TurbineTemplateService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TurbineTemplateService.java	30 May 2002 02:27:37 -0000	1.1
  +++ TurbineTemplateService.java	4 Nov 2002 05:36:49 -0000	1.2
  @@ -60,9 +60,12 @@
   import java.util.HashMap;
   import java.util.Hashtable;
   import org.apache.fulcrum.ServiceException;
  -import org.apache.fulcrum.BaseService;
   import org.apache.fulcrum.InitializationException;
   import org.apache.fulcrum.template.TemplateContext;
  +import org.apache.fulcrum.HasApplicationRoot;
  +
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.thread.ThreadSafe;
   
   /**
    * This service provides a method for mapping templates to their
  @@ -105,8 +108,8 @@
    * @version $Id$
    */
   public class TurbineTemplateService
  -    extends BaseService
  -    implements TemplateService
  +    extends HasApplicationRoot
  +    implements TemplateService, Initializable, ThreadSafe
   {
       /**
        * The default file extension used as a registry key when a
  @@ -134,17 +137,6 @@
       }
   
       /**
  -     * Called the first time the Service is used.
  -     *
  -     * @exception InitializationException.
  -     */
  -    public void init()
  -        throws InitializationException
  -    {
  -        setInit(true);
  -    }
  -
  -    /**
        * Translates the supplied template paths into their Turbine-canonical
        * equivalent (probably absolute paths).
        *
  @@ -278,5 +270,25 @@
       public TemplateContext getTemplateContext()
       {
           return new DefaultTemplateContext();
  +    }
  +
  +    // ---------------- Avalon Lifecycle Methods ---------------------
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void initialize()
  +        throws InitializationException
  +    {
  +        setInit(true);
  +    }
  +
  +    /** 
  +     * The name used to specify this component in TurbineResources.properties 
  +     * @deprecated part of the pre-avalon compatibility layer
  +     */
  +    protected String getName()
  +    {
  +        return "TemplateService";
       }
   }
  
  
  
  1.2       +189 -105  jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/velocity/TurbineVelocityService.java
  
  Index: TurbineVelocityService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/velocity/TurbineVelocityService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TurbineVelocityService.java	30 May 2002 02:27:39 -0000	1.1
  +++ TurbineVelocityService.java	4 Nov 2002 05:36:49 -0000	1.2
  @@ -57,6 +57,10 @@
   import java.util.Vector;
   import java.util.Iterator;
   import java.util.Enumeration;
  +import java.util.List;
  +import java.util.ArrayList;
  +import java.util.Collections;
  +import java.io.File;
   import java.io.IOException;
   import java.io.OutputStream;
   import java.io.Writer;
  @@ -77,6 +81,9 @@
   import org.apache.fulcrum.template.BaseTemplateEngineService;
   import org.apache.commons.configuration.ConfigurationConverter;
   
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
  +
   /**
    * This is a Service that can process Velocity templates from within a
    * Turbine Screen.  Here's an example of how you might use it from a
  @@ -138,33 +145,14 @@
        */
       private boolean eventCartridgeEnabled = true;
   
  +
  +    // put conf into object to pass to the velocity engine
  +    org.apache.commons.configuration.Configuration velocityConf;
  +
       /**
        * The VelocityEngine used by the service to merge templates
        */
  -    private VelocityEngine velocityEngine = new VelocityEngine();
  -
  -    /**
  -     * Performs early initialization of this Turbine service.
  -     */
  -    public void init()
  -        throws InitializationException
  -    {
  -        try
  -        {
  -            initVelocity();
  -            initEventCartridges();
  -
  -            // Register with the template service.
  -            registerConfiguration("vm");
  -            setInit(true);
  -        }
  -        catch (Exception e)
  -        {
  -            e.printStackTrace();
  -            throw new InitializationException(
  -                "Failed to initialize TurbineVelocityService", e);
  -        }
  -    }
  +    private VelocityEngine velocityEngine;
   
       /**
        * @see org.apache.fulcrum.velocity.VelocityService
  @@ -412,7 +400,7 @@
           throws ServiceException
       {
           String err = "Error rendering Velocity template: " + filename;
  -        getCategory().error(err + ": " + e.getMessage());
  +        getLogger().error(err + ": " + e.getMessage());
           // if the Exception is a MethodInvocationException, the underlying
           // Exception is likely to be more informative, so rewrap that one.
           if (e instanceof MethodInvocationException)
  @@ -424,6 +412,136 @@
       }
   
       /**
  +     * Find out if a given template exists. Velocity
  +     * will do its own searching to determine whether
  +     * a template exists or not.
  +     *
  +     * @param String template to search for
  +     * @return boolean
  +     */
  +    public boolean templateExists(String template)
  +    {
  +        return velocityEngine.templateExists(template);
  +    }
  +
  +    // ---------------- Avalon Lifecycle Methods ---------------------
  +
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void configure(Configuration conf)
  +        throws ConfigurationException
  +    {
  +        // put conf into object to pass to the velocity engine
  +        velocityConf = 
  +            new org.apache.commons.configuration.BaseConfiguration();
  +        List ecconfig = null;
  +        String logPath = null;
  +        List templatePathKeys = new ArrayList();
  +        List templatePaths = new ArrayList();
  +
  +        if (useOldConfiguration(conf))
  +        {
  +            org.apache.commons.configuration.Configuration oldConf =
  +                getConfiguration();
  +
  +            ecconfig = oldConf
  +                .getVector("eventCartridge.classes", new Vector(0));
  +            if (ecconfig.size() == 0)
  +            {
  +                getLogger().info("No Velocity EventCartridges configured.");
  +            }
  +            
  +            // Now we have to perform a couple of path translations
  +            // for our log file and template paths.
  +            logPath = 
  +                oldConf.getString(VelocityEngine.RUNTIME_LOG, null);
  +            if (logPath == null || logPath.length() == 0)
  +            {
  +                String msg = VelocityService.SERVICE_NAME+" runtime log file "+
  +                    "is misconfigured: '" + logPath + "' is not a valid log file";
  +                throw new Error(msg);
  +            }
  +
  +            // Get all the template paths where the velocity
  +            // runtime should search for templates and
  +            // collect them into a separate vector
  +            // to avoid concurrent modification exceptions.
  +            for (Iterator i = oldConf.getKeys(); i.hasNext();)
  +            {
  +                String key = (String) i.next();
  +                if (key.endsWith(RESOURCE_LOADER_PATH))
  +                {
  +                    templatePathKeys.add(key);
  +                    templatePaths.add(oldConf.getVector(key));
  +                }
  +            }
  +
  +        }
  +        else
  +        {
  +            // trick compiler
  +            if (true) 
  +            {
  +                throw new ConfigurationException(
  +                    "Use of avalon-style configuration not completed yet");   
  +            }
  +            
  +            final Configuration eventCartridgeConfs = 
  +                conf.getChild("event-cartriges", false);
  +            if (eventCartridgeConfs == null)
  +            {
  +                ecconfig = Collections.EMPTY_LIST; 
  +            }
  +            else
  +            {
  +                Configuration[] classNameConfs = 
  +                    eventCartridgeConfs.getChildren("classname");
  +                if (classNameConfs == null)
  +                {
  +                    ecconfig = Collections.EMPTY_LIST; 
  +                }
  +                else 
  +                {
  +                    ecconfig = new ArrayList(classNameConfs.length);
  +                    for (int i=0; i < classNameConfs.length; i++)
  +                    {
  +                        ecconfig.add(classNameConfs[i].getValue());
  +                    }
  +                }
  +            }
  +
  +            /*
  +            final Configuration pathConfs = 
  +                conf.getChild("event-cartriges", false);
  +            if (pathConfs != null)
  +            {
  +                Configuration[] nameVal = ecConfs.getChildren();
  +                for (int i=0; i < nameVal.length; i++)
  +                {
  +                    String key = nameVal[i].getName();
  +                    String val = nameVal[i].getValue();
  +                }
  +            }
  +            */
  +        }
  +
  +        initEventCartridges(ecconfig);
  +
  +        // check if path to logfile needs translation to webapp root 
  +        if ( !(new File(logPath).isAbsolute()) ) 
  +        {
  +            logPath = getRealPath(logPath);
  +        }
  +        velocityConf.setProperty(VelocityEngine.RUNTIME_LOG, logPath);
  +
  +        configureTemplatePaths(templatePathKeys, templatePaths);
  +
  +        // Register with the template service.
  +        registerConfiguration(conf, "vm");
  +    }
  +
  +    /**
        * This method is responsible for initializing the various Velocity
        * EventCartridges. You just add a configuration like this:
        * <code>
  @@ -432,24 +550,15 @@
        * and list out (comma separated) the list of EC's that you want to
        * initialize.
        */
  -    private void initEventCartridges()
  -        throws InitializationException
  +    private void initEventCartridges(List ecconfig)
  +        throws ConfigurationException
       {
           eventCartridge = new EventCartridge();
  -
  -        Vector ecconfig = getConfiguration()
  -            .getVector("eventCartridge.classes", null);
  -        if (ecconfig == null)
  -        {
  -            getCategory().info("No Velocity EventCartridges configured.");
  -            return;
  -        }
  -
           Object obj = null;
           String className = null;
  -        for (Enumeration e = ecconfig.elements() ; e.hasMoreElements() ;)
  +        for (Iterator i = ecconfig.iterator() ; i.hasNext() ;)
           {
  -            className = (String) e.nextElement();
  +            className = (String)i.next();
               try
               {
                   boolean result = false;
  @@ -471,13 +580,13 @@
                       result = getEventCartridge()
                           .addEventHandler((MethodExceptionEventHandler)obj);
                   }
  -                getCategory().info("Added EventCartridge: " +
  +                getLogger().info("Added EventCartridge: " +
                       obj.getClass().getName() + " : " + result);
               }
               catch (Exception h)
               {
  -                throw new InitializationException(
  -                    "Could not initialize EventCartridge: " +
  +                throw new ConfigurationException(
  +                    "Could not configure EventCartridge: " +
                       className, h);
               }
           }
  @@ -487,65 +596,28 @@
        * Setup the velocity runtime by using a subset of the
        * Turbine configuration which relates to velocity.
        *
  -     * @exception InitializationException For any errors during initialization.
  +     * @exception ConfigurationException For any errors during initialization.
        */
  -    private void initVelocity()
  -        throws InitializationException
  +    private void configureTemplatePaths(
  +        List templatePathKeys, List templatePaths)
       {
  -        // Now we have to perform a couple of path translations
  -        // for our log file and template paths.
  -        String path = getRealPath(
  -            getConfiguration().getString(VelocityEngine.RUNTIME_LOG, null));
  -
  -        if (path != null && path.length() > 0)
  -        {
  -            getConfiguration().setProperty(VelocityEngine.RUNTIME_LOG, path);
  -        }
  -        else
  -        {
  -            String msg = VelocityService.SERVICE_NAME + " runtime log file " +
  -                "is misconfigured: '" + path + "' is not a valid log file";
  -
  -            throw new Error(msg);
  -        }
  -
  -        // Get all the template paths where the velocity
  -        // runtime should search for templates and
  -        // collect them into a separate vector
  -        // to avoid concurrent modification exceptions.
  -        String key;
  -        Vector keys = new Vector();
  -        for (Iterator i = getConfiguration().getKeys(); i.hasNext();)
  -        {
  -            key = (String) i.next();
  -            if (key.endsWith(RESOURCE_LOADER_PATH))
  -            {
  -                keys.add(key);
  -            }
  -        }
  -
           // Loop through all template paths, clear the corresponding
           // velocity properties and translate them all to the webapp space.
  -        int ind;
  -        Vector paths;
  -        String entry;
  -        for (Iterator i = keys.iterator(); i.hasNext();)
  +        for (int i=0; i<templatePathKeys.size(); i++)
           {
  -            key = (String) i.next();
  -            paths = getConfiguration().getVector(key,null);
  +            String key = (String) templatePathKeys.get(i);
  +            Vector paths = (Vector) templatePaths.get(i);
               if (paths != null)
               {
  -                velocityEngine.clearProperty(key);
  -                getConfiguration().clearProperty(key);
  -
  +                String entry;
                   for (Iterator j = paths.iterator(); j.hasNext();)
                   {
  -                    path = (String) j.next();
  +                    String path = (String) j.next();
                       if (path.startsWith(JAR_PREFIX + "file"))
                       {
                           // A local jar resource URL path is a bit more
                           // complicated, but we can translate it as well.
  -                        ind = path.indexOf("!/");
  +                        int ind = path.indexOf("!/");
                           if (ind >= 0)
                           {
                               entry = path.substring(ind);
  @@ -570,38 +642,50 @@
                           path = getRealPath(path);
                       }
                       // Put the translated paths back to the configuration.
  -                    getConfiguration().addProperty(key,path);
  +                    velocityConf.addProperty(key,path);
                   }
               }
           }
  +    }
   
  +    /**
  +     * Avalon component lifecycle method
  +     */
  +    public void initialize()
  +        throws InitializationException
  +    {
           try
           {
  -            velocityEngine.setExtendedProperties(ConfigurationConverter
  -                    .getExtendedProperties(getConfiguration()));
  +            velocityEngine = new VelocityEngine();
  +            
  +            // clear the property to prepare for new value, 
  +            //is this needed?
  +            Iterator i = velocityConf.getKeys();
  +            while (i.hasNext()) 
  +            {            
  +                velocityEngine.clearProperty((String)i.next());
  +            }
   
  +            velocityEngine.setExtendedProperties(ConfigurationConverter
  +                    .getExtendedProperties(velocityConf));
               velocityEngine.init();
  +            velocityConf = null;
  +            setInit(true);
           }
  -        catch(Exception e)
  +        catch (Exception e)
           {
  -            // This will be caught and rethrown by the init() method.
  -            // Oh well, that will protect us from RuntimeException folk showing
  -            // up somewhere above this try/catch
  +            e.printStackTrace();
               throw new InitializationException(
  -                "Failed to set up TurbineVelocityService", e);
  +                "Failed to initialize TurbineVelocityService", e);
           }
       }
   
  -    /**
  -     * Find out if a given template exists. Velocity
  -     * will do its own searching to determine whether
  -     * a template exists or not.
  -     *
  -     * @param String template to search for
  -     * @return boolean
  +    /** 
  +     * The name used to specify this component in TurbineResources.properties 
  +     * @deprecated part of the pre-avalon compatibility layer
        */
  -    public boolean templateExists(String template)
  +    protected String getName()
       {
  -        return velocityEngine.templateExists(template);
  +        return "VelocityService";
       }
   }
  
  
  
  1.2       +7 -3      jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/velocity/VelocityService.java
  
  Index: VelocityService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/java/org/apache/fulcrum/velocity/VelocityService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- VelocityService.java	30 May 2002 02:27:39 -0000	1.1
  +++ VelocityService.java	4 Nov 2002 05:36:49 -0000	1.2
  @@ -62,6 +62,8 @@
   import org.apache.velocity.context.Context;
   import org.apache.velocity.app.event.EventCartridge;
   
  +import org.apache.avalon.framework.component.Component;
  +
   /**
    * The Turbine service interface to
    * <a href="http://jakarta.apache.org/velocity/">Velocity</a>.
  @@ -72,9 +74,11 @@
    * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
    * @version $Id$
    */
  -public interface VelocityService extends Service
  +public interface VelocityService 
  +    extends Component
   {
  -    public static final String SERVICE_NAME = "VelocityService";
  +    String ROLE = VelocityService.class.getName();
  +    String SERVICE_NAME = ROLE;
   
       /**
        * Process the request and fill in the template using the values
  
  
  
  1.2       +11 -33    jakarta-turbine-fulcrum/src/test/org/apache/fulcrum/crypto/CryptoDefaultTest.java
  
  Index: CryptoDefaultTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/test/org/apache/fulcrum/crypto/CryptoDefaultTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CryptoDefaultTest.java	14 Aug 2002 14:18:09 -0000	1.1
  +++ CryptoDefaultTest.java	4 Nov 2002 05:36:49 -0000	1.2
  @@ -58,52 +58,30 @@
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
   
  -import org.apache.commons.configuration.BaseConfiguration;
  -import org.apache.commons.configuration.Configuration;
  -
  -import org.apache.fulcrum.ServiceManager;
  -import org.apache.fulcrum.TurbineServices;
  -
   import org.apache.fulcrum.factory.FactoryService; 
   import org.apache.fulcrum.factory.TurbineFactoryService; 
   
  +import org.apache.fulcrum.FulcrumContainer;
  +import org.apache.avalon.framework.context.DefaultContext;
  +
   public class CryptoDefaultTest
       extends TestCase
   {
  -    private static final String PREFIX = "services." +
  -        CryptoService.SERVICE_NAME + '.';
  -
       private static final String preDefinedInput = "Oeltanks";
   
       public CryptoDefaultTest( String name )
  +        throws Exception
       {
           super(name);
   
  -        ServiceManager serviceManager = TurbineServices.getInstance();
  -        serviceManager.setApplicationRoot(".");
  -        
  -        Configuration cfg = new BaseConfiguration();
  -        cfg.setProperty(PREFIX + "classname",
  -                        TurbineCryptoService.class.getName());
  -
  -        /* No providers configured. Should be "java" then */
  -
  -        /* Ugh */
  -
  -        cfg.setProperty("services." + FactoryService.SERVICE_NAME + ".classname",
  -                        TurbineFactoryService.class.getName());
  -
  -        serviceManager.setConfiguration(cfg);
  +        FulcrumContainer fulcrum = new FulcrumContainer();
  +        DefaultContext ctx = new DefaultContext();
  +        ctx.put(fulcrum.APP_ROOT, ".");
  +        ctx.put(fulcrum.CONF_XML, 
  +            "<fulcrum-services><crypto/><factory/></fulcrum-services>");
   
  -        try
  -        {
  -            serviceManager.init();
  -        }
  -        catch (Exception e)
  -        {
  -            e.printStackTrace();
  -            fail();
  -        }
  +        fulcrum.contextualize(ctx);
  +        fulcrum.initialize();
       }
   
       public static Test suite()
  
  
  
  1.2       +18 -43    jakarta-turbine-fulcrum/src/test/org/apache/fulcrum/crypto/CryptoTest.java
  
  Index: CryptoTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/test/org/apache/fulcrum/crypto/CryptoTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CryptoTest.java	14 Aug 2002 14:18:09 -0000	1.1
  +++ CryptoTest.java	4 Nov 2002 05:36:49 -0000	1.2
  @@ -61,9 +61,6 @@
   import org.apache.commons.configuration.BaseConfiguration;
   import org.apache.commons.configuration.Configuration;
   
  -import org.apache.fulcrum.ServiceManager;
  -import org.apache.fulcrum.TurbineServices;
  -
   import org.apache.fulcrum.factory.FactoryService; 
   import org.apache.fulcrum.factory.TurbineFactoryService; 
   
  @@ -72,55 +69,33 @@
   import org.apache.fulcrum.crypto.provider.JavaCrypt;
   import org.apache.fulcrum.crypto.provider.OldJavaCrypt;
   
  +import org.apache.fulcrum.FulcrumContainer;
  +import org.apache.avalon.framework.context.DefaultContext;
  +
   public class CryptoTest
       extends TestCase
   {
  -    private static final String PREFIX = "services." +
  -        CryptoService.SERVICE_NAME + '.';
  -
       private static final String preDefinedInput = "Oeltanks";
   
       public CryptoTest( String name )
  +        throws Exception
       {
           super(name);
   
  -        ServiceManager serviceManager = TurbineServices.getInstance();
  -        serviceManager.setApplicationRoot(".");
  -        
  -        Configuration cfg = new BaseConfiguration();
  -        cfg.setProperty(PREFIX + "classname",
  -                        TurbineCryptoService.class.getName());
  -
  -        cfg.setProperty(PREFIX + "algorithm.unix",
  -                        UnixCrypt.class.getName());
  -        cfg.setProperty(PREFIX + "algorithm.clear",
  -                        ClearCrypt.class.getName());
  -        cfg.setProperty(PREFIX + "algorithm.java",
  -                        JavaCrypt.class.getName());
  -        cfg.setProperty(PREFIX + "algorithm.oldjava",
  -                        OldJavaCrypt.class.getName());
  -
  -        /* Do _not_ configure a default! We want to test explicitly */
  -
  -        cfg.setProperty(PREFIX + "algorithm.default",
  -                        "none");
  -
  -        /* Ugh */
  -
  -        cfg.setProperty("services." + FactoryService.SERVICE_NAME + ".classname",
  -                        TurbineFactoryService.class.getName());
  -
  -        serviceManager.setConfiguration(cfg);
  -
  -        try
  -        {
  -            serviceManager.init();
  -        }
  -        catch (Exception e)
  -        {
  -            e.printStackTrace();
  -            fail();
  -        }
  +        FulcrumContainer fulcrum = new FulcrumContainer();
  +        DefaultContext ctx = new DefaultContext();
  +        ctx.put(fulcrum.APP_ROOT, ".");
  +        ctx.put(fulcrum.CONF_XML, 
  +            "<fulcrum-services><crypto><algorithm>" +
  +                "<unix>" + UnixCrypt.class.getName() + "</unix>" +
  +                "<clear>" + ClearCrypt.class.getName() + "</clear>" +
  +                "<java>" + JavaCrypt.class.getName() + "</java>" +
  +                "<oldjava>" + OldJavaCrypt.class.getName() + "</oldjava>" +
  +                "<default>none</default>" +
  +            "</algorithm></crypto><factory/></fulcrum-services>");
  +
  +        fulcrum.contextualize(ctx);
  +        fulcrum.initialize();
       }
   
       public static Test suite()
  
  
  
  1.8       +17 -8     jakarta-turbine-fulcrum/src/test/org/apache/fulcrum/localization/LocalizationTest.java
  
  Index: LocalizationTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/test/org/apache/fulcrum/localization/LocalizationTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- LocalizationTest.java	15 Jul 2002 10:02:37 -0000	1.7
  +++ LocalizationTest.java	4 Nov 2002 05:36:50 -0000	1.8
  @@ -68,6 +68,9 @@
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
   
  +import org.apache.fulcrum.FulcrumContainer;
  +import org.apache.avalon.framework.context.DefaultContext;
  +
   /**
    * Tests the API of the
    * {@link org.apache.fulcrum.localization.LocalizationService}.
  @@ -79,8 +82,7 @@
   public class LocalizationTest
       extends TestCase
   {
  -    private static final String PREFIX = "services." +
  -        LocalizationService.SERVICE_NAME + '.';
  +    private static final String PREFIX = "services.LocalizationService.";
   
       public LocalizationTest(String name)
       {
  @@ -96,20 +98,27 @@
       {
           try
           {
  -            ServiceManager serviceManager = TurbineServices.getInstance();
  -            serviceManager.setApplicationRoot(".");
  -
               Configuration cfg = new BaseConfiguration();
  -            cfg.setProperty(PREFIX + "classname",
  -                            TurbineLocalizationService.class.getName());
  +            //cfg.setProperty(PREFIX + "classname",
  +            //                TurbineLocalizationService.class.getName());
               cfg.setProperty(PREFIX + "locale.default.bundles",
                               "org.apache.fulcrum.localization.FooBundle,org.apache.fulcrum.localization.MissingBundle,org.apache.fulcrum.localization.BarBundle");
               cfg.setProperty(PREFIX + "locale.default.language", "en");
               cfg.setProperty(PREFIX + "locale.default.country", "US");
   
  +            ServiceManager serviceManager = TurbineServices.getInstance();
  +            serviceManager.setApplicationRoot(".");
               serviceManager.setConfiguration(cfg);
  -
               serviceManager.init();
  +
  +            FulcrumContainer fulcrum = new FulcrumContainer();
  +            DefaultContext ctx = new DefaultContext();
  +            ctx.put(fulcrum.APP_ROOT, ".");
  +            ctx.put(fulcrum.CONF_XML, 
  +                    "<fulcrum-services><localization use-property-file=\"true\"/></fulcrum-services>");
  +            ctx.put(fulcrum.PROP_CONF, cfg);
  +            fulcrum.contextualize(ctx);
  +            fulcrum.initialize();
   
               // Test retrieval of text using multiple default bundles
               String s = Localization.getString(null, null, "key1");
  
  
  
  1.2       +13 -13    jakarta-turbine-fulcrum/src/test/org/apache/fulcrum/security/AccessControlListTest.java
  
  Index: AccessControlListTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/test/org/apache/fulcrum/security/AccessControlListTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AccessControlListTest.java	15 Jul 2002 09:51:18 -0000	1.1
  +++ AccessControlListTest.java	4 Nov 2002 05:36:50 -0000	1.2
  @@ -77,6 +77,9 @@
   
   import org.apache.fulcrum.security.impl.db.DBSecurityService;
   
  +import org.apache.fulcrum.FulcrumContainer;
  +import org.apache.avalon.framework.context.DefaultContext;
  +
   public class AccessControlListTest
       extends TestCase
   {
  @@ -103,28 +106,25 @@
       public void doit()
           throws Exception
       {
  -        ServiceManager serviceManager = TurbineServices.getInstance();
  -        serviceManager.setApplicationRoot(".");
  -
           Configuration cfg = new BaseConfiguration();
  -
  -        cfg.setProperty(PREFIX + "classname", 
  -                        DBSecurityService.class.getName());
  -
           cfg.setProperty(PREFIX + "acl.class", 
                           TurbineAccessControlList.class.getName());
   
           // We must run init! 
           cfg.setProperty(PREFIX+"earlyInit", "true");
   
  -        /* Ugh */
  -
  -        cfg.setProperty("services." + FactoryService.SERVICE_NAME + ".classname",
  -                        TurbineFactoryService.class.getName());
  -
  +        ServiceManager serviceManager = TurbineServices.getInstance();
  +        serviceManager.setApplicationRoot(".");
           serviceManager.setConfiguration(cfg);
  -
           serviceManager.init();
  +
  +        FulcrumContainer fulcrum = new FulcrumContainer();
  +        DefaultContext ctx = new DefaultContext();
  +        ctx.put(fulcrum.APP_ROOT, ".");
  +        ctx.put(fulcrum.CONF_XML, 
  +            "<fulcrum-services><factory/><security class=\"org.apache.fulcrum.security.impl.db.DBSecurityService\"/></fulcrum-services>");
  +        fulcrum.contextualize(ctx);
  +        fulcrum.initialize();
   
           Class aclClass = TurbineSecurity.getService().getAclClass();
   
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>