commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly JellyContext.java
Date Mon, 19 Aug 2002 16:30:05 GMT
jstrachan    2002/08/19 09:30:05

  Modified:    jelly/src/java/org/apache/commons/jelly JellyContext.java
  Log:
  Patch so that child contexts can register new tag libraries, or even override which tag
library is active for a given URI, without affectiing the parent context.
  This is a similar pattern to allow child variable scopes to be local and not affect the
parent scope
  
  Revision  Changes    Path
  1.23      +16 -11    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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- JellyContext.java	12 Aug 2002 19:11:46 -0000	1.22
  +++ JellyContext.java	19 Aug 2002 16:30:05 -0000	1.23
  @@ -142,7 +142,6 @@
           this.parent = parent;
           this.rootURL = parent.rootURL;
           this.currentURL = parent.currentURL;
  -        this.taglibs = parent.taglibs;
           this.variables.put("parentScope", parent.variables);
           this.cacheTags = cacheTags;
           init();
  @@ -364,7 +363,16 @@
       }
   
       public boolean isTagLibraryRegistered(String namespaceURI) {
  -        return taglibs.containsKey( namespaceURI );
  +        boolean answer = taglibs.containsKey( namespaceURI );
  +        if (answer) {
  +            return true;
  +        }
  +        else if ( parent != null ) {
  +            return parent.isTagLibraryRegistered(namespaceURI);
  +        }
  +        else {
  +            return false;
  +        }
       }
   
       /** 
  @@ -372,16 +380,13 @@
        */
       public TagLibrary getTagLibrary(String namespaceURI) {
   
  -        Object answer = null;
  -
  -        if ( getInherit()
  -             &&
  -             getParent() != null ) {
  -            answer = getParent().getTagLibrary( namespaceURI );
  -        }
  +        // use my own mapping first, so that namespaceURIs can 
  +        // be redefined inside child contexts...
  +        
  +        Object answer = taglibs.get(namespaceURI);
   
  -        if ( answer == null ) {
  -            answer = taglibs.get(namespaceURI);
  +        if ( answer == null && parent != null ) {
  +            answer = parent.getTagLibrary( namespaceURI );
           }
   
           if ( answer instanceof TagLibrary ) {
  
  
  

--
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