1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.struts.tiles;
21
22 import java.io.Serializable;
23
24 import javax.servlet.ServletContext;
25 import javax.servlet.ServletRequest;
26
27 /***
28 * Tiles Definition factory.
29 * This interface replace old ComponentDefinitionsFactory.
30 * Main method getDefinition() is exactly the same. Initialization method change.
31 * This interface allows to retrieve a definition by its name, independently of
32 * the factory implementation.
33 * Object life cycle is as follow:
34 * <ul>
35 * <li>Constructor: create object</li>
36 * <li>setConfig: set config and initialize factory. After first call to this
37 * method, factory is operational.</li>
38 * <li>destroy: factory is being shutdown.</li>
39 * </ul>
40 * Implementation must be Serializable, in order to be compliant with web Container
41 * having this constraint (Weblogic 6.x).
42 */
43 public interface DefinitionsFactory extends Serializable
44 {
45
46 /***
47 * Get a definition by its name.
48 * @param name Name of requested definition.
49 * @param request Current servelet request
50 * @param servletContext current servlet context
51 * @throws DefinitionsFactoryException An error occur while getting definition.
52 * @throws NoSuchDefinitionException No definition found for specified name
53 * Implementation can throw more accurate exception as a subclass of this exception
54 */
55 public ComponentDefinition getDefinition(String name, ServletRequest request, ServletContext servletContext)
56 throws NoSuchDefinitionException,DefinitionsFactoryException;
57
58 /***
59 * Init definition factory.
60 * This method is called immediately after factory creation, and prior any call
61 * to setConfig().
62 *
63 * @param config Configuration object used to set factory configuration.
64 * @param servletContext Servlet Context passed to factory.
65 * @throws DefinitionsFactoryException An error occur during initialization.
66 */
67 public void init(DefinitionsFactoryConfig config, ServletContext servletContext)
68 throws DefinitionsFactoryException;
69
70 /***
71 * <p>Receive notification that the factory is being
72 * shut down.</p>
73 */
74 public void destroy();
75
76 /***
77 * Set factory configuration.
78 * This method is used to change factory configuration.
79 * This method is optional, and can send an exception if implementation
80 * doesn't allow change in configuration.
81 *
82 * @param config Configuration object used to set factory configuration.
83 * @param servletContext Servlet Context passed to factory.
84 * @throws DefinitionsFactoryException An error occur during initialization.
85 */
86 public void setConfig(DefinitionsFactoryConfig config, ServletContext servletContext)
87 throws DefinitionsFactoryException;
88
89 /***
90 * Get factory configuration.
91 * @return TilesConfig
92 */
93 public DefinitionsFactoryConfig getConfig();
94
95
96 }