cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: xml-cocoon2/webapp cocoon.xconf
Date Thu, 05 Jul 2001 16:45:28 GMT
bloritsch    01/07/05 09:45:27

  Modified:    src/org/apache/cocoon cocoon.roles
               src/org/apache/cocoon/components/language/generator
                        ProgramGeneratorImpl.java
               webapp   cocoon.xconf
  Log:
  Update ProgramGenerator to handle pre-compiled sites with optional "preload"
  parameter.
  
  Cleaned up configuration a little.
  
  Revision  Changes    Path
  1.14      +7 -2      xml-cocoon2/src/org/apache/cocoon/cocoon.roles
  
  Index: cocoon.roles
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/cocoon.roles,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- cocoon.roles	2001/07/05 15:33:19	1.13
  +++ cocoon.roles	2001/07/05 16:45:22	1.14
  @@ -26,11 +26,16 @@
   
    <role name="org.apache.cocoon.components.language.markup.MarkupLanguageSelector"
          shorthand="markup-languages"
  -       default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector"/>
  +       default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector">
  +   <hint shorthand="sitemap-language" class="org.apache.cocoon.components.language.markup.sitemap.SitemapMarkupLanguage"/>
  +   <hint shorthand="xsp-language" class="org.apache.cocoon.components.language.markup.xsp.XSPMarkupLanguage"/>
  + </role>
   
    <role name="org.apache.cocoon.components.language.programming.ProgrammingLanguageSelector"
          shorthand="programming-languages"
  -       default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector"/>
  +       default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector">
  +   <hint shorthand="java-language" class="org.apache.cocoon.components.language.programming.java.JavaLanguage"/>
  + </role>
   
    <role name="org.apache.cocoon.components.language.generator.ProgramGenerator"
          shorthand="program-generator"
  
  
  
  1.8       +31 -3     xml-cocoon2/src/org/apache/cocoon/components/language/generator/ProgramGeneratorImpl.java
  
  Index: ProgramGeneratorImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/language/generator/ProgramGeneratorImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ProgramGeneratorImpl.java	2001/06/19 16:06:27	1.7
  +++ ProgramGeneratorImpl.java	2001/07/05 16:45:24	1.8
  @@ -30,6 +30,7 @@
   import org.apache.cocoon.Constants;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.Roles;
  +import org.apache.cocoon.components.classloader.ClassLoaderManager;
   import org.apache.cocoon.components.language.LanguageException;
   import org.apache.cocoon.components.language.markup.MarkupLanguage;
   import org.apache.cocoon.components.language.markup.sitemap.SitemapMarkupLanguage;
  @@ -48,7 +49,7 @@
   /**
    * The default implementation of <code>ProgramGenerator</code>
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.7 $ $Date: 2001/06/19 16:06:27 $
  + * @version CVS $Revision: 1.8 $ $Date: 2001/07/05 16:45:24 $
    */
   public class ProgramGeneratorImpl extends AbstractLoggable
       implements ProgramGenerator, Contextualizable, Composable, Configurable, ThreadSafe,
