This project has retired. For details please refer to its Attic page.
AbstractTilesContainerFactory xref
View Javadoc

1   /*
2    * $Id: AbstractTilesContainerFactory.java 797540 2009-07-24 15:42:00Z apetrelli $
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  package org.apache.tiles.factory;
22  
23  import org.apache.tiles.TilesApplicationContext;
24  import org.apache.tiles.TilesContainer;
25  import org.apache.tiles.reflect.ClassUtil;
26  
27  /***
28   * Abstract Factory that creates instances of {@link TilesContainerFactory}.
29   *
30   * @version $Rev: 797540 $ $Date: 2009-07-24 17:42:00 +0200 (ven, 24 lug 2009) $
31   * @since 2.1.0
32   */
33  public abstract class AbstractTilesContainerFactory {
34  
35      /***
36       * Initialization parameter that represents the container factory class
37       * name.
38       *
39       * @since 2.1.0
40       */
41      public static final String CONTAINER_FACTORY_INIT_PARAM =
42          "org.apache.tiles.factory.AbstractTilesContainerFactory";
43  
44      /***
45       * Creates a factory instance.
46       *
47       * @param context The application context object.
48       * @return The created factory.
49       * @throws TilesContainerFactoryException If something goes wrong during
50       * creation.
51       * @since 2.1.1
52       * @deprecated Create directly a new instance of this class.
53       */
54      public static AbstractTilesContainerFactory getTilesContainerFactory(
55              TilesApplicationContext context) {
56          AbstractTilesContainerFactory retValue;
57          String factoryName = context.getInitParams().get(
58                  CONTAINER_FACTORY_INIT_PARAM);
59          if (factoryName == null) {
60              factoryName = context.getInitParams().get(
61                      TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM);
62          }
63          if (factoryName != null) {
64              retValue = (AbstractTilesContainerFactory) ClassUtil.instantiate(factoryName);
65          } else {
66              retValue = new TilesContainerFactory();
67          }
68          return retValue;
69      }
70  
71      /***
72       * Creates a Tiles container.
73       *
74       * @param applicationContext The Tiles application context object.
75       * @return The created container.
76       * @throws TilesContainerFactoryException If something goes wrong during
77       * instantiation.
78       * @since 2.1.1
79       */
80      public abstract TilesContainer createContainer(TilesApplicationContext applicationContext);
81  }