1/*2 * $Id: BasicTilesInitializer.java 831448 2009-10-30 20:39:52Z apetrelli $3 *4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */21package org.apache.tiles.startup;
2223import org.apache.tiles.Initializable;
24import org.apache.tiles.TilesApplicationContext;
25import org.apache.tiles.context.AbstractTilesApplicationContextFactory;
26import org.apache.tiles.factory.AbstractTilesContainerFactory;
2728/***29 * Default Tiles initialization delegate implementation under a servlet30 * environment. It uses init parameters to create the31 * {@link TilesApplicationContext} and the {@link org.apache.tiles.TilesContainer}.32 *33 * @version $Rev: 831448 $ $Date: 2009-10-30 21:39:52 +0100 (ven, 30 ott 2009) $34 * @since 2.1.235 * @deprecated Don't use it, please extend {@link AbstractTilesInitializer}.36 */37publicclassBasicTilesInitializerextendsAbstractTilesInitializer {
3839/***40 * Init parameter to define the key under which the container will be41 * stored.42 *43 * @since 2.1.244 */45publicstaticfinal String CONTAINER_KEY_INIT_PARAMETER =
46"org.apache.tiles.startup.BasicTilesInitializer.CONTAINER_KEY";
4748/***49 * Creates the Tiles application context, to be used across all the50 * Tiles-based application. If you override this class, please override this51 * method or52 * {@link #createAndInitializeTilesApplicationContextFactory(TilesApplicationContext)}.53 *54 * @param preliminaryContext The preliminary application context to use.55 * @return The Tiles application context.56 * @since 2.1.257 */58protected TilesApplicationContext createTilesApplicationContext(
59 TilesApplicationContext preliminaryContext) {
60AbstractTilesApplicationContextFactory acFactory =
61 createAndInitializeTilesApplicationContextFactory(preliminaryContext);
62return acFactory.createApplicationContext(preliminaryContext.getContext());
63 }
6465/***66 * Creates and initializes the Tiles application context factory, to create67 * a {@link TilesApplicationContext} to be used across all the Tiles-based68 * application. If you override this class, please override this method or69 * {@link #createTilesApplicationContext(TilesApplicationContext)}.70 *71 * @param preliminaryContext The preliminary application context to use.72 * @return The Tiles application context factory.73 * @since 2.1.274 */75protectedAbstractTilesApplicationContextFactory createAndInitializeTilesApplicationContextFactory(
76 TilesApplicationContext preliminaryContext) {
77AbstractTilesApplicationContextFactory acFactory = AbstractTilesApplicationContextFactory78 .createFactory(preliminaryContext);
79if (acFactory instanceof Initializable) {
80 ((Initializable) acFactory).init(preliminaryContext.getInitParams());
81 }
82return acFactory;
83 }
8485/***86 * Returns the container key under which the container will be stored.87 *88 * @param applicationContext The Tiles application context to use.89 * @return The container key.90 * @since 2.1.291 */92protected String getContainerKey(TilesApplicationContext applicationContext) {
93 String key = applicationContext.getInitParams().get(
94 CONTAINER_KEY_INIT_PARAMETER);
95return key;
96 }
9798/***99 * Creates a Tiles container factory. If you override this class, please100 * override this method or {@link #createContainer(TilesApplicationContext)}.101 *102 * @param context The servlet context to use.103 * @return The created container factory.104 * @since 2.1.2105 */106protectedAbstractTilesContainerFactory createContainerFactory(
107 TilesApplicationContext context) {
108AbstractTilesContainerFactory factory = AbstractTilesContainerFactory109 .getTilesContainerFactory(context);
110return factory;
111 }
112 }