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.1/src/java/org/apache/cocoon/components CocoonComponentManager.java
Date Sat, 26 Apr 2003 14:06:50 GMT
cziegeler    2003/04/26 07:06:50

  Modified:    src/java/org/apache/cocoon/environment
                        AbstractEnvironment.java
               src/java/org/apache/cocoon/components/treeprocessor
                        TreeProcessor.java
               src/java/org/apache/cocoon/components
                        CocoonComponentManager.java
  Log:
  Fixing NPE in sitemap reloading and
  removing the static rootManager from CocoonComponentManager
  this addresses patch 19282
  
  Revision  Changes    Path
  1.7       +30 -9     cocoon-2.1/src/java/org/apache/cocoon/environment/AbstractEnvironment.java
  
  Index: AbstractEnvironment.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/environment/AbstractEnvironment.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractEnvironment.java	20 Mar 2003 13:11:28 -0000	1.6
  +++ AbstractEnvironment.java	26 Apr 2003 14:06:50 -0000	1.7
  @@ -128,6 +128,9 @@
       /** The AvalonToCocoonSourceWrapper (this is for the deprecated support) */
       static protected Constructor avalonToCocoonSourceWrapper;
   
  +    /** Do we have our components ? */
  +    protected boolean initializedComponents;
  +    
       /**
        * Constructs the abstract environment
        */
  @@ -344,6 +347,9 @@
        */
       public Source resolve(String systemId)
       throws ProcessingException, SAXException, IOException {
  +        if ( !this.initializedComponents) {
  +            this.initComponents();
  +        }
           if (getLogger().isDebugEnabled()) {
               this.getLogger().debug("Resolving '"+systemId+"' in context '" + this.context
+ "'");
           }
  @@ -487,6 +493,9 @@
                                                            String baseURI,
                                                            final Map    parameters)
       throws MalformedURLException, IOException, SourceException {
  +        if ( !this.initializedComponents) {
  +            this.initComponents();
  +        }
           return this.sourceResolver.resolveURI(location, baseURI, parameters);
       }
   
  @@ -516,6 +525,9 @@
                   String         mimeTypeHint,
                   ContentHandler handler )
       throws SAXException, IOException, ProcessingException {
  +        if ( !this.initializedComponents) {
  +            this.initComponents();
  +        }
           String mimeType = source.getMimeType();
           if (null == mimeType) {
               mimeType = mimeTypeHint;
  @@ -551,18 +563,26 @@
           }
       }
   
  +    /**
  +     * Initialize the components for the environment
  +     * This gets the source resolver and the xmlizer component
  +     */
  +    protected void initComponents() {
  +        try {
  +            this.manager = CocoonComponentManager.getSitemapComponentManager();
  +            this.xmlizer = (XMLizer)this.manager.lookup(XMLizer.ROLE);
  +            this.sourceResolver = (org.apache.excalibur.source.SourceResolver)this.manager.lookup(org.apache.excalibur.source.SourceResolver.ROLE);
  +        } catch (ComponentException ce) {
  +            // this should never happen!
  +            throw new CascadingRuntimeException("Unable to lookup component.", ce);
  +        }
  +    }
  +    
   	/**
   	 * Notify that the processing starts.
   	 */
   	public void startingProcessing() {
  -		try {
  -			this.manager = CocoonComponentManager.getSitemapComponentManager();
  -			this.xmlizer = (XMLizer)this.manager.lookup(XMLizer.ROLE);
  -			this.sourceResolver = (org.apache.excalibur.source.SourceResolver)this.manager.lookup(org.apache.excalibur.source.SourceResolver.ROLE);
  -		} catch (ComponentException ce) {
  -			// this should never happen!
  -			throw new CascadingRuntimeException("Unable to lookup component.", ce);
  -		}
  +        // do nothing here
   	}
   
   	/**
  @@ -577,6 +597,7 @@
   			this.xmlizer = null;
   			this.sourceResolver = null;
   		}
  +        this.initializedComponents = false;
   	}
   
   }
  
  
  
  1.4       +2 -2      cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
  
  Index: TreeProcessor.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TreeProcessor.java	20 Mar 2003 11:45:58 -0000	1.3
  +++ TreeProcessor.java	26 Apr 2003 14:06:50 -0000	1.4
  @@ -258,7 +258,7 @@
               org.apache.excalibur.source.Source source = resolver.resolveURI( xconfURL );
               try {
                   SAXConfigurationHandler handler = new SAXConfigurationHandler();
  -                SourceUtil.toSAX(source, handler);
  +                SourceUtil.toSAX( this.manager, source, null, handler);
                   builtin = handler.getConfiguration();
               } finally {
                   resolver.release( source );
  
  
  
  1.10      +3 -10     cocoon-2.1/src/java/org/apache/cocoon/components/CocoonComponentManager.java
  
  Index: CocoonComponentManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/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	26 Apr 2003 13:35:39 -0000	1.9
  +++ CocoonComponentManager.java	26 Apr 2003 14:06:50 -0000	1.10
  @@ -104,34 +104,27 @@
       /** The {@link RoleManager} */
       private RoleManager roleManager;
   
  -    /** The root component manager */
  -    private static ComponentManager rootManager;
  -    
       /** The {@link SitemapConfigurationHolder}s */
       private Map sitemapConfigurationHolders = new HashMap(15);
       
       /** Create the ComponentManager */
       public CocoonComponentManager() {
           super( null, Thread.currentThread().getContextClassLoader() );
  -        if ( null == rootManager ) rootManager = this;
       }
   
       /** Create the ComponentManager with a Classloader */
       public CocoonComponentManager(final ClassLoader loader) {
           super( null, loader );
  -        rootManager = this;
       }
   
       /** Create the ComponentManager with a Classloader and parent ComponentManager */
       public CocoonComponentManager(final ComponentManager manager, final ClassLoader loader)
{
           super( manager, loader );
  -        if (rootManager != manager) rootManager = this;
       }
   
       /** Create the ComponentManager with a parent ComponentManager */
       public CocoonComponentManager(final ComponentManager manager) {
           super( manager);
  -        if (rootManager != manager) rootManager = this;
       }
   
       /**
  @@ -246,8 +239,8 @@
   			return (ComponentManager)o[2];
   		}
   
  -        // if we don't have an environment yet, just return the root manager
  -        return rootManager;
  +        // if we don't have an environment yet, just return null
  +        return null;
       }
       
       /**
  
  
  

Mime
View raw message