cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/language/generator GeneratorSelector.java ProgramGenerator.java ProgramGeneratorImpl.java
Date Sun, 10 Feb 2002 04:54:48 GMT
vgritsenko    02/02/09 20:54:48

  Modified:    src/java/org/apache/cocoon/components/language/generator
                        GeneratorSelector.java ProgramGenerator.java
                        ProgramGeneratorImpl.java
  Log:
  fix memory leak;
  get rid of repository
  
  Revision  Changes    Path
  1.7       +12 -20    xml-cocoon2/src/java/org/apache/cocoon/components/language/generator/GeneratorSelector.java
  
  Index: GeneratorSelector.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/generator/GeneratorSelector.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- GeneratorSelector.java	7 Feb 2002 04:07:27 -0000	1.6
  +++ GeneratorSelector.java	10 Feb 2002 04:54:48 -0000	1.7
  @@ -82,9 +82,8 @@
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
  - * @version CVS $Id: GeneratorSelector.java,v 1.6 2002/02/07 04:07:27 vgritsenko Exp $
  + * @version CVS $Id: GeneratorSelector.java,v 1.7 2002/02/10 04:54:48 vgritsenko Exp $
    */
  -// FIXME: remove extends, add implements ComponentSelector
   public class GeneratorSelector extends ExcaliburComponentSelector implements Disposable
{
   
       public static String ROLE = "org.apache.cocoon.components.language.generator.ServerPages";
  @@ -105,6 +104,7 @@
       /** Dynamic component handlers mapping. */
       private Map componentMapping = new HashMap();
   
  +
       public void contextualize(Context context) {
           super.contextualize(context);
           this.context = context;
  @@ -138,33 +138,25 @@
       }
   
       public Component select(Object hint) throws ComponentException {
  -//        try {
  -//            return super.select(hint);
  -//        } catch (Exception e) {
  -
  -            // if it isn't loaded, it may already be compiled...
  -            try {
  -                ComponentHandler handler = (ComponentHandler) this.componentHandlers.get(hint);
  -                Component component = (Component) handler.get();
  -                componentMapping.put(component, handler);
  -                return component;
  -            } catch (Exception ce) {
  -                getLogger().debug("Could not access component for hint: " + hint);
  -                throw new ComponentException("Could not access component for hint: " +
hint, null);
  -            }
  -//        }
  +        try {
  +            ComponentHandler handler = (ComponentHandler) this.componentHandlers.get(hint);
  +            Component component = (Component) handler.get();
  +            componentMapping.put(component, handler);
  +            return component;
  +        } catch (Exception ce) {
  +            getLogger().debug("Could not access component for hint: " + hint);
  +            throw new ComponentException("Could not access component for hint: " + hint,
null);
  +        }
       }
   
       public void release(Component component) {
  -        ComponentHandler handler = (ComponentHandler)componentMapping.get(component);
  +        ComponentHandler handler = (ComponentHandler)componentMapping.remove(component);
           if (handler != null) {
               try {
                   handler.put(component);
               } catch (Exception e) {
                   getLogger().error("Error trying to release component", e);
               }
  -//        } else {
  -//            super.release(component);
           }
       }
   
  
  
  
  1.6       +3 -3      xml-cocoon2/src/java/org/apache/cocoon/components/language/generator/ProgramGenerator.java
  
  Index: ProgramGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/generator/ProgramGenerator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ProgramGenerator.java	7 Feb 2002 04:07:27 -0000	1.5
  +++ ProgramGenerator.java	10 Feb 2002 04:54:48 -0000	1.6
  @@ -65,7 +65,7 @@
    * documents written in a <code>MarkupLanguage</code>
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Id: ProgramGenerator.java,v 1.5 2002/02/07 04:07:27 vgritsenko Exp $
  + * @version CVS $Id: ProgramGenerator.java,v 1.6 2002/02/10 04:54:48 vgritsenko Exp $
    */
   public interface ProgramGenerator extends Component {
   
