You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2006/02/25 21:42:40 UTC

svn commit: r380988 - in /cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon: components/source/impl/ core/

Author: cziegeler
Date: Sat Feb 25 12:42:40 2006
New Revision: 380988

URL: http://svn.apache.org/viewcvs?rev=380988&view=rev
Log:
Cleanup

Modified:
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/source/impl/ContextSourceFactory.java
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/source/impl/DelayedRefreshSourceWrapper.java
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/source/impl/TraversableContextSource.java
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/source/impl/ContextSourceFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/source/impl/ContextSourceFactory.java?rev=380988&r1=380987&r2=380988&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/source/impl/ContextSourceFactory.java (original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/source/impl/ContextSourceFactory.java Sat Feb 25 12:42:40 2006
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999-2005 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -68,15 +68,15 @@
 
     /** Http servlet context - if available */
     protected ServletContext servletContext;
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
     public void service(ServiceManager manager) throws ServiceException {
         this.manager = manager;
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
      */
     public void contextualize(org.apache.avalon.framework.context.Context context)
@@ -89,7 +89,7 @@
         }
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.excalibur.source.SourceFactory#getSource(java.lang.String, java.util.Map)
      */
     public Source getSource( String location, Map parameters )
@@ -107,14 +107,14 @@
             final int pos = location.indexOf(":/");
             final String scheme = location.substring(0, pos);
             final String path = location.substring(pos+1);
-            
+
             // fix for #24093, we don't give access to files outside the context:
             if ( path.indexOf("../") != -1 ) {
                 throw new MalformedURLException("Invalid path ('../' is not allowed) : " + path);
             }
-            
+
             URL u;
-            
+
             // Try to get a file first and fall back to a resource URL
             String actualPath = envContext.getRealPath(path);
             if (actualPath != null) {
@@ -144,10 +144,9 @@
         } finally {
             this.manager.release( resolver );
         }
-                
     }
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.excalibur.source.SourceFactory#release(org.apache.excalibur.source.Source)
      */
     public void release( Source source ) {
@@ -174,7 +173,7 @@
         }
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.excalibur.source.URIAbsolutizer#absolutize(java.lang.String, java.lang.String)
      */
     public String absolutize(String baseURI, String location) {

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/source/impl/DelayedRefreshSourceWrapper.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/source/impl/DelayedRefreshSourceWrapper.java?rev=380988&r1=380987&r2=380988&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/source/impl/DelayedRefreshSourceWrapper.java (original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/source/impl/DelayedRefreshSourceWrapper.java Sat Feb 25 12:42:40 2006
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999-2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,7 +22,6 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Iterator;
 
 /**
  * A wrapper around a <code>Source</code> that reduces the number of calls to
@@ -31,15 +30,15 @@
  * @version $Id$
  */
 public final class DelayedRefreshSourceWrapper
-    implements Source {
+    implements Source, Recyclable {
 
     private Source source;
 
     private long delay;
 
-    private long nextCheckTime = 0;
+    private long nextCheckTime;
 
-    private long lastModified = 0;
+    private long lastModified;
 
     /**
      * Creates a wrapper for a <code>Source</code> which ensures that
@@ -53,48 +52,50 @@
         this.source = source;
         this.delay = delay;
     }
-    
+
     /**
      * Get the real source
      */
     public Source getSource() {
         return this.source;
     }
-    
+
+    /**
+     * @see org.apache.excalibur.source.Source#getInputStream()
+     */
     public final InputStream getInputStream()
     throws SourceException, IOException {
         return this.source.getInputStream();
     }
 
+    /**
+     * @see org.apache.excalibur.source.Source#getURI()
+     */
     public final String getURI() {
         return this.source.getURI();
     }
 
     /**
-     *  Get the Validity object. This can either wrap the last modification
-     *  date or the expires information or...
-     *  If it is currently not possible to calculate such an information
-     *  <code>null</code> is returned.
+     * @see org.apache.excalibur.source.Source#getValidity()
      */
     public SourceValidity getValidity() {
         return this.source.getValidity();
     }
 
     /**
-     * Return the protocol identifier.
+     * @see org.apache.excalibur.source.Source#getScheme()
      */
     public String getScheme() {
         return this.source.getScheme();
     }
 
     /**
-     * 
      * @see org.apache.excalibur.source.Source#exists()
      */
     public boolean exists() {
         return this.source.exists();
     }
-    
+
     /**
      * Get the last modification time for the wrapped <code>Source</code>. The
      * age of the returned information is guaranteed to be lower than or equal to
@@ -103,6 +104,7 @@
      * This method is also thread-safe, even if the underlying Source is not.
      *
      * @return the last modification time.
+     * @see org.apache.excalibur.source.Source#getLastModified()
      */
     public final long getLastModified() {
 
@@ -119,6 +121,7 @@
      * isn't over, and starts a new period.
      * <p>
      * This method is thread-safe, even if the underlying Source is not.
+     * @see org.apache.excalibur.source.Source#refresh()
      */
     public synchronized final void refresh() {
 
@@ -130,52 +133,26 @@
         this.lastModified = source.getLastModified();
     }
 
+    /**
+     * @see org.apache.excalibur.source.Source#getContentLength()
+     */
     public final long getContentLength() {
         return this.source.getContentLength();
     }
 
     /**
-     * The mime-type of the content described by this object.
-     * If the source is not able to determine the mime-type by itself
-     * this can be <code>null</code>.
+     * @see org.apache.excalibur.source.Source#getMimeType()
      */
     public String getMimeType() {
         return this.source.getMimeType();
     }
 
+    /**
+     * @see org.apache.avalon.excalibur.pool.Recyclable#recycle()
+     */
     public final void recycle() {
         if (this.source instanceof Recyclable) {
             ((Recyclable)this.source).recycle();
         }
     }
-
-    /**
-     * Get the value of a parameter.
-     * Using this it is possible to get custom information provided by the
-     * source implementation, like an expires date, HTTP headers etc.
-     */
-    public String getParameter(String name) {
-        return null;
-    }
-
-    /**
-     * Get the value of a parameter.
-     * Using this it is possible to get custom information provided by the
-     * source implementation, like an expires date, HTTP headers etc.
-     */
-    public long getParameterAsLong(String name) {
-        return 0;
-    }
-
-    /**
-     * Get parameter names
-     * Using this it is possible to get custom information provided by the
-     * source implementation, like an expires date, HTTP headers etc.
-     */
-    public Iterator getParameterNames() {
-        return java.util.Collections.EMPTY_LIST.iterator();
-
-    }
-
-
 }

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/source/impl/TraversableContextSource.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/source/impl/TraversableContextSource.java?rev=380988&r1=380987&r2=380988&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/source/impl/TraversableContextSource.java (original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/source/impl/TraversableContextSource.java Sat Feb 25 12:42:40 2006
@@ -33,14 +33,14 @@
  * @version SVN $Id$
  */
 public class TraversableContextSource
-implements Source, TraversableSource { 
+    implements Source, TraversableSource { 
 
     final protected Source wrappedSource;
     final protected Set children;
     final protected ContextSourceFactory factory;
     final protected String path;
     final protected String scheme;
-    
+
     public TraversableContextSource(Source source, 
                                     Set children, 
                                     ContextSourceFactory factory,
@@ -53,72 +53,71 @@
         this.scheme = scheme;
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.excalibur.source.Source#exists()
      */
     public boolean exists() {
         return this.wrappedSource.exists();
     }
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.excalibur.source.Source#getContentLength()
      */
     public long getContentLength() {
         return this.wrappedSource.getContentLength();
     }
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.excalibur.source.Source#getInputStream()
      */
     public InputStream getInputStream() 
     throws IOException, SourceNotFoundException {
         return this.wrappedSource.getInputStream();
     }
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.excalibur.source.Source#getLastModified()
      */
     public long getLastModified() {
         return this.wrappedSource.getLastModified();
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.excalibur.source.Source#getMimeType()
      */
     public String getMimeType() {
         return this.wrappedSource.getMimeType();
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.excalibur.source.Source#getScheme()
      */
     public String getScheme() {
         return this.scheme;
     }
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.excalibur.source.Source#getURI()
      */
     public String getURI() {
         return this.wrappedSource.getURI();
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.excalibur.source.Source#getValidity()
      */
     public SourceValidity getValidity() {
         return this.wrappedSource.getValidity();
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.excalibur.source.Source#refresh()
      */
     public void refresh() {
         this.wrappedSource.refresh();
     }
-    
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.excalibur.source.TraversableSource#getChild(java.lang.String)
      */
     public Source getChild(String name) throws SourceException {
@@ -146,8 +145,8 @@
         }
         return null;
     }
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.excalibur.source.TraversableSource#getChildren()
      */
     public Collection getChildren() throws SourceException {
@@ -168,16 +167,16 @@
         }
         return l;
     }
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.excalibur.source.TraversableSource#getName()
      */
     public String getName() {
         final String uri = this.wrappedSource.getURI();
         return uri.substring(uri.lastIndexOf('/')+1);
     }
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.excalibur.source.TraversableSource#getParent()
      */
     public Source getParent() throws SourceException {
@@ -189,8 +188,8 @@
             throw new SourceException("Unable to get source for: " + uri);
         }                
     }
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.excalibur.source.TraversableSource#isCollection()
      */
     public boolean isCollection() {

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java?rev=380988&r1=380987&r2=380988&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java (original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java Sat Feb 25 12:42:40 2006
@@ -165,7 +165,6 @@
         this.servletContext = context;
         this.env = environment;
         this.init();
-        this.createClassloader();
     }
 
     protected void init()
@@ -267,12 +266,9 @@
         this.appContext.put(Constants.CONTEXT_DEFAULT_ENCODING, settings.getFormEncoding());
 
         // set class loader
+        this.createClassloader();
         this.appContext.put(Constants.CONTEXT_CLASS_LOADER, this.classloader);
 
-        // Set the system properties needed by Xalan2.
-        // FIXME Do we still need this?
-        //this.setSystemProperties();
-
         // dump system properties
         this.dumpSystemProperties();
 
@@ -408,53 +404,11 @@
     }
 
     /**
-     * Sets required system properties.
-     */
-    protected void setSystemProperties() {
-        try {
-            // FIXME We shouldn't have to specify the SAXParser...
-            // This is needed by Xalan2, it is used by org.xml.sax.helpers.XMLReaderFactory
-            // to locate the SAX2 driver.
-            if (getSystemProperty("org.xml.sax.driver", null) == null) {
-                System.setProperty("org.xml.sax.driver", "org.apache.xerces.parsers.SAXParser");
-            }
-        } catch (SecurityException e) {
-            // Ignore security exceptions
-            System.out.println("Caught a SecurityException writing the system property: " + e);
-        }
-
-        try {
-            // FIXME We shouldn't have to specify these. Needed to override jaxp implementation of weblogic.
-            if (getSystemProperty("javax.xml.parsers.DocumentBuilderFactory", "").startsWith("weblogic")) {
-                System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
-                System.setProperty("javax.xml.parsers.SAXParserFactory","org.apache.xerces.jaxp.SAXParserFactoryImpl");
-            }
-        } catch (SecurityException e) {
-            // Ignore security exceptions
-            System.out.println("Caught a SecurityException writing the system property: " + e);
-        }
-    }
-
-    /**
-     * Helper method to retrieve system property.
-     * Returns default value if SecurityException is caught.
-     */
-    protected String getSystemProperty(String property, String value) {
-        try {
-            return System.getProperty(property, value);
-        } catch (SecurityException e) {
-            System.err.println("Caught a SecurityException reading the system property '" + property + "';" +
-                               " Cocoon will default to '" + value + "' value.");
-            return value;
-        }
-    }
-
-    /**
      * Read all property files from the given directory and apply them to the settings.
      */
-    protected void readProperties(String directoryName,
+    protected void readProperties(String          directoryName,
                                   MutableSettings s,
-                                  SourceResolver resolver) {
+                                  SourceResolver  resolver) {
         Source directory = null;
         try {
             directory = resolver.resolveURI(directoryName, null, CONTEXT_PARAMETERS);