cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject cvs commit: xml-cocoon2/src/org/apache/cocoon/components/language/generator ProgramGeneratorImpl.java
Date Tue, 11 Dec 2001 13:06:04 GMT
sylvain     01/12/11 05:06:04

  Modified:    src/org/apache/cocoon/components/language/generator
                        ProgramGeneratorImpl.java
  Log:
  Undoed previous changes : it broke sitemap/XSP reloading
  
  Revision  Changes    Path
  1.25      +20 -58    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.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- ProgramGeneratorImpl.java	2001/12/09 21:36:42	1.24
  +++ ProgramGeneratorImpl.java	2001/12/11 13:06:04	1.25
  @@ -8,8 +8,6 @@
   
   package org.apache.cocoon.components.language.generator;
   
  -import org.apache.avalon.excalibur.monitor.FileResource;
  -import org.apache.avalon.excalibur.monitor.Monitor;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.component.*;
   import org.apache.avalon.framework.configuration.Configurable;
  @@ -33,23 +31,18 @@
   import org.apache.cocoon.environment.Source;
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.cocoon.util.IOUtils;
  -import org.apache.cocoon.util.NetUtils;
   import org.xml.sax.InputSource;
   
  -import java.beans.PropertyChangeListener;
  -import java.beans.PropertyChangeEvent;
   import java.io.File;
  -import java.net.URL;
   import java.net.MalformedURLException;
   
   /**
    * The default implementation of <code>ProgramGenerator</code>
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.24 $ $Date: 2001/12/09 21:36:42 $
  + * @version CVS $Revision: 1.25 $ $Date: 2001/12/11 13:06:04 $
    */
   public class ProgramGeneratorImpl extends AbstractLoggable
  -    implements ProgramGenerator, Contextualizable, Composable, Configurable, ThreadSafe,

  -               Disposable, PropertyChangeListener {
  +    implements ProgramGenerator, Contextualizable, Composable, Configurable, ThreadSafe,
Disposable {
   
       /** The auto-reloading option */
       protected boolean autoReload = false;
  @@ -84,15 +77,6 @@
       /** Servlet Context Directory */
       protected String contextDir;
   
  -    /** Resource monitoring */
  -    protected Monitor monitor;
  -
  -    /** lastModified date */
  -    protected long lastModified;
  -
  -    /** File resource */
  -    protected FileResource file;
  -
       /** Contextualize this class */
       public void contextualize(Context context) throws ContextException {
           if (this.workDir == null) {
  @@ -127,7 +111,6 @@
                   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);
  -                this.monitor = (Monitor) this.manager.lookup(Monitor.ROLE);
               } catch (Exception e) {
                   getLogger().warn("Could not lookup Component", e);
               }
  @@ -162,15 +145,6 @@
           throws Exception {
   
           Source source = resolver.resolve(fileName);
  -        
  -        /** Monitoring the Sitemap source */
  -        URL url = new URL(source.getSystemId());
  -        getLogger().debug("Sitemap path=" + url.getFile());
  -        file = new FileResource(url.getFile());
  -        file.addPropertyChangeListener(this);
  -        monitor.addResource(file);
  -        getLogger().debug("lastModified date=" + this.getLastModified());
  -        
           try {
               // Set filenames
               StringBuffer contextFilename = new StringBuffer(this.rootPackage.replace('.',
File.separatorChar));
  @@ -185,21 +159,21 @@
                   contextFilename.append(id);
               }
               String normalizedName = IOUtils.normalizedFilename(contextFilename.toString());
  -
  +    
               // Ensure no 2 requests for the same file overlap
               Class program = null;
               CompiledComponent programInstance = null;
  -
  +    
               // Attempt to load program object from cache
               try {
                   programInstance = (CompiledComponent) select(normalizedName);
               } catch (Exception e) {
                   getLogger().debug("The instance was not accessible from the internal cache.
Proceeding.");
               }
  -
  +    
               if ((programInstance == null) && this.preload) {
                   String className = normalizedName.replace(File.separatorChar, '.');
  -
  +    
                   try {
                       program = this.classManager.loadClass(className);
                       this.addCompiledComponent(newManager, normalizedName, program);
  @@ -208,44 +182,44 @@
                       getLogger().debug("The class was not preloaded");
                   }
               }
  -
  +    
               if (programInstance == null) {
  -            programInstance =
  +	        programInstance =
                       this.createResource(
                           newManager, fileName, normalizedName,
                           markupLanguageName, programmingLanguageName, resolver
                       );
               }
  -
  +    
               if (this.autoReload == false) {
                   return programInstance;
               }
  -
  +    
               /*
                * FIXME: It's the program (not the instance) that must
                * be queried for changes!!!
                */
  -
  -            if (programInstance != null && programInstance.modifiedSince(this.getLastModified()))
{
  +    
  +            if (programInstance != null && programInstance.modifiedSince(source.getLastModified()))
{
                   // Release the component.
                   release(programInstance);
  -
  +    
                   // Unload program
                   ProgrammingLanguage programmingLanguage = (ProgrammingLanguage)this.languageSelector.select(programmingLanguageName);
                   programmingLanguage.setLanguageName(programmingLanguageName);
                   programmingLanguage.unload(program, normalizedName, this.workDir);
                   this.cache.removeGenerator(normalizedName);
  -
  +    
                   // Invalidate previous program/instance pair
                   program = null;
                   programInstance = null;
               }
  -
  +    
               if (programInstance == null) {
                   if (program == null) {
                       programInstance =
                           this.createResource(
  -                            newManager, fileName, normalizedName,
  +                            newManager, fileName, normalizedName, 
                               markupLanguageName, programmingLanguageName,
                               resolver
                           );
  @@ -316,7 +290,7 @@
               }
           }
   
  -    return programInstance;
  +	return programInstance;
       }
   
       private Class generateResource(ComponentManager newManager,
  @@ -328,7 +302,7 @@
           throws Exception {
   
           Source source = resolver.resolve(fileName);
  -        try {
  +        try { 
               // Input Source
               InputSource is = source.getInputSource();
               // Generate code
  @@ -347,7 +321,7 @@
               Class program = programmingLanguage.load(normalizedName, this.workDir, markupLanguage.getEncoding());
               // Store generated program in cache
               this.addCompiledComponent(newManager, normalizedName, program);
  -
  +    
               // FIXME: Do we want this functionality?  All analysis says no.
               if (markupLanguage.getClass().equals(SitemapMarkupLanguage.class)) {
                   try {
  @@ -357,7 +331,7 @@
                       this.addCompiledComponent(newManager, "sitemap", program);
                   }
               }
  -
  +    
               return program;
           } finally {
               source.recycle();
  @@ -389,17 +363,5 @@
           this.manager.release((Component)this.repository);
           this.manager.release((Component)this.markupSelector);
           this.manager.release((Component)this.languageSelector);
  -    }
  -
  -    public void propertyChange(PropertyChangeEvent evt) {
  -        setLastModified(((Long)evt.getNewValue()).longValue());
  -    }
  -
  -    private void setLastModified(long _lastModified) {
  -        lastModified = _lastModified;
  -    }
  -
  -    private long getLastModified() {
  -        return lastModified;
       }
   }
  
  
  

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