Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 77714 invoked from network); 11 Jan 2003 04:06:49 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 11 Jan 2003 04:06:49 -0000 Received: (qmail 28450 invoked by uid 97); 11 Jan 2003 04:08:16 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 28434 invoked by uid 97); 11 Jan 2003 04:08:15 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: 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 28423 invoked by uid 97); 11 Jan 2003 04:08:15 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Date: 11 Jan 2003 04:06:43 -0000 Message-ID: <20030111040643.25639.qmail@icarus.apache.org> From: dion@apache.org To: jakarta-commons-sandbox-cvs@apache.org Subject: cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly JellyContext.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N dion 2003/01/10 20:06:43 Modified: jelly/src/java/org/apache/commons/jelly JellyContext.java Log: - Refactor JellyContext.runScript so that the various methods are consistent. - Add a file option to the core:import tag Revision Changes Path 1.38 +41 -22 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/JellyContext.java Index: JellyContext.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/JellyContext.java,v retrieving revision 1.37 retrieving revision 1.38 diff -u -r1.37 -r1.38 --- JellyContext.java 31 Dec 2002 01:31:14 -0000 1.37 +++ JellyContext.java 11 Jan 2003 04:06:43 -0000 1.38 @@ -98,11 +98,17 @@ /** The parent context */ private JellyContext parent; + /** Default for inheritance of variables **/ + private static boolean DEFAULT_INHERIT = true; + /** Do we inherit variables from parent context? */ - private boolean inherit = true; + private boolean inherit = JellyContext.DEFAULT_INHERIT; + + /** Default for export of variables **/ + private static boolean DEFAULT_EXPORT = false; /** Do we export our variables to parent context? */ - private boolean export = false; + private boolean export = JellyContext.DEFAULT_EXPORT; /** Should we export tag libraries to our parents context */ private boolean exportLibraries = true; @@ -486,7 +492,8 @@ * @return the new child context that was used to run the script */ public JellyContext runScript(File file, XMLOutput output) throws Exception { - return runScript(file.toURL(), output); + return runScript(file.toURL(), output, JellyContext.DEFAULT_EXPORT, + JellyContext.DEFAULT_INHERIT); } /** @@ -495,19 +502,8 @@ * @return the new child context that was used to run the script */ public JellyContext runScript(URL url, XMLOutput output) throws Exception { - Script script = compileScript(url); - - URL newJellyContextURL = getJellyContextURL(url); - JellyContext newJellyContext = new JellyContext(this, newJellyContextURL); - - if (log.isDebugEnabled() ) { - log.debug( "About to run script: " + url ); - log.debug( "root context URL: " + newJellyContext.rootURL ); - log.debug( "current context URL: " + newJellyContext.currentURL ); - } - - script.run(newJellyContext, output); - return newJellyContext; + return runScript(url, output, JellyContext.DEFAULT_EXPORT, + JellyContext.DEFAULT_INHERIT); } /** @@ -521,12 +517,8 @@ if (url == null) { throw new JellyException("Could not find Jelly script: " + url); } - Script script = compileScript(url); - - URL newJellyContextURL = getJellyContextURL(url); - JellyContext newJellyContext = new JellyContext(this, newJellyContextURL); - script.run(newJellyContext, output); - return newJellyContext; + return runScript(url, output, JellyContext.DEFAULT_EXPORT, + JellyContext.DEFAULT_INHERIT); } /** @@ -541,6 +533,27 @@ if (url == null) { throw new JellyException("Could not find Jelly script: " + url); } + + return runScript(url, output, export, inherit); + } + + /** + * Parses the script from the given file then compiles it and runs it. + * + * @return the new child context that was used to run the script + */ + public JellyContext runScript(File file, XMLOutput output, + boolean export, boolean inherit) throws Exception { + return runScript(file.toURL(), output, export, inherit); + } + + /** + * Parses the script from the given URL then compiles it and runs it. + * + * @return the new child context that was used to run the script + */ + public JellyContext runScript(URL url, XMLOutput output, + boolean export, boolean inherit) throws Exception { Script script = compileScript(url); URL newJellyContextURL = getJellyContextURL(url); @@ -553,6 +566,12 @@ // use the same variable scopes newJellyContext.variables = this.variables; } + + if (log.isDebugEnabled() ) { + log.debug( "About to run script: " + url ); + log.debug( "root context URL: " + newJellyContext.rootURL ); + log.debug( "current context URL: " + newJellyContext.currentURL ); + } script.run(newJellyContext, output); -- To unsubscribe, e-mail: For additional commands, e-mail: