cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components CocoonSourceResolver.java CocoonComponentManager.java
Date Wed, 13 Mar 2002 14:50:57 GMT
cziegeler    02/03/13 06:50:57

  Modified:    src/java/org/apache/cocoon/components
                        CocoonComponentManager.java
  Added:       lib/core avalon-excalibur-20020313.jar
                        avalon-scratchpad-20020313.jar
               src/java/org/apache/cocoon/components
                        CocoonSourceResolver.java
  Removed:     lib/core avalon-excalibur-4.1.jar
                        avalon-scratchpad-20020212.jar
  Log:
  Updating to latest avalon excalibur and (finally) starting to integrate the new avalon source
resolving
  
  Revision  Changes    Path
  1.1                  xml-cocoon2/lib/core/avalon-excalibur-20020313.jar
  
  	<<Binary file>>
  
  
  1.1                  xml-cocoon2/lib/core/avalon-scratchpad-20020313.jar
  
  	<<Binary file>>
  
  
  1.10      +19 -7     xml-cocoon2/src/java/org/apache/cocoon/components/CocoonComponentManager.java
  
  Index: CocoonComponentManager.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/CocoonComponentManager.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- CocoonComponentManager.java	22 Feb 2002 07:00:06 -0000	1.9
  +++ CocoonComponentManager.java	13 Mar 2002 14:50:57 -0000	1.10
  @@ -56,23 +56,25 @@
   import java.util.Map;
   import java.util.Stack;
   import org.apache.avalon.excalibur.component.ExcaliburComponentManager;
  +import org.apache.avalon.excalibur.source.SourceResolver;
   import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.component.ComponentException;
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.Recomposable;
   import org.apache.cocoon.ProcessingException;
  +import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.environment.Source;
  -import org.apache.cocoon.environment.SourceResolver;
   
   import org.xml.sax.SAXException;
   
   /**
    * Cocoon Component Manager.
    * This manager extends the <code>ExcaliburComponentManager</code>
  - * by a special lifecycle handling for a RequestLifecycleComponent.
  + * by a special lifecycle handling for a RequestLifecycleComponent
  + * and by handling the lookup of the <code>SourceResolver</code> (in development)
    *
    * @author <a href="mailto:cziegeler@org.com">Carsten Ziegeler</a>
  - * @version CVS $Id: CocoonComponentManager.java,v 1.9 2002/02/22 07:00:06 cziegeler Exp
$
  + * @version CVS $Id: CocoonComponentManager.java,v 1.10 2002/03/13 14:50:57 cziegeler Exp
$
    */
   public final class CocoonComponentManager
   extends ExcaliburComponentManager
  @@ -110,7 +112,7 @@
       /**
        * This hook must be called by the sitemap each time a sitemap is entered
        */
  -    public static void enterEnvironment(SourceResolver resolver, Map objectModel) {
  +    public static void enterEnvironment(Environment env, Map objectModel) {
           if (environmentStack.get() == null) {
               environmentStack.set(new Stack());
           }
  @@ -118,11 +120,11 @@
           if ( !stack.empty() ) {
               final Object[] objects = (Object[])stack.peek();
               if ( objects[1] == objectModel ) {
  -                stack.push(new Object[] {resolver, objectModel, objects[2], TWO});
  +                stack.push(new Object[] {env, objectModel, objects[2], TWO});
                   return;
               }
           }
  -        stack.push(new Object[] {resolver, objectModel, new HashMap(5), ONE});
  +        stack.push(new Object[] {env, objectModel, new HashMap(5), ONE});
       }
   
       /**
  @@ -162,6 +164,12 @@
                       return component;
                   }
               }
  +
  +            if ( role.equals(SourceResolver.ROLE) ) {
  +                SourceResolver resolver = (SourceResolver) super.lookup( role );
  +                // wrap resolver here:
  +                return new CocoonSourceResolver((Environment)objects[0], resolver);
  +            }
           }
   
           final Component component = super.lookup( role );
  @@ -175,7 +183,7 @@
                   if (component instanceof Recomposable) {
                       ((Recomposable) component).recompose(this);
                   }
  -                ((RequestLifecycleComponent) component).setup((SourceResolver)objects[0],
  +                ((RequestLifecycleComponent) component).setup((org.apache.cocoon.environment.SourceResolver)objects[0],
                                                                 (Map)objects[1]);
               } catch (Exception local) {
                   throw new ComponentException("Exception during setup of RequestLifecycleComponent
with role '"+role+"'", local);
  @@ -195,6 +203,10 @@
           }
   
           if ( component instanceof RequestLifecycleComponent) {
  +            return;
  +        }
  +        if ( component instanceof CocoonSourceResolver ) {
  +            super.release(((CocoonSourceResolver)component).getSourceResolver());
               return;
           }
           super.release( component);
  
  
  
  1.1                  xml-cocoon2/src/java/org/apache/cocoon/components/CocoonSourceResolver.java
  
  Index: CocoonSourceResolver.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.cocoon.components;
  
  import org.apache.avalon.excalibur.source.Source;
  import org.apache.avalon.excalibur.source.SourceResolver;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.cocoon.environment.Environment;
  import java.io.IOException;
  import java.net.MalformedURLException;
  import java.util.Map;
  
  
  /**
   * This SourceResolver enables the relative resolving and the special cocoon
   * protocol.
   *
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version $Id: CocoonSourceResolver.java,v 1.1 2002/03/13 14:50:57 cziegeler Exp $
   */
  public final class CocoonSourceResolver
  implements SourceResolver {
  
      /** The real SourceResolver */
      private SourceResolver resolver;
  
      /** The current environment */
      private Environment environment;
  
      /** Constructor */
      public CocoonSourceResolver(Environment environment,
                                  SourceResolver resolver) {
          this.environment = environment;
          this.resolver = resolver;
      }
  
      /**
       * Get a <code>Source</code> object.
       */
      public Source resolve(String location)
      throws MalformedURLException, IOException, ComponentException {
          return this.resolve(location, null, null);
      }
  
      /**
       * Get a <code>Source</code> object.
       */
      public Source resolve(String location,
                            String baseURI,
                            Map    parameters)
      throws MalformedURLException, IOException, ComponentException {
          return this.resolver.resolve(location, baseURI, parameters);
      }
  
      /**
       * Releases a resolved resource
       */
      public void release( Source source ) {
          this.resolver.release( source );
      }
  
      /**
       * Get the real SourceResolver
       */
      public SourceResolver getSourceResolver() {
          return this.resolver;
      }
  }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message