Author: apetrelli
Date: Mon Apr  7 11:12:50 2008
New Revision: 645636

URL: http://svn.apache.org/viewvc?rev=645636&view=rev
Log:
TILES-262
Created an abstract factory to create Tiles container.

Added:
    
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/AbstractTilesContainerFactory.java
   (with props)
Modified:
    
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/TilesContainerFactory.java
    
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/web/startup/TilesListener.java
    
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/KeyedDefinitionsFactoryTilesContainerFactoryTest.java
    
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/TilesContainerFactoryTest.java
    
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/BasicTilesContainerTest.java
    
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/KeyedDefinitionsFactoryTilesContainerTest.java
    
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/util/RollingVectorEnumeration.java
    
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/definition/InitContainerTag.java

Added: 
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/AbstractTilesContainerFactory.java
URL: 
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/AbstractTilesContainerFactory.java?rev=645636&view=auto
==============================================================================
--- 
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/AbstractTilesContainerFactory.java
 (added)
+++ 
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/AbstractTilesContainerFactory.java
 Mon Apr  7 11:12:50 2008
@@ -0,0 +1,151 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tiles.factory;
+
+import java.lang.reflect.Method;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tiles.TilesContainer;
+import org.apache.tiles.util.ClassUtil;
+
+/**
+ * Abstract Factory that creates instances of [EMAIL PROTECTED] 
TilesContainerFactory}.
+ *
+ * @version $Rev$ $Date$
+ * @since 2.1.0
+ */
+public abstract class AbstractTilesContainerFactory {
+
+    /**
+     * Initialization parameter that represents the container factory class
+     * name.
+     *
+     * @since 2.1.0
+     */
+    public static final String CONTAINER_FACTORY_INIT_PARAM =
+        "org.apache.tiles.factory.TilesContainerFactory";
+
+    /**
+     * Default configuration parameters.
+     */
+    private static final Map<String, String> DEFAULTS =
+        new HashMap<String, String>();
+
+    static {
+        DEFAULTS.put(CONTAINER_FACTORY_INIT_PARAM, 
TilesContainerFactory.class.getName());
+    }
+
+    /**
+     * Creates a factory instance.
+     *
+     * @param context The application context object.
+     * @return The created factory.
+     * @throws TilesContainerFactoryException If something goes wrong during
+     * creation.
+     * @since 2.1.0
+     */
+    @SuppressWarnings("deprecation")
+    public static AbstractTilesContainerFactory 
getTilesContainerFactory(Object context) {
+        AbstractTilesContainerFactory retValue;
+        String factoryName = getInitParameter(context, 
CONTAINER_FACTORY_INIT_PARAM);
+        if (factoryName == null) {
+            factoryName = getInitParameter(context,
+                    TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM);
+        }
+        if (factoryName != null) {
+            retValue = (AbstractTilesContainerFactory) 
ClassUtil.instantiate(factoryName);
+        } else {
+            retValue = new TilesContainerFactory();
+        }
+        return retValue;
+    }
+
+    /**
+     * Creates a Tiles container.
+     *
+     * @param context The (application) context object.
+     * @return The created container.
+     * @throws TilesContainerFactoryException If something goes wrong during
+     * instantiation.
+     * @since 2.1.0
+     */
+    public abstract TilesContainer createContainer(Object context);
+
+    /**
+     * Returns a map containing parameters name-value entries.
+     *
+     * @param context The (application) context object to use.
+     * @return The initialization parameters map.
+     * @throws TilesContainerFactoryException If the context object has not 
been
+     * recognized.
+     * @since 2.1.0
+     */
+    @SuppressWarnings("unchecked")
+    protected static Map<String, String> getInitParameterMap(Object context) {
+        Map<String, String> initParameters = new HashMap<String, String>();
+        Class<?> contextClass = context.getClass();
+        try {
+            Method method = contextClass.getMethod("getInitParameterNames");
+            Enumeration<String> e = (Enumeration<String>) method
+                    .invoke(context);
+
+            method = contextClass.getMethod("getInitParameter", String.class);
+            while (e.hasMoreElements()) {
+                String key = e.nextElement();
+                initParameters.put(key, (String) method.invoke(context, key));
+            }
+        } catch (Exception e) {
+            throw new TilesContainerFactoryException(
+                    "Unable to retrieve init parameters."
+                    + " Is this context a ServletContext, PortletContext,"
+                    + " or similar object?", e);
+        }
+        return initParameters;
+    }
+
+    /**
+     * Returns the value of an initialization parameter.
+     *
+     * @param context The (application) context object to use.
+     * @param parameterName The parameter name to retrieve.
+     * @return The parameter value.
+     * @throws TilesContainerFactoryException If the context has not been
+     * recognized.
+     * @since 2.1.0
+     */
+    protected static String getInitParameter(Object context,
+            String parameterName) {
+        Object value;
+        try {
+            Class<?> contextClass = context.getClass();
+            Method getInitParameterMethod =
+                contextClass.getMethod("getInitParameter", String.class);
+            value = getInitParameterMethod.invoke(context, parameterName);
+        } catch (Exception e) {
+            throw new TilesContainerFactoryException(
+                    "Unrecognized context.  Is this context"
+                    + " a ServletContext, PortletContext, or similar?", e);
+        }
+        return value == null ? null : value.toString();
+    }
+}