  @@ -75,8 +75,8 @@
        * Load a program built from an XML document written in a
        * <code>MarkupLanguage</code>
        *
  -     * @param newManager  The ComponentManager that it will be loaded with.
  -     * @param file The input document's <code>File</code>
  +     * @param newManager  The ComponentManager that it will be loaded with
  +     * @param fileName The input document's <code>File</code> name
        * @param markupLanguage The <code>MarkupLanguage</code> in which the input
        * document is written
        * @param programmingLanguage The <code>ProgrammingLanguage</code> in which
  
  
  
  1.10      +10 -17    xml-cocoon2/src/java/org/apache/cocoon/components/language/generator/ProgramGeneratorImpl.java
  
  Index: ProgramGeneratorImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/generator/ProgramGeneratorImpl.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ProgramGeneratorImpl.java	8 Feb 2002 21:36:53 -0000	1.9
  +++ ProgramGeneratorImpl.java	10 Feb 2002 04:54:48 -0000	1.10
  @@ -53,7 +53,6 @@
    * <http://www.apache.org/>.
    */
   
  -
   package org.apache.cocoon.components.language.generator;
   
   import org.apache.avalon.framework.activity.Disposable;
  @@ -93,7 +92,7 @@
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
    * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
  - * @version CVS $Id: ProgramGeneratorImpl.java,v 1.9 2002/02/08 21:36:53 dims Exp $
  + * @version CVS $Id: ProgramGeneratorImpl.java,v 1.10 2002/02/10 04:54:48 vgritsenko Exp
$
    */
   public class ProgramGeneratorImpl extends AbstractLoggable
       implements ProgramGenerator, Contextualizable, Composable, Parameterizable,
  @@ -111,9 +110,6 @@
        */
       protected GeneratorSelector cache;
   
  -    /** The repository store */
  -    protected Store repository;
  -
       /** The component manager */
       protected ComponentManager manager;
   
  @@ -174,7 +170,6 @@
           if ((this.manager == null) && (manager != null)) {
               this.manager = manager;
               this.cache = (GeneratorSelector) this.manager.lookup(GeneratorSelector.ROLE
+ "Selector");
  -            this.repository = (Store) this.manager.lookup(Store.ROLE + "/Filesystem");
               this.markupSelector = (ComponentSelector)this.manager.lookup(MarkupLanguage.ROLE
+ "Selector");
               this.languageSelector = (ComponentSelector)this.manager.lookup(ProgrammingLanguage.ROLE
+ "Selector");
               this.classManager = (ClassLoaderManager)this.manager.lookup(ClassLoaderManager.ROLE);
  @@ -309,8 +304,8 @@
               return programInstance;
           } finally {
               source.recycle();
  -            this.manager.release(markupLanguage);
  -            this.manager.release(programmingLanguage);
  +            this.markupSelector.release(markupLanguage);
  +            this.languageSelector.release(programmingLanguage);
           }
       }
   
  @@ -336,9 +331,7 @@
               } catch (Exception cme) { }
   
               // If failed, generate. This is for the first thread entering this block
  -            getLogger().debug("Creating resource " + normalizedName +
  -                 ", using generator " + this);
  -
  +            getLogger().debug("Creating resource " + normalizedName);
               try {
                   Program program = this.generateResource(newManager, source,
                           normalizedName, markupLanguage, programmingLanguage, resolver);
  @@ -387,10 +380,12 @@
           }
   
           // Store generated code
  -        String sourceFilename = normalizedName + "." + programmingLanguage.getSourceExtension();
  -
  -        // FIXME(VG): Get rid of repository.
  -        repository.store(sourceFilename, code);
  +        final File sourceFile = new File(this.workDir, normalizedName + "." + programmingLanguage.getSourceExtension());
  +        final File sourceDir = sourceFile.getParentFile();
  +        if (sourceDir != null) {
  +            sourceDir.mkdirs();
  +        }
  +        IOUtils.serializeString(sourceFile, code);
   
           // [Compile]/Load generated program
           Program program = programmingLanguage.load(normalizedName,
  @@ -409,8 +404,6 @@
       public void dispose() {
           this.manager.release(this.cache);
           this.cache = null;
  -        this.manager.release(this.repository);
  -        this.repository = null;
           this.manager.release(this.markupSelector);
           this.markupSelector = null;
           this.manager.release(this.languageSelector);
  
  
  

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