1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 }