Return-Path: Delivered-To: apmail-xml-cocoon-cvs-archive@xml.apache.org Received: (qmail 94015 invoked by uid 500); 11 Oct 2001 14:39:17 -0000 Mailing-List: contact cocoon-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: cocoon-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cocoon-cvs@xml.apache.org Received: (qmail 93999 invoked by uid 500); 11 Oct 2001 14:39:17 -0000 Delivered-To: apmail-xml-cocoon2-cvs@apache.org Date: 11 Oct 2001 14:34:44 -0000 Message-ID: <20011011143444.33725.qmail@icarus.apache.org> From: bloritsch@apache.org To: xml-cocoon2-cvs@apache.org Subject: cvs commit: xml-cocoon2/src/org/apache/cocoon/servlet CocoonServlet.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N bloritsch 01/10/11 07:34:44 Modified: src/org/apache/cocoon Main.java src/org/apache/cocoon/servlet CocoonServlet.java Added: src/META-INF/services org.apache.batik.util.ParsedURLProtocolHandler src/org/apache/cocoon/components/url ParsedContextURLProtocolHandler.java Log: Add support for "context://" urls in Batik Revision Changes Path 1.1 xml-cocoon2/src/META-INF/services/org.apache.batik.util.ParsedURLProtocolHandler Index: org.apache.batik.util.ParsedURLProtocolHandler =================================================================== org.apache.cocoon.components.url.ParsedContextURLProtocolHandler #context:// urls 1.22 +3 -1 xml-cocoon2/src/org/apache/cocoon/Main.java Index: Main.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Main.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- Main.java 2001/10/10 11:18:05 1.21 +++ Main.java 2001/10/11 14:34:44 1.22 @@ -23,6 +23,7 @@ import org.apache.cocoon.util.IOUtils; import org.apache.cocoon.util.MIMEUtils; import org.apache.cocoon.util.NetUtils; +import org.apache.cocoon.components.url.ParsedContextURLProtocolHandler; import org.apache.log.Hierarchy; import org.apache.log.Logger; import org.apache.log.Priority; @@ -34,7 +35,7 @@ * Command line entry point. * * @author Stefano Mazzocchi - * @version CVS $Revision: 1.21 $ $Date: 2001/10/10 11:18:05 $ + * @version CVS $Revision: 1.22 $ $Date: 2001/10/11 14:34:44 $ */ public class Main { @@ -260,6 +261,7 @@ CommandlineContext clContext = new CommandlineContext(contextDir); clContext.setLogger(log); appContext.put(Constants.CONTEXT_ENVIRONMENT_CONTEXT, clContext); + ParsedContextURLProtocolHandler.setContext(clContext); DefaultLogKitManager logKitManager = null; if(logKit != null) { final FileInputStream fis = new FileInputStream(logKit); 1.1 xml-cocoon2/src/org/apache/cocoon/components/url/ParsedContextURLProtocolHandler.java Index: ParsedContextURLProtocolHandler.java =================================================================== /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.cocoon.components.url; import org.apache.batik.util.AbstractParsedURLProtocolHandler; import org.apache.batik.util.ParsedURL; import org.apache.batik.util.ParsedURLData; import org.apache.cocoon.environment.Context; import java.net.MalformedURLException; /** * Provide an extension to Batik to handle the "context:" protocol. This class * assumes it will live in a separate classloader as the Context is set statically. * Batik uses the Jar file Services extension, so the class is instantiated in * an uncontrolled manner (as far as Cocoon is concerned). * * @author Berin Loritsch * @version $Id: ParsedContextURLProtocolHandler.java,v 1.1 2001/10/11 14:34:44 bloritsch Exp $ */ public class ParsedContextURLProtocolHandler extends AbstractParsedURLProtocolHandler { private static Context context = null; /** * Set the ServletContext for this protocol. If it does not exist, you will * get NullPointerExceptions! */ public static final void setContext(final Context newContext) { if (ParsedContextURLProtocolHandler.context == null) { ParsedContextURLProtocolHandler.context = newContext; } } /** * Create a new instance, this doesn't do much beyond register the type of * protocol we handle. */ public ParsedContextURLProtocolHandler() { super("context"); } /** * Getbase.getPath() the ParsedURLData for the context. Absolute URIs are specified like * "context://". */ public ParsedURLData parseURL(String uri) { try { return new ParsedURLData(ParsedContextURLProtocolHandler.context .getResource(uri.substring("context://".length()))); } catch (MalformedURLException mue) { StringBuffer baseFile = new StringBuffer(ParsedContextURLProtocolHandler .context.getRealPath("/")); if ( !baseFile.toString().endsWith("/")) { baseFile.append("/"); } baseFile.append(baseFile); baseFile.append(uri.substring("context://".length())); ParsedURLData purl = new ParsedURLData(); purl.protocol = "file"; purl.path = baseFile.toString(); return purl; } } /** * The build the relative URL. Relative URIs are specified like "context:". */ public ParsedURLData parseURL(ParsedURL base, String uri) { StringBuffer newURI = new StringBuffer("context://"); newURI.append(base.getPath()); if ( !newURI.toString().endsWith("/") ) { newURI.append("/"); } newURI.append(uri.substring("context:".length())); return this.parseURL(newURI.toString()); } } 1.44 +5 -2 xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java Index: CocoonServlet.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- CocoonServlet.java 2001/10/11 09:06:02 1.43 +++ CocoonServlet.java 2001/10/11 14:34:44 1.44 @@ -17,6 +17,7 @@ import org.apache.avalon.framework.logger.Loggable; import org.apache.cocoon.*; import org.apache.cocoon.components.classloader.RepositoryClassLoader; +import org.apache.cocoon.components.url.ParsedContextURLProtocolHandler; import org.apache.cocoon.environment.Environment; import org.apache.cocoon.environment.http.HttpContext; import org.apache.cocoon.environment.http.HttpEnvironment; @@ -58,7 +59,7 @@ * @author Berin Loritsch * @author Carsten Ziegeler * @author Leo Sutic - * @version CVS $Revision: 1.43 $ $Date: 2001/10/11 09:06:02 $ + * @version CVS $Revision: 1.44 $ $Date: 2001/10/11 14:34:44 $ */ public class CocoonServlet extends HttpServlet { @@ -123,7 +124,9 @@ String value; this.servletContext = conf.getServletContext(); - this.appContext.put(Constants.CONTEXT_ENVIRONMENT_CONTEXT, new HttpContext(this.servletContext)); + HttpContext envContext = new HttpContext(this.servletContext); + this.appContext.put(Constants.CONTEXT_ENVIRONMENT_CONTEXT, envContext); + ParsedContextURLProtocolHandler.setContext(envContext); this.initLogger(); ---------------------------------------------------------------------- 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