cziegeler    01/06/05 01:05:17

  Modified:    src/org/apache/cocoon Cocoon.java
  Log:
  Fixed handling of last modification date of the xconf. It was always 0.
  
  Revision  Changes    Path
  1.9       +17 -17    xml-cocoon2/src/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Cocoon.java       2001/05/31 17:37:30     1.8
  +++ Cocoon.java       2001/06/05 08:05:13     1.9
  @@ -39,6 +39,7 @@
   import org.apache.cocoon.components.store.FilesystemStore;
   import org.apache.cocoon.components.url.URLFactory;
   import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.environment.Source;
   import org.apache.cocoon.serialization.Serializer;
   import org.apache.cocoon.sitemap.Manager;
   import org.apache.cocoon.util.ClassUtils;
  @@ -53,14 +54,14 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Pierpaolo Fumagalli</a> (Apache 
Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.8 $ $Date: 2001/05/31 17:37:30 $
  + * @version CVS $Revision: 1.9 $ $Date: 2001/06/05 08:05:13 $
    */
   public class Cocoon extends AbstractLoggable implements ThreadSafe, Component, 
Initializable, Disposable, Modifiable, Processor, Contextualizable {
       /** The application context */
       private Context context;
   
       /** The configuration file */
  -    private URL configurationFile;
  +    private Source configurationFile;
   
       /** The sitemap file */
       private String sitemapFileName;
  @@ -100,7 +101,12 @@
               this.context = context;
               this.classpath = (String)context.get(Constants.CONTEXT_CLASSPATH);
               this.workDir = (File)context.get(Constants.CONTEXT_WORK_DIR);
  -            this.configurationFile = (URL)context.get(Constants.CONTEXT_CONFIG_URL);
  +            try {
  +                this.configurationFile = new 
Source((URL)context.get(Constants.CONTEXT_CONFIG_URL));
  +            } catch (IOException ioe) {
  +                getLogger().error("Could not open configuration file.", ioe);
  +                throw new ContextException("Could not open configuration file.", 
ioe);
  +            }
           }
       }
   
  @@ -144,11 +150,12 @@
           Configuration roleConfig = null;
   
           try {
  +            this.configurationFile.refresh();
               p = (Parser)this.componentManager.lookup(Roles.PARSER);
               SAXConfigurationHandler b = new SAXConfigurationHandler();
               InputStream inputStream = 
ClassUtils.getResource("org/apache/cocoon/cocoon.roles").openStream();
               InputSource is = new InputSource(inputStream);
  -            is.setSystemId(this.configurationFile.toExternalForm());
  +            is.setSystemId(this.configurationFile.getSystemId());
               p.setContentHandler(b);
               p.parse(is);
               roleConfig = b.getConfiguration();
  @@ -167,8 +174,7 @@
           try {
               p = (Parser)this.componentManager.lookup(Roles.PARSER);
               SAXConfigurationHandler b = new SAXConfigurationHandler();
  -            InputSource is = new InputSource(this.configurationFile.openStream());
  -            is.setSystemId(this.configurationFile.toExternalForm());
  +            InputSource is = this.configurationFile.getInputSource();
               p.setContentHandler(b);
               p.parse(is);
               this.configuration = b.getConfiguration();
  @@ -195,11 +201,11 @@
               try {
                   p = (Parser)this.componentManager.lookup(Roles.PARSER);
                   SAXConfigurationHandler b = new SAXConfigurationHandler();
  -                org.apache.cocoon.environment.Context context = 
  +                org.apache.cocoon.environment.Context context =
                       (org.apache.cocoon.environment.Context) 
this.context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
                   URL url = context.getResource(userRoles);
                   InputSource is = new InputSource(new 
BufferedInputStream(url.openStream()));
  -                is.setSystemId(this.configurationFile.toExternalForm());
  +                is.setSystemId(this.configurationFile.getSystemId());
                   p.setContentHandler(b);
                   p.parse(is);
                   roleConfig = b.getConfiguration();
  @@ -245,14 +251,8 @@
   
       /** Queries the class to estimate its ergodic period termination. */
       public boolean modifiedSince(long date) {
  -        boolean answer;
  -        try {
  -            answer = date < 
this.configurationFile.openConnection().getLastModified();
  -        } catch (IOException ioe) {
  -            getLogger().warn("Problem checking the date on the Configuration 
File.", ioe);
  -            answer = false;
  -        }
  -        return answer;
  +        this.configurationFile.refresh();
  +        return date < this.configurationFile.getLastModified();
       }
   
       /** Sets required system properties . */
  @@ -270,7 +270,7 @@
                   systemProps.put(prop, props.getProperty(prop));
           }
           // FIXME We shouldn't have to specify these. Needed to override jaxp 
implementation of weblogic.
  -        if(systemProps.containsKey("javax.xml.parsers.DocumentBuilderFactory") && 
  +        if(systemProps.containsKey("javax.xml.parsers.DocumentBuilderFactory") &&
              
systemProps.getProperty("javax.xml.parsers.DocumentBuilderFactory").startsWith("weblogic"))
 {
               systemProps.put("javax.xml.parsers.DocumentBuilderFactory", 
"org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
               
systemProps.put("javax.xml.parsers.SAXParserFactory","org.apache.xerces.jaxp.SAXParserFactoryImpl");
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to