Propchange: 
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/AbstractTilesContainerFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/AbstractTilesContainerFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: 
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/TilesContainerFactory.java
URL: 
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/TilesContainerFactory.java?rev=645636&r1=645635&r2=645636&view=diff
==============================================================================
--- 
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/TilesContainerFactory.java
 (original)
+++ 
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/TilesContainerFactory.java
 Mon Apr  7 11:12:50 2008
@@ -43,8 +43,6 @@
 import org.apache.tiles.renderer.impl.BasicRendererFactory;
 import org.apache.tiles.util.ClassUtil;
 
-import java.lang.reflect.Method;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -56,11 +54,13 @@
  * @version $Rev$ $Date$
  * @since 2.0
  */
-public class TilesContainerFactory {
+public class TilesContainerFactory extends AbstractTilesContainerFactory {
 
     /**
      * Initialization parameter that represents the container factory class
      * name.
+     *
+     * @deprecated Use [EMAIL PROTECTED] 
AbstractTilesContainerFactory#CONTAINER_FACTORY_INIT_PARAM}.
      */
     public static final String CONTAINER_FACTORY_INIT_PARAM =
         "org.apache.tiles.factory.TilesContainerFactory";
@@ -119,7 +119,6 @@
         new HashMap<String, String>();
 
     static {
-        DEFAULTS.put(CONTAINER_FACTORY_INIT_PARAM, 
TilesContainerFactory.class.getName());
         DEFAULTS.put(CONTEXT_FACTORY_INIT_PARAM, 
ChainedTilesContextFactory.class.getName());
         DEFAULTS.put(DEFINITIONS_FACTORY_INIT_PARAM, 
UrlDefinitionsFactory.class.getName());
         DEFAULTS.put(PREPARER_FACTORY_INIT_PARAM, 
BasicPreparerFactory.class.getName());
@@ -134,21 +133,22 @@
         new HashMap<String, String>(DEFAULTS);
 
     /**
-     * Retrieve a factory instance as configured through the
-     * specified context.
-     * <p/>
-     * The context will be queried and if a init parameter
-     * named 'org.apache.tiles.factory.TilesContainerFactory' is discovered
-     * this class will be instantiated and returned. Otherwise,
-     * the factory will attempt to utilize one of it's internal
-     * factories.
+     * Retrieve a factory instance as configured through the specified context.
+     * <p/> The context will be queried and if a init parameter named
+     * 'org.apache.tiles.factory.TilesContainerFactory' is discovered this 
class
+     * will be instantiated and returned. Otherwise, the factory will attempt 
to
+     * utilize one of it's internal factories.
      *
-     * @param context the executing applications context.
-     *                Typically a ServletContext or PortletContext
+     * @param context the executing applications context. Typically a
+     * ServletContext or PortletContext
      * @return a tiles container
      * @throws TilesContainerFactoryException if an error occurs creating the
      * factory.
+     * @since 2.1.0
+     * @deprecated Use
+     * [EMAIL PROTECTED] 
AbstractTilesContainerFactory#getTilesContainerFactory(Object)}.
      */
+    @Deprecated
     public static TilesContainerFactory getFactory(Object context) {
         return getFactory(context, DEFAULTS);
     }
@@ -167,6 +167,9 @@
      * @return a tiles container
      * @throws TilesContainerFactoryException if an error occurs creating the
      * factory.
+     * @deprecated Use
+     * [EMAIL PROTECTED] 
AbstractTilesContainerFactory#getTilesContainerFactory(Object)}
+     * and then [EMAIL PROTECTED] #setDefaultConfiguration(Map)}.
      */
     public static TilesContainerFactory getFactory(Object context,
             Map<String, String> defaults) {
@@ -417,62 +420,4 @@
             ? DEFAULTS.get(parameterName)
             : factoryName.toString();
     }
-
-    /**
-     * Returns the value of an initialization parameter.
-     *
-     * @param context The (application) context object to use.
-     * @param parameterName The parameter name to retrieve.
-     * @return The parameter value.
-     * @throws TilesContainerFactoryException If the context has not been
-     * recognized.
-     */
-    protected static String getInitParameter(Object context,
-            String parameterName) {
-        Object value;
-        try {
-            Class<?> contextClass = context.getClass();
-            Method getInitParameterMethod =
-                contextClass.getMethod("getInitParameter", String.class);
-            value = getInitParameterMethod.invoke(context, parameterName);
-        } catch (Exception e) {
-            throw new TilesContainerFactoryException(
-                    "Unrecognized context.  Is this context"
-                    + " a ServletContext, PortletContext, or similar?", e);
-        }
-        return value == null ? null : value.toString();
-    }
-
-    /**
-     * Returns a map containing parameters name-value entries.
-     *
-     * @param context The (application) context object to use.
-     * @return The initialization parameters map.
-     * @throws TilesContainerFactoryException If the context object has not 
been
-     * recognized.
-     */
-    @SuppressWarnings("unchecked")
-    protected static Map<String, String> getInitParameterMap(Object context) {
-        Map<String, String> initParameters = new HashMap<String, String>();
-        Class<?> contextClass = context.getClass();
-        try {
-            Method method = contextClass.getMethod("getInitParameterNames");
-            Enumeration<String> e = (Enumeration<String>) method
-                    .invoke(context);
-
-            method = contextClass.getMethod("getInitParameter", String.class);
-            while (e.hasMoreElements()) {
-                String key = e.nextElement();
-                initParameters.put(key, (String) method.invoke(context, key));
-            }
-        } catch (Exception e) {
-            throw new TilesContainerFactoryException(
-                    "Unable to retrieve init parameters."
-                    + " Is this context a ServletContext, PortletContext,"
-                    + " or similar object?", e);
-        }
-        return initParameters;
-    }
-
-
 }

Modified: 
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/web/startup/TilesListener.java
URL: 
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/web/startup/TilesListener.java?rev=645636&r1=645635&r2=645636&view=diff
==============================================================================
--- 
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/web/startup/TilesListener.java
 (original)
+++ 
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/web/startup/TilesListener.java
 Mon Apr  7 11:12:50 2008
@@ -25,7 +25,7 @@
 import org.apache.tiles.TilesContainer;
 import org.apache.tiles.TilesException;
 import org.apache.tiles.access.TilesAccess;
-import org.apache.tiles.factory.TilesContainerFactory;
+import org.apache.tiles.factory.AbstractTilesContainerFactory;
 
 import javax.servlet.ServletContext;
 import javax.servlet.ServletContextEvent;
@@ -78,8 +78,8 @@
      * @return The created container
      */
     protected TilesContainer createContainer(ServletContext context) {
-        TilesContainerFactory factory =
-            TilesContainerFactory.getFactory(context);
+        AbstractTilesContainerFactory factory =
+            AbstractTilesContainerFactory.getTilesContainerFactory(context);
         return factory.createContainer(context);
     }
 

Modified: 
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/KeyedDefinitionsFactoryTilesContainerFactoryTest.java
URL: 
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/KeyedDefinitionsFactoryTilesContainerFactoryTest.java?rev=645636&r1=645635&r2=645636&view=diff
==============================================================================
--- 
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/KeyedDefinitionsFactoryTilesContainerFactoryTest.java
 (original)
+++ 
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/KeyedDefinitionsFactoryTilesContainerFactoryTest.java
 Mon Apr  7 11:12:50 2008
@@ -62,9 +62,10 @@
     @Override
     public void setUp() {
         context = EasyMock.createMock(ServletContext.class);
-        defaults = new HashMap<String, String>();
-        defaults.put(TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM,
+        EasyMock.expect(context.getInitParameter(
+                
AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM)).andReturn(
                 KeyedDefinitionsFactoryTilesContainerFactory.class.getName());
+        defaults = new HashMap<String, String>();
     }
 
     /**
@@ -72,12 +73,13 @@
      */
     public void testGetFactory() {
         Vector<String> v = new Vector<String>();
+        v.add(AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM);
 
         
EasyMock.expect(context.getInitParameterNames()).andReturn(v.elements());
-        
EasyMock.expect(context.getInitParameter(TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM)).andReturn(null);
         EasyMock.replay(context);
-        TilesContainerFactory factory = 
TilesContainerFactory.getFactory(context,
-                defaults);
+        TilesContainerFactory factory = (TilesContainerFactory) 
AbstractTilesContainerFactory
+                .getTilesContainerFactory(context);
+        factory.setDefaultConfiguration(defaults);
         assertNotNull(factory);
         assertEquals(KeyedDefinitionsFactoryTilesContainerFactory.class,
                 factory.getClass());
@@ -91,7 +93,7 @@
      */
     public void testCreateContainer() throws MalformedURLException {
         Vector<String> enumeration = new Vector<String>();
-        
EasyMock.expect(context.getInitParameter(TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM)).andReturn(null);
+        
enumeration.add(AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM);
         
EasyMock.expect(context.getInitParameter(TilesContainerFactory.CONTEXT_FACTORY_INIT_PARAM)).andReturn(null);
         
EasyMock.expect(context.getInitParameter(TilesContainerFactory.DEFINITIONS_FACTORY_INIT_PARAM)).andReturn(null);
         EasyMock.expect(context.getInitParameter(
@@ -114,7 +116,9 @@
         
EasyMock.expect(context.getResource("/WEB-INF/tiles-two.xml")).andReturn(url);
         EasyMock.replay(context);
 
-        TilesContainerFactory factory = 
TilesContainerFactory.getFactory(context, defaults);
+        TilesContainerFactory factory = (TilesContainerFactory) 
AbstractTilesContainerFactory
+                .getTilesContainerFactory(context);
+        factory.setDefaultConfiguration(defaults);
         TilesContainer container = factory.createContainer(context);
 
         assertNotNull(container);

Modified: 
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/TilesContainerFactoryTest.java
URL: 
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/TilesContainerFactoryTest.java?rev=645636&r1=645635&r2=645636&view=diff
==============================================================================
--- 
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/TilesContainerFactoryTest.java
 (original)
+++ 
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/TilesContainerFactoryTest.java
 Mon Apr  7 11:12:50 2008
@@ -62,46 +62,57 @@
     /**
      * Tests getting the factory.
      */
+    @SuppressWarnings("deprecation")
     public void testGetFactory() {
         Vector<String> v = new Vector<String>();
         Vector<String> emptyVector = new Vector<String>();
-        v.add(TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM);
+        v.add(AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM);
 
-        
EasyMock.expect(context.getInitParameterNames()).andReturn(v.elements());
-        
EasyMock.expect(context.getInitParameter(TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM)).andReturn(null);
+        EasyMock.expect(context.getInitParameterNames()).andReturn(
+                emptyVector.elements());
+        EasyMock.expect(context.getInitParameter(
+                AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM))
+                .andReturn(null);
+        EasyMock.expect(context.getInitParameter(
+                TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM))
+                .andReturn(null);
         EasyMock.replay(context);
-        TilesContainerFactory factory = 
TilesContainerFactory.getFactory(context);
+        AbstractTilesContainerFactory factory = AbstractTilesContainerFactory
+                .getTilesContainerFactory(context);
         assertNotNull(factory);
         assertEquals(TilesContainerFactory.class, factory.getClass());
 
         EasyMock.reset(context);
         
EasyMock.expect(context.getInitParameterNames()).andReturn(v.elements());
-        EasyMock.expect(context.getInitParameter(TilesContainerFactory
-                .CONTAINER_FACTORY_INIT_PARAM)).andReturn(
-                        TestFactory.class.getName());
+        EasyMock.expect(context.getInitParameter(
+                AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM))
+                .andReturn(TestFactory.class.getName());
         EasyMock.replay(context);
-        factory = TilesContainerFactory.getFactory(context);
+        factory = AbstractTilesContainerFactory
+                .getTilesContainerFactory(context);
         assertNotNull(factory);
         assertEquals(TestFactory.class, factory.getClass());
 
         Map<String, String> defaults = new HashMap<String, String>();
-        defaults.put(TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM,
-                TestFactory.class.getName());
         EasyMock.reset(context);
-        
EasyMock.expect(context.getInitParameterNames()).andReturn(emptyVector.elements());
-        
EasyMock.expect(context.getInitParameter(TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM)).andReturn(null);
+        
EasyMock.expect(context.getInitParameterNames()).andReturn(v.elements());
+        EasyMock.expect(context.getInitParameter(
+                AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM))
+                .andReturn(TestFactory.class.getName());
         EasyMock.replay(context);
-        factory = TilesContainerFactory.getFactory(context, defaults);
+        factory = AbstractTilesContainerFactory
+                .getTilesContainerFactory(context);
+        ((TilesContainerFactory) factory).setDefaultConfiguration(defaults);
         assertNotNull(factory);
         assertEquals(TestFactory.class, factory.getClass());
 
         EasyMock.reset(context);
         
EasyMock.expect(context.getInitParameterNames()).andReturn(v.elements());
-        EasyMock.expect(context.getInitParameter(TilesContainerFactory
+        EasyMock.expect(context.getInitParameter(AbstractTilesContainerFactory
                 .CONTAINER_FACTORY_INIT_PARAM)).andReturn("org.missing.Class");
         EasyMock.replay(context);
         try {
-            TilesContainerFactory.getFactory(context);
+            AbstractTilesContainerFactory.getTilesContainerFactory(context);
             fail("Invalid classname.  Exception should have been thrown.");
         } catch (TilesException e) {
             if (LOG.isDebugEnabled()) {
@@ -120,7 +131,6 @@
     public void testCreateContainer() throws MalformedURLException {
         URL url = getClass().getResource("test-defs.xml");
         Vector<String> enumeration = new Vector<String>();
-        
EasyMock.expect(context.getInitParameter(TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM)).andReturn(null);
         
EasyMock.expect(context.getInitParameter(TilesContainerFactory.CONTEXT_FACTORY_INIT_PARAM)).andReturn(null);
         
EasyMock.expect(context.getInitParameter(TilesContainerFactory.DEFINITIONS_FACTORY_INIT_PARAM)).andReturn(null);
         
EasyMock.expect(context.getInitParameter(EasyMock.isA(String.class))).andReturn(null).anyTimes();
@@ -128,7 +138,8 @@
         
EasyMock.expect(context.getResource("/WEB-INF/tiles.xml")).andReturn(url);
         EasyMock.replay(context);
 
-        TilesContainerFactory factory = 
TilesContainerFactory.getFactory(context);
+        AbstractTilesContainerFactory factory = AbstractTilesContainerFactory
+                .getTilesContainerFactory(context);
         TilesContainer container = factory.createContainer(context);
 
         assertNotNull(container);
@@ -153,7 +164,8 @@
         keys.add("one");
         keys.add("two");
 
-        
EasyMock.expect(context.getInitParameter(TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM)).andReturn(null);
+        EasyMock.expect(context.getInitParameter(
+                
AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM)).andReturn(null);
         
EasyMock.expect(context.getInitParameterNames()).andReturn(keys.elements());
         
EasyMock.expect(context.getInitParameterNames()).andReturn(keys.elements());
         
EasyMock.expect(context.getInitParameter("one")).andReturn("oneValue").anyTimes();

Modified: 
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/BasicTilesContainerTest.java
URL: 
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/BasicTilesContainerTest.java?rev=645636&r1=645635&r2=645636&view=diff
==============================================================================
--- 
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/BasicTilesContainerTest.java
 (original)
+++ 
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/BasicTilesContainerTest.java
 Mon Apr  7 11:12:50 2008
@@ -41,6 +41,7 @@
 import org.apache.shale.test.mock.MockHttpSession;
 import org.apache.tiles.Attribute;
 import org.apache.tiles.TilesException;
+import org.apache.tiles.factory.AbstractTilesContainerFactory;
 import org.apache.tiles.factory.TilesContainerFactory;
 import org.easymock.EasyMock;
 
@@ -67,6 +68,7 @@
     private BasicTilesContainer container;
 
     /** [EMAIL PROTECTED] */
+    @SuppressWarnings("deprecation")
     @Override
     public void setUp() {
         ServletContext context = EasyMock.createMock(ServletContext.class);
@@ -74,6 +76,8 @@
 
         Vector<String> v = new Vector<String>();
 
+        EasyMock.expect(context.getInitParameter(
+                
AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM)).andReturn(null);
         
EasyMock.expect(context.getInitParameter(TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM)).andReturn(null);
         
EasyMock.expect(context.getInitParameter(TilesContainerFactory.CONTEXT_FACTORY_INIT_PARAM)).andReturn(null);
         
EasyMock.expect(context.getInitParameter(TilesContainerFactory.DEFINITIONS_FACTORY_INIT_PARAM)).andReturn(null);
@@ -86,7 +90,8 @@
                     e);
         }
         EasyMock.replay(context);
-        TilesContainerFactory factory = 
TilesContainerFactory.getFactory(context);
+        AbstractTilesContainerFactory factory = AbstractTilesContainerFactory
+                .getTilesContainerFactory(context);
         container = (BasicTilesContainer) factory.createContainer(context);
     }
 

Modified: 
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/KeyedDefinitionsFactoryTilesContainerTest.java
URL: 
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/KeyedDefinitionsFactoryTilesContainerTest.java?rev=645636&r1=645635&r2=645636&view=diff
==============================================================================
--- 
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/KeyedDefinitionsFactoryTilesContainerTest.java
 (original)
+++ 
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/KeyedDefinitionsFactoryTilesContainerTest.java
 Mon Apr  7 11:12:50 2008
@@ -34,6 +34,7 @@
 import junit.framework.TestCase;
 
 import org.apache.tiles.definition.DefinitionsFactory;
+import org.apache.tiles.factory.AbstractTilesContainerFactory;
 import org.apache.tiles.factory.KeyedDefinitionsFactoryTilesContainerFactory;
 import org.apache.tiles.factory.TilesContainerFactory;
 import 
org.apache.tiles.impl.KeyedDefinitionsFactoryTilesContainer.DefaultKeyExtractor;
@@ -60,20 +61,19 @@
     /** [EMAIL PROTECTED] */
     @Override
     public void setUp() {
-        defaults = new HashMap<String, String>();
-        defaults.put(TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM,
-                KeyedDefinitionsFactoryTilesContainerFactory.class.getName());
-
         ServletContext context = EasyMock.createMock(ServletContext.class);
 
         Vector<String> v = new Vector<String>();
+        v.add(AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM);
         
v.add(KeyedDefinitionsFactoryTilesContainerFactory.CONTAINER_KEYS_INIT_PARAM);
         v.add(KeyedDefinitionsFactoryTilesContainer.DEFINITIONS_CONFIG_PREFIX
                 + "one");
         v.add(KeyedDefinitionsFactoryTilesContainer.DEFINITIONS_CONFIG_PREFIX
                 + "two");
 
-        
EasyMock.expect(context.getInitParameter(TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM)).andReturn(null);
+        EasyMock.expect(context.getInitParameter(
+                AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM))
+                
.andReturn(KeyedDefinitionsFactoryTilesContainerFactory.class.getName());
         
EasyMock.expect(context.getInitParameter(TilesContainerFactory.CONTEXT_FACTORY_INIT_PARAM)).andReturn(null);
         
EasyMock.expect(context.getInitParameter(TilesContainerFactory.DEFINITIONS_FACTORY_INIT_PARAM)).andReturn(null);
         EasyMock.expect(context.getInitParameter(
@@ -99,7 +99,8 @@
                     e);
         }
         EasyMock.replay(context);
-        TilesContainerFactory factory = 
TilesContainerFactory.getFactory(context, defaults);
+        TilesContainerFactory factory = (TilesContainerFactory) 
AbstractTilesContainerFactory
+                .getTilesContainerFactory(context);
         container = (KeyedDefinitionsFactoryTilesContainer) 
factory.createContainer(context);
     }
 
@@ -129,7 +130,9 @@
         Vector<String> v = new Vector<String>();
 
         EasyMock.reset(context);
-        
EasyMock.expect(context.getInitParameter(TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM)).andReturn(null);
+        EasyMock.expect(context.getInitParameter(
+                AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM))
+                
.andReturn(KeyedDefinitionsFactoryTilesContainerFactory.class.getName());
         
EasyMock.expect(context.getInitParameter(TilesContainerFactory.CONTEXT_FACTORY_INIT_PARAM)).andReturn(null);
         
EasyMock.expect(context.getInitParameter(TilesContainerFactory.DEFINITIONS_FACTORY_INIT_PARAM)).andReturn(null);
         
EasyMock.expect(context.getInitParameter(DefinitionsFactory.DEFINITIONS_CONFIG)).andReturn(null);
@@ -150,7 +153,8 @@
         EasyMock.replay(context);
         KeyedDefinitionsFactoryTilesContainerFactory factory =
             (KeyedDefinitionsFactoryTilesContainerFactory)
-            TilesContainerFactory.getFactory(context, defaults);
+            AbstractTilesContainerFactory.getTilesContainerFactory(context);
+        factory.setDefaultConfiguration(defaults);
         container = (KeyedDefinitionsFactoryTilesContainer) 
factory.createContainer(context);
 
         assertNotNull(container);

Modified: 
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/util/RollingVectorEnumeration.java
URL: 
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/util/RollingVectorEnumeration.java?rev=645636&r1=645635&r2=645636&view=diff
==============================================================================
--- 
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/util/RollingVectorEnumeration.java
 (original)
+++ 
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/util/RollingVectorEnumeration.java
 Mon Apr  7 11:12:50 2008
@@ -50,6 +50,7 @@
      */
     public RollingVectorEnumeration(Vector<E> vector) {
         this.vector = vector;
+        elements = vector.elements();
     }
 
     /** [EMAIL PROTECTED] */

Modified: 
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/definition/InitContainerTag.java
URL: 
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/definition/InitContainerTag.java?rev=645636&r1=645635&r2=645636&view=diff
==============================================================================
--- 
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/definition/InitContainerTag.java
 (original)
+++ 
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/definition/InitContainerTag.java
 Mon Apr  7 11:12:50 2008
@@ -26,10 +26,10 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.tiles.TilesContainer;
 import org.apache.tiles.access.TilesAccess;
+import org.apache.tiles.factory.AbstractTilesContainerFactory;
 import org.apache.tiles.factory.TilesContainerFactory;
 import org.apache.tiles.jsp.taglib.PutAttributeTag;
 import org.apache.tiles.jsp.taglib.PutAttributeTagParent;
-import org.apache.tiles.mgmt.MutableTilesContainer;
 
 import javax.servlet.RequestDispatcher;
 import javax.servlet.Servlet;
@@ -124,17 +124,21 @@
 
         if (containerFactory != null) {
             context.setInitParameter(
-                TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM,
+                AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM,
                 containerFactory);
         }
 
+        // This is to provide compatibility with Tiles 2.0.x
+        context.setInitParameter(
+                TilesContainerFactory.CONTAINER_FACTORY_MUTABLE_INIT_PARAM,
+                "true");
+
         for (Map.Entry<String, String> entry : initParameters.entrySet()) {
             context.setInitParameter(entry.getKey(), entry.getValue());
         }
 
-        MutableTilesContainer mutableContainer =
-            TilesContainerFactory.getFactory(context)
-                .createMutableTilesContainer(context);
+        TilesContainer mutableContainer = AbstractTilesContainerFactory
+                .getTilesContainerFactory(context).createContainer(context);
         TilesAccess.setContainer(context, mutableContainer);
 
         return EVAL_PAGE;


Reply via email to