You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tiles.apache.org by ap...@apache.org on 2008/12/01 14:09:14 UTC

svn commit: r722062 [1/2] - in /tiles/framework/trunk: tiles-core/src/main/java/org/apache/tiles/awareness/ tiles-core/src/main/java/org/apache/tiles/context/ tiles-core/src/main/java/org/apache/tiles/factory/ tiles-core/src/test/java/org/apache/tiles/...

Author: apetrelli
Date: Mon Dec  1 05:09:09 2008
New Revision: 722062

URL: http://svn.apache.org/viewvc?rev=722062&view=rev
Log:
TILES-334: TilesApplicationContext is now created outside of container creation.

Removed:
    tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/TilesApplicationContextFactory.java
Modified:
    tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/awareness/TilesApplicationContextFactoryAware.java
    tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/ChainedTilesApplicationContextFactory.java
    tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/TilesContextFactory.java
    tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/AbstractTilesContainerFactory.java
    tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/BasicTilesContainerFactory.java
    tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/KeyedDefinitionsFactoryTilesContainerFactory.java
    tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/TilesContainerFactory.java
    tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/context/ChainedTilesApplicationContextFactoryTest.java
    tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/BasicTilesContainerFactoryTest.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/mock/RepeaterTilesApplicationContextFactory.java
    tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/definition/InitContainerTag.java
    tiles/framework/trunk/tiles-portlet/src/main/java/org/apache/tiles/portlet/context/PortletTilesApplicationContextFactory.java
    tiles/framework/trunk/tiles-servlet/src/main/java/org/apache/tiles/servlet/context/ServletTilesApplicationContextFactory.java
    tiles/framework/trunk/tiles-servlet/src/main/java/org/apache/tiles/servlet/context/ServletTilesContextFactory.java
    tiles/framework/trunk/tiles-servlet/src/main/java/org/apache/tiles/servlet/context/wildcard/WildcardServletTilesApplicationContextFactory.java
    tiles/framework/trunk/tiles-servlet/src/main/java/org/apache/tiles/web/startup/TilesListener.java
    tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/factory/TestAlternateTilesContainerFactory.java
    tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/factory/TestDbTilesContainerFactory.java
    tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/factory/TestTilesContainerFactory.java
    tiles/framework/trunk/tiles-test/src/main/webapp/WEB-INF/web-24.xml
    tiles/framework/trunk/tiles-test/src/main/webapp/WEB-INF/web.xml

Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/awareness/TilesApplicationContextFactoryAware.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/awareness/TilesApplicationContextFactoryAware.java?rev=722062&r1=722061&r2=722062&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/awareness/TilesApplicationContextFactoryAware.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/awareness/TilesApplicationContextFactoryAware.java Mon Dec  1 05:09:09 2008
@@ -1,42 +0,0 @@
-/*
- * $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.awareness;
-
-import org.apache.tiles.context.TilesApplicationContextFactory;
-
-/**
- * It represents an object that can have a reference to the
- * {@link TilesApplicationContextFactory}.
- *
- * @version $Rev$ $Date$
- * @since 2.1.1
- */
-public interface TilesApplicationContextFactoryAware {
-
-    /**
-     * Sets the Tiles application context factory.
-     *
-     * @param contextFactory The Tiles application context factory.
-     * @since 2.1.1
-     */
-    void setApplicationContextFactory(
-            TilesApplicationContextFactory contextFactory);
-}

Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/ChainedTilesApplicationContextFactory.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/ChainedTilesApplicationContextFactory.java?rev=722062&r1=722061&r2=722062&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/ChainedTilesApplicationContextFactory.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/ChainedTilesApplicationContextFactory.java Mon Dec  1 05:09:09 2008
@@ -23,8 +23,9 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.tiles.Initializable;
 import org.apache.tiles.TilesApplicationContext;
-import org.apache.tiles.awareness.TilesApplicationContextFactoryAware;
+import org.apache.tiles.awareness.AbstractTilesApplicationContextFactoryAware;
 
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -38,7 +39,8 @@
  * @version $Rev$ $Date$
  * @since 2.1.1
  */
