jstrachan    02/05/28 03:28:37

  Modified:    jelly/src/java/org/apache/commons/jelly JellyContext.java
  Log:
  added getter and setter methods for the rootURL and currentURL so that the context 
can be explicitly set by an external controller that invokes Jelly
  
  Revision  Changes    Path
  1.7       +50 -14    
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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JellyContext.java 21 May 2002 16:53:26 -0000      1.6
  +++ JellyContext.java 28 May 2002 10:28:36 -0000      1.7
  @@ -81,10 +81,10 @@
   public class JellyContext {
   
       /** The root URL context (where scripts are located from) */
  -    private URL rootContext;
  +    private URL rootURL;
   
       /** The current URL context (where relative scripts are located from) */
  -    private URL currentJellyContext;
  +    private URL currentURL;
   
       /** Tag libraries found so far */
       private Map taglibs = new Hashtable();
  @@ -111,28 +111,28 @@
   
   
       public JellyContext() {
  -        this.currentJellyContext = rootContext;
  +        this.currentURL = rootURL;
       }
   
  -    public JellyContext(URL rootContext) {
  -        this( rootContext, rootContext );
  +    public JellyContext(URL rootURL) {
  +        this( rootURL, rootURL );
       }
   
  -    public JellyContext(URL rootContext, URL currentJellyContext) {
  -        this.rootContext = rootContext;
  -        this.currentJellyContext = currentJellyContext;
  +    public JellyContext(URL rootURL, URL currentURL) {
  +        this.rootURL = rootURL;
  +        this.currentURL = currentURL;
       }
   
       public JellyContext(JellyContext parentJellyContext) {
  -        this.rootContext = parentJellyContext.rootContext;
  -        this.currentJellyContext = parentJellyContext.currentJellyContext;
  +        this.rootURL = parentJellyContext.rootURL;
  +        this.currentURL = parentJellyContext.currentURL;
           this.taglibs = parentJellyContext.taglibs;
           this.variables.put("parentScope", parentJellyContext.variables);
       }
   
  -    public JellyContext(JellyContext parentJellyContext, URL currentJellyContext) {
  +    public JellyContext(JellyContext parentJellyContext, URL currentURL) {
           this(parentJellyContext);
  -        this.currentJellyContext = currentJellyContext;
  +        this.currentURL = currentURL;
       }
   
       /** @return the value of the given variable name */
  @@ -311,7 +311,7 @@
       public URL getResource(String uri) throws MalformedURLException {
           if (uri.startsWith("/")) {
               // append this uri to the context root
  -            return createRelativeURL(rootContext, uri.substring(1));
  +            return createRelativeURL(rootURL, uri.substring(1));
           }
           else {
               try {
  @@ -320,7 +320,7 @@
               catch (MalformedURLException e) {
                   // lets try find a relative resource
                   try {
  -                    return createRelativeURL(currentJellyContext, uri);
  +                    return createRelativeURL(currentURL, uri);
                   }
                   catch (MalformedURLException e2) {
                       throw e;
  @@ -358,6 +358,42 @@
       // Properties
       //-------------------------------------------------------------------------     
           
   
  +    /**
  +     * @return the current root context URL from which all absolute resource URIs
  +     *  will be relative to. For example in a web application the root URL will
  +     *  map to the web directory which contains the WEB-INF directory.
  +     */
  +    public URL getRootURL() {
  +        return rootURL;
  +    }
  +    
  +    /**
  +     * Sets the current root context URL from which all absolute resource URIs
  +     *  will be relative to. For example in a web application the root URL will
  +     *  map to the web directory which contains the WEB-INF directory.
  +     */
  +    public void setRootURL(URL rootURL) {
  +        this.rootURL = rootURL;
  +    }
  +    
  +
  +    /** 
  +     * @return the current URL context of the current script that is executing. 
  +     *  This URL context is used to deduce relative scripts when relative URIs are
  +     *  used in calls to {@link getResource()} to process relative scripts.
  +     */ 
  +    public URL getCurrentURL() {
  +        return currentURL;
  +    }
  +    
  +    /** 
  +     * Sets the current URL context of the current script that is executing. 
  +     *  This URL context is used to deduce relative scripts when relative URIs are
  +     *  used in calls to {@link getResource()} to process relative scripts.
  +     */ 
  +    public void setCurrentURL(URL currentURL) { 
  +        this.currentURL = currentURL;
  +    }
   
       /**
        * Return the class loader to be used for instantiating application objects
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to