cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/components/language/generator GeneratorSelector.java CompiledComponent.java ProgramGeneratorImpl.java
Date Fri, 16 Feb 2001 16:21:40 GMT
bloritsch    01/02/16 08:21:39

  Modified:    src/org/apache/cocoon Tag: xml-cocoon2
                        CocoonComponentSelector.java
               src/org/apache/cocoon/components/language/generator Tag:
                        xml-cocoon2 CompiledComponent.java
                        ProgramGeneratorImpl.java
  Added:       src/org/apache/cocoon/components/language/generator Tag:
                        xml-cocoon2 GeneratorSelector.java
  Log:
  Make ProgramGeneratorImpl use a ComponentSelector for the cache.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.17  +3 -3      xml-cocoon/src/org/apache/cocoon/Attic/CocoonComponentSelector.java
  
  Index: CocoonComponentSelector.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Attic/CocoonComponentSelector.java,v
  retrieving revision 1.1.2.16
  retrieving revision 1.1.2.17
  diff -u -r1.1.2.16 -r1.1.2.17
  --- CocoonComponentSelector.java	2001/02/15 21:09:28	1.1.2.16
  +++ CocoonComponentSelector.java	2001/02/16 16:21:34	1.1.2.17
  @@ -42,13 +42,13 @@
   /** Default component manager for Cocoon's non sitemap components.
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:paul@luminas.co.uk">Paul Russell</a>
  - * @version CVS $Revision: 1.1.2.16 $ $Date: 2001/02/15 21:09:28 $
  + * @version CVS $Revision: 1.1.2.17 $ $Date: 2001/02/16 16:21:34 $
    */
   public class CocoonComponentSelector implements Contextualizable, ComponentSelector, Composer,
