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