You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by dd...@apache.org on 2006/11/03 17:42:55 UTC

svn commit: r470893 [2/2] - in /struts/sandbox/trunk/tiles: tiles-api/src/main/java/org/apache/tiles/ tiles-container-test/src/main/webapp/WEB-INF/ tiles-core/src/main/java/org/apache/tiles/context/ tiles-core/src/main/java/org/apache/tiles/context/jsp...

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/BaseInsertTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/BaseInsertTag.java?view=diff&rev=470893&r1=470892&r2=470893
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/BaseInsertTag.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/BaseInsertTag.java Fri Nov  3 08:42:53 2006
@@ -22,24 +22,20 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.tiles.definition.ComponentAttribute;
-import org.apache.tiles.context.ComponentContext;
+import org.apache.tiles.ComponentAttribute;
+import org.apache.tiles.ComponentContext;
+import org.apache.tiles.TilesContainer;
+import org.apache.tiles.TilesException;
+import org.apache.tiles.access.TilesAccess;
+import org.apache.tiles.context.BasicComponentContext;
 import org.apache.tiles.context.jsp.JspUtil;
-import org.apache.tiles.TilesRequestContext;
-import org.apache.tiles.definition.ComponentDefinition;
-import org.apache.tiles.preparer.ViewPreparer;
-import org.apache.tiles.preparer.NoSuchPreparerException;
-import org.apache.tiles.preparer.PreparerFactory;
-import org.apache.tiles.taglib.util.TagUtils;
-import org.apache.tiles.util.TilesUtil;
 
-import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.PageContext;
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.Map;
-import java.util.StringTokenizer;
 
 /**
  * This is the base abstract class for all Tiles composition JSP tags. The tag's
@@ -81,7 +77,7 @@
     /**
      * Current component context.
      */
-    protected ComponentContext cachedCurrentContext;
+    protected BasicComponentContext cachedCurrentContext;
 
     /**
      * Final handler of tag methods.
@@ -94,6 +90,11 @@
     protected PageContext pageContext = null;
 
     /**
+     * Container within which we execute.
+     */
+    protected TilesContainer container;
+
+    /**
      * Reset member values for reuse. This method calls super.release(), which
      * invokes TagSupport.release(), which typically does nothing.
      */
@@ -245,9 +246,9 @@
     /**
      * Get current component context.
      */