Disposable {
  @@ -56,6 +57,9 @@
       /** The auto-reloading option */
       protected boolean autoReload = false;
   
  +    /** The pre-loading option */
  +    protected boolean preload = false;
  +
       /** The ComponentSelector for CompiledPages */
       protected GeneratorSelector cache;
   
  @@ -74,6 +78,9 @@
       /** The working directory */
       protected File workDir;
   
  +    /** The ClassLoaderManager */
  +    protected ClassLoaderManager classManager;
  +
       /** The root package */
       protected String rootPackage;
   
  @@ -97,6 +104,7 @@
                   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);
  +                this.classManager = (ClassLoaderManager)this.manager.lookup(Roles.CLASS_LOADER);
               } catch (Exception e) {
                   getLogger().warn("Could not lookup Component", e);
               }
  @@ -112,6 +120,7 @@
           Parameters params = Parameters.fromConfiguration(conf);
           this.autoReload = params.getParameterAsBoolean("auto-reload", autoReload);
           this.rootPackage = params.getParameter("root-package", "org.apache.cocoon");
  +        this.preload = params.getParameterAsBoolean("preload", preload);
       }
   
       /**
  @@ -148,6 +157,18 @@
               getLogger().debug("The instance was not accessible, creating it now.");
           }
   
  +        if ((programInstance == null) && this.preload) {
  +            String className = normalizedName.replace(File.separatorChar, '.');
  +
  +            try {
  +                program = this.classManager.loadClass(className);
  +                this.addCompiledComponent(newManager, normalizedName, program);
  +                programInstance = (CompiledComponent) select(normalizedName);
  +            } catch (Exception e) {
  +                getLogger().debug("The class was not preloaded");
  +            }
  +        }
  +
           if (programInstance == null) {
               MarkupLanguage markupLanguage = null;
               ProgrammingLanguage programmingLanguage = null;
  @@ -249,7 +270,7 @@
           // [Compile]/Load generated program
           Class program = programmingLanguage.load(normalizedName, this.workDir, markupLanguage.getEncoding());
           // Store generated program in cache
  -        this.cache.addGenerator(newManager, normalizedName, program);
  +        this.addCompiledComponent(newManager, normalizedName, program);
   
           // FIXME: Do we want this functionality?  All analysis says no.
           if (markupLanguage.getClass().equals(SitemapMarkupLanguage.class)) {
  @@ -257,11 +278,18 @@
                   select("sitemap");
               } catch (Exception e) {
                   // If the root sitemap has not been compiled, add an alias here.
  -                this.cache.addGenerator(newManager, "sitemap", program);
  +                this.addCompiledComponent(newManager, "sitemap", program);
               }
           }
   
           return program;
  +    }
  +
  +    private final void addCompiledComponent(ComponentManager newManager,
  +                                            String normalizedName,
  +                                            Class program)
  +    throws Exception {
  +        this.cache.addGenerator(newManager, normalizedName, program);
       }
   
       public CompiledComponent select(String componentName)
  
  
  
  1.14      +9 -8      xml-cocoon2/webapp/cocoon.xconf
  
  Index: cocoon.xconf
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/webapp/cocoon.xconf,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- cocoon.xconf	2001/07/04 07:57:42	1.13
  +++ cocoon.xconf	2001/07/05 16:45:26	1.14
  @@ -61,20 +61,21 @@
     <program-generator>
       <parameter name="auto-reload" value="true"/>
       <parameter name="root-package" value="org.apache.cocoon.www"/>
  +    <parameter name="preload" value="true"/>
     </program-generator>
   
     <programming-languages>
  -    <component-instance name="java" class="org.apache.cocoon.components.language.programming.java.JavaLanguage">
  +    <java-language name="java">
         <parameter name="compiler" value="org.apache.cocoon.components.language.programming.java.Javac"/>
         <parameter name="code-formatter" value="org.apache.cocoon.components.language.programming.java.JstyleFormatter"/>
         <parameter name="class-loader" value="org.apache.cocoon.components.classloader.ClassLoaderManagerImpl"/>
  -    </component-instance>
  +    </java-language>
     </programming-languages>
   
     <classloader class="org.apache.cocoon.components.classloader.ClassLoaderManagerImpl"/>
   
     <markup-languages>
  -    <component-instance name="xsp" class="org.apache.cocoon.components.language.markup.xsp.XSPMarkupLanguage">
  +    <xsp-language name="xsp">
         <parameter name="prefix" value="xsp"/>
         <parameter name="uri" value="http://apache.org/xsp"/>
   
  @@ -136,16 +137,16 @@
           </builtin-logicsheet>
   
         </target-language>
  -    </component-instance>
  +    </xsp-language>
   
  -    <component-instance name="sitemap" class="org.apache.cocoon.components.language.markup.sitemap.SitemapMarkupLanguage">
  +    <sitemap-language name="sitemap">
         <parameter name="prefix" value="map"/>
         <parameter name="uri" value="http://apache.org/cocoon/sitemap/1.0"/>
   
         <target-language name="java">
           <parameter name="core-logicsheet" value="resource://org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl"/>
         </target-language>
  -    </component-instance>
  +    </sitemap-language>
     </markup-languages>
   
     <datasources>
  @@ -242,11 +243,11 @@
        <parameter name="threadpriority" value="5"/>
     </event-cache>
   
  -  <!-- The SAXConnector connects the various pipeline components. 
  +  <!-- The SAXConnector connects the various pipeline components.
          Uncomment the following line for using the SAXConnector.
     <sax-connector class="org.apache.cocoon.components.saxconnector.LoggingSAXConnector"/>
     -->
  - 
  +
   <!-- ======================== The sitemap  ============================== -->
   
     <!-- The reloading of the sitemap:
  
  
  

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