11/*
2- * Copyright 2002-2009 the original author or authors.
2+ * Copyright 2002-2010 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1616
1717package org .springframework .web .servlet .view .tiles2 ;
1818
19- import java .util .Enumeration ;
20- import java .util .LinkedHashMap ;
19+ import java .util .HashMap ;
2120import java .util .Map ;
2221import java .util .Properties ;
2322import javax .servlet .ServletContext ;
2423
2524import org .apache .commons .logging .Log ;
2625import org .apache .commons .logging .LogFactory ;
26+ import org .apache .tiles .TilesApplicationContext ;
2727import org .apache .tiles .TilesException ;
2828import org .apache .tiles .context .AbstractTilesApplicationContextFactory ;
2929import org .apache .tiles .definition .DefinitionsFactory ;
3232import org .apache .tiles .evaluator .impl .DirectAttributeEvaluator ;
3333import org .apache .tiles .factory .TilesContainerFactory ;
3434import org .apache .tiles .preparer .BasicPreparerFactory ;
35- import org .apache .tiles .servlet .context .ServletTilesApplicationContext ;
3635import org .apache .tiles .servlet .context .ServletUtil ;
37- import org .apache .tiles .servlet .context .wildcard .WildcardServletTilesApplicationContextFactory ;
3836import org .apache .tiles .startup .BasicTilesInitializer ;
3937import org .apache .tiles .startup .TilesInitializer ;
4038
@@ -91,14 +89,14 @@ public class TilesConfigurer implements ServletContextAware, InitializingBean, D
9189
9290 protected final Log logger = LogFactory .getLog (getClass ());
9391
94- private final Properties tilesPropertyMap = new Properties ();
92+ private final Map < String , String > tilesPropertyMap = new HashMap < String , String > ();
9593
9694 private ServletContext servletContext ;
9795
9896
9997 public TilesConfigurer () {
10098 this .tilesPropertyMap .put (AbstractTilesApplicationContextFactory .APPLICATION_CONTEXT_FACTORY_INIT_PARAM ,
101- WildcardServletTilesApplicationContextFactory .class .getName ());
99+ SpringTilesApplicationContextFactory .class .getName ());
102100 this .tilesPropertyMap .put (TilesContainerFactory .PREPARER_FACTORY_INIT_PARAM ,
103101 BasicPreparerFactory .class .getName ());
104102 this .tilesPropertyMap .put (TilesContainerFactory .CONTAINER_FACTORY_MUTABLE_INIT_PARAM ,
@@ -199,13 +197,15 @@ public void setServletContext(ServletContext servletContext) {
199197 * @see #createTilesInitializer()
200198 */
201199 public void afterPropertiesSet () throws TilesException {
202- createTilesInitializer ().initialize (
203- new PropertyExposingServletTilesApplicationContext (this .servletContext , this .tilesPropertyMap ));
200+ SpringTilesApplicationContextFactory factory = new SpringTilesApplicationContextFactory ();
201+ factory .init (this .tilesPropertyMap );
202+ TilesApplicationContext preliminaryContext = factory .createApplicationContext (this .servletContext );
203+ createTilesInitializer ().initialize (preliminaryContext );
204204 }
205205
206206 /**
207207 * Creates a new instance of {@link org.apache.tiles.startup.BasicTilesInitializer}.
208- * Override it to use a different initializer.
208+ * <p> Override it to use a different initializer.
209209 * @see org.apache.tiles.web.startup.TilesListener#createTilesInitializer()
210210 */
211211 protected TilesInitializer createTilesInitializer () {
@@ -220,30 +220,4 @@ public void destroy() throws TilesException {
220220 ServletUtil .setContainer (this .servletContext , null );
221221 }
222222
223-
224- private static class PropertyExposingServletTilesApplicationContext extends ServletTilesApplicationContext {
225-
226- private final Map <String , String > mergedInitParams ;
227-
228- public PropertyExposingServletTilesApplicationContext (ServletContext servletContext , Properties properties ) {
229- super (servletContext );
230- this .mergedInitParams = new LinkedHashMap <String , String >();
231- Enumeration initParamNames = servletContext .getInitParameterNames ();
232- while (initParamNames .hasMoreElements ()) {
233- String initParamName = (String ) initParamNames .nextElement ();
234- this .mergedInitParams .put (initParamName , servletContext .getInitParameter (initParamName ));
235- }
236- Enumeration propertyNames = properties .propertyNames ();
237- while (propertyNames .hasMoreElements ()) {
238- String propertyName = (String ) propertyNames .nextElement ();
239- this .mergedInitParams .put (propertyName , properties .getProperty (propertyName ));
240- }
241- }
242-
243- @ Override
244- public Map <String , String > getInitParams () {
245- return this .mergedInitParams ;
246- }
247- }
248-
249223}
0 commit comments