1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.tiles.definition;
23
24 import org.apache.tiles.context.TilesRequestContext;
25 import org.apache.tiles.Definition;
26 import org.apache.tiles.TilesException;
27
28 import java.util.Map;
29
30 /***
31 * Interface for creating a {@link org.apache.tiles.definition.Definitions} object and managing
32 * its contents.
33 * <p/>
34 * <p>DefinitionsFactory implementations are responsible for maintaining the data
35 * sources of Tiles configuration data and using the data to create
36 * Definitions sets. Implementations also know how to append
37 * locale-specific configuration data to an existing Definitions set.</p>
38 *
39 * @version $Rev: 537196 $ $Date: 2007-05-11 16:07:35 +0200 (Fri, 11 May 2007) $
40 */
41 public interface DefinitionsFactory {
42
43 /***
44 * Property name that specifies the implementation of the DefinitionsReader.
45 */
46 String READER_IMPL_PROPERTY =
47 "org.apache.tiles.definition.DefinitionsReader";
48
49 /***
50 * Property name that specifies the implementation of
51 * {@link org.apache.tiles.locale.LocaleResolver}.
52 */
53 String LOCALE_RESOLVER_IMPL_PROPERTY =
54 "org.apache.tiles.locale.LocaleResolver";
55
56 /***
57 * Initializes the DefinitionsFactory and its subcomponents. <p/>
58 * Implementations may support configuration properties to be passed in via
59 * the params Map.
60 *
61 * @param params The Map of configuration properties.
62 * @throws TilesException If a Tiles exception, such as an initialization
63 * error, occurs.
64 */
65 void init(Map<String, String> params) throws TilesException;
66
67 /***
68 * Returns a Definition object that matches the given name and
69 * Tiles context.
70 *
71 * @param name The name of the Definition to return.
72 * @param tilesContext The Tiles context to use to resolve the definition.
73 * @return the Definition matching the given name or null if none
74 * is found.
75 * @throws DefinitionsFactoryException if an error occurs reading definitions.
76 */
77 Definition getDefinition(String name, TilesRequestContext tilesContext)
78 throws DefinitionsFactoryException;
79
80 /***
81 * Adds a source where Definition objects are stored.
82 * <p/>
83 * Implementations should publish what type of source object they expect.
84 * The source should contain enough information to resolve a configuration
85 * source containing definitions. The source should be a "base" source for
86 * configurations. Internationalization and Localization properties will be
87 * applied by implementations to discriminate the correct data sources based
88 * on locale.
89 *
90 * @param source The configuration source for definitions.
91 * @throws DefinitionsFactoryException if an invalid source is passed in or
92 * an error occurs resolving the source to an actual data store.
93 */
94 void addSource(Object source) throws DefinitionsFactoryException;
95
96 /***
97 * Creates and returns a {@link Definitions} set by reading
98 * configuration data from the applied sources.
99 *
100 * @return The read definitions.
101 * @throws DefinitionsFactoryException if an error occurs reading the
102 * sources.
103 */
104 Definitions readDefinitions()
105 throws DefinitionsFactoryException;
106 }