You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Geoffrey Begley (JIRA)" <co...@jakarta.apache.org> on 2006/03/20 06:35:05 UTC
[jira] Created: (JELLY-227) JellyContext Mangles rootURL in
imported scripts from other directories
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