Configurable, ThreadSafe, Loggable {
       protected Logger log;
       /** Hashmap of all components which this ComponentManager knows about.
        */
  -    private Map components;
  +    protected Map components;
   
       /** The app Context */
       private Context context;
  @@ -64,7 +64,7 @@
       /** Component pools. */
       private Map pools;
   
  -        /** Parent Component Manager */
  +    /** Parent Component Manager */
       private ComponentManager manager;
   
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +2 -2      xml-cocoon/src/org/apache/cocoon/components/language/generator/Attic/CompiledComponent.java
  
  Index: CompiledComponent.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/generator/Attic/CompiledComponent.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- CompiledComponent.java	2001/02/16 15:41:43	1.1.2.1
  +++ CompiledComponent.java	2001/02/16 16:21:36	1.1.2.2
  @@ -14,8 +14,8 @@
    * This interface is the common base of all Compiled Components.  This
    * includes Sitemaps and XSP Pages
    *
  - * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2001/02/16 15:41:43 $
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2001/02/16 16:21:36 $
    */
   public interface CompiledComponent extends Composer, Modifiable {
   }
  
  
  
  1.1.2.27  +49 -29    xml-cocoon/src/org/apache/cocoon/components/language/generator/Attic/ProgramGeneratorImpl.java
  
  Index: ProgramGeneratorImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/generator/Attic/ProgramGeneratorImpl.java,v
  retrieving revision 1.1.2.26
  retrieving revision 1.1.2.27
  diff -u -r1.1.2.26 -r1.1.2.27
  --- ProgramGeneratorImpl.java	2001/02/16 15:38:27	1.1.2.26
  +++ ProgramGeneratorImpl.java	2001/02/16 16:21:38	1.1.2.27
  @@ -12,10 +12,14 @@
   import java.io.FileReader;
   import java.io.IOException;
   import java.io.FileNotFoundException;
  +import org.apache.log.Logger;
  +import org.apache.avalon.Loggable;
  +import org.apache.avalon.AbstractLoggable;
   import org.apache.avalon.Modifiable;
   import org.apache.avalon.Component;
   import org.apache.avalon.Composer;
   import org.apache.avalon.ComponentManager;
  +import org.apache.avalon.ComponentManagerException;
   import org.apache.avalon.Context;
   import org.apache.avalon.Contextualizable;
   import org.apache.avalon.Configurable;
  @@ -32,8 +36,6 @@
   import org.apache.cocoon.components.language.programming.CodeFormatter;
   import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
   import org.apache.cocoon.util.IOUtils;
  -import org.apache.avalon.Loggable;
  -import org.apache.avalon.AbstractLoggable;
   import org.w3c.dom.Document;
   import org.w3c.dom.Document;
   import org.xml.sax.InputSource;
  @@ -43,15 +45,15 @@
   /**
    * The default implementation of <code>ProgramGenerator</code>
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.26 $ $Date: 2001/02/16 15:38:27 $
  + * @version CVS $Revision: 1.1.2.27 $ $Date: 2001/02/16 16:21:38 $
    */
   public class ProgramGeneratorImpl extends AbstractLoggable implements ProgramGenerator,
Contextualizable, Composer, Configurable, ThreadSafe {
   
       /** The auto-reloading option */
       protected boolean autoReload = false;
   
  -    /** The in-memory store */
  -    protected Store cache;
  +    /** The ComponentSelector for CompiledPages */
  +    protected GeneratorSelector cache;
   
       /** The repository store */
       protected Store repository;
  @@ -68,10 +70,22 @@
       /** The working directory */
       protected File workDir;
   
  +    public ProgramGeneratorImpl() {
  +        this.cache = new GeneratorSelector();
  +    }
  +
  +    /** Set the Cache's logger */
  +    public void setLogger(Logger log) {
  +        super.setLogger(log);
  +
  +        this.cache.setLogger(log);
  +    }
  +
       /** Contextualize this class */
       public void contextualize(Context context) {
          if (this.workDir == null) {
              this.workDir = (File) context.get(Constants.CONTEXT_WORK_DIR);
  +           this.cache.contextualize(context);
          }
       }
   
  @@ -80,11 +94,11 @@
        * <code>ComponentSelector</code> used as language factory for both markup
and programming languages.
        * @param manager The global component manager
        */
  -    public void compose(ComponentManager manager) {
  +    public void compose(ComponentManager manager) throws ComponentManagerException {
           if ((this.manager == null) && (manager != null)) {
               this.manager = manager;
  +            this.cache.compose(manager);
               try {
  -                this.cache = (Store) this.manager.lookup(Roles.STORE);
                   this.repository = (Store) this.manager.lookup(Roles.REPOSITORY);
                   this.markupSelector = (ComponentSelector)this.manager.lookup(Roles.MARKUP_LANGUAGE);
                   this.languageSelector = (ComponentSelector)this.manager.lookup(Roles.PROGRAMMING_LANGUAGE);
  @@ -129,30 +143,36 @@
               CompiledComponent programInstance = null;
               synchronized(filename.intern()) {
                   // Attempt to load program object from cache
  -                program = (Class) this.cache.get(filename);
                   try {
  -                    if (program == null) {
  -          /*
  -             FIXME: Passing null as encoding may result in invalid
  -             recompilation under certain circumstances!
  -          */
  -
  -                        program = programmingLanguage.load(normalizedName, this.workDir,
null);
  -                        // Store loaded program in cache
  -                        this.cache.store(filename, program);
  +                    programInstance = (CompiledComponent) this.cache.select(filename);
  +                } catch (Exception e) {
  +                    getLogger().debug("The instance was not accessible, creating it now.");
  +                    try {
  +                        if (programInstance == null) {
  +                          /*
  +                             FIXME: Passing null as encoding may result in invalid
  +                             recompilation under certain circumstances!
  +                          */
  +
  +                            program = programmingLanguage.load(normalizedName, this.workDir,
null);
  +                            // Store loaded program in cache
  +                            this.cache.addGenerator(filename, program);
  +                        }
  +                        // Instantiate program
  +                        programInstance = programmingLanguage.instantiate(program);
  +                        if (programInstance instanceof Loggable) {
  +                            ((Loggable)programInstance).setLogger(getLogger());
  +                        }
  +                        programInstance.compose(this.manager);
  +                    } catch (LanguageException le) {
  +                        getLogger().debug("Language Exception", le);
                       }
  -                    // Instantiate program
  -                    programInstance = programmingLanguage.instantiate(program);
  -                    if (programInstance instanceof Loggable) {
  -                        ((Loggable)programInstance).setLogger(getLogger());
  -                    }
  -                    programInstance.compose(this.manager);
  -                } catch (LanguageException e) { getLogger().debug("Language Exception",
e); }
  +                }
   
  -      /*
  -         FIXME: It's the program (not the instance) that must
  -         be queried for changes!!!
  -      */
  +              /*
  +                 FIXME: It's the program (not the instance) that must
  +                 be queried for changes!!!
  +              */
   
                   if (this.autoReload && programInstance != null && programInstance.modifiedSince(file.lastModified()))
{
                           // Unload program
  @@ -178,7 +198,7 @@
                       // [Compile]/Load generated program
                       program = programmingLanguage.load(normalizedName, this.workDir, encoding);
                       // Store generated program in cache
  -                    this.cache.store(filename, program);
  +                    this.cache.addGenerator(filename, program);
                   }
                   // Instantiate
                   programInstance = programmingLanguage.instantiate(program);
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +24 -0     xml-cocoon/src/org/apache/cocoon/components/language/generator/Attic/GeneratorSelector.java
  
  
  
  

Mime
View raw message