cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Timm, Sean" <ST...@mailgo.com>
Subject RE: cvs commit: xml-cocoon/src/org/apache/cocoon/processor/xslt XSLTProcessor.java
Date Wed, 16 Feb 2000 17:45:46 GMT
Hmm...I don't know why I didn't run into this before.  This is because we're
now tacking the resource name on to the end of the request info for XSLT
stylesheets.  Perhaps this change should be moved into Utils.encode and
decode, since it appears that we are always assuming that the object passed
into hasChanged is the request object.  We could just calculate the resource
information in those functions and tack it on.  Does this sound reasonable
to everyone?  I can go through and make the changes...

- Sean T.

-----Original Message-----
From: Zvi Avraham [mailto:zvia@netmanage.co.il]
Sent: Wednesday, February 16, 2000 12:25 PM
To: cocoon-dev@xml.apache.org
Subject: Re: cvs commit: xml-cocoon/src/org/apache/cocoon/processor/xslt
XSLTProcessor.java


Stefano,

you entered bug here !
Cocoon trying to cast HttpServletRequestFacade to String,
maybe this work on JServ, but on Tomcat 3.0 (which I using).

    public boolean hasChanged(Object context) {
        return this.monitor.hasChanged((String) context);
                                                            ^--- Error
    }


Error found handling the request.
java.lang.ClassCastException:
org.apache.tomcat.core.HttpServletRequestFacade
 at
org.apache.cocoon.processor.xslt.XSLTProcessor.hasChanged(XSLTProcessor.java
:203)
 at org.apache.cocoon.cache.CocoonCache.getPage(CocoonCache.java:92)
 at org.apache.cocoon.Engine.handle(Engine.java:250)
 at org.apache.cocoon.Cocoon.service(Cocoon.java:145)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
 at
org.apache.tomcat.core.ServiceInvocationHandler.method(ServletWrapper.java:6
26)
 at
org.apache.tomcat.core.ServletWrapper.handleInvocation(ServletWrapper.java:5
34)
 at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:378)
 at org.apache.tomcat.core.Context.handleRequest(Context.java:644)
 at org.apache.tomcat.core.ContextManager.service(ContextManager.java:440)
 at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:144)
 at org.apache.tomcat.service.TcpConnectionThread.run(TcpEndpoint.java:304)
 at java.lang.Thread.run(Unknown Source)



stefano@locus.apache.org wrote:

