You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by bl...@apache.org on 2001/01/31 16:04:00 UTC

cvs commit: xml-cocoon/src/org/apache/cocoon/util/url/resource Handler.java

bloritsch    01/01/31 07:04:00

  Modified:    src      Tag: xml-cocoon2 Manifest.mf
               src/org/apache/cocoon/components/language/markup Tag:
                        xml-cocoon2 AbstractMarkupLanguage.java
               src/org/apache/cocoon/components/language/markup/sitemap
                        Tag: xml-cocoon2 SitemapMarkupLanguage.java
               src/org/apache/cocoon/servlet Tag: xml-cocoon2
                        CocoonServlet.java
               src/org/apache/cocoon/util Tag: xml-cocoon2 NetUtils.java
  Added:       src/org/apache/cocoon/util/url Tag: xml-cocoon2
                        CocoonURLStreamHandlerFactory.java
               src/org/apache/cocoon/util/url/context Tag: xml-cocoon2
                        Handler.java
               src/org/apache/cocoon/util/url/resource Tag: xml-cocoon2
                        Handler.java
  Log:
  First stab at putting in the context and resource Handlers.  Please note, that while the
  Handlers are there, I can't get them to work reliably.  They are basically dead code
  until we make it live.  We have both "context:" and "resource:" handlers.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.6   +3 -0      xml-cocoon/src/Manifest.mf
  
  Index: Manifest.mf
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/Manifest.mf,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- Manifest.mf	2001/01/31 04:02:36	1.1.2.5
  +++ Manifest.mf	2001/01/31 15:03:51	1.1.2.6
  @@ -1,5 +1,8 @@
   Manifest-Version: 1.0
   Main-Class: org.apache.cocoon.Main
  +Class-Path: avalonapi.jar batik-all.jar bsf.jar fop-0_16_0.jar
  + jakarta-regexp-1.2.jar jstyle.jar rhino.jar xalan_2_0_D07.jar
  + xerces_1_2_3.jar xt.jar
   
   Name: org/apache/cocoon/components/markup/sitemap/java/sitemap.xsl
   Mime-Type: application/xml
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.19  +12 -20    xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/AbstractMarkupLanguage.java
  
  Index: AbstractMarkupLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/AbstractMarkupLanguage.java,v
  retrieving revision 1.1.2.18
  retrieving revision 1.1.2.19
  diff -u -r1.1.2.18 -r1.1.2.19
  --- AbstractMarkupLanguage.java	2001/01/22 21:56:34	1.1.2.18
  +++ AbstractMarkupLanguage.java	2001/01/31 15:03:52	1.1.2.19
  @@ -41,8 +41,7 @@
   import org.apache.cocoon.components.store.MemoryStore;
   import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
   
  -import org.apache.avalon.Loggable;
  -import org.apache.log.Logger;
  +import org.apache.avalon.AbstractLoggable;
   
   /**
    * Base implementation of <code>MarkupLanguage</code>. This class uses
  @@ -50,16 +49,12 @@
    * be decoupled from this context!!!
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.18 $ $Date: 2001/01/22 21:56:34 $
  + * @version CVS $Revision: 1.1.2.19 $ $Date: 2001/01/31 15:03:52 $
    */
  -public abstract class AbstractMarkupLanguage
  -     implements MarkupLanguage, Composer, Configurable, Loggable
  +public abstract class AbstractMarkupLanguage extends AbstractLoggable
  +     implements MarkupLanguage, Composer, Configurable
   {
       /**
  -     * The logger for AbstractMarkupLanguage
  -     */
  -    protected Logger log;
  -    /**
       * The supported language table
       */
       protected Hashtable languages;
  @@ -102,12 +97,6 @@
           this.logicsheetCache = new MemoryStore();
       }
   
  -    public void setLogger(Logger logger) {
  -        if (this.log == null) {
  -            this.log = logger;
  -        }
  -    }
  -
       /**
       * Initialize the (required) markup language namespace definition.
       *
  @@ -148,6 +137,7 @@
                   Logicsheet logicsheet = new Logicsheet();
                   logicsheet.setInputSource(new InputSource(logicsheetURL.toString()));
                   CachedURL entry = new CachedURL(logicsheetURL, logicsheet);
  +                entry.setLogger(getLogger());
                   this.logicsheetCache.store(logicsheetName, entry);
                   language.setLogicsheet(logicsheetName);
   
  @@ -162,6 +152,7 @@
   
                       // FIXME: This is repetitive; add method for both cases
                       URL namedLogicsheetURL = NetUtils.getURL(namedLogicsheetLocation);
  +                    getLogger().info(namedLogicsheetLocation + ": " + namedLogicsheetURL.toExternalForm());
                       String namedLogicsheetName = namedLogicsheetURL.toExternalForm();
                       NamedLogicsheet namedLogicsheet = new NamedLogicsheet();
                       namedLogicsheet.setInputSource(
  @@ -171,6 +162,7 @@
                       namedLogicsheet.setUri(namedLogicsheetUri);
                       CachedURL namedEntry =
                       new CachedURL(namedLogicsheetURL, namedLogicsheet);
  +                    namedEntry.setLogger(getLogger());
                       this.logicsheetCache.store(namedLogicsheetName, namedEntry);
                       language.addNamedLogicsheet(
                           namedLogicsheetPrefix, namedLogicsheetName
  @@ -180,7 +172,7 @@
               this.languages.put(language.getName(), language);
               }
           } catch (Exception e) {
  -            log.warn("Configuration Error: " + e.getMessage(), e);
  +            getLogger().warn("Configuration Error: " + e.getMessage(), e);
               throw new ConfigurationException("AbstractMarkupLanguage: " + e.getMessage(), e);
           }
       }
  @@ -320,7 +312,7 @@
           InputSource inputSource = null;
   
           if (codeGenerator == null) {
  -            log.debug("This should never happen: codeGenerator is null");
  +            getLogger().debug("This should never happen: codeGenerator is null");
               throw new SAXException("codeGenerator must never be null.");
           }
   
  @@ -343,6 +335,7 @@
               logicsheet = new Logicsheet();
               logicsheet.setInputSource(inputSource);
               entry = new CachedURL(url, logicsheet);
  +            entry.setLogger(getLogger());
               this.logicsheetCache.store(logicsheetName, entry);
           }
   
  @@ -455,7 +448,7 @@
       * This class holds a cached URL entry associated with a logicsheet
       *
       */
  -    protected class CachedURL {
  +    protected class CachedURL extends AbstractLoggable {
           /**
            * The logicsheet URL
            */
  @@ -535,7 +528,7 @@
               try {
                   hasChanged = this.lastModified < this.file.lastModified();
               } catch (SecurityException se) {
  -                log.warn("SecurityException", se);
  +                getLogger().warn("SecurityException", se);
               }
   
               return hasChanged;
  @@ -644,7 +637,6 @@
                           this.logicsheetMarkupGenerator, this.language.getLogicsheet(), resolver
                       );
                   } catch (IOException ioe) {
  -                    log.warn("AbstractMarkupLanguage.startElement", ioe);
                       throw new SAXException (ioe);
                   }
                   // All stylesheet have been configured and correctly setup.
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.11  +3 -3      xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/Attic/SitemapMarkupLanguage.java
  
  Index: SitemapMarkupLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/Attic/SitemapMarkupLanguage.java,v
  retrieving revision 1.1.2.10
  retrieving revision 1.1.2.11
  diff -u -r1.1.2.10 -r1.1.2.11
  --- SitemapMarkupLanguage.java	2001/01/22 21:56:35	1.1.2.10
  +++ SitemapMarkupLanguage.java	2001/01/31 15:03:54	1.1.2.11
  @@ -39,9 +39,9 @@
    * <a href="http://xml.apache.org/cocoon/sitemap.html">Sitemap</a>.
    *
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.10 $ $Date: 2001/01/22 21:56:35 $
  + * @version CVS $Revision: 1.1.2.11 $ $Date: 2001/01/31 15:03:54 $
    */
  -public class SitemapMarkupLanguage extends AbstractMarkupLanguage implements Loggable {
  +public class SitemapMarkupLanguage extends AbstractMarkupLanguage {
   
       /**
       * the dependencies' list
  @@ -135,7 +135,7 @@
                   logicsheetMarkupGenerator,
                   resolver
                );
  -        filter.setLogger(this.log);
  +        filter.setLogger(getLogger());
           return filter;
       }
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.4.48  +4 -1      xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServlet.java
  
  Index: CocoonServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServlet.java,v
  retrieving revision 1.1.4.47
  retrieving revision 1.1.4.48
  diff -u -r1.1.4.47 -r1.1.4.48
  --- CocoonServlet.java	2001/01/31 05:21:48	1.1.4.47
  +++ CocoonServlet.java	2001/01/31 15:03:55	1.1.4.48
  @@ -37,6 +37,7 @@
   import org.apache.cocoon.Notification;
   import org.apache.cocoon.environment.http.HttpEnvironment;
   import org.apache.cocoon.util.ClassUtils;
  +import org.apache.cocoon.util.NetUtils;
   
   import org.apache.log.Logger;
   import org.apache.log.LogKit;
  @@ -53,7 +54,7 @@
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
    * @author <a href="mailto:nicolaken@supereva.it">Nicola Ken Barozzi</a> Aisa
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1.4.47 $ $Date: 2001/01/31 05:21:48 $
  + * @version CVS $Revision: 1.1.4.48 $ $Date: 2001/01/31 15:03:55 $
    */
   
   public class CocoonServlet extends HttpServlet {
  @@ -105,6 +106,8 @@
           this.root = this.context.getRealPath("/");
   
           ClassUtils.setClassLoader(this.getClass().getClassLoader());
  +
  +        NetUtils.setContext(this.context);
   
           this.createCocoon();
       }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.5   +18 -2     xml-cocoon/src/org/apache/cocoon/util/Attic/NetUtils.java
  
  Index: NetUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/util/Attic/NetUtils.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- NetUtils.java	2000/12/29 18:50:46	1.1.2.4
  +++ NetUtils.java	2001/01/31 15:03:56	1.1.2.5
  @@ -12,13 +12,14 @@
   import java.util.Map;
   import java.net.URL;
   import java.net.MalformedURLException;
  +import javax.servlet.ServletContext;
   
   /**
    * A collection of <code>File</code>, <code>URL</code> and filename
    * utility methods
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/12/29 18:50:46 $
  + * @version CVS $Revision: 1.1.2.5 $ $Date: 2001/01/31 15:03:56 $
    */
   
   public class NetUtils {
  @@ -35,6 +36,17 @@
           }
       }
   
  +    /** Temporary Hack until the protocols are actually working */
  +    private static ServletContext context = null;
  +
  +    public static void setContext(ServletContext context) {
  +        if (NetUtils.context == null) {
  +            NetUtils.context = context;
  +        }
  +
  +        org.apache.cocoon.util.url.context.Handler.setContext(context);
  +    }
  +
       /**
        * Create a URL from a location. This method supports the
        * <i>resource://</i> pseudo-protocol for loading resources
  @@ -55,7 +67,11 @@
               URL u = ClassUtils.getResource(location.substring("resource://".length()));
               if (u != null) return u;
               else throw new RuntimeException(location + " could not be found. (possible classloader problem)");
  -        } else {
  +        } else if (location.startsWith("context://")) {
  +        URL u = NetUtils.context.getResource(location.substring("context://".length()));
  +        if (u != null) return u;
  +        else throw new RuntimeException(location + " could not be found. (possible classloader problem)");
  +    } else {
               return new URL(location);
           }
       }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +47 -0     xml-cocoon/src/org/apache/cocoon/util/url/Attic/CocoonURLStreamHandlerFactory.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +72 -0     xml-cocoon/src/org/apache/cocoon/util/url/context/Attic/Handler.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +69 -0     xml-cocoon/src/org/apache/cocoon/util/url/resource/Attic/Handler.java