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/jelly/src/java/org/apache/commons/jelly JellyContext.java
Date Tue, 02 Sep 2003 15:57:54 GMT
dion        2003/09/02 08:57:54

  Modified:    jelly/src/java/org/apache/commons/jelly JellyContext.java
  Log:
  Remove duplicate parent registration.
  Allow the parent context to be changed dynamically
  
  Revision  Changes    Path
  1.46      +27 -4     jakarta-commons/jelly/src/java/org/apache/commons/jelly/JellyContext.java
  
  Index: JellyContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/src/java/org/apache/commons/jelly/JellyContext.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- JellyContext.java	24 Jul 2003 06:43:05 -0000	1.45
  +++ JellyContext.java	2 Sep 2003 15:57:54 -0000	1.46
  @@ -368,10 +368,6 @@
           if (isExportLibraries() && parent != null) {
               parent.registerTagLibrary( namespaceURI, taglib );
           }
  -        
  -        if (isExportLibraries() && parent != null) {
  -            parent.registerTagLibrary( namespaceURI, taglib );
  -        }
       }
   
       /** Registers the given tag library class name against the given namespace URI.
  @@ -892,6 +888,33 @@
        */
       protected JellyContext createChildContext() {
           return new JellyContext(this);
  +    }
  +
  +    /**
  +     * Change the parent context to the one provided
  +     * @param context the new parent context
  +     */
  +    protected void setParent(JellyContext context)
  +    {
  +        parent = context;
  +        this.variables.put("parentScope", parent.variables);
  +        // need to re-export tag libraries to the new parent
  +        if (isExportLibraries() && parent != null) {
  +            for (Iterator keys = taglibs.keySet().iterator(); keys.hasNext();)
  +            {
  +                String namespaceURI = (String) keys.next();
  +                Object tagLibOrClassName = taglibs.get(namespaceURI);
  +                if (tagLibOrClassName instanceof TagLibrary)
  +                {
  +                    parent.registerTagLibrary( namespaceURI, (TagLibrary) tagLibOrClassName
);
  +                }
  +                else
  +                {
  +                    parent.registerTagLibrary( namespaceURI, (String) tagLibOrClassName
);
  +                }
  +            }
  +        }
  +
       }
   
   }
  
  
  

Mime
View raw message