> stefano     00/02/15 17:11:18
>
>   Modified:    src/org/apache/cocoon/processor/xslt XSLTProcessor.java
>   Log:
>   patched to allow better synch when stylesheets are updated.
>
>   Thanks to Sean Timm for this. (yes, Sean, I've seen it :)
>
>   Revision  Changes    Path
>   1.7       +38 -36
xml-cocoon/src/org/apache/cocoon/processor/xslt/XSLTProcessor.java
>
>   Index: XSLTProcessor.java
>   ===================================================================
>   RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/processor/xslt/XSLTProcessor.java
,v
>   retrieving revision 1.6
>   retrieving revision 1.7
>   diff -u -r1.6 -r1.7
>   --- XSLTProcessor.java        2000/02/13 18:29:34     1.6
>   +++ XSLTProcessor.java        2000/02/16 01:11:18     1.7
>   @@ -1,36 +1,36 @@
>   -/*-- $Id: XSLTProcessor.java,v 1.6 2000/02/13 18:29:34 stefano Exp $ --
>   +/*-- $Id: XSLTProcessor.java,v 1.7 2000/02/16 01:11:18 stefano Exp $ --
>
>
============================================================================
>                       The Apache Software License, Version 1.1
>
============================================================================
>   -
>   +
>     Copyright (C) @year@ The Apache Software Foundation. All rights
reserved.
>   -
>   +
>     Redistribution and use in source and binary forms, with or without
modifica-
>     tion, are permitted provided that the following conditions are met:
>   -
>   +
>     1. Redistributions of  source code must  retain the above copyright
notice,
>        this list of conditions and the following disclaimer.
>   -
>   +
>     2. Redistributions in binary form must reproduce the above copyright
notice,
>        this list of conditions and the following disclaimer in the
documentation
>        and/or other materials provided with the distribution.
>   -
>   +
>     3. The end-user documentation included with the redistribution, if
any, must
>        include  the following  acknowledgment:  "This product includes
software
>        developed  by the  Apache Software Foundation
(http://www.apache.org/)."
>        Alternately, this  acknowledgment may  appear in the software
itself,  if
>        and wherever such third-party acknowledgments normally appear.
>   -
>   +
>     4. The names "Cocoon" and  "Apache Software Foundation"  must not be
used to
>        endorse  or promote  products derived  from this  software without
prior
>        written permission. For written permission, please contact
>        apache@apache.org.
>   -
>   +
>     5. Products  derived from this software may not  be called "Apache",
nor may
>        "Apache" appear  in their name,  without prior written permission
of the
>        Apache Software Foundation.
>   -
>   +
>     THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES,
>     INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND
>     FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT
SHALL  THE
>   @@ -41,14 +41,14 @@
>     ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,
OR TORT
>     (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE
USE OF
>     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>   -
>   +
>     This software  consists of voluntary contributions made  by many
individuals
>     on  behalf of the Apache Software  Foundation and was  originally
created by
>   - Stefano Mazzocchi  <stefano@apache.org>. For more  information on the
Apache
>   + Stefano Mazzocchi  <stefano@apache.org>. For more  information on the
Apache
>     Software Foundation, please see <http://www.apache.org/>.
>   -
>   +
>     */
>   -
>   +
>    package org.apache.cocoon.processor.xslt;
>
>    import java.io.*;
>   @@ -70,13 +70,13 @@
>     * This class implements an XSLT processor.
>     *
>     * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
>   - * @version $Revision: 1.6 $ $Date: 2000/02/13 18:29:34 $
>   + * @version $Revision: 1.7 $ $Date: 2000/02/16 01:11:18 $
>     */
>
>    public class XSLTProcessor implements Actor, Processor, Status,
Defaults {
>
>        private Monitor monitor = new Monitor(10);
>   -
>   +
>        private Parser parser;
>        private Store store;
>        private Transformer transformer;
>   @@ -88,14 +88,14 @@
>        }
>
>        public Document process(Document document, Dictionary parameters)
throws Exception {
>   -
>   +
>            Document sheet = (Document) parameters.get("stylesheet");
>            if (sheet != null) return sheet;
>
>            HttpServletRequest request = (HttpServletRequest)
parameters.get("request");
>            String path = (String) parameters.get("path");
>            String browser = (String) parameters.get("browser");
>   -
>   +
>            try {
>                Object resource = getResource(document, path, browser);
>                Document stylesheet = getStylesheet(resource, document,
request);
>   @@ -107,19 +107,19 @@
>        }
>
>        private Object getResource(Document document, String path, String
browser) throws ProcessorException {
>   -
>   +
>            Object resource = null;
>   -
>   +
>            Enumeration pis = Utils.getAllPIs(document,
STYLESHEET_PI).elements();
>            while (pis.hasMoreElements()) {
>                Hashtable attributes =
Utils.getPIPseudoAttributes((ProcessingInstruction) pis.nextElement());
>   -
>   +
>                String type = (String) attributes.get("type");
>                if ((type != null) && (type.equals("text/xsl"))) {
>                    String url = (String) attributes.get("href");
>                    if (url != null) {
>                        Object local = null;
>   -
>   +
>                        try {
>                            if (url.indexOf("://") < 0) {
>                                local = new File(path + url);
>   @@ -127,12 +127,12 @@
>                                local = new URL(url);
>                            }
>                        } catch (MalformedURLException e) {
>   -                        throw new ProcessorException("Could not
associate stylesheet to document: "
>   +                        throw new ProcessorException("Could not
associate stylesheet to document: "
>                                + url + " is a malformed URL.");
>                        }
>   -
>   +
>                        String media = (String) attributes.get("media");
>   -
>   +
>                        if (media == null) {
>                            resource = local;
>                            if (browser == null) break;
>   @@ -153,29 +153,31 @@
>                return resource;
>            }
>        }
>   -
>   +
>        private Document getStylesheet(Object resource, Document document,
HttpServletRequest request) throws ProcessorException {
>
>            try {
>                Document sheet;
>   -
>   -            if (this.hasChanged(request)) {
>   +            String stylesheetKey = Utils.encode(request, true) +
resource.toString();
>   +
>   +            if (this.hasChanged(stylesheetKey)) {
>                    sheet = getDocument(resource);
>                    this.store.hold(resource, sheet);
>   -                this.monitor.watch(Utils.encode(request, true),
resource);
>   +                this.monitor.watch(stylesheetKey, resource);
>                } else {
>                    Object o = this.store.get(resource);
>                    if (o != null) {
>                        sheet = (Document) o;
>                    } else {
>   -                    sheet  = getDocument(resource);
>   +                    sheet = getDocument(resource);
>                        this.store.hold(resource, sheet);
>   +                    this.monitor.watch(stylesheetKey, resource);
>                    }
>                }
>   -
>   +
>                return sheet;
>            } catch (Exception e) {
>   -            throw new ProcessorException("Could not associate
stylesheet to document: "
>   +            throw new ProcessorException("Could not associate
stylesheet to document: "
>                    + " error reading " + resource + ": " +
e.getMessage());
>            }
>        }
>   @@ -183,7 +185,7 @@
>        private Document getDocument(Object resource) throws Exception {
>            InputSource input = new InputSource();
>            input.setSystemId(resource.toString());
>   -
>   +
>            if (resource instanceof File) {
>                input.setCharacterStream(new FileReader(((File)
resource)));
>            } else if (resource instanceof URL) {
>   @@ -192,15 +194,15 @@
>                // should never happen
>                throw new Error("Fatal error: Could not elaborate given
resource: " + resource);
>            }
>   -
>   +
>            // do not validate stylesheets
>            return this.parser.parse(input, false);
>        }
>   -
>   +
>        public boolean hasChanged(Object context) {
>   -        return
this.monitor.hasChanged(Utils.encode((HttpServletRequest) context, true));
>   +        return this.monitor.hasChanged((String) context);
>        }
>   -
>   +
>        public String getStatus() {
>            return "XSLT Processor";
>        }
>
>
>

Mime
View raw message