-    protected ComponentContext getCurrentContext() {
+    protected BasicComponentContext getCurrentContext() {
         if (cachedCurrentContext == null) {
-            cachedCurrentContext = (ComponentContext) pageContext.getAttribute(
+            cachedCurrentContext = (BasicComponentContext) pageContext.getAttribute(
                 ComponentConstants.COMPONENT_CONTEXT,
                 PageContext.REQUEST_SCOPE);
         }
@@ -255,24 +256,6 @@
         return cachedCurrentContext;
     }
 
-    /**
-     * Get instantiated ViewPreparer. Return preparerInstance denoted by preparerType,
-     * or <code>null</code> if preparerType is null.
-     *
-     * @throws JspException If preparerInstance can't be created.
-     */
-    protected ViewPreparer getPreparerInstance() throws JspException {
-        if (preparer == null) {
-            return null;
-        }
-
-        try {
-            PreparerFactory f = TilesUtil.getPreparerFactory();
-            return f.getPreparer(preparer, null);
-        } catch (NoSuchPreparerException e) {
-            throw new JspException(e);
-        }
-    }
 
     /**
      * Process the start tag by checking tag's attributes and creating
@@ -300,6 +283,8 @@
             return SKIP_BODY;
         }
 
+        container = TilesAccess.getContainer(pageContext.getServletContext());
+
         try {
             tagHandler = createTagHandler();
 
@@ -347,68 +332,14 @@
      * @throws JspException InstantiationException Can't create requested
      *                      preparerInstance
      */
-    protected TagHandler processDefinition(ComponentDefinition definition)
+    protected TagHandler processDefinition(String definition, Map<String, Object> attributes)
         throws JspException {
         // Declare local variable in order to not change Tag attribute values.
         String role = this.role;
-        String page = this.template;
-        ViewPreparer viewPreparer = null;
-
-        try {
-
-            // Overload definition with tag's template and role.
-            if (role == null) {
-                role = definition.getRole();
-            }
-
-            if (page == null) {
-                page = definition.getTemplate();
-            }
-
-            if (preparer != null) {
-                viewPreparer = TilesUtil.getPreparerFactory()
-                    .getPreparer(definition.getPreparer(), null);
-            }
+        String preparer = this.preparer;
 
-            // Can check if page is set
-            return new InsertHandler(definition.getAttributes(), page, role,
-                viewPreparer);
-        } catch (NoSuchPreparerException e) {
-            throw new JspException(e);
-        }
-    }
-
-    /**
-     * Do an include of specified page. This method is used internally to do all
-     * includes from this class. It delegates the include call to the
-     * TilesUtil.doInclude().
-     *
-     * @param page  The page that will be included
-     * @param flush If the writer should be flushed before the include
-     * @throws javax.servlet.jsp.JspException
-     */
-    protected void doInclude(String page, boolean flush) throws JspException {
-        JspUtil.doInclude(pageContext, page, flush);
-    }
-
-    // ///////////////////////////////////////////////////////////////////////////
-
-    /**
-     * Parse the list of roles and return <code>true</code> or
-     * <code>false</code> based on whether the user has that role or not.
-     *
-     * @param role    Comma-delimited list of roles.
-     * @param request The request.
-     */
-    static public boolean userHasRole(HttpServletRequest request, String role) {
-        StringTokenizer st = new StringTokenizer(role, ",");
-        while (st.hasMoreTokens()) {
-            if (request.isUserInRole(st.nextToken())) {
-                return true;
-            }
-        }
-
-        return false;
+        // Can check if page is set
+        return new DefinitionHandler(attributes, definition, role, preparer);
     }
 
     // ///////////////////////////////////////////////////////////////////////////
@@ -418,7 +349,7 @@
      */
     protected interface TagHandler {
         /**
-         * Create ComponentContext for type depicted by implementation class.
+         * Create BasicComponentContext for type depicted by implementation class.
          */
         public int doStartTag() throws JspException;
 
@@ -441,35 +372,62 @@
     protected class InsertHandler implements TagHandler {
         protected String page;
 
-        protected ComponentContext currentContext;
-
-        protected ComponentContext subCompContext;
-
         protected String role;
 
-        protected ViewPreparer preparerInstance;
+        protected String preparer;
+
+        protected Map<String, ComponentAttribute> attributes;
 
         /**
          * Constructor. Create insert handler using Component definition.
+         *
+         * @param attributes custom attributes
+         * @param page       resulting page
+         * @param role       required role
+         * @param preparer   custom preparer
          */
-        public InsertHandler(Map attributes, String page, String role,
-                             ViewPreparer preparer) {
+        public InsertHandler(Map<String, Object> attributes, String page, String role,
+                             String preparer) {
 
             this.page = page;
             this.role = role;
-            this.preparerInstance = preparer;
-            subCompContext = new ComponentContext(attributes);
+            this.preparer = preparer;
+            this.attributes = new HashMap<String, ComponentAttribute>();
+            if (attributes != null) {
+                for (Map.Entry<String, Object> entry : attributes.entrySet()) {
+                    ComponentAttribute attr = null;
+                    if (entry.getValue() instanceof ComponentAttribute) {
+                        attr = (ComponentAttribute) entry.getValue();
+                    } else {
+                        attr = new ComponentAttribute(entry.getValue());
+                    }
+                    this.attributes.put(entry.getKey(), attr);
+                }
+            }
         }
 
         /**
          * Constructor. Create insert handler to insert page at specified
          * location.
+         *
+         * @param page     resulting page
+         * @param role     required role
+         * @param preparer custom preparer
          */
-        public InsertHandler(String page, String role, ViewPreparer preparer) {
+        public InsertHandler(String page, String role, String preparer) {
             this.page = page;
             this.role = role;
-            this.preparerInstance = preparer;
-            subCompContext = new ComponentContext();
+            this.preparer = preparer;
+            this.attributes = new HashMap<String, ComponentAttribute>();
+        }
+
+
+        public void putAttribute(String name, Object value) {
+            if (value instanceof ComponentAttribute) {
+                attributes.put(name, (ComponentAttribute) value);
+            } else {
+                attributes.put(name, new ComponentAttribute(value));
+            }
         }
 
         /**
@@ -485,16 +443,9 @@
             }
 
             // save current context
-            this.currentContext = getCurrentContext();
             return EVAL_BODY_INCLUDE;
         }
 
-        /**
-         * Add attribute to sub context. Do nothing.
-         */
-        public void putAttribute(String name, Object value) {
-            subCompContext.putAttribute(name, value);
-        }
 
         /**
          * Include requested page.
@@ -509,24 +460,19 @@
             }
 
             try {
+                ComponentContext context = container.getComponentContext(pageContext);
+                for (Map.Entry<String, ComponentAttribute> entry : attributes.entrySet()) {
+                    context.putAttribute(entry.getKey(), entry.getValue());
+                }
+
                 if (log.isDebugEnabled()) {
                     log.debug("insert page='" + page + "'.");
                 }
 
-                // set new context for included component.
-                pageContext.setAttribute(ComponentConstants.COMPONENT_CONTEXT,
-                    subCompContext, PageContext.REQUEST_SCOPE);
-
                 // Call preparerInstance if any
-                if (preparerInstance != null) {
-                    try {
-                        TilesRequestContext tilesContext = TagUtils
-                            .getTilesRequestContext(pageContext);
-                        preparerInstance.execute(tilesContext, subCompContext);
-                    } catch (Exception e) {
-                        throw new ServletException(e);
-                    }
-
+                if (preparer != null) {
+                    container.prepare(request, pageContext.getResponse(),
+                        preparer);
                 }
 
                 // include requested component.
@@ -563,19 +509,51 @@
 
                 log.error(msg, e);
                 throw new JspException(msg, e);
-
-            } finally {
-                // restore old context only if currentContext not null
-                // (bug with Silverstream ?; related by Arvindra Sehmi 20010712)
-                if (currentContext != null) {
-                    pageContext.setAttribute(
-                        ComponentConstants.COMPONENT_CONTEXT,
-                        currentContext, PageContext.REQUEST_SCOPE);
-                }
             }
 
             return EVAL_PAGE;
         }
+
+        /**
+         * Do an include of specified page. This method is used internally to do all
+         * includes from this class. It delegates the include call to the
+         * JspUtil.doInclude().
+         *
+         * @param page  The page that will be included
+         * @param flush If the writer should be flushed before the include
+         * @throws javax.servlet.jsp.JspException
+         */
+        protected void doInclude(String page, boolean flush) throws JspException {
+            JspUtil.doInclude(pageContext, page, flush);
+        }
+    }
+
+    protected class DefinitionHandler extends InsertHandler {
+
+        public DefinitionHandler(Map<String, Object> attributes,
+                                 String page,
+                                 String role,
+                                 String preparer) {
+            super(attributes, page, role, preparer);
+        }
+
+        public DefinitionHandler(String page,
+                                 String role,
+                                 String preparer) {
+            super(page, role, preparer);
+        }
+
+        public void doInclude(String page, boolean flush) throws JspException {
+            try {
+
+                container.render(pageContext.getRequest(),
+                    pageContext.getResponse(), page);
+            } catch (TilesException e) {
+                throw new JspException(e);
+            }
+
+        }
+
     }
 
     // ///////////////////////////////////////////////////////////////////////////

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/DefinitionTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/DefinitionTag.java?view=diff&rev=470893&r1=470892&r2=470893
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/DefinitionTag.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/DefinitionTag.java Fri Nov  3 08:42:53 2006
@@ -20,7 +20,7 @@
 
 package org.apache.tiles.taglib;
 
-import org.apache.tiles.definition.ComponentAttribute;
+import org.apache.tiles.ComponentAttribute;
 import org.apache.tiles.definition.ComponentDefinition;
 import org.apache.tiles.taglib.util.TagUtils;
 
@@ -204,11 +204,14 @@
     }
 
     /**
+     * TODO revisit.  how do we support random tiles defs in the container environment? Add a mutable container interface?
+     *
      * Process the start tag by creating a new definition.
      *
      * @throws JspException On errors processing tag.
      */
     public int doStartTag() throws JspException {
+/*
         // Do we extend a definition ?
         if (extendsDefinition != null && !extendsDefinition.equals("")) {
             ComponentDefinition parentDef =
@@ -228,6 +231,7 @@
         if (role != null) {
             definition.setRole(role);
         }
+*/
 
         return EVAL_BODY_INCLUDE;
     }

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/GetAsStringTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/GetAsStringTag.java?view=diff&rev=470893&r1=470892&r2=470893
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/GetAsStringTag.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/GetAsStringTag.java Fri Nov  3 08:42:53 2006
@@ -21,7 +21,7 @@
 
 package org.apache.tiles.taglib;
 
-import org.apache.tiles.context.ComponentContext;
+import org.apache.tiles.context.BasicComponentContext;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.jsp.JspException;
@@ -154,7 +154,7 @@
         } // end if
 
         // Get context
-        ComponentContext compContext = (ComponentContext) pageContext.getAttribute(ComponentConstants.COMPONENT_CONTEXT, PageContext.REQUEST_SCOPE);
+        BasicComponentContext compContext = (BasicComponentContext) pageContext.getAttribute(ComponentConstants.COMPONENT_CONTEXT, PageContext.REQUEST_SCOPE);
 
         if (compContext == null)
             throw new JspException("Error - tag.getAsString : component context is not defined. Check tag syntax");

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/ImportAttributeTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/ImportAttributeTag.java?view=diff&rev=470893&r1=470892&r2=470893
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/ImportAttributeTag.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/ImportAttributeTag.java Fri Nov  3 08:42:53 2006
@@ -21,8 +21,8 @@
 
 package org.apache.tiles.taglib;
 
-import org.apache.tiles.definition.ComponentAttribute;
-import org.apache.tiles.context.ComponentContext;
+import org.apache.tiles.ComponentAttribute;
+import org.apache.tiles.context.BasicComponentContext;
 import org.apache.tiles.taglib.util.TagUtils;
 
 import javax.servlet.jsp.JspException;
@@ -141,7 +141,7 @@
      */
     public int doStartTag() throws JspException {
         // retrieve component context
-        ComponentContext compContext = (ComponentContext) pageContext.getAttribute(ComponentConstants.COMPONENT_CONTEXT, PageContext.REQUEST_SCOPE);
+        BasicComponentContext compContext = (BasicComponentContext) pageContext.getAttribute(ComponentConstants.COMPONENT_CONTEXT, PageContext.REQUEST_SCOPE);
         if (compContext == null)
             throw new JspException("Error - tag importAttribute : no tiles context found.");
 

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InitDefinitionsTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InitDefinitionsTag.java?view=diff&rev=470893&r1=470892&r2=470893
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InitDefinitionsTag.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InitDefinitionsTag.java Fri Nov  3 08:42:53 2006
@@ -21,13 +21,6 @@
 
 package org.apache.tiles.taglib;
 
-import org.apache.tiles.TilesApplicationContext;
-import org.apache.tiles.access.TilesAccess;
-import org.apache.tiles.definition.DefinitionsFactory;
-import org.apache.tiles.definition.DefinitionsFactoryConfig;
-import org.apache.tiles.definition.DefinitionsFactoryException;
-import org.apache.tiles.util.TilesUtil;
-
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.tagext.TagSupport;
 
@@ -71,24 +64,25 @@
     }
 
     /**
+     * TODO Add a MutableContainer so that this can be done?
      * Do start tag.
      */
     public int doStartTag() throws JspException {
-        DefinitionsFactory factory = TilesUtil.getDefinitionsFactory();
-        if (factory != null) {
-            return SKIP_BODY;
-        }
-
-        DefinitionsFactoryConfig factoryConfig = new DefinitionsFactoryConfig();
-        factoryConfig.setFactoryClassname(classname);
-        factoryConfig.setDefinitionConfigFiles(filename);
-
-        try {
-            factory = TilesUtil.createDefinitionsFactory(factoryConfig);
-        } catch (DefinitionsFactoryException ex) {
-            ex.printStackTrace();
-            throw new JspException(ex);
-        }
+//        DefinitionsFactory factory = TilesUtil.getDefinitionsFactory();
+//        if (factory != null) {
+//            return SKIP_BODY;
+//        }
+//
+//        DefinitionsFactoryConfig factoryConfig = new DefinitionsFactoryConfig();
+//        factoryConfig.setFactoryClassname(classname);
+//        factoryConfig.setDefinitionConfigFiles(filename);
+//
+//        try {
+//            factory = TilesUtil.createDefinitionsFactory(factoryConfig);
+//        } catch (DefinitionsFactoryException ex) {
+//            ex.printStackTrace();
+//            throw new JspException(ex);
+//        }
 
         return SKIP_BODY;
     }

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertDefinitionTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertDefinitionTag.java?view=diff&rev=470893&r1=470892&r2=470893
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertDefinitionTag.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertDefinitionTag.java Fri Nov  3 08:42:53 2006
@@ -85,7 +85,6 @@
      * Process tag attribute "definition". First, search definition in the
      * factory, then create handler from this definition.
      *
-     * @param name Name of the definition.
      * @return Appropriate TagHandler.
      * @throws JspException- NoSuchDefinitionException No Definition found for
      *                       name.
@@ -96,13 +95,9 @@
      * @throws JspException  InstantiationException Can't create requested
      *                       preparerInstance
      */
-    protected TagHandler processDefinitionName(String name) throws JspException {
+    protected TagHandler processDefinitionName(String definition) throws JspException {
 
         try {
-            TilesRequestContext tilesContext = TagUtils.getTilesRequestContext(pageContext);
-            ComponentDefinition definition = null;
-            definition = TagUtils.getComponentDefinition(name, pageContext,
-                tilesContext);
 
             if (definition == null) { // is it possible ?
                 throw new NoSuchDefinitionException(
@@ -111,7 +106,7 @@
                         + "'. Check if this name exists in definitions factory.");
             }
 
-            return processDefinition(definition);
+            return processDefinition(definition, null);
 
         } catch (NoSuchDefinitionException ex) {
             // Save exception to be able to show it later

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertTemplateTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertTemplateTag.java?view=diff&rev=470893&r1=470892&r2=470893
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertTemplateTag.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertTemplateTag.java Fri Nov  3 08:42:53 2006
@@ -45,6 +45,6 @@
      * @throws JspException If failed to create preparerInstance
      */
     protected TagHandler processUrl(String url) throws JspException {
-        return new InsertHandler(url, role, getPreparerInstance());
+        return new InsertHandler(url, role, preparer);
     }
 }

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutListTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutListTag.java?view=diff&rev=470893&r1=470892&r2=470893
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutListTag.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutListTag.java Fri Nov  3 08:42:53 2006
@@ -20,7 +20,7 @@
 
 package org.apache.tiles.taglib;
 
-import org.apache.tiles.definition.ComponentAttribute;
+import org.apache.tiles.ComponentAttribute;
 
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.tagext.TagSupport;

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/UseAttributeTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/UseAttributeTag.java?view=diff&rev=470893&r1=470892&r2=470893
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/UseAttributeTag.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/UseAttributeTag.java Fri Nov  3 08:42:53 2006
@@ -21,7 +21,7 @@
 
 package org.apache.tiles.taglib;
 
-import org.apache.tiles.context.ComponentContext;
+import org.apache.tiles.context.BasicComponentContext;
 import org.apache.tiles.taglib.util.TagUtils;
 
 import javax.servlet.jsp.JspException;
@@ -164,7 +164,7 @@
         if (localId == null)
             localId = attributeName;
 
-        ComponentContext compContext = (ComponentContext) pageContext.getAttribute(ComponentConstants.COMPONENT_CONTEXT, PageContext.REQUEST_SCOPE);
+        BasicComponentContext compContext = (BasicComponentContext) pageContext.getAttribute(ComponentConstants.COMPONENT_CONTEXT, PageContext.REQUEST_SCOPE);
         if (compContext == null)
             throw new JspException("Error - tag useAttribute : no tiles context found.");
 

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/util/TagUtils.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/util/TagUtils.java?view=diff&rev=470893&r1=470892&r2=470893
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/util/TagUtils.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/util/TagUtils.java Fri Nov  3 08:42:53 2006
@@ -20,20 +20,13 @@
 package org.apache.tiles.taglib.util;
 
 import org.apache.commons.beanutils.PropertyUtils;
-import org.apache.tiles.context.ComponentContext;
+import org.apache.tiles.ComponentContext;
 import org.apache.tiles.TilesApplicationContext;
-import org.apache.tiles.TilesRequestContext;
+import org.apache.tiles.TilesContainer;
 import org.apache.tiles.access.TilesAccess;
-import org.apache.tiles.definition.ComponentDefinition;
-import org.apache.tiles.definition.DefinitionsFactoryException;
-import org.apache.tiles.definition.FactoryNotFoundException;
-import org.apache.tiles.definition.NoSuchDefinitionException;
 import org.apache.tiles.taglib.ComponentConstants;
-import org.apache.tiles.util.TilesUtil;
 
 import javax.servlet.ServletContext;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.PageContext;
 import java.lang.reflect.InvocationTargetException;
@@ -74,14 +67,6 @@
         return TilesAccess.getApplicationContext(context);
     }
 
-    public static TilesRequestContext getTilesRequestContext(PageContext context) {
-        ServletRequest request = context.getRequest();
-        ServletResponse response = context.getResponse();
-        ServletContext ctx = context.getServletContext();
-
-        return TilesUtil.createRequestContext(request, response);
-    }
-
 
     /**
      * Get scope value from string value
@@ -190,8 +175,8 @@
      * @return Requested bean or <code>null</code> if not found.
      */
     public static Object findAttribute(String beanName, PageContext pageContext) {
-        TilesRequestContext tilesContext = getTilesRequestContext(pageContext);
-        ComponentContext compContext = ComponentContext.getContext(tilesContext);
+        TilesContainer container = TilesAccess.getContainer(pageContext);
+        ComponentContext compContext = container.getComponentContext(pageContext);
 
         if (compContext != null) {
             Object attribute = compContext.findAttribute(beanName, pageContext);
@@ -214,9 +199,11 @@
      * @return Requested bean or <code>null</code> if not found.
      */
     public static Object getAttribute(String beanName, int scope, PageContext pageContext) {
+
         if (scope == ComponentConstants.COMPONENT_SCOPE) {
-            TilesRequestContext tilesContext = getTilesRequestContext(pageContext);
-            ComponentContext compContext = ComponentContext.getContext(tilesContext);
+            TilesContainer container = TilesAccess.getContainer(pageContext);
+            ComponentContext compContext = container.getComponentContext(pageContext);
+
             return compContext.getAttribute(beanName);
         }
         return pageContext.getAttribute(beanName, scope);
@@ -344,64 +331,6 @@
      */
     public static void saveException(PageContext pageContext, Throwable exception) {
         pageContext.setAttribute(ComponentConstants.EXCEPTION_KEY, exception, PageContext.REQUEST_SCOPE);
-    }
-
-    /**
-     * Get component definition by its name.
-     *
-     * @param name        Definition name.
-     * @param pageContext The PageContext for the current page.
-     * @throws JspException -
-     */
-    public static ComponentDefinition getComponentDefinition(String name, PageContext pageContext)
-        throws JspException {
-        return getComponentDefinition(name, pageContext, null);
-    }
-
-
-    /**
-     * Get component definition by its name.
-     *
-     * @param name         Definition name.
-     * @param pageContext  The PageContext for the current page.
-     * @param tilesContext The TilesApplicationContext for the current request. If it is
-     *                     null, it will be created.
-     * @throws JspException -
-     */
-    public static ComponentDefinition getComponentDefinition(String name,
-                                                             PageContext pageContext,
-                                                             TilesRequestContext tilesContext)
-        throws JspException {
-
-        try {
-            ComponentDefinition definition;
-            Object definitionCandidate = findAttribute(name, pageContext);
-            if (definitionCandidate != null
-                && definitionCandidate instanceof ComponentDefinition) {
-                definition = (ComponentDefinition) definitionCandidate;
-            } else {
-                if (tilesContext == null) {
-                    tilesContext = getTilesRequestContext(pageContext);
-                }
-                definition = TilesUtil.getDefinition(name, tilesContext);
-            }
-            return definition;
-
-        } catch (NoSuchDefinitionException ex) {
-            throw new JspException(
-                "Error : Can't get component definition for '"
-                    + name
-                    + "'. Check if this name exist in component definitions.", ex);
-        } catch (FactoryNotFoundException ex) { // impl not found.
-            throw new JspException(ex);
-
-        } catch (DefinitionsFactoryException ex) {
-            if (debug)
-                ex.printStackTrace();
-            // Save exception to be able to show it later
-            saveException(pageContext, ex);
-            throw new JspException(ex);
-        }
     }
 
 }

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/util/package.html
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/util/package.html?view=diff&rev=470893&r1=470892&r2=470893
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/util/package.html (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/util/package.html Fri Nov  3 08:42:53 2006
@@ -3,8 +3,6 @@
     <title>tiles.util package</title>
 </head>
 <body>
-Static utility classes.
-These have been deprecated and will be refactored or removed before the release of Tiles2
-and replaced by the TilesContainer architecture.
+Static utility classes used throughout the implementation.
 </body>
 </html>

Modified: struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/definition/MockOnlyLocaleTilesContext.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/definition/MockOnlyLocaleTilesContext.java?view=diff&rev=470893&r1=470892&r2=470893
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/definition/MockOnlyLocaleTilesContext.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/definition/MockOnlyLocaleTilesContext.java Fri Nov  3 08:42:53 2006
@@ -107,4 +107,8 @@
 
     public void include(String path) throws IOException, Exception {
     }
+
+    public boolean isUserInRole(String role) {
+        return false;
+    }
 }

Modified: struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/definition/TestComponentDefinitions.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/definition/TestComponentDefinitions.java?view=diff&rev=470893&r1=470892&r2=470893
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/definition/TestComponentDefinitions.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/definition/TestComponentDefinitions.java Fri Nov  3 08:42:53 2006
@@ -30,7 +30,7 @@
 import org.apache.tiles.definition.ComponentDefinitions;
 import org.apache.tiles.definition.NoSuchDefinitionException;
 import org.apache.tiles.definition.ComponentDefinition;
-import org.apache.tiles.definition.ComponentAttribute;
+import org.apache.tiles.ComponentAttribute;
 
 /**
  * Tests the ComponentDefinitionsImpl class.

Modified: struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/preparer/BasicPreparerFactoryTest.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/preparer/BasicPreparerFactoryTest.java?view=diff&rev=470893&r1=470892&r2=470893
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/preparer/BasicPreparerFactoryTest.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/test/java/org/apache/tiles/preparer/BasicPreparerFactoryTest.java Fri Nov  3 08:42:53 2006
@@ -31,19 +31,14 @@
         factory = new BasicPreparerFactory();
     }
 
-    public void testGetPreparer() throws NoSuchPreparerException {
+    public void testGetPreparer() throws PreparerException {
         String name = ViewPreparerSupport.class.getName();
         ViewPreparer p = factory.getPreparer(name, null);
         assertNotNull(p);
         assertTrue(p instanceof ViewPreparerSupport);
 
         name = "org.doesnotexist.Class";
-        try {
-            p = factory.getPreparer(name, null);
-            assertNull(p);
-            fail("Exception should have been thrown.");
-        } catch(NoSuchPreparerException n) {
-            //Good!
-        }
+        p = factory.getPreparer(name, null);
+        assertNull(p);
     }
 }

Modified: struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/index.jsp?view=diff&rev=470893&r1=470892&r2=470893
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/index.jsp (original)
+++ struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/index.jsp Fri Nov  3 08:42:53 2006
@@ -25,22 +25,22 @@
     <h1>Tiles 2 Test Application</h1>
     
     <h2>Currently working tests</h2>
-    <a href="testdef.jsp">Test Definition Tag</a><br/>
     <a href="testinsertdefinition.jsp">Test Insert Configured Definition</a><br/>
     <a href="testinsertdefinition_notype.jsp">Test Insert Configured Definition with no type specified</a><br/>
     <a href="testinsertdefinition_override.jsp">Test Insert Configured Definition with an overridden content</a><br/>
     <a href="testinsertdefinition_inline.jsp">Test Insert Configured Definition with an inline content</a><br/>
     <a href="testinsertdefinition_composite.jsp">Test Insert Configured Definition that contains another definition inside</a><br/>
-    <a href="testinsertdefinition_composite_tags_includes_configured.jsp">Test Insert Definition that contains another definition inside (configured via tiles-defs.xml) using JSP tags</a><br/>
-    <a href="testinsertdefinition_composite_tags_includes_configured_notype.jsp">Test Insert Definition that contains another definition inside (configured via tiles-defs.xml) using JSP tags without types</a><br/>
-    <a href="testinsertdefinition_composite_tags.jsp">Test Insert Definition that contains another definition inside using JSP tags</a><br/>
-    <a href="testinsertdefinition_composite_tags_notype.jsp">Test Insert Definition that contains another definition inside using JSP tags without types</a><br/>
+    <!-- Broken Tests Go Here! -->
     <a href="testput.jsp">Test Put Tag</a><br/>
     <a href="testput_servlet.jsp">Test Put Tag using a servlet mapping as a template</a><br/>
     <a href="testimportattribute.jsp">Test importAttribute Tag</a><br/>
     
     <h2>Currently not working tests</h2>
-    Currently all the tests work.
-</body>
+    <a href="testdef.jsp">Test Definition Tag</a><br/>
+    <!-- Currently all the tests work.-->
+    <a href="testinsertdefinition_composite_tags_includes_configured.jsp">Test Insert Definition that contains another definition inside (configured via tiles-defs.xml) using JSP tags</a><br/>
+    <a href="testinsertdefinition_composite_tags_includes_configured_notype.jsp">Test Insert Definition that contains another definition inside (configured via tiles-defs.xml) using JSP tags without types</a><br/>
+    <a href="testinsertdefinition_composite_tags.jsp">Test Insert Definition that contains another definition inside using JSP tags</a><br/>
+    <a href="testinsertdefinition_composite_tags_notype.jsp">Test Insert Definition that contains another definition inside using JSP tags without types</a><br/></body>
 
 </html>