commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly JellyContext.java
Date Sat, 11 Jan 2003 04:06:43 GMT
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:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message