cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.2/src/java/org/apache/cocoon/components/pipeline AbstractProcessingPipeline.java
Date Wed, 07 Jan 2004 15:57:30 GMT
cziegeler    2004/01/07 07:57:30

  Modified:    src/java/org/apache/cocoon/bean CocoonBean.java
               src/java/org/apache/cocoon/components/pipeline
                        AbstractProcessingPipeline.java
  Added:       src/java/org/apache/cocoon/components/container
                        DefaultSitemapConfigurationHolder.java
                        ComponentLocatorImpl.java
                        SitemapConfigurableCreator.java
                        CocoonComponentManager.java ComponentContext.java
                        CocoonContainer.java
                        RequestLifestyleComponentHandler.java
                        RequestLifecycleHelper.java
  Removed:     src/java/org/apache/cocoon/components
                        DefaultSitemapConfigurationHolder.java
                        RequestLifecycleHelper.java
                        RequestLifestyleComponentHandler.java
                        SitemapConfigurableAccessor.java
                        CocoonComponentManager.java ComponentContext.java
                        CocoonContainer.java ComponentLocatorImpl.java
  Log:
  Move all container (fortress) related classes into a single package.
  This way we can simply mark the whole package as internal only
  
  Revision  Changes    Path
  1.46      +4 -4      cocoon-2.2/src/java/org/apache/cocoon/bean/CocoonBean.java
  
  Index: CocoonBean.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/bean/CocoonBean.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- CocoonBean.java	7 Jan 2004 13:21:23 -0000	1.45
  +++ CocoonBean.java	7 Jan 2004 15:57:30 -0000	1.46
  @@ -69,9 +69,9 @@
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.cocoon.CompilingProcessor;
   import org.apache.cocoon.Constants;
  -import org.apache.cocoon.components.CocoonContainer;
  -import org.apache.cocoon.components.ComponentContext;
  -import org.apache.cocoon.components.SitemapConfigurableAccessor;
  +import org.apache.cocoon.components.container.CocoonContainer;
  +import org.apache.cocoon.components.container.ComponentContext;
  +import org.apache.cocoon.components.container.SitemapConfigurableCreator;
   
   /**
    * CocoonBean does XYZ
  @@ -326,7 +326,7 @@
       private LifecycleExtensionManager getLifecycleExtensionManager()
       {
           LifecycleExtensionManager manager = new LifecycleExtensionManager();
  -        manager.addCreatorExtension(new SitemapConfigurableAccessor());
  +        manager.addCreatorExtension(new SitemapConfigurableCreator());
   
           return manager;
       }
  
  
  
  1.1                  cocoon-2.2/src/java/org/apache/cocoon/components/container/DefaultSitemapConfigurationHolder.java
  
  Index: DefaultSitemapConfigurationHolder.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 Cocoon" and  "Apache Software Foundation" 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", 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 (INCLU-
   DING, 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 and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.container;
  
  import java.util.HashMap;
  import java.util.Map;
  
  import org.apache.cocoon.components.ChainedConfiguration;
  import org.apache.cocoon.components.SitemapConfigurationHolder;
  import org.apache.cocoon.environment.EnvironmentHelper;
  
  /**
   * This is the implementation for the sitemap configuration holder that implements
   * the the sitemap component configurations
   * 
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version CVS $Id: DefaultSitemapConfigurationHolder.java,v 1.1 2004/01/07 15:57:30 cziegeler Exp $
   */
  public final class DefaultSitemapConfigurationHolder
      implements SitemapConfigurationHolder {
  
      /** The role of the sitemap component */
      private String role;
  
      /** The prepared configurations indexed by the ChainedConfiguration */
      private Map preparedConfigurations;
  
      public DefaultSitemapConfigurationHolder(String role) {
          this.role = role;
      }
  
      /**
       * @see SitemapConfigurationHolder#getConfiguration()
       */
      public ChainedConfiguration getConfiguration() {
          Map confs = EnvironmentHelper.getCurrentProcessor().getComponentConfigurations();
          return (ChainedConfiguration) (confs == null ? null : confs.get(this.role));
      }
  
      /**
       * @see SitemapConfigurationHolder#getPreparedConfiguration()
       */
      public Object getPreparedConfiguration() {
          if ( null != this.preparedConfigurations ) {
              ChainedConfiguration conf = this.getConfiguration();
              if ( null != conf ) {
                  return this.preparedConfigurations.get( conf );
              }
          }
          return null;
      }
  
      /**
       * @see SitemapConfigurationHolder#setPreparedConfiguration(ChainedConfiguration, java.lang.Object)
       */
      public void setPreparedConfiguration(ChainedConfiguration configuration,
                                            Object preparedConfig) {
          if ( null == this.preparedConfigurations ) {
              this.preparedConfigurations = new HashMap(5);
          }
          this.preparedConfigurations.put(configuration, preparedConfig);
      }
  
  }
  
  
  
  1.1                  cocoon-2.2/src/java/org/apache/cocoon/components/container/ComponentLocatorImpl.java
  
  Index: ComponentLocatorImpl.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 Cocoon" and  "Apache Software Foundation" 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", 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 (INCLU-
   DING, 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 and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.container;
  
  import org.apache.avalon.framework.service.ServiceException;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.cocoon.components.ComponentLocator;
  
  /**
   * This object is set to a {@link ParentAware} component and allows
   * access to the parent component.
   *
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version CVS $Id: ComponentLocatorImpl.java,v 1.1 2004/01/07 15:57:30 cziegeler Exp $
   */
  public class ComponentLocatorImpl
      implements ComponentLocator {
  
      protected ServiceManager manager;
      protected String           role;
  
      public ComponentLocatorImpl(ServiceManager manager, String role) {
          this.manager = manager;
          this.role = role;
      }
  
      public Object lookup()
      throws ServiceException {
          return this.manager.lookup( this.role );
      }
  
      public void release(Object parent) {
          this.manager.release( parent);
      }
  }
  
  
  
  1.1                  cocoon-2.2/src/java/org/apache/cocoon/components/container/SitemapConfigurableCreator.java
  
  Index: SitemapConfigurableCreator.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 Cocoon" and  "Apache Software Foundation" 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", 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 (INCLU-
   DING, 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 and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.container;
  
  import org.apache.avalon.fortress.ContainerManagerConstants;
  import org.apache.avalon.fortress.MetaInfoManager;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.avalon.lifecycle.Creator;
  import org.apache.cocoon.components.SitemapConfigurable;
  import org.apache.cocoon.components.SitemapConfigurationHolder;
  
  import java.util.HashMap;
  import java.util.Map;
  
  /**
   * SitemapConfigurableCreator is the Lifecycle extension for [@link SitemapConfigurable}
   *
   * @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
   * @author <a href="cziegeler@apache.org">Carsten Ziegeler</a>
   * @version CVS $ Revision: 1.1 $
   */
  public class SitemapConfigurableCreator 
  implements Creator {
  
      /** 
       * The {@link SitemapConfigurationHolder}s 
       */
      private Map m_sitemapConfigurationHolders = new HashMap( 15 );
  
      /* (non-Javadoc)
       * @see org.apache.avalon.lifecycle.Creator#create(java.lang.Object, org.apache.avalon.framework.context.Context)
       */
      public void create(Object object, Context context) 
      throws Exception {
          if ( object instanceof SitemapConfigurable ) {
              ServiceManager manager = (ServiceManager) context.get(ContainerManagerConstants.SERVICE_MANAGER);
              MetaInfoManager metaInfoManager = (MetaInfoManager)manager.lookup(MetaInfoManager.ROLE);
              try {
                  String role = metaInfoManager.getMetaInfoForClassname(object.getClass().getName()).getConfigurationName();
                  SitemapConfigurationHolder holder;
                  
                  holder = (SitemapConfigurationHolder) m_sitemapConfigurationHolders.get( role );
                  if ( null == holder ) {
                      // create new holder
                      holder = new DefaultSitemapConfigurationHolder( role );
                      m_sitemapConfigurationHolders.put( role, holder );
                  }
                  
                  ( (SitemapConfigurable) object ).configure( holder );
              } finally {
                  manager.release(metaInfoManager);
              }
          }
      }
  
      /* (non-Javadoc)
       * @see org.apache.avalon.lifecycle.Creator#destroy(java.lang.Object, org.apache.avalon.framework.context.Context)
       */
      public void destroy(Object object, Context context) {
      }
  
  }
  
  
  
  1.1                  cocoon-2.2/src/java/org/apache/cocoon/components/container/CocoonComponentManager.java
  
  Index: CocoonComponentManager.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 Cocoon" and  "Apache Software Foundation" 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", 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 (INCLU-
   DING, 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 and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.container;
  
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.avalon.framework.service.ServiceSelector;
  import org.apache.cocoon.ProcessingException;
  
  /**
   * Cocoon Component Manager.
   * This class is just only used for auto-releasing components.
   * Auto-releasing is currently required for the RequestLifeCycle Components
   * and the pipeline implementations.
   * 
   * WARNING: This is a "private" Cocoon core class - do NOT use this class
   * directly - and do not assume that a {@link org.apache.avalon.framework.service.ServiceManager} you get
   * via the compose() method is an instance of CocoonComponentManager.
   *
   * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj&ouml;rn L&uuml;tkemeier</a>
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version CVS $Id: CocoonComponentManager.java,v 1.1 2004/01/07 15:57:30 cziegeler Exp $
   */
  public final class CocoonComponentManager
  {
  
      /**
       * Add an automatically released component
       */
      public static void addComponentForAutomaticRelease(final ServiceSelector selector,
                                                         final Object          component,
                                                         final ServiceManager  manager)
      throws ProcessingException {
          RequestLifecycleHelper.addComponentForAutomaticRelease(selector, component, manager);
      }
  
      /**
       * Add an automatically released component
       */
      public static void addComponentForAutomaticRelease(final ServiceManager manager,
                                                         final Object         component)
      throws ProcessingException {
          RequestLifecycleHelper.addComponentForAutomaticRelease(manager, component);
      }
  
      /**
       * Remove from automatically released components
       */
      public static void removeFromAutomaticRelease(final Object component)
      throws ProcessingException {
          RequestLifecycleHelper.removeFromAutomaticRelease(component);
      }
  }
  
  
  
  
  
  1.1                  cocoon-2.2/src/java/org/apache/cocoon/components/container/ComponentContext.java
  
  Index: ComponentContext.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 Cocoon" and  "Apache Software Foundation" 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", 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 (INCLU-
   DING, 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 and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.container;
  
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.DefaultContext;
  import org.apache.cocoon.components.ContextHelper;
  import org.apache.cocoon.environment.EnvironmentHelper;
  
  import java.util.Map;
  
  /**
   * This is the {@link Context} implementation for Cocoon components.
   * It extends the {@link DefaultContext} by a special handling for
   * getting objects from the object model.
   *
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version CVS $Id: ComponentContext.java,v 1.1 2004/01/07 15:57:30 cziegeler Exp $
   */
  
  public class ComponentContext
      extends DefaultContext {
  
      protected static final String OBJECT_MODEL_KEY_PREFIX = ContextHelper.CONTEXT_OBJECT_MODEL + '.';
  
      /**
       * Create a Context with specified data and parent.
       *
       * @param contextData the context data
       * @param parent the parent Context (may be null)
       */
      public ComponentContext(final Map contextData, final Context parent) {
          super( contextData, parent );
      }
  
      /**
       * Create a Context with specified data.
       *
       * @param contextData the context data
       */
      public ComponentContext(final Map contextData) {
          super( contextData );
      }
  
      /**
       * Create a Context with specified parent.
       *
       * @param parent the parent Context (may be null)
       */
      public ComponentContext(final Context parent) {
          super( parent );
      }
  
      /**
       * Create a Context with no parent.
       *
       */
      public ComponentContext() {
          super();
      }
  
      /**
       * Retrieve an item from the Context.
       *
       * @param key the key of item
       * @return the item stored in context
       * @throws ContextException if item not present
       */
      public Object get( final Object key )
      throws ContextException {
          if ( key.equals(ContextHelper.CONTEXT_OBJECT_MODEL)) {
              return EnvironmentHelper.getCurrentEnvironmentContext().getEnvironment().getObjectModel();
          }
          if ( key instanceof String ) {
              String stringKey = (String)key;
              if ( stringKey.startsWith(OBJECT_MODEL_KEY_PREFIX) ) {
                  final Map objectModel = EnvironmentHelper.getCurrentEnvironmentContext().getEnvironment().getObjectModel();
                  String objectKey = stringKey.substring(OBJECT_MODEL_KEY_PREFIX.length());
  
                  Object o = objectModel.get( objectKey );
                  if ( o == null ) {
                      final String message = "Unable to locate " + key;
                      throw new ContextException( message );
                  }
                  return o;
              }
          }
          return super.get( key );
      }
  
  }
  
  
  
  1.1                  cocoon-2.2/src/java/org/apache/cocoon/components/container/CocoonContainer.java
  
  Index: CocoonContainer.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 Cocoon" and  "Apache Software Foundation" 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", 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 (INCLU-
   DING, 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 and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.container;
  
  import org.apache.avalon.fortress.impl.AbstractContainer;
  import org.apache.avalon.fortress.impl.DefaultContainer;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.service.ServiceException;
  import org.apache.cocoon.Constants;
  
  import java.util.Map;
  
  /**
   * Customize the Fortress container to handle Cocoon semantics.
   *
   * @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
   * @version CVS $ Revision: 1.1 $
   */
  public class CocoonContainer extends DefaultContainer
  {
      /**
       * Provide some validation for the core Cocoon components
       *
       * @param conf The configuration
       * @throws ConfigurationException if the coniguration is invalid
       */
      public void configure( Configuration conf ) throws ConfigurationException
      {
          if ( !"cocoon".equals( conf.getName() ) ) throw new ConfigurationException( "Invalid configuration format",
                  conf );
          String confVersion = conf.getAttribute( "version" );
  
          if ( !Constants.CONF_VERSION.equals( confVersion ) ) throw new ConfigurationException(
                  "Uncompatible configuration format", conf );
  
          super.configure( conf );
      }
  
      /**
       * Ensure that we return the latest and greatest component for the role/hint combo if possible.
       * Otherwise default to normal behavior.
       *
       * @param role The role of the component we are looking up.
       * @param hint The hint for the component we are looking up.
       * @return The component for the role/hint combo
       * @throws ServiceException if the role/hint combo cannot be resolved.
       */
      public Object get( final String role, final Object hint ) throws ServiceException
      {
          Object component = null;
  
          if ( null != hint
               && !AbstractContainer.DEFAULT_ENTRY.equals( hint )
               && !AbstractContainer.SELECTOR_ENTRY.equals( hint ) )
          {
              Map implementations = (Map) m_mapper.get( role );
              if ( null != implementations )
              {
                  component = implementations.get( hint );
              }
          }
  
          if ( null == component )
          {
              component = super.get( role, hint );
          }
  
          return component;
      }
  }
  
  
  
  1.1                  cocoon-2.2/src/java/org/apache/cocoon/components/container/RequestLifestyleComponentHandler.java
  
  Index: RequestLifestyleComponentHandler.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 Cocoon" and  "Apache Software Foundation" 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", 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 (INCLU-
   DING, 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 and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.container;
  
  import org.apache.avalon.fortress.impl.handler.AbstractComponentHandler;
  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.service.ServiceException;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.cocoon.components.GlobalRequestLifecycleComponent;
  import org.apache.cocoon.components.RequestLifecycleComponent;
  import org.apache.excalibur.mpool.Pool;
  import org.apache.excalibur.mpool.PoolManager;
  
  
  /**
   * RequestLifestyleComponentHandler does XYZ
   *
   * @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
   * @version CVS $ Revision: 1.1 $
   */
  public class RequestLifestyleComponentHandler 
  extends AbstractComponentHandler 
  implements Configurable {
      private static int lastInstance = 0;
  
      /** The instance of the PoolManager to create the Pool for the Handler */
      private PoolManager m_poolManager;
  
      /** The pool of components for <code>Poolable</code> Components */
      private Pool m_pool;
  
      /** The Config element for the poolable */
      private int m_poolMin;
  
      private String m_role = generateRole();
  
      /**
       * Application of suporting services to the handler.
       * @param serviceManager the service manager
       * @exception ServiceException if a service related error occurs
       * @avalon.dependency type="PoolManager"
       */
      public void service( final ServiceManager serviceManager )
              throws ServiceException
      {
          super.service( serviceManager );
          m_poolManager =
          (PoolManager) serviceManager.lookup( PoolManager.ROLE );
      }
  
      /**
       * Configuration of the handler under which the minimum pool size
       * is established.
       * @param configuration the configuration fragment
       * @exception ConfigurationException if the supplied configuration attribute
       *    for 'pool-min' cannot be resolved to an integer value
       */
      public void configure( final Configuration configuration )
              throws ConfigurationException
      {
          m_poolMin = configuration.getAttributeAsInteger( "pool-min", 10 );
      }
  
      /**
       * Initialize the ComponentHandler.
       * @exception Exception if an error occurs
       */
      protected void doPrepare()
              throws Exception
      {
          m_pool = m_poolManager.getManagedPool( m_factory, m_poolMin );
      }
  
      /**
       * Get a reference of the desired Component
       * @exception Exception if an error occurs
       */
      protected Object doGet()
      throws Exception {
          EnvironmentDescription desc = RequestLifecycleHelper.getEnvironmentDescription();
          if ( null != desc ) {
              if ( null != desc ) {
                  Object component = desc.getRequestLifecycleComponent( m_role );
                  if ( null != component )
                  {
                      return component;
                  }
                  component = desc.getGlobalRequestLifecycleComponent( m_role );
                  if ( null != component )
                  {
                      return component;
                  }
              }
          }
  
          final Object component = m_pool.acquire();
          if ( null != component && component instanceof RequestLifecycleComponent )
          {
              if ( desc == null )
              {
                  throw new ServiceException( m_role, "ComponentManager has no Environment Stack." );
              }
  
              // first test if the parent CM has already initialized this component
              if ( !desc.containsRequestLifecycleComponent( m_role ) )
              {
                  try
                  {   // FIXME - we need a source resolver here!
                      ( (RequestLifecycleComponent) component ).setup(
                              null,
                              desc.objectModel );
                  }
                  catch ( Exception local )
                  {
                      throw new ServiceException( m_role, "Exception during setup of RequestLifecycleComponent.", local );
                  }
                  desc.addRequestLifecycleComponent( m_role, component, this );
              }
          }
  
          if ( null != component && component instanceof GlobalRequestLifecycleComponent )
          {
              if ( desc == null  )
              {
                  throw new ServiceException( m_role, "ComponentManager has no Environment Stack." );
              }
  
              // first test if the parent CM has already initialized this component
              if ( !desc.containsGlobalRequestLifecycleComponent( m_role ) )
              {
                  try
                  {   // FIXME - we need a source resolver here!
                      ( (GlobalRequestLifecycleComponent) component ).setup(
                              null,
                              desc.objectModel );
                  }
                  catch ( Exception local )
                  {
                      throw new ServiceException( m_role, "Exception during setup of RequestLifecycleComponent.", local );
                  }
                  desc.addGlobalRequestLifecycleComponent( m_role, component, this );
              }
          }
  
          return component;
      }
  
      /**
       * Return a reference of the desired Component
       * @param component the component to return to the handler
       */
      protected void doPut( final Object component )
      {}
  
      void release( final Object component )
      {
          m_pool.release( component );
      }
  
      private static synchronized String generateRole()
      {
          return "component" + lastInstance++;
      }
  }
  
  
  
  1.1                  cocoon-2.2/src/java/org/apache/cocoon/components/container/RequestLifecycleHelper.java
  
  Index: RequestLifecycleHelper.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 Cocoon" and  "Apache Software Foundation" 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", 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 (INCLU-
   DING, 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 and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.container;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  
  import org.apache.avalon.fortress.impl.handler.ComponentHandler;
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.avalon.framework.service.ServiceSelector;
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.components.GlobalRequestLifecycleComponent;
  import org.apache.cocoon.environment.Environment;
  import org.apache.cocoon.environment.EnvironmentContext;
  import org.apache.cocoon.environment.EnvironmentHelper;
  
  /**
   * RequestLifecycleHelper Encapsulates all the static processing that is needed
   * for handling RequestLifecycle components.
   * 
   * @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
   * @version CVS $ Revision: 1.1 $
   */
  class RequestLifecycleHelper {
  
      static final String KEY = RequestLifecycleHelper.class.getName();
  
      static EnvironmentDescription getEnvironmentDescription() {
          final EnvironmentContext context =
              EnvironmentHelper.getCurrentEnvironmentContext();
          EnvironmentDescription desc =
              (EnvironmentDescription) context.getAttribute(KEY);
          if (desc == null) {
              desc = new EnvironmentDescription(context.getEnvironment());
              context.addAttribute(KEY, desc);
          }
          return desc;
      }
  
      /**
  	 * Add an automatically released component
  	 */
      static void addComponentForAutomaticRelease(final ServiceManager manager,
                                                 final Object component)
      throws ProcessingException {
          EnvironmentDescription desc = getEnvironmentDescription();
          if (null != desc) {
              desc.addToAutoRelease(manager, component);
          }
      }
  
      /**
       * Add an automatically released component
       */
      static void addComponentForAutomaticRelease(final ServiceSelector selector,
                                                 final Object component,
                                                  final ServiceManager manager)
      throws ProcessingException {
          EnvironmentDescription desc = getEnvironmentDescription();
          if (null != desc) {
              desc.addToAutoRelease(manager, component);
          }
      }
  
      /**
  	 * Remove from automatically released components
  	 */
      public static void removeFromAutomaticRelease(final Object component)
          throws ProcessingException {
          EnvironmentDescription desc = getEnvironmentDescription();
          if (null != desc) {
              desc.removeFromAutoRelease(component);
          }
      }
  }
  
  final class EnvironmentDescription implements Disposable {
      Environment environment;
      Map objectModel;
      Map requestLifecycleComponents;
      List autoreleaseComponents = new ArrayList(4);
  
      /**
  	 * Constructor
  	 */
      EnvironmentDescription(Environment env) {
          this.environment = env;
          this.objectModel = env.getObjectModel();
      }
  
      Map getGlobalRequestLifcecycleComponents() {
          Map m =
              (Map) environment.getAttribute(
                  GlobalRequestLifecycleComponent.class.getName());
          if (m == null) {
              m = new HashMap();
              environment.setAttribute(
                  GlobalRequestLifecycleComponent.class.getName(),
                  m);
          }
          return m;
      }
  
      /**
  	 * Release all components of this environment All
  	 * RequestLifecycleComponents and autoreleaseComponents are released.
  	 */
      public void dispose() {
          if (this.requestLifecycleComponents != null) {
              final Iterator iter =
                  this.requestLifecycleComponents.values().iterator();
              while (iter.hasNext()) {
                  final Object[] o = (Object[]) iter.next();
                  final Object component = o[0];
                  ((ComponentHandler) o[1]).put(component);
              }
              this.requestLifecycleComponents.clear();
          }
  
          for (int i = 0; i < autoreleaseComponents.size(); i++) {
              final Object[] o = (Object[]) autoreleaseComponents.get(i);
              final Object component = o[0];
              final ComponentHandler handler = (ComponentHandler) o[1];
              handler.put(component);
          }
          this.autoreleaseComponents.clear();
          this.environment = null;
          this.objectModel = null;
      }
  
      /**
  	 * Add a RequestLifecycleComponent to the environment
  	 */
      void addRequestLifecycleComponent(
          final String role,
          final Object co,
          final ComponentHandler manager) {
          if (this.requestLifecycleComponents == null) {
              this.requestLifecycleComponents = new HashMap();
          }
          this.requestLifecycleComponents.put(role, new Object[] { co, manager });
      }
  
      /**
  	 * Add a GlobalRequestLifecycleComponent to the environment
  	 */
      void addGlobalRequestLifecycleComponent(
          final String role,
          final Object co,
          final ComponentHandler manager) {
          this.getGlobalRequestLifcecycleComponents().put(
              role,
              new Object[] { co, manager });
      }
  
      /**
  	 * Do we already have a request lifecycle component
  	 */
      boolean containsRequestLifecycleComponent(final String role) {
          if (this.requestLifecycleComponents == null) {
              return false;
          }
          return this.requestLifecycleComponents.containsKey(role);
      }
  
      /**
  	 * Do we already have a global request lifecycle component
  	 */
      boolean containsGlobalRequestLifecycleComponent(final String role) {
          return this.getGlobalRequestLifcecycleComponents().containsKey(role);
      }
  
      /**
  	 * Search a RequestLifecycleComponent
  	 */
      Object getRequestLifecycleComponent(final String role) {
          if (this.requestLifecycleComponents == null) {
              return null;
          }
          final Object[] o = (Object[]) this.requestLifecycleComponents.get(role);
          if (null != o) {
              return o[0];
          }
          return null;
      }
  
      /**
  	 * Search a GlobalRequestLifecycleComponent
  	 */
      Object getGlobalRequestLifecycleComponent(final String role) {
          final Object[] o =
              (Object[]) this.getGlobalRequestLifcecycleComponents().get(role);
          if (null != o) {
              return o[0];
          }
          return null;
      }
  
      /**
       * Add an automatically released component
       */
      void addToAutoRelease(final ServiceSelector selector,
                            final Object          component,
                            final ServiceManager  manager) {
          this.autoreleaseComponents.add(new Object[] {component, selector, manager});
      }
  
      /**
  	 * Add an automatically released component
  	 */
      void addToAutoRelease(final ServiceManager manager,
                            final Object component) {
          this.autoreleaseComponents.add(new Object[] { component, manager });
      }
  
      /**
  	 * Remove from automatically released components
  	 */
      void removeFromAutoRelease(final Object component)
      throws ProcessingException {
          int i = 0;
          boolean found = false;
          while (i < this.autoreleaseComponents.size() && !found) {
              final Object[] o = (Object[]) this.autoreleaseComponents.get(i);
              if (o[0] == component) {
                  found = true;
                  if (o[1] instanceof ServiceManager) {
                      ((ServiceManager)o[1]).release( component );
                  } else {
                      ((ServiceSelector)o[1]).release( component );
                      if (o[2] != null) {
                          ((ServiceManager)o[2]).release( o[1] );
                      }
                  }
                  this.autoreleaseComponents.remove(i);
              } else {
                  i++;
              }
          }
          if (!found) {
              throw new ProcessingException("Unable to remove component from automatic release: component not found.");
          }
      }
  }
  
  
  
  1.23      +2 -2      cocoon-2.2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
  
  Index: AbstractProcessingPipeline.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- AbstractProcessingPipeline.java	5 Jan 2004 08:16:01 -0000	1.22
  +++ AbstractProcessingPipeline.java	7 Jan 2004 15:57:30 -0000	1.23
  @@ -69,7 +69,7 @@
   import org.apache.cocoon.ConnectionResetException;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.Processor;
  -import org.apache.cocoon.components.CocoonComponentManager;
  +import org.apache.cocoon.components.container.CocoonComponentManager;
   import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.environment.EnvironmentHelper;
   import org.apache.cocoon.environment.ObjectModelHelper;
  
  
  

Mime
View raw message