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 CocoonComponentManager.java
Date Wed, 20 Nov 2002 09:19:16 GMT
cziegeler    2002/11/20 01:19:16

  Modified:    src/java/org/apache/cocoon/components/source/impl
                        SitemapSource.java
               src/java/org/apache/cocoon/components
                        CocoonComponentManager.java
  Log:
  Improvement for RequestLifecycleComponents
  
  Revision  Changes    Path
  1.22      +3 -2      xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
  
  Index: SitemapSource.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- SitemapSource.java	16 Nov 2002 21:01:54 -0000	1.21
  +++ SitemapSource.java	20 Nov 2002 09:19:16 -0000	1.22
  @@ -396,6 +396,7 @@
               // Preserve original exception
               throw e;
           } catch (Exception e) {
  +            e.printStackTrace();
               throw new SAXException("Exception during processing of "
                                             + this.systemId, e);
           } finally {
  @@ -404,11 +405,11 @@
       }
   
       private void reset() {
  +        if (this.processingPipeline != null) this.processingPipeline.release();
           if (this.processKey != null) {
               CocoonComponentManager.endProcessing(this.processKey);
               this.processKey = null;
           }
  -        if (this.processingPipeline != null) this.processingPipeline.release();
           this.processingPipeline = null;
           this.sourceValidity = null;
           if (this.redirectSource != null) this.environment.release(this.redirectSource);
  
  
  
  1.37      +21 -57    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.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- CocoonComponentManager.java	16 Nov 2002 21:01:54 -0000	1.36
  +++ CocoonComponentManager.java	20 Nov 2002 09:19:16 -0000	1.37
  @@ -65,6 +65,7 @@
   import org.apache.avalon.framework.component.ComponentSelector;
   import org.apache.avalon.framework.component.Recomposable;
   import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.DefaultConfiguration;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.Processor;
   import org.apache.cocoon.environment.Environment;
  @@ -90,12 +91,10 @@
       private static final String PROCESS_KEY =
                  "org.apache.cocoon.components.CocoonComponentManager";
            
  +    
       /** The environment information */
       private static InheritableThreadLocal environmentStack = new InheritableThreadLocal();
   
  -    /** The processing information */
  -    private static InheritableThreadLocal processList = new InheritableThreadLocal();
  -    
       /** The configured <code>SourceResolver</code> */
       private SourceResolver sourceResolver;
   
  @@ -138,7 +137,7 @@
           final Stack stack = (Stack)environmentStack.get();
           stack.push(new Object[] {env, processor});
           
  -        EnvironmentDescription desc = getDescription(objectModel);
  +        EnvironmentDescription desc = (EnvironmentDescription)objectModel.get(PROCESS_KEY);
           if ( null != desc ) {
               desc.addSitemapConfiguration(processor.getComponentConfigurations());
           }
  @@ -151,6 +150,10 @@
           final Stack stack = (Stack)environmentStack.get();
           if (null != stack && !stack.empty()) {
               final Object[] objects = (Object[])stack.pop();
  +            EnvironmentDescription desc = (EnvironmentDescription)((Environment)objects[0]).getObjectModel().get(PROCESS_KEY);
  +            if ( null != desc ) {
  +                desc.removeLastSitemapConfiguration();
  +            }
           }
       }
   
  @@ -161,23 +164,9 @@
        * @return A unique key within this thread.
        */
       public static Object startProcessing(Environment env) {
  -        Map processes = (Map)processList.get();
  -        
  -        if (processes == null) {
  -            processes = new HashMap(4);
  -            processList.set(processes);
  -        }
           EnvironmentDescription desc = new EnvironmentDescription(env);
  -        Object key = new Long(System.currentTimeMillis());
  -        // unique test (this is currently a sanity check
  -        // perhaps it's not needed - if it's needed we
  -        // have to improve it for performance
  -        while (processes.containsKey(key)) {
  -        	key = "A" + key;
  -        }
  -        processes.put(key, desc);
  -        env.getObjectModel().put(PROCESS_KEY, key);
  -        return key;
  +        env.getObjectModel().put(PROCESS_KEY, desc);
  +        return desc;
       }
       
       /**
  @@ -188,14 +177,8 @@
        *         {@link startProcessing(Environment)}.
        */
       public static void endProcessing(Object key) {
  -        Map processes = (Map)processList.get();
  -        if ( null != processes ) {
  -            EnvironmentDescription desc = (EnvironmentDescription)processes.get(key);
  -            if ( null != desc ) {
  -                desc.release();
  -                processes.remove(key);            
  -            }
  -        }
  +        EnvironmentDescription desc = (EnvironmentDescription)key;
  +        desc.release();
       }
       
       /**
  @@ -246,7 +229,7 @@
           if ( null != stack && !stack.empty()) {
               final Object[] objects = (Object[])stack.peek();
               final Map objectModel = ((Environment)objects[0]).getObjectModel();
  -            EnvironmentDescription desc = getDescription(objectModel);
  +            EnvironmentDescription desc = (EnvironmentDescription)objectModel.get(PROCESS_KEY);
               if ( null != desc ) {
                   final Component component = desc.getRequestLifecycleComponent(role);
                   if (null != component) {
  @@ -262,7 +245,7 @@
               }
               final Object[] objects = (Object[]) stack.peek();
               final Map objectModel = ((Environment)objects[0]).getObjectModel();
  -            EnvironmentDescription desc = getDescription(objectModel);
  +            EnvironmentDescription desc = (EnvironmentDescription)objectModel.get(PROCESS_KEY);
               if ( null != desc ) {
   
                   // first test if the parent CM has already initialized this component
  @@ -335,7 +318,7 @@
           if ( null != stack && !stack.empty()) {
               final Object[] objects = (Object[])stack.firstElement();
               final Map objectModel = ((Environment)objects[0]).getObjectModel();
  -            EnvironmentDescription desc = getDescription(objectModel);
  +            EnvironmentDescription desc = (EnvironmentDescription)objectModel.get(PROCESS_KEY);
               if ( null != desc ) {
                   desc.addToAutoRelease(selector, component, manager);
               }
  @@ -354,7 +337,7 @@
           if ( null != stack && !stack.empty()) {
               final Object[] objects = (Object[])stack.firstElement();
               final Map objectModel = ((Environment)objects[0]).getObjectModel();
  -            EnvironmentDescription desc = getDescription(objectModel);
  +            EnvironmentDescription desc = (EnvironmentDescription)objectModel.get(PROCESS_KEY);
               if ( null != desc ) {
                   desc.addToAutoRelease(manager, component);
               }
  @@ -372,7 +355,7 @@
           if ( null != stack && !stack.empty()) {
               final Object[] objects = (Object[])stack.firstElement();
               final Map objectModel = ((Environment)objects[0]).getObjectModel();
  -            EnvironmentDescription desc = getDescription(objectModel);
  +            EnvironmentDescription desc = (EnvironmentDescription)objectModel.get(PROCESS_KEY);
               if ( null != desc ) {
                   desc.removeFromAutoRelease(component);
               }
  @@ -424,26 +407,17 @@
           this.sourceResolver.release( source );
       }
   
  -    private static EnvironmentDescription getDescription(Map objectModel) {
  -        Object processKey = objectModel.get(PROCESS_KEY);
  -        if ( null != processKey) {
  -            Map processes = (Map)CocoonComponentManager.processList.get();
  -            if ( null != processes) {
  -                return (EnvironmentDescription)processes.get(processKey);
  -            }
  -        }
  -        return null;
  -    }
  -    
   }
   
   final class EnvironmentDescription {
       
  +    private static final Configuration EMPTY_CONFIGURATION = 
  +            new DefaultConfiguration("config", "");
  +    
       Environment environment;
       Map         objectModel;
       Map         requestLifecycleComponents = new HashMap(5);
       List        autoreleaseComponents      = new ArrayList(2);
  -    List        sitemapConfigurations      = new ArrayList(4);
       
       /**
        * Constructor
  @@ -549,15 +523,5 @@
               throw new ProcessingException("Unable to remove component from automatic release:
component not found.");
           }
       }
  -        
  -    void addSitemapConfiguration(Configuration conf) {
  -        if (conf != null) {
  -            this.sitemapConfigurations.add(conf);
  -        }
  -    }
  -    
  -    List getSitemapConfigurations() {
  -        return this.sitemapConfigurations;
  -    }
  -    
  +            
   }
  
  
  

----------------------------------------------------------------------
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