Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 62286 invoked from network); 20 Mar 2006 05:35:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Mar 2006 05:35:31 -0000 Received: (qmail 53942 invoked by uid 500); 20 Mar 2006 05:35:28 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 53854 invoked by uid 500); 20 Mar 2006 05:35:27 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 53843 invoked by uid 99); 20 Mar 2006 05:35:27 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 19 Mar 2006 21:35:27 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 19 Mar 2006 21:35:26 -0800 Received: from ajax (localhost.localdomain [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id D6E88D49FF for ; Mon, 20 Mar 2006 05:35:05 +0000 (GMT) Message-ID: <1368902727.1142832905877.JavaMail.jira@ajax> Date: Mon, 20 Mar 2006 05:35:05 +0000 (GMT) From: "Geoffrey Begley (JIRA)" To: commons-dev@jakarta.apache.org Subject: [jira] Created: (JELLY-227) JellyContext Mangles rootURL in imported scripts from other directories MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N JellyContext Mangles rootURL in imported scripts from other directories ----------------------------------------------------------------------- Key: JELLY-227 URL: http://issues.apache.org/jira/browse/JELLY-227 Project: jelly Type: Improvement Reporter: Geoffrey Begley When using the importTag and including scripts from other directories, The root URL seems to following the path of the included directory. Cause /x/y/a.jellyxml which imports /w/y/header.jx to fail if header.jx tries to import anything, it's URLs are rooted incorrectly. One would expect them to root at / but instead then root at /w/y/header.jx I used the following JellyContext extension to get around the problem: package com.myco.jelly import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.Script; import org.apache.log4j.Logger; import org.xml.sax.InputSource; import java.net.URL; import java.net.MalformedURLException; /** * Extension that Causes root to remain at the application context root */ public class RootedJellyContext extends JellyContext { public RootedJellyContext() { } public RootedJellyContext(URL rootURL) { super(rootURL); } public RootedJellyContext(URL rootURL, URL currentURL) { super(rootURL, currentURL); } public RootedJellyContext(JellyContext parent) { super(parent); } public RootedJellyContext(JellyContext parentJellyContext, URL currentURL) { super(parentJellyContext, currentURL); } public RootedJellyContext(JellyContext parentJellyContext, URL rootURL, URL currentURL) { super(parentJellyContext, rootURL, currentURL); } /** * Parses the script from the given InputSource then compiles it and runs it. * * @return the new child context that was used to run the script */ public JellyContext runScript(InputSource source, XMLOutput output, boolean export, boolean inherit) throws JellyException { Script script = compileScript(source); URL newJellyContextURL = null; try { newJellyContextURL = getJellyContextURL(source); } catch (MalformedURLException e) { throw new JellyException(e.toString()); } JellyContext newJellyContext = newJellyContext(); // ------------------ CHANGE --------------------------- newJellyContext.setRootURL( getRootURL() ); // ------------------ CHANGE --------------------------- newJellyContext.setCurrentURL( newJellyContextURL ); newJellyContext.setExport( export ); newJellyContext.setInherit( inherit ); if ( inherit ) { // use the same variable scopes newJellyContext.setVariables( this.getVariables() ); } if (log.isDebugEnabled() ) { log.debug( "About to run script: " + source.getSystemId() ); log.debug( "root context URL: " + newJellyContext.getRootURL() ); log.debug( "current context URL: " + newJellyContext.getCurrentURL() ); } script.run(newJellyContext, output); return newJellyContext; } /** * Factory method to create a new child of this context */ protected JellyContext createChildContext() { return new RootedJellyContext(this); } private Logger log = Logger.getLogger(getClass()); } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org