-public class ChainedTilesApplicationContextFactory implements TilesApplicationContextFactory {
+public class ChainedTilesApplicationContextFactory extends
+        AbstractTilesApplicationContextFactory implements Initializable {
 
     /**
      * Factory class names initialization parameter to use.
@@ -66,14 +68,15 @@
     /**
      * The Tiles context factories composing the chain.
      */
-    private List<TilesApplicationContextFactory> factories;
+    private List<AbstractTilesApplicationContextFactory> factories;
 
     /**
      * Sets the factories to be used.
      *
      * @param factories The factories to be used.
      */
-    public void setFactories(List<TilesApplicationContextFactory> factories) {
+    public void setFactories(
+            List<AbstractTilesApplicationContextFactory> factories) {
         this.factories = factories;
     }
 
@@ -89,15 +92,18 @@
             classNames = DEFAULT_FACTORY_CLASS_NAMES;
         }
 
-        factories = new ArrayList<TilesApplicationContextFactory>();
+        factories = new ArrayList<AbstractTilesApplicationContextFactory>();
         for (int i = 0; i < classNames.length; i++) {
             try {
-                Class<TilesApplicationContextFactory> clazz = (Class<TilesApplicationContextFactory>) Class
+                Class<AbstractTilesApplicationContextFactory> clazz =
+                    (Class<AbstractTilesApplicationContextFactory>) Class
                         .forName(classNames[i]);
-                if (TilesApplicationContextFactory.class.isAssignableFrom(clazz)) {
-                    TilesApplicationContextFactory factory = clazz.newInstance();
-                    if (factory instanceof TilesApplicationContextFactoryAware) {
-                        ((TilesApplicationContextFactoryAware) factory)
+                if (AbstractTilesApplicationContextFactory.class
+                        .isAssignableFrom(clazz)) {
+                    AbstractTilesApplicationContextFactory factory = clazz
+                            .newInstance();
+                    if (factory instanceof AbstractTilesApplicationContextFactoryAware) {
+                        ((AbstractTilesApplicationContextFactoryAware) factory)
                                 .setApplicationContextFactory(this);
                     }
                     factories.add(factory);
@@ -131,7 +137,7 @@
     public TilesApplicationContext createApplicationContext(Object context) {
         TilesApplicationContext retValue = null;
 
-        for (Iterator<TilesApplicationContextFactory> factoryIt = factories
+        for (Iterator<AbstractTilesApplicationContextFactory> factoryIt = factories
                 .iterator(); factoryIt.hasNext() && retValue == null;) {
             retValue = factoryIt.next().createApplicationContext(context);
         }

Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/TilesContextFactory.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/TilesContextFactory.java?rev=722062&r1=722061&r2=722062&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/TilesContextFactory.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/TilesContextFactory.java Mon Dec  1 05:09:09 2008
@@ -20,6 +20,8 @@
  */
 package org.apache.tiles.context;
 
+import org.apache.tiles.TilesApplicationContext;
+
 /**
  * Creates an instance of the appropriate TilesApplicationContext
  * implementation.
@@ -28,6 +30,14 @@
  * @deprecated Use {@link TilesApplicationContextFactory} or
  * {@link TilesRequestContextFactory}.
  */
-public interface TilesContextFactory extends TilesApplicationContextFactory,
-        TilesRequestContextFactory {
+public interface TilesContextFactory extends TilesRequestContextFactory {
+
+    /**
+     * Create a TilesApplicationContext for the given context.
+     *
+     * @param context The (application) context to use.
+     * @return TilesApplicationContext The Tiles application context.
+     */
+    TilesApplicationContext createApplicationContext(
+            Object context);
 }

Modified: 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=722062&r1=722061&r2=722062&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/AbstractTilesContainerFactory.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/AbstractTilesContainerFactory.java Mon Dec  1 05:09:09 2008
@@ -25,6 +25,7 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.tiles.TilesApplicationContext;
 import org.apache.tiles.TilesContainer;
 import org.apache.tiles.reflect.ClassUtil;
 
@@ -62,14 +63,16 @@
      * @return The created factory.
      * @throws TilesContainerFactoryException If something goes wrong during
      * creation.
-     * @since 2.1.0
+     * @since 2.1.1
      */
     @SuppressWarnings("deprecation")
-    public static AbstractTilesContainerFactory getTilesContainerFactory(Object context) {
+    public static AbstractTilesContainerFactory getTilesContainerFactory(
+            TilesApplicationContext context) {
         AbstractTilesContainerFactory retValue;
-        String factoryName = getInitParameter(context, CONTAINER_FACTORY_INIT_PARAM);
+        String factoryName = context.getInitParams().get(
+                CONTAINER_FACTORY_INIT_PARAM);
         if (factoryName == null) {
-            factoryName = getInitParameter(context,
+            factoryName = context.getInitParams().get(
                     TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM);
         }
         if (factoryName != null) {
@@ -83,13 +86,13 @@
     /**
      * Creates a Tiles container.
      *
-     * @param context The (application) context object.
+     * @param preliminaryContext The Tiles application context object.
      * @return The created container.
      * @throws TilesContainerFactoryException If something goes wrong during
      * instantiation.
-     * @since 2.1.0
+     * @since 2.1.1
      */
-    public abstract TilesContainer createContainer(Object context);
+    public abstract TilesContainer createContainer(TilesApplicationContext applicationContext);
 
     /**
      * Returns a map containing parameters name-value entries.

Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/BasicTilesContainerFactory.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/BasicTilesContainerFactory.java?rev=722062&r1=722061&r2=722062&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/BasicTilesContainerFactory.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/BasicTilesContainerFactory.java Mon Dec  1 05:09:09 2008
@@ -30,11 +30,8 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.tiles.TilesApplicationContext;
 import org.apache.tiles.TilesContainer;
-import org.apache.tiles.awareness.TilesApplicationContextFactoryAware;
 import org.apache.tiles.awareness.TilesRequestContextFactoryAware;
-import org.apache.tiles.context.ChainedTilesApplicationContextFactory;
 import org.apache.tiles.context.ChainedTilesRequestContextFactory;
-import org.apache.tiles.context.TilesApplicationContextFactory;
 import org.apache.tiles.context.TilesRequestContextFactory;
 import org.apache.tiles.definition.DefinitionsFactory;
 import org.apache.tiles.definition.DefinitionsReader;
@@ -80,64 +77,48 @@
 
     /** {@inheritDoc} */
     @Override
-    public TilesContainer createContainer(Object context) {
-        BasicTilesContainer container = instantiateContainer(context);
-        TilesApplicationContextFactory contextFactory = createApplicationContextFactory(context);
-        TilesApplicationContext applicationContext = contextFactory
-                .createApplicationContext(context);
-        TilesRequestContextFactory requestContextFactory = createRequestContextFactory();
+    public TilesContainer createContainer(TilesApplicationContext applicationContext) {
+        BasicTilesContainer container = instantiateContainer(applicationContext);
+        TilesRequestContextFactory requestContextFactory =
+            createRequestContextFactory(applicationContext);
         container.setRequestContextFactory(requestContextFactory);
         container.setApplicationContext(applicationContext);
-        LocaleResolver resolver = createLocaleResolver(context,
-                applicationContext, requestContextFactory);
-        container.setDefinitionsFactory(createDefinitionsFactory(context,
-                applicationContext, requestContextFactory, resolver));
-        AttributeEvaluator evaluator = createEvaluator(context,
-                applicationContext, requestContextFactory, resolver);
+        LocaleResolver resolver = createLocaleResolver(applicationContext,
+                requestContextFactory);
+        container.setDefinitionsFactory(createDefinitionsFactory(applicationContext,
+                requestContextFactory, resolver));
+        AttributeEvaluator evaluator = createEvaluator(applicationContext,
+                requestContextFactory, resolver);
         container.setEvaluator(evaluator);
-        container.setPreparerFactory(createPreparerFactory(context,
-                applicationContext, requestContextFactory));
-        container.setRendererFactory(createRendererFactory(context,
-                applicationContext, requestContextFactory, container,
-                evaluator));
+        container.setPreparerFactory(createPreparerFactory(applicationContext,
+                requestContextFactory));
+        container.setRendererFactory(createRendererFactory(applicationContext,
+                requestContextFactory, container, evaluator));
         return container;
     }
 
     /**
      * Instantiate the container, without initialization.
      *
-     * @param context The context object.
+     * @param context The Tiles application context object.
      * @return The instantiated container.
-     * @since 2.1.0
-     */
-    protected BasicTilesContainer instantiateContainer(Object context) {
-        return new BasicTilesContainer();
-    }
-
-    /**
-     * Create a Tiles applicaitoncontext factory. By default it creates a
-     * {@link ChainedTilesApplicationContextFactory}.
-     *
-     * @param context The context.
-     * @return The application context factory.
      * @since 2.1.1
      */
-    protected TilesApplicationContextFactory createApplicationContextFactory(
-            Object context) {
-        ChainedTilesApplicationContextFactory contextFactory = new ChainedTilesApplicationContextFactory();
-        registerChainedApplicationContextFactories(context, contextFactory);
-
-        return contextFactory;
+    protected BasicTilesContainer instantiateContainer(
+            TilesApplicationContext context) {
+        return new BasicTilesContainer();
     }
 
     /**
      * Create a Tiles request context factory. By default it creates a
      * {@link ChainedTilesRequestContextFactory}.
      *
+     * @param context The Tiles application context.
      * @return The request context factory.
      * @since 2.1.1
      */
-    protected TilesRequestContextFactory createRequestContextFactory() {
+    protected TilesRequestContextFactory createRequestContextFactory(
+            TilesApplicationContext context) {
         ChainedTilesRequestContextFactory contextFactory = new ChainedTilesRequestContextFactory();
         registerChainedRequestContextFactories(contextFactory);
 
@@ -145,26 +126,6 @@
     }
 
     /**
-     * Register elements of a chained application context factory.
-     *
-     * @param context The context.
-     * @param contextFactory The application context factory to use.
-     * @since 2.1.1
-     */
-    protected void registerChainedApplicationContextFactories(Object context,
-            ChainedTilesApplicationContextFactory contextFactory) {
-        List<TilesApplicationContextFactory> factories = new ArrayList<TilesApplicationContextFactory>(
-                CONTEXT_FACTORY_CHAIN_COUNT);
-        registerApplicationContextFactory(
-                "org.apache.tiles.servlet.context.ServletTilesApplicationContextFactory",
-                factories, contextFactory);
-        registerApplicationContextFactory(
-                "org.apache.tiles.portlet.context.PortletTilesApplicationContextFactory",
-                factories, contextFactory);
-        contextFactory.setFactories(factories);
-    }
-
-    /**
      * Register elements of a chained request context factory.
      *
      * @param contextFactory The request context factory to use.
@@ -187,47 +148,6 @@
     }
 
     /**
-     * Registers a {@link TilesApplicationContextFactory} specifying its
-     * classname.
-     *
-     * @param className The name of the class to instantiate.
-     * @param factories The list of factories to add to.
-     * @param parent The parent {@link TilesApplicationContextFactory}. If null
-     * it won't be considered.
-     * @since 2.1.1
-     */
-    protected void registerApplicationContextFactory(String className,
-            List<TilesApplicationContextFactory> factories,
-            TilesApplicationContextFactory parent) {
-        TilesApplicationContextFactory retValue = null;
-        try {
-            Class<? extends TilesApplicationContextFactory> clazz = Class
-                    .forName(className).asSubclass(
-                            TilesApplicationContextFactory.class);
-            retValue = clazz.newInstance();
-            if (parent != null
-                    && retValue instanceof TilesApplicationContextFactoryAware) {
-                ((TilesApplicationContextFactoryAware) retValue)
-                        .setApplicationContextFactory(parent);
-            }
-        } catch (ClassNotFoundException e) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Cannot find JspTilesContextFactory, ignoring problem", e);
-            }
-        } catch (InstantiationException e) {
-            throw new TilesContainerFactoryException(
-                    "Cannot instantiate JspTilesContextFactory", e);
-        } catch (IllegalAccessException e) {
-            throw new TilesContainerFactoryException(
-                    "Cannot access default constructor JspTilesContextFactory",
-                    e);
-        }
-        if (retValue != null) {
-            factories.add(retValue);
-        }
-    }
-
-    /**
      * Registers a {@link TilesRequestContextFactory} specifying its
      * classname.
      *
@@ -271,23 +191,22 @@
     /**
      * Creates the definitions factory. By default it creates a
      * {@link UrlDefinitionsFactory} with default dependencies.
-     *
-     * @param context The context.
      * @param applicationContext The Tiles application context.
      * @param contextFactory The Tiles context factory.
      * @param resolver The locale resolver.
+     *
      * @return The definitions factory.
      * @since 2.1.1
      */
-    protected DefinitionsFactory createDefinitionsFactory(Object context,
-            TilesApplicationContext applicationContext,
-            TilesRequestContextFactory contextFactory, LocaleResolver resolver) {
+    protected DefinitionsFactory createDefinitionsFactory(TilesApplicationContext applicationContext,
+            TilesRequestContextFactory contextFactory,
+            LocaleResolver resolver) {
         LocaleDefinitionsFactory factory = instantiateDefinitionsFactory(
-                context, applicationContext, contextFactory, resolver);
+                applicationContext, contextFactory, resolver);
         factory.setApplicationContext(applicationContext);
         factory.setLocaleResolver(resolver);
-        factory.setDefinitionDAO(createLocaleDefinitionDao(context,
-                applicationContext, contextFactory, resolver));
+        factory.setDefinitionDAO(createLocaleDefinitionDao(applicationContext,
+                contextFactory, resolver));
         if (factory instanceof Refreshable) {
             ((Refreshable) factory).refresh();
         }
@@ -296,56 +215,51 @@
 
     /**
      * Instantiate a new definitions factory based on Locale.
-     *
-     * @param context The context.
      * @param applicationContext The Tiles application context.
      * @param contextFactory The Tiles context factory.
      * @param resolver The locale resolver.
+     *
      * @return The definitions factory.
      * @since 2.1.1
      */
-    protected LocaleDefinitionsFactory instantiateDefinitionsFactory(Object context,
-            TilesApplicationContext applicationContext,
-            TilesRequestContextFactory contextFactory, LocaleResolver resolver) {
+    protected LocaleDefinitionsFactory instantiateDefinitionsFactory(TilesApplicationContext applicationContext,
+            TilesRequestContextFactory contextFactory,
+            LocaleResolver resolver) {
         return new UrlDefinitionsFactory();
     }
 
 
     /**
      * Instantiate (and does not initialize) a Locale-based definition DAO.
-     *
-     * @param context The context.
      * @param applicationContext The Tiles application context.
      * @param contextFactory The Tiles context factory.
      * @param resolver The locale resolver.
+     *
      * @return The definition DAO.
      * @since 2.1.1
      */
-    protected BaseLocaleUrlDefinitionDAO instantiateLocaleDefinitionDao(Object context,
-            TilesApplicationContext applicationContext,
-            TilesRequestContextFactory contextFactory, LocaleResolver resolver) {
+    protected BaseLocaleUrlDefinitionDAO instantiateLocaleDefinitionDao(TilesApplicationContext applicationContext,
+            TilesRequestContextFactory contextFactory,
+            LocaleResolver resolver) {
         return new ResolvingLocaleUrlDefinitionDAO();
     }
 
     /**
      * Creates a Locale-based definition DAO.
-     *
-     * @param context The context.
      * @param applicationContext The Tiles application context.
      * @param contextFactory The Tiles context factory.
      * @param resolver The locale resolver.
+     *
      * @return The definition DAO.
      * @since 2.1.1
      */
-    protected DefinitionDAO<Locale> createLocaleDefinitionDao(Object context,
-            TilesApplicationContext applicationContext,
-            TilesRequestContextFactory contextFactory, LocaleResolver resolver) {
+    protected DefinitionDAO<Locale> createLocaleDefinitionDao(TilesApplicationContext applicationContext,
+            TilesRequestContextFactory contextFactory,
+            LocaleResolver resolver) {
         BaseLocaleUrlDefinitionDAO definitionDao = instantiateLocaleDefinitionDao(
-                context, applicationContext, contextFactory, resolver);
-        definitionDao.setReader(createDefinitionsReader(context, applicationContext,
-                contextFactory));
-        definitionDao.setSourceURLs(getSourceURLs(context, applicationContext,
-                contextFactory));
+                applicationContext, contextFactory, resolver);
+        definitionDao.setReader(createDefinitionsReader(applicationContext, contextFactory));
+        definitionDao.setSourceURLs(getSourceURLs(applicationContext, contextFactory));
         definitionDao.setApplicationContext(applicationContext);
         return definitionDao;
     }
@@ -353,15 +267,13 @@
     /**
      * Creates the locale resolver. By default it creates a
      * {@link DefaultLocaleResolver}.
-     *
-     * @param context The context.
      * @param applicationContext The Tiles application context.
      * @param contextFactory The Tiles context factory.
+     *
      * @return The locale resolver.
      * @since 2.1.1
      */
-    protected LocaleResolver createLocaleResolver(Object context,
-            TilesApplicationContext applicationContext,
+    protected LocaleResolver createLocaleResolver(TilesApplicationContext applicationContext,
             TilesRequestContextFactory contextFactory) {
         return new DefaultLocaleResolver();
     }
@@ -369,14 +281,13 @@
     /**
      * Creates the definitions reader. By default it creates a
      * {@link DigesterDefinitionsReader}.
-     *
-     * @param context The context.
      * @param applicationContext The Tiles application context.
      * @param contextFactory The Tiles context factory.
+     *
      * @return The definitions reader.
      * @since 2.1.1
      */
-    protected DefinitionsReader createDefinitionsReader(Object context,
+    protected DefinitionsReader createDefinitionsReader(
             TilesApplicationContext applicationContext,
             TilesRequestContextFactory contextFactory) {
         return new DigesterDefinitionsReader();
@@ -385,15 +296,13 @@
     /**
      * Returns a list containing the URLs to be parsed. By default, it returns a
      * list containing the URL point to "/WEB-INF/tiles.xml".
-     *
-     * @param context The context.
      * @param applicationContext The Tiles application context.
      * @param contextFactory The Tiles context factory.
+     *
      * @return The source URLs.
      * @since 2.1.1
      */
-    protected List<URL> getSourceURLs(Object context,
-            TilesApplicationContext applicationContext,
+    protected List<URL> getSourceURLs(TilesApplicationContext applicationContext,
             TilesRequestContextFactory contextFactory) {
         List<URL> retValue = new ArrayList<URL>(1);
         try {
@@ -407,31 +316,28 @@
 
     /**
      * Creates the attribute evaluator to use. By default it returns a {@link DirectAttributeEvaluator}.
-     *
-     * @param context The context.
      * @param applicationContext The Tiles application context.
      * @param contextFactory The Tiles context factory.
      * @param resolver The locale resolver.
+     *
      * @return The evaluator.
      */
-    protected AttributeEvaluator createEvaluator(Object context,
-            TilesApplicationContext applicationContext,
-            TilesRequestContextFactory contextFactory, LocaleResolver resolver) {
+    protected AttributeEvaluator createEvaluator(TilesApplicationContext applicationContext,
+            TilesRequestContextFactory contextFactory,
+            LocaleResolver resolver) {
         return new DirectAttributeEvaluator();
     }
 
     /**
      * Creates the preparer factory to use. By default it returns a
      * {@link BasicPreparerFactory}.
-     *
-     * @param context The context.
      * @param applicationContext The Tiles application context.
      * @param contextFactory The Tiles context factory.
+     *
      * @return The preparer factory.
      * @since 2.1.1
      */
-    protected PreparerFactory createPreparerFactory(Object context,
-            TilesApplicationContext applicationContext,
+    protected PreparerFactory createPreparerFactory(TilesApplicationContext applicationContext,
             TilesRequestContextFactory contextFactory) {
         return new BasicPreparerFactory();
     }
@@ -442,47 +348,44 @@
      * {@link UntypedAttributeRenderer} as default, and
      * {@link StringAttributeRenderer}, {@link TemplateAttributeRenderer} and
      * {@link DefinitionAttributeRenderer}.
-     *
-     * @param context The context.
      * @param applicationContext The Tiles application context.
      * @param contextFactory The Tiles context factory.
      * @param container The container.
      * @param evaluator The evaluator.
+     *
      * @return The renderer factory.
      * @since 2.1.1
      */
-    protected RendererFactory createRendererFactory(Object context,
-            TilesApplicationContext applicationContext,
-            TilesRequestContextFactory contextFactory, TilesContainer container,
-            AttributeEvaluator evaluator) {
+    protected RendererFactory createRendererFactory(TilesApplicationContext applicationContext,
+            TilesRequestContextFactory contextFactory,
+            TilesContainer container, AttributeEvaluator evaluator) {
         BasicRendererFactory retValue = new BasicRendererFactory();
         retValue.setApplicationContext(applicationContext);
         retValue.setRequestContextFactory(contextFactory);
         retValue.setContainer(container);
         retValue.setEvaluator(evaluator);
-        retValue.setDefaultRenderer(createDefaultAttributeRenderer(context,
-                applicationContext, contextFactory, container, evaluator));
-        registerAttributeRenderers(retValue, context, applicationContext,
-                contextFactory, container, evaluator);
+        retValue.setDefaultRenderer(createDefaultAttributeRenderer(applicationContext,
+                contextFactory, container, evaluator));
+        registerAttributeRenderers(retValue, applicationContext, contextFactory,
+                container, evaluator);
         return retValue;
     }
 
     /**
      * Creates the default attribute renderer. By default it is an
      * {@link UntypedAttributeRenderer}.
-     *
-     * @param context The context.
      * @param applicationContext The Tiles application context.
      * @param contextFactory The Tiles context factory.
      * @param container The container.
      * @param evaluator The evaluator.
+     *
      * @return The default attribute renderer.
      * @since 2.1.1
      */
-    protected AttributeRenderer createDefaultAttributeRenderer(Object context,
-            TilesApplicationContext applicationContext,
+    protected AttributeRenderer createDefaultAttributeRenderer(TilesApplicationContext applicationContext,
             TilesRequestContextFactory contextFactory,
-            TilesContainer container, AttributeEvaluator evaluator) {
+            TilesContainer container,
+            AttributeEvaluator evaluator) {
         UntypedAttributeRenderer retValue = new UntypedAttributeRenderer();
         retValue.setApplicationContext(applicationContext);
         retValue.setContainer(container);
@@ -498,7 +401,6 @@
      * {@link DefinitionAttributeRenderer}.
      *
      * @param rendererFactory The renderer factory to configure.
-     * @param context The context.
      * @param applicationContext The Tiles application context.
      * @param contextFactory The Tiles context factory.
      * @param container The container.
@@ -506,10 +408,9 @@
      * @since 2.1.1
      */
     protected void registerAttributeRenderers(
-            BasicRendererFactory rendererFactory, Object context,
-            TilesApplicationContext applicationContext,
-            TilesRequestContextFactory contextFactory, TilesContainer container,
-            AttributeEvaluator evaluator) {
+            BasicRendererFactory rendererFactory, TilesApplicationContext applicationContext,
+            TilesRequestContextFactory contextFactory,
+            TilesContainer container, AttributeEvaluator evaluator) {
         StringAttributeRenderer stringRenderer = new StringAttributeRenderer();
         stringRenderer.setApplicationContext(applicationContext);
         stringRenderer.setRequestContextFactory(contextFactory);

Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/KeyedDefinitionsFactoryTilesContainerFactory.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/KeyedDefinitionsFactoryTilesContainerFactory.java?rev=722062&r1=722061&r2=722062&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/KeyedDefinitionsFactoryTilesContainerFactory.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/KeyedDefinitionsFactoryTilesContainerFactory.java Mon Dec  1 05:09:09 2008
@@ -68,7 +68,8 @@
 
     /** {@inheritDoc} */
     @Override
-    public MutableTilesContainer createMutableTilesContainer(Object context) {
+    public MutableTilesContainer createMutableTilesContainer(
+            TilesApplicationContext context) {
         CachingKeyedDefinitionsFactoryTilesContainer container =
             new CachingKeyedDefinitionsFactoryTilesContainer();
         initializeContainer(context, container);
@@ -77,26 +78,43 @@
 
     /** {@inheritDoc} */
     @Override
-    public TilesContainer createTilesContainer(Object context) {
+    public TilesContainer createTilesContainer(TilesApplicationContext context) {
         KeyedDefinitionsFactoryTilesContainer container =
             new KeyedDefinitionsFactoryTilesContainer();
         initializeContainer(context, container);
         return container;
     }
 
-    // FIXME Probably we should create some sort of "FactoryUtils" to create
-    // factories dynamically depending on a configuration.
-    // I think this method does not belong here.
     /**
      * Creates a definitions factory.
      * @param context The context object to use.
      * @return The newly created definitions factory.
      * @throws TilesContainerFactoryException If something goes wrong.
+     * @deprecated Use
+     * {@link #createDefinitionsFactory(TilesApplicationContext)}.
      */
+    @Deprecated
     public DefinitionsFactory createDefinitionsFactory(Object context) {
+        if (context instanceof TilesApplicationContext) {
+            createDefinitionsFactory((TilesApplicationContext) context);
+        }
+
+        throw new UnsupportedOperationException("Class "
+                + context.getClass().getName()
+                + " not recognized a TilesApplicationContext");
+    }
+
+    /**
+     * Creates a definitions factory.
+     * @param context The Tiles application context object to use.
+     * @return The newly created definitions factory.
+     * @throws TilesContainerFactoryException If something goes wrong.
+     */
+    public DefinitionsFactory createDefinitionsFactory(
+            TilesApplicationContext context) {
         DefinitionsFactory retValue;
         Map<String, String> config = new HashMap<String, String>(defaultConfiguration);
-        config.putAll(getInitParameterMap(context));
+        config.putAll(context.getInitParams());
         retValue = (DefinitionsFactory) createFactory(config,
                     DEFINITIONS_FACTORY_INIT_PARAM);
         if (retValue instanceof TilesApplicationContextAware) {

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=722062&r1=722061&r2=722062&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 Dec  1 05:09:09 2008
@@ -22,14 +22,15 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.tiles.Initializable;
 import org.apache.tiles.TilesApplicationContext;
 import org.apache.tiles.TilesContainer;
 import org.apache.tiles.awareness.TilesApplicationContextAware;
 import org.apache.tiles.awareness.TilesContainerAware;
 import org.apache.tiles.awareness.TilesRequestContextFactoryAware;
+import org.apache.tiles.context.AbstractTilesApplicationContextFactory;
 import org.apache.tiles.context.ChainedTilesApplicationContextFactory;
 import org.apache.tiles.context.ChainedTilesRequestContextFactory;
-import org.apache.tiles.context.TilesApplicationContextFactory;
 import org.apache.tiles.context.TilesRequestContextFactory;
 import org.apache.tiles.definition.DefinitionsFactory;
 import org.apache.tiles.definition.UrlDefinitionsFactory;
@@ -77,7 +78,7 @@
     /**
      * Initialization parameter that represents the context factory class name.
      *
-     * @deprecated Use {@link #APPLICATION_CONTEXT_FACTORY_INIT_PARAM} or
+     * @deprecated Use {@link AbstractTilesApplicationContextFactory#APPLICATION_CONTEXT_FACTORY_INIT_PARAM} or
      * {@link #REQUEST_CONTEXT_FACTORY_INIT_PARAM}.
      */
     public static final String CONTEXT_FACTORY_INIT_PARAM =
@@ -85,12 +86,8 @@
 
     /**
      * Initialization parameter that represents the context factory class name.
-     */
-    public static final String APPLICATION_CONTEXT_FACTORY_INIT_PARAM =
-        "org.apache.tiles.context.TilesApplicationContextFactory";
-
-    /**
-     * Initialization parameter that represents the context factory class name.
+     *
+     * @since 2.1.1
      */
     public static final String REQUEST_CONTEXT_FACTORY_INIT_PARAM =
         "org.apache.tiles.context.TilesRequestContextFactory";
@@ -136,7 +133,7 @@
         new HashMap<String, String>();
 
     static {
-        DEFAULTS.put(APPLICATION_CONTEXT_FACTORY_INIT_PARAM,
+        DEFAULTS.put(AbstractTilesApplicationContextFactory.APPLICATION_CONTEXT_FACTORY_INIT_PARAM,
                 ChainedTilesApplicationContextFactory.class.getName());
         DEFAULTS.put(REQUEST_CONTEXT_FACTORY_INIT_PARAM,
                 ChainedTilesRequestContextFactory.class.getName());
@@ -209,9 +206,23 @@
      * @return The created container.
      * @throws TilesContainerFactoryException If something goes wrong during
      * instantiation.
+     * @deprecated Use {@link #createContainer(TilesApplicationContext)}.
      */
+    @Deprecated
     public TilesContainer createContainer(Object context) {
-        String value = getInitParameter(context, CONTAINER_FACTORY_MUTABLE_INIT_PARAM);
+        if (context instanceof TilesApplicationContext) {
+            return createContainer((TilesApplicationContext) context);
+        }
+
+        throw new UnsupportedOperationException("Class "
+                + context.getClass().getName()
+                + " not recognized a TilesApplicationContext");
+    }
+
+    /** {@inheritDoc} */
+    public TilesContainer createContainer(TilesApplicationContext context) {
+        String value = context.getInitParams().get(
+                CONTAINER_FACTORY_MUTABLE_INIT_PARAM);
         if (Boolean.parseBoolean(value)) {
             return createMutableTilesContainer(context);
         } else {
@@ -247,22 +258,65 @@
      * @return The created Tiles container.
      * @throws TilesContainerFactoryException If something goes wrong during
      * initialization.
+     * @deprecated Use {@link #createTilesContainer(TilesApplicationContext)}.
      */
+    @Deprecated
     public TilesContainer createTilesContainer(Object context) {
+        if (context instanceof TilesApplicationContext) {
+            return createTilesContainer((TilesApplicationContext) context);
+        }
+
+        throw new UnsupportedOperationException("Class "
+                + context.getClass().getName()
+                + " not recognized a TilesApplicationContext");
+    }
+
+    /**
+     * Creates an immutable Tiles container.
+     *
+     * @param context The Tiles application context object.
+     * @return The created Tiles container.
+     * @throws TilesContainerFactoryException If something goes wrong during
+     * initialization.
+     * @since 2.1.1
+     */
+    public TilesContainer createTilesContainer(TilesApplicationContext context) {
         BasicTilesContainer container = new BasicTilesContainer();
         initializeContainer(context, container);
         return container;
     }
 
     /**
-     * Creates a mutable Tiles container.
+     * Creates an immutable Tiles container.
      *
      * @param context The (application) context object.
      * @return The created Tiles container.
      * @throws TilesContainerFactoryException If something goes wrong during
      * initialization.
+     * @deprecated Use
+     * {@link #createMutableTilesContainer(TilesApplicationContext)}.
      */
-    public MutableTilesContainer createMutableTilesContainer(Object context) {
+    @Deprecated
+    public TilesContainer createMutableTilesContainer(Object context) {
+        if (context instanceof TilesApplicationContext) {
+            return createMutableTilesContainer((TilesApplicationContext) context);
+        }
+
+        throw new UnsupportedOperationException("Class "
+                + context.getClass().getName()
+                + " not recognized a TilesApplicationContext");
+    }
+
+    /**
+     * Creates a mutable Tiles container.
+     *
+     * @param context The Tiles application context object.
+     * @return The created Tiles container.
+     * @throws TilesContainerFactoryException If something goes wrong during
+     * initialization.
+     */
+    public MutableTilesContainer createMutableTilesContainer(
+            TilesApplicationContext context) {
         CachingTilesContainer container = new CachingTilesContainer();
         initializeContainer(context, container);
         return container;
@@ -275,16 +329,38 @@
      * @param container The container to be initialized.
      * @throws TilesContainerFactoryException If something goes wrong during
      * initialization.
+     * @deprecated Use
+     * {@link #initializeContainer(TilesApplicationContext, BasicTilesContainer)}.
      */
+    @Deprecated
     protected void initializeContainer(Object context,
             BasicTilesContainer container) {
+        if (context instanceof TilesApplicationContext) {
+            initializeContainer((TilesApplicationContext) context, container);
+        }
+
+        throw new UnsupportedOperationException("Class "
+                + context.getClass().getName()
+                + " not recognized a TilesApplicationContext");
+    }
+
+    /**
+     * Initializes a container.
+     *
+     * @param context The Tiles application context object to use.
+     * @param container The container to be initialized.
+     * @throws TilesContainerFactoryException If something goes wrong during
+     * initialization.
+     */
+    protected void initializeContainer(TilesApplicationContext context,
+            BasicTilesContainer container) {
         Map <String, String> initParameterMap;
 
         if (LOG.isInfoEnabled()) {
             LOG.info("Initializing Tiles2 container. . .");
         }
 
-        initParameterMap = getInitParameterMap(context);
+        initParameterMap = context.getInitParams();
         Map<String, String> configuration = new HashMap<String, String>(defaultConfiguration);
         configuration.putAll(initParameterMap);
         storeContainerDependencies(context, initParameterMap, configuration, container);
@@ -310,13 +386,37 @@
     protected void storeContainerDependencies(Object context,
             Map<String, String> initParameters,
             Map<String, String> configuration, BasicTilesContainer container) {
-        TilesApplicationContextFactory contextFactory =
-            (TilesApplicationContextFactory) createFactory(configuration,
-                APPLICATION_CONTEXT_FACTORY_INIT_PARAM);
-        contextFactory.init(configuration);
+        if (context instanceof TilesApplicationContext) {
+            storeContainerDependencies((TilesApplicationContext) context,
+                    initParameters, configuration, container);
+        }
+
+        throw new UnsupportedOperationException("Class "
+                + context.getClass().getName()
+                + " not recognized a TilesApplicationContext");
+    }
 
-        TilesApplicationContext tilesContext =
-            contextFactory.createApplicationContext(context);
+    /**
+     * Stores container dependencies, that is called before
+     * {@link TilesContainer#init(Map)}.
+     *
+     * @param context The (application) context object to use.
+     * @param initParameters The initialization parameters.
+     * @param configuration The merged configuration parameters (both defaults
+     * and context ones).
+     * @param container The container to use.
+     * @throws TilesContainerFactoryException If something goes wrong during
+     * initialization.
+     */
+    protected void storeContainerDependencies(TilesApplicationContext context,
+            Map<String, String> initParameters,
+            Map<String, String> configuration, BasicTilesContainer container) {
+        AbstractTilesApplicationContextFactory contextFactory =
+            (AbstractTilesApplicationContextFactory) createFactory(configuration,
+                AbstractTilesApplicationContextFactory.APPLICATION_CONTEXT_FACTORY_INIT_PARAM);
+        if (contextFactory instanceof Initializable) {
+            ((Initializable) contextFactory).init(configuration);
+        }
 
         TilesRequestContextFactory requestContextFactory =
             (TilesRequestContextFactory) createFactory(configuration,
@@ -332,7 +432,7 @@
 
         if (evaluator instanceof TilesApplicationContextAware) {
             ((TilesApplicationContextAware) evaluator)
-                    .setApplicationContext(tilesContext);
+                    .setApplicationContext(context);
         }
 
         if (evaluator instanceof TilesContainerAware) {
@@ -348,7 +448,7 @@
 
         if (rendererFactory instanceof TilesApplicationContextAware) {
             ((TilesApplicationContextAware) rendererFactory)
-                    .setApplicationContext(tilesContext);
+                    .setApplicationContext(context);
         }
 
         if (rendererFactory instanceof TilesContainerAware) {
@@ -364,13 +464,12 @@
             (PreparerFactory) createFactory(configuration,
                 PREPARER_FACTORY_INIT_PARAM);
 
-        postCreationOperations(requestContextFactory, tilesContext,
-                rendererFactory, evaluator, initParameters, configuration,
-                container);
+        postCreationOperations(requestContextFactory, context, rendererFactory,
+                evaluator, initParameters, configuration, container);
 
         container.setRequestContextFactory(requestContextFactory);
         container.setPreparerFactory(prepFactory);
-        container.setApplicationContext(tilesContext);
+        container.setApplicationContext(context);
         container.setRendererFactory(rendererFactory);
         container.setEvaluator(evaluator);
     }

Modified: tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/context/ChainedTilesApplicationContextFactoryTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/context/ChainedTilesApplicationContextFactoryTest.java?rev=722062&r1=722061&r2=722062&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/context/ChainedTilesApplicationContextFactoryTest.java (original)
+++ tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/context/ChainedTilesApplicationContextFactoryTest.java Mon Dec  1 05:09:09 2008
@@ -77,7 +77,8 @@
      */
     public void testSetFactories() {
         ChainedTilesApplicationContextFactory factory = new ChainedTilesApplicationContextFactory();
-        List<TilesApplicationContextFactory> factories = new ArrayList<TilesApplicationContextFactory>();
+        List<AbstractTilesApplicationContextFactory> factories =
+            new ArrayList<AbstractTilesApplicationContextFactory>();
         RepeaterTilesApplicationContextFactory repFactory = new RepeaterTilesApplicationContextFactory();
         factories.add(repFactory);
         factory.setFactories(factories);

Modified: tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/BasicTilesContainerFactoryTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/BasicTilesContainerFactoryTest.java?rev=722062&r1=722061&r2=722062&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/BasicTilesContainerFactoryTest.java (original)
+++ tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/BasicTilesContainerFactoryTest.java Mon Dec  1 05:09:09 2008
@@ -28,9 +28,7 @@
 
 import org.apache.tiles.TilesApplicationContext;
 import org.apache.tiles.TilesContainer;
-import org.apache.tiles.context.ChainedTilesApplicationContextFactory;
 import org.apache.tiles.context.ChainedTilesRequestContextFactory;
-import org.apache.tiles.context.TilesApplicationContextFactory;
 import org.apache.tiles.context.TilesRequestContextFactory;
 import org.apache.tiles.definition.DefinitionsFactory;
 import org.apache.tiles.definition.DefinitionsReader;
@@ -41,7 +39,6 @@
 import org.apache.tiles.impl.BasicTilesContainer;
 import org.apache.tiles.locale.LocaleResolver;
 import org.apache.tiles.locale.impl.DefaultLocaleResolver;
-import org.apache.tiles.mock.RepeaterTilesApplicationContextFactory;
 import org.apache.tiles.mock.RepeaterTilesRequestContextFactory;
 import org.apache.tiles.preparer.BasicPreparerFactory;
 import org.apache.tiles.preparer.PreparerFactory;
@@ -69,7 +66,7 @@
     /**
      * The context object.
      */
-    private TilesApplicationContext context;
+    private TilesApplicationContext applicationContext;
 
     /**
      * The URL to load.
@@ -79,168 +76,128 @@
     /** {@inheritDoc} */
     @Override
     protected void setUp() throws Exception {
-        context = EasyMock.createMock(TilesApplicationContext.class);
+        applicationContext = EasyMock.createMock(TilesApplicationContext.class);
         url = getClass().getResource("/org/apache/tiles/config/tiles-defs.xml");
-        EasyMock.expect(context.getResource("/WEB-INF/tiles.xml")).andReturn(url);
-        EasyMock.replay(context);
+        EasyMock.expect(applicationContext.getResource("/WEB-INF/tiles.xml")).andReturn(url);
+        EasyMock.replay(applicationContext);
         factory = new CustomBasicTilesContainerFactory();
     }
 
     /**
-     * Tests {@link BasicTilesContainerFactory#createContainer(Object)}.
+     * Tests {@link BasicTilesContainerFactory#createContainer(TilesApplicationContext)}.
      */
     public void testCreateContainer() {
-        TilesContainer container = factory.createContainer(context);
+        TilesContainer container = factory.createContainer(applicationContext);
         assertTrue("The class of the container is not correct",
                 container instanceof BasicTilesContainer);
     }
 
     /**
-     * Tests {@link BasicTilesContainerFactory#createApplicationContextFactory(Object)}.
-     */
-    public void testCreateApplicationContextFactory() {
-        TilesApplicationContextFactory contextFactory = factory
-                .createApplicationContextFactory(context);
-        assertTrue("The class of the context factory is not correct",
-                contextFactory instanceof ChainedTilesApplicationContextFactory);
-    }
-
-    /**
      * Tests {@link BasicTilesContainerFactory#createRequestContextFactory()}.
      */
     public void testCreateRequestContextFactory() {
         TilesRequestContextFactory contextFactory = factory
-                .createRequestContextFactory();
+                .createRequestContextFactory(null);
         assertTrue("The class of the context factory is not correct",
                 contextFactory instanceof ChainedTilesRequestContextFactory);
     }
 
     /**
-     * Tests {@link BasicTilesContainerFactory#createDefinitionsFactory(Object,
-     * TilesApplicationContext, TilesContextFactory, LocaleResolver)}.
+     * Tests {@link BasicTilesContainerFactory#createDefinitionsFactory(TilesApplicationContext,
+     * TilesContextFactory, LocaleResolver)}.
      */
     public void testCreateDefinitionsFactory() {
-        TilesApplicationContextFactory contextFactory = factory
-                .createApplicationContextFactory(context);
-        TilesApplicationContext applicationContext = contextFactory
-                .createApplicationContext(context);
         TilesRequestContextFactory requestContextFactory = factory
-                .createRequestContextFactory();
-        LocaleResolver resolver = factory.createLocaleResolver(context,
-                applicationContext, requestContextFactory);
+                .createRequestContextFactory(applicationContext);
+        LocaleResolver resolver = factory.createLocaleResolver(applicationContext,
+                requestContextFactory);
         DefinitionsFactory defsFactory = factory.createDefinitionsFactory(
-                context, applicationContext, requestContextFactory, resolver);
+                applicationContext, requestContextFactory, resolver);
         assertTrue("The class of the definitions factory is not correct",
                 defsFactory instanceof UrlDefinitionsFactory);
     }
 
     /**
-     * Tests {@link BasicTilesContainerFactory#createLocaleResolver(Object,
-     * TilesApplicationContext, TilesContextFactory)}.
+     * Tests {@link BasicTilesContainerFactory#createLocaleResolver(TilesApplicationContext,
+     * TilesContextFactory)}.
      */
     public void testCreateLocaleResolver() {
-        TilesApplicationContextFactory contextFactory = factory
-                .createApplicationContextFactory(context);
-        TilesApplicationContext applicationContext = contextFactory
-                .createApplicationContext(context);
         TilesRequestContextFactory requestContextFactory = factory
-                .createRequestContextFactory();
-        LocaleResolver localeResolver = factory.createLocaleResolver(context,
-                applicationContext, requestContextFactory);
+                .createRequestContextFactory(applicationContext);
+        LocaleResolver localeResolver = factory.createLocaleResolver(applicationContext,
+                requestContextFactory);
         assertTrue("The class of the locale resolver is not correct",
                 localeResolver instanceof DefaultLocaleResolver);
     }
 
     /**
-     * Tests {@link BasicTilesContainerFactory#createDefinitionsReader(Object,
-     * TilesApplicationContext, TilesContextFactory)}.
+     * Tests {@link BasicTilesContainerFactory#createDefinitionsReader(TilesApplicationContext,
+     * TilesContextFactory)}.
      */
     public void testCreateDefinitionsReader() {
-        TilesApplicationContextFactory contextFactory = factory
-                .createApplicationContextFactory(context);
-        TilesApplicationContext applicationContext = contextFactory
-                .createApplicationContext(context);
         TilesRequestContextFactory requestContextFactory = factory
-                .createRequestContextFactory();
-        DefinitionsReader reader = factory.createDefinitionsReader(context,
-                applicationContext, requestContextFactory);
+                .createRequestContextFactory(applicationContext);
+        DefinitionsReader reader = factory.createDefinitionsReader(applicationContext,
+                requestContextFactory);
         assertTrue("The class of the reader is not correct",
                 reader instanceof DigesterDefinitionsReader);
     }
 
     /**
      * Tests
-     * {@link BasicTilesContainerFactory#getSourceURLs(Object, TilesApplicationContext, TilesContextFactory)}.
+     * {@link BasicTilesContainerFactory#getSourceURLs(TilesApplicationContext, TilesContextFactory)}.
      */
     public void testGetSourceURLs() {
-        TilesApplicationContextFactory contextFactory = factory
-                .createApplicationContextFactory(context);
-        TilesApplicationContext applicationContext = contextFactory
-                .createApplicationContext(context);
         TilesRequestContextFactory requestContextFactory = factory
-                .createRequestContextFactory();
-        List<URL> urls = factory.getSourceURLs(context, applicationContext,
-                requestContextFactory);
+                .createRequestContextFactory(applicationContext);
+        List<URL> urls = factory.getSourceURLs(applicationContext, requestContextFactory);
         assertEquals("The urls list is not one-sized", 1, urls.size());
         assertEquals("The URL is not correct", url, urls.get(0));
     }
 
     /**
      * Tests
-     * {@link BasicTilesContainerFactory#createEvaluator(Object,
-     * TilesApplicationContext, TilesContextFactory, LocaleResolver)}.
+     * {@link BasicTilesContainerFactory#createEvaluator(TilesApplicationContext,
+     * TilesContextFactory, LocaleResolver)}.
      */
     public void testCreateEvaluator() {
-        TilesApplicationContextFactory contextFactory = factory
-                .createApplicationContextFactory(context);
-        TilesApplicationContext applicationContext = contextFactory
-                .createApplicationContext(context);
         TilesRequestContextFactory requestContextFactory = factory
-                .createRequestContextFactory();
-        LocaleResolver resolver = factory.createLocaleResolver(context,
-                applicationContext, requestContextFactory);
-        AttributeEvaluator evaluator = factory.createEvaluator(context,
-                applicationContext, requestContextFactory, resolver);
+                .createRequestContextFactory(applicationContext);
+        LocaleResolver resolver = factory.createLocaleResolver(applicationContext,
+                requestContextFactory);
+        AttributeEvaluator evaluator = factory.createEvaluator(applicationContext,
+                requestContextFactory, resolver);
         assertTrue("The class of the evaluator is not correct",
                 evaluator instanceof DirectAttributeEvaluator);
     }
 
     /**
      * Tests
-     * {@link BasicTilesContainerFactory#createPreparerFactory(Object, TilesApplicationContext, TilesContextFactory)}.
+     * {@link BasicTilesContainerFactory#createPreparerFactory(TilesApplicationContext, TilesContextFactory)}.
      */
     public void testCreatePreparerFactory() {
-        TilesApplicationContextFactory contextFactory = factory
-                .createApplicationContextFactory(context);
-        TilesApplicationContext applicationContext = contextFactory
-                .createApplicationContext(context);
         TilesRequestContextFactory requestContextFactory = factory
-                .createRequestContextFactory();
+                .createRequestContextFactory(applicationContext);
         PreparerFactory preparerFactory = factory.createPreparerFactory(
-                context, applicationContext, requestContextFactory);
+                applicationContext, requestContextFactory);
         assertTrue("The class of the preparer factory is not correct",
                 preparerFactory instanceof BasicPreparerFactory);
     }
 
     /**
-     * Tests {@link BasicTilesContainerFactory#createRendererFactory(Object,
-     * TilesApplicationContext, TilesContextFactory, TilesContainer, AttributeEvaluator)}.
+     * Tests {@link BasicTilesContainerFactory#createRendererFactory(TilesApplicationContext,
+     * TilesContextFactory, TilesContainer, AttributeEvaluator)}.
      */
     public void testCreateRendererFactory() {
-        TilesContainer container = factory.createContainer(context);
-        TilesApplicationContextFactory contextFactory = factory
-                .createApplicationContextFactory(context);
-        TilesApplicationContext applicationContext = contextFactory
-                .createApplicationContext(context);
+        TilesContainer container = factory.createContainer(applicationContext);
         TilesRequestContextFactory requestContextFactory = factory
-                .createRequestContextFactory();
-        LocaleResolver resolver = factory.createLocaleResolver(context,
-                applicationContext, requestContextFactory);
-        AttributeEvaluator evaluator = factory.createEvaluator(context,
-                applicationContext, requestContextFactory, resolver);
+                .createRequestContextFactory(applicationContext);
+        LocaleResolver resolver = factory.createLocaleResolver(applicationContext,
+                requestContextFactory);
+        AttributeEvaluator evaluator = factory.createEvaluator(applicationContext,
+                requestContextFactory, resolver);
         RendererFactory rendererFactory = factory.createRendererFactory(
-                context, applicationContext, requestContextFactory, container,
-                evaluator);
+                applicationContext, requestContextFactory, container, evaluator);
         assertTrue("The class of the renderer factory is not correct",
                 rendererFactory instanceof BasicRendererFactory);
         AttributeRenderer renderer = rendererFactory.getRenderer("string");
@@ -258,24 +215,19 @@
     }
 
     /**
-     * Tests {@link BasicTilesContainerFactory#createDefaultAttributeRenderer(Object,
-     * TilesApplicationContext, TilesContextFactory, TilesContainer, AttributeEvaluator)}.
+     * Tests {@link BasicTilesContainerFactory#createDefaultAttributeRenderer(TilesApplicationContext,
+     * TilesContextFactory, TilesContainer, AttributeEvaluator)}.
      */
     public void testCreateDefaultAttributeRenderer() {
-        TilesContainer container = factory.createContainer(context);
-        TilesApplicationContextFactory contextFactory = factory
-                .createApplicationContextFactory(context);
-        TilesApplicationContext applicationContext = contextFactory
-                .createApplicationContext(context);
+        TilesContainer container = factory.createContainer(applicationContext);
         TilesRequestContextFactory requestContextFactory = factory
-                .createRequestContextFactory();
-        LocaleResolver resolver = factory.createLocaleResolver(context,
-                applicationContext, requestContextFactory);
-        AttributeEvaluator evaluator = factory.createEvaluator(context,
-                applicationContext, requestContextFactory, resolver);
+                .createRequestContextFactory(applicationContext);
+        LocaleResolver resolver = factory.createLocaleResolver(applicationContext,
+                requestContextFactory);
+        AttributeEvaluator evaluator = factory.createEvaluator(applicationContext,
+                requestContextFactory, resolver);
         AttributeRenderer renderer = factory.createDefaultAttributeRenderer(
-                context, applicationContext, requestContextFactory, container,
-                evaluator);
+                applicationContext, requestContextFactory, container, evaluator);
         assertTrue("The default renderer class is not correct",
                 renderer instanceof UntypedAttributeRenderer);
     }
@@ -296,18 +248,5 @@
             factories.add(factory);
             contextFactory.setFactories(factories);
         }
-
-        /** {@inheritDoc} */
-        @Override
-        protected void registerChainedApplicationContextFactories(
-                Object context,
-                ChainedTilesApplicationContextFactory contextFactory) {
-            List<TilesApplicationContextFactory> factories =
-                new ArrayList<TilesApplicationContextFactory>(1);
-            RepeaterTilesApplicationContextFactory factory = new RepeaterTilesApplicationContextFactory();
-            factories.add(factory);
-            contextFactory.setFactories(factories);
-        }
-
     }
 }

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=722062&r1=722061&r2=722062&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 Dec  1 05:09:09 2008
@@ -20,18 +20,18 @@
  */
 package org.apache.tiles.factory;
 
-import java.net.MalformedURLException;
+import java.io.IOException;
 import java.net.URL;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
-import java.util.Vector;
-
-import javax.servlet.ServletContext;
+import java.util.Set;
 
 import junit.framework.TestCase;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.tiles.TilesApplicationContext;
 import org.apache.tiles.TilesContainer;
 import org.apache.tiles.context.ChainedTilesApplicationContextFactory;
 import org.apache.tiles.context.ChainedTilesRequestContextFactory;
@@ -53,11 +53,16 @@
             .getLog(KeyedDefinitionsFactoryTilesContainerFactoryTest.class);
 
     /**
-     * The servlet context.
+     * The application context.
      */
-    private ServletContext context;
+    private TilesApplicationContext context;
 
     /**
+     * Initialization parameters.
+     */
+    private Map<String, String> initParams;
+    
+    /**
      * Default configuration parameters.
      */
     private Map<String, String> defaults;
@@ -65,17 +70,19 @@
     /** {@inheritDoc} */
     @Override
     public void setUp() {
-        context = EasyMock.createMock(ServletContext.class);
-        EasyMock.expect(context.getInitParameter(
-                AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM)).andReturn(
+        context = EasyMock.createMock(TilesApplicationContext.class);
+        initParams = new HashMap<String, String>();
+        initParams.put(
+                AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM,
                 KeyedDefinitionsFactoryTilesContainerFactory.class.getName());
-        EasyMock.expect(context.getInitParameter(
-                ChainedTilesApplicationContextFactory.FACTORY_CLASS_NAMES))
-                .andReturn(RepeaterTilesApplicationContextFactory.class
-                        .getName());
-        EasyMock.expect(context.getInitParameter(
-                ChainedTilesRequestContextFactory.FACTORY_CLASS_NAMES))
-                .andReturn(RepeaterTilesRequestContextFactory.class.getName());
+        initParams.put(
+                ChainedTilesApplicationContextFactory.FACTORY_CLASS_NAMES,
+                RepeaterTilesApplicationContextFactory.class.getName());
+        initParams.put(
+                ChainedTilesRequestContextFactory.FACTORY_CLASS_NAMES,
+                RepeaterTilesRequestContextFactory.class.getName());
+        EasyMock.expect(context.getInitParams()).andReturn(initParams)
+                .anyTimes();
         defaults = new HashMap<String, String>();
     }
 
@@ -83,12 +90,6 @@
      * Tests getting a container factory.
      */
     public void testGetFactory() {
-        Vector<String> v = new Vector<String>();
-        v.add(AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM);
-        v.add(ChainedTilesApplicationContextFactory.FACTORY_CLASS_NAMES);
-        v.add(ChainedTilesRequestContextFactory.FACTORY_CLASS_NAMES);
-
-        EasyMock.expect(context.getInitParameterNames()).andReturn(v.elements());
         EasyMock.replay(context);
         TilesContainerFactory factory = (TilesContainerFactory) AbstractTilesContainerFactory
                 .getTilesContainerFactory(context);
@@ -100,38 +101,26 @@
 
     /**
      * Tests creating a container.
-     *
-     * @throws MalformedURLException If the resources have an invalid form (that
-     * should not happen).
-     */
-    public void testCreateContainer() throws MalformedURLException {
-        Vector<String> enumeration = new Vector<String>();
-        enumeration.add(AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM);
-        enumeration.add(ChainedTilesApplicationContextFactory.FACTORY_CLASS_NAMES);
-        enumeration.add(ChainedTilesRequestContextFactory.FACTORY_CLASS_NAMES);
-        EasyMock.expect(context.getInitParameter(TilesContainerFactory
-                .APPLICATION_CONTEXT_FACTORY_INIT_PARAM)).andReturn(null);
-        EasyMock.expect(context.getInitParameter(TilesContainerFactory
-                .REQUEST_CONTEXT_FACTORY_INIT_PARAM)).andReturn(null);
-        EasyMock.expect(context.getInitParameter(TilesContainerFactory.DEFINITIONS_FACTORY_INIT_PARAM)).andReturn(null);
-        EasyMock.expect(context.getInitParameter(
-                KeyedDefinitionsFactoryTilesContainerFactory.CONTAINER_KEYS_INIT_PARAM))
-                .andReturn("one,two").anyTimes();
-        EasyMock.expect(context.getInitParameter(
-                KeyedDefinitionsFactoryTilesContainer.DEFINITIONS_CONFIG_PREFIX
-                + "one"))
-                .andReturn("/WEB-INF/tiles-one.xml").anyTimes();
-        EasyMock.expect(context.getInitParameter(
-                KeyedDefinitionsFactoryTilesContainer.DEFINITIONS_CONFIG_PREFIX
-                + "@two")).andReturn("/WEB-INF/tiles-two.xml").anyTimes();
-        EasyMock.expect(context.getInitParameter(EasyMock.isA(String.class))).andReturn(null).anyTimes();
-        EasyMock.expect(context.getInitParameterNames()).andReturn(enumeration.elements()).anyTimes();
+     * @throws IOException If something goes wrong.
+     */
+    public void testCreateContainer() throws IOException {
+        initParams.put(KeyedDefinitionsFactoryTilesContainerFactory
+                .CONTAINER_KEYS_INIT_PARAM, "one,two");
+        initParams.put(KeyedDefinitionsFactoryTilesContainer
+                .DEFINITIONS_CONFIG_PREFIX + "one", "/WEB-INF/tiles-one.xml");
+        initParams.put(KeyedDefinitionsFactoryTilesContainer
+                .DEFINITIONS_CONFIG_PREFIX + "two", "/WEB-INF/tiles-two.xml");
         URL url = getClass().getResource("test-defs.xml");
-        EasyMock.expect(context.getResource("/WEB-INF/tiles.xml")).andReturn(url);
+        Set<URL> urls = new HashSet<URL>();
+        urls.add(url);
+        EasyMock.expect(context.getResources("/WEB-INF/tiles.xml")).andReturn(
+                urls);
         url = getClass().getResource("test-defs-key-one.xml");
-        EasyMock.expect(context.getResource("/WEB-INF/tiles-one.xml")).andReturn(url);
+        EasyMock.expect(context.getResources("/WEB-INF/tiles-one.xml"))
+                .andReturn(urls);
         url = getClass().getResource("test-defs-key-two.xml");
-        EasyMock.expect(context.getResource("/WEB-INF/tiles-two.xml")).andReturn(url);
+        EasyMock.expect(context.getResources("/WEB-INF/tiles-two.xml"))
+                .andReturn(urls);
         EasyMock.replay(context);
 
         TilesContainerFactory factory = (TilesContainerFactory) AbstractTilesContainerFactory

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=722062&r1=722061&r2=722062&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 Dec  1 05:09:09 2008
@@ -20,25 +20,26 @@
  */
 package org.apache.tiles.factory;
 
-import junit.framework.TestCase;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
 
-import javax.servlet.ServletContext;
+import junit.framework.TestCase;
 
-import org.easymock.EasyMock;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.tiles.TilesApplicationContext;
 import org.apache.tiles.TilesContainer;
 import org.apache.tiles.TilesException;
 import org.apache.tiles.context.ChainedTilesApplicationContextFactory;
 import org.apache.tiles.context.ChainedTilesRequestContextFactory;
 import org.apache.tiles.mock.RepeaterTilesApplicationContextFactory;
 import org.apache.tiles.mock.RepeaterTilesRequestContextFactory;
-
-import java.util.Map;
-import java.util.Vector;
-import java.util.HashMap;
-import java.net.URL;
-import java.net.MalformedURLException;
+import org.easymock.EasyMock;
 
 
 /**
@@ -55,33 +56,21 @@
     /**
      * The servlet context.
      */
-    private ServletContext context;
+    private TilesApplicationContext context;
 
     /** {@inheritDoc} */
     @Override
     public void setUp() {
-        context = EasyMock.createMock(ServletContext.class);
+        context = EasyMock.createMock(TilesApplicationContext.class);
     }
 
     /**
      * Tests getting the factory.
      */
-    @SuppressWarnings("deprecation")
     public void testGetFactory() {
-        Vector<String> v = new Vector<String>();
-        Vector<String> emptyVector = new Vector<String>();
-        v.add(AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM);
-        v.add(ChainedTilesApplicationContextFactory.FACTORY_CLASS_NAMES);
-        v.add(ChainedTilesRequestContextFactory.FACTORY_CLASS_NAMES);
-
-        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);
+        Map<String, String> initParams = new HashMap<String, String>();
+        EasyMock.expect(context.getInitParams()).andReturn(initParams)
+                .anyTimes();
         EasyMock.replay(context);
         AbstractTilesContainerFactory factory = AbstractTilesContainerFactory
                 .getTilesContainerFactory(context);
@@ -89,17 +78,16 @@
         assertEquals(TilesContainerFactory.class, factory.getClass());
 
         EasyMock.reset(context);
-        EasyMock.expect(context.getInitParameterNames()).andReturn(v.elements());
-        EasyMock.expect(context.getInitParameter(
-                AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM))
-                .andReturn(TestFactory.class.getName());
-        EasyMock.expect(context.getInitParameter(
-                ChainedTilesApplicationContextFactory.FACTORY_CLASS_NAMES))
-                .andReturn(RepeaterTilesApplicationContextFactory.class
-                        .getName());
-        EasyMock.expect(context.getInitParameter(
-                ChainedTilesRequestContextFactory.FACTORY_CLASS_NAMES))
-                .andReturn(RepeaterTilesRequestContextFactory.class.getName());
+        initParams.put(AbstractTilesContainerFactory
+                .CONTAINER_FACTORY_INIT_PARAM, TestFactory.class.getName());
+        initParams.put(
+                ChainedTilesApplicationContextFactory.FACTORY_CLASS_NAMES,
+                RepeaterTilesApplicationContextFactory.class.getName());
+        initParams.put(
+                ChainedTilesRequestContextFactory.FACTORY_CLASS_NAMES,
+                RepeaterTilesRequestContextFactory.class.getName());
+        EasyMock.expect(context.getInitParams()).andReturn(initParams)
+                .anyTimes();
         EasyMock.replay(context);
         factory = AbstractTilesContainerFactory
                 .getTilesContainerFactory(context);
@@ -108,17 +96,16 @@
 
         Map<String, String> defaults = new HashMap<String, String>();
         EasyMock.reset(context);
-        EasyMock.expect(context.getInitParameterNames()).andReturn(v.elements());
-        EasyMock.expect(context.getInitParameter(
-                AbstractTilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM))
-                .andReturn(TestFactory.class.getName());
-        EasyMock.expect(context.getInitParameter(
-                ChainedTilesApplicationContextFactory.FACTORY_CLASS_NAMES))
-                .andReturn(RepeaterTilesApplicationContextFactory.class
-                        .getName());
-        EasyMock.expect(context.getInitParameter(
-                ChainedTilesRequestContextFactory.FACTORY_CLASS_NAMES))
-                .andReturn(RepeaterTilesRequestContextFactory.class.getName());
+        initParams.put(AbstractTilesContainerFactory
+                .CONTAINER_FACTORY_INIT_PARAM, TestFactory.class.getName());
+        initParams.put(
+                ChainedTilesApplicationContextFactory.FACTORY_CLASS_NAMES,
+                RepeaterTilesApplicationContextFactory.class.getName());
+        initParams.put(
+                ChainedTilesRequestContextFactory.FACTORY_CLASS_NAMES,
+                RepeaterTilesRequestContextFactory.class.getName());
+        EasyMock.expect(context.getInitParams()).andReturn(initParams)
+                .anyTimes();
         EasyMock.replay(context);
         factory = AbstractTilesContainerFactory
                 .getTilesContainerFactory(context);
@@ -127,16 +114,16 @@
         assertEquals(TestFactory.class, factory.getClass());
 
         EasyMock.reset(context);
-        EasyMock.expect(context.getInitParameterNames()).andReturn(v.elements());
-        EasyMock.expect(context.getInitParameter(AbstractTilesContainerFactory
-                .CONTAINER_FACTORY_INIT_PARAM)).andReturn("org.missing.Class");
-        EasyMock.expect(context.getInitParameter(
-                ChainedTilesApplicationContextFactory.FACTORY_CLASS_NAMES))
-                .andReturn(RepeaterTilesApplicationContextFactory.class
-                        .getName());
-        EasyMock.expect(context.getInitParameter(
-                ChainedTilesRequestContextFactory.FACTORY_CLASS_NAMES))
-                .andReturn(RepeaterTilesRequestContextFactory.class.getName());
+        initParams.put(AbstractTilesContainerFactory
+                .CONTAINER_FACTORY_INIT_PARAM, "org.missing.Class");
+        initParams.put(
+                ChainedTilesApplicationContextFactory.FACTORY_CLASS_NAMES,
+                RepeaterTilesApplicationContextFactory.class.getName());
+        initParams.put(
+                ChainedTilesRequestContextFactory.FACTORY_CLASS_NAMES,
+                RepeaterTilesRequestContextFactory.class.getName());
+        EasyMock.expect(context.getInitParams()).andReturn(initParams)
+                .anyTimes();
         EasyMock.replay(context);
         try {
             AbstractTilesContainerFactory.getTilesContainerFactory(context);
@@ -148,33 +135,26 @@
         }
     }
 
-
     /**
      * Tests the creation of a container.
      *
-     * @throws MalformedURLException If something goes wrong when obtaining URL
-     * resources.
+     * @throws IOException If something goes wrong when obtaining URL resources.
      */
-    public void testCreateContainer() throws MalformedURLException {
+    public void testCreateContainer() throws IOException {
+        Map<String, String> initParams = new HashMap<String, String>();
         URL url = getClass().getResource("test-defs.xml");
-        Vector<String> enumeration = new Vector<String>();
-        enumeration.add(ChainedTilesApplicationContextFactory.FACTORY_CLASS_NAMES);
-        enumeration.add(ChainedTilesRequestContextFactory.FACTORY_CLASS_NAMES);
-        EasyMock.expect(context.getInitParameter(
-                ChainedTilesApplicationContextFactory.FACTORY_CLASS_NAMES))
-                .andReturn(RepeaterTilesApplicationContextFactory.class
-                        .getName());
-        EasyMock.expect(context.getInitParameter(
-                ChainedTilesRequestContextFactory.FACTORY_CLASS_NAMES))
-                .andReturn(RepeaterTilesRequestContextFactory.class.getName());
-        EasyMock.expect(context.getInitParameter(TilesContainerFactory
-                .APPLICATION_CONTEXT_FACTORY_INIT_PARAM)).andReturn(null);
-        EasyMock.expect(context.getInitParameter(TilesContainerFactory
-                .REQUEST_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();
-        EasyMock.expect(context.getInitParameterNames()).andReturn(enumeration.elements()).anyTimes();
-        EasyMock.expect(context.getResource("/WEB-INF/tiles.xml")).andReturn(url);
+        initParams.put(
+                ChainedTilesApplicationContextFactory.FACTORY_CLASS_NAMES,
+                RepeaterTilesApplicationContextFactory.class.getName());
+        initParams.put(
+                ChainedTilesRequestContextFactory.FACTORY_CLASS_NAMES,
+                RepeaterTilesRequestContextFactory.class.getName());
+        Set<URL> urls = new HashSet<URL>();
+        urls.add(url);
+        EasyMock.expect(context.getResources("/WEB-INF/tiles.xml")).andReturn(
+                urls);
+        EasyMock.expect(context.getInitParams()).andReturn(initParams)
+                .anyTimes();
         EasyMock.replay(context);
 
         AbstractTilesContainerFactory factory = AbstractTilesContainerFactory
@@ -199,26 +179,26 @@
      * Tests getting init parameter map.
      */
     public void testGetInitParameterMap() {
+        Map<String, String> initParams = new HashMap<String, String>();
         Vector<String> keys = new Vector<String>();
         keys.add("one");
         keys.add("two");
 
-        EasyMock.expect(context.getInitParameter(
-                ChainedTilesApplicationContextFactory.FACTORY_CLASS_NAMES))
-                .andReturn(RepeaterTilesApplicationContextFactory.class
-                        .getName());
-        EasyMock.expect(context.getInitParameter(
-                ChainedTilesRequestContextFactory.FACTORY_CLASS_NAMES))
-                .andReturn(RepeaterTilesRequestContextFactory.class.getName());
-        EasyMock.expect(context.getInitParameterNames()).andReturn(keys.elements());
-        EasyMock.expect(context.getInitParameterNames()).andReturn(keys.elements());
-        EasyMock.expect(context.getInitParameter("one")).andReturn("oneValue").anyTimes();
-        EasyMock.expect(context.getInitParameter("two")).andReturn("twoValue").anyTimes();
+        initParams.put(
+                ChainedTilesApplicationContextFactory.FACTORY_CLASS_NAMES,
+                RepeaterTilesApplicationContextFactory.class.getName());
+        initParams.put(
+                ChainedTilesRequestContextFactory.FACTORY_CLASS_NAMES,
+                RepeaterTilesRequestContextFactory.class.getName());
+        initParams.put("one", "oneValue");
+        initParams.put("two", "twoValue");
+        EasyMock.expect(context.getInitParams()).andReturn(initParams)
+                .anyTimes();
         EasyMock.replay(context);
 
-        Map<String, String> map = TilesContainerFactory.getInitParameterMap(context);
+        Map<String, String> map = context.getInitParams();
 
-        assertEquals(2, map.size());
+        assertEquals(4, map.size());
         assertTrue(map.containsKey("one"));
         assertTrue(map.containsKey("two"));
         assertEquals("oneValue", map.get("one"));