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.talika.tarsis.context;
24
25 import java.io.InputStream;
26 import java.net.MalformedURLException;
27 import java.net.URL;
28 import java.util.Map;
29
30 import org.talika.tarsis.command.factory.CommandFactory;
31 import org.talika.tarsis.factory.Factory;
32 import org.talika.tarsis.log.Logger;
33 import org.talika.tarsis.security.Authenticator;
34 import org.talika.tarsis.security.Authorizator;
35
36 /**
37 * Interface that defines the context in Tarsis MVC Framework.<br>
38 * <br>
39 * Context defines a set of methods that allows access services provided by it. These
40 * services includes access to object factories, init parameters or logger.<br>
41 * <br>
42 * Context is passed to all components defined in Tarsis MVC Framework when they are
43 * initialized.
44 *
45 * @author Jose M. Palomar
46 * @version $Revision: 117 $
47 */
48 public interface Context {
49
50 /**
51 * Returns an init parameter of this context.
52 *
53 * @param name String name of parameter.
54 * @return String value of parameter or <code>null</code> if parameter does not
55 * exist.
56 */
57 String getInitParameter(String name);
58
59 /**
60 * Returns a map with all the init parameters of this context.
61 *
62 * @return Map map with all the init parameters of this context.
63 */
64 Map getInitParameters();
65
66 /**
67 * Returns default <code>Authenticator</code> for this context.
68 *
69 * @return Authenticator default <code>Authenticator</code> for this context.
70 */
71 Authenticator getAuthenticator();
72
73 /**
74 * Returns default <code>Authorizator</code> for this context.
75 *
76 * @return Authorizator default <code>Authorizator</code> for this context.
77 */
78 Authorizator getAuthorizator();
79
80 /**
81 * Returns <code>Logger</code> of this context.
82 *
83 * @return Logger <code>Logger</code> of this context.
84 */
85 Logger getLogger();
86
87 /**
88 * Returns default <code>CommandFactory</code> for this context.
89 *
90 * @return CommandFactory default <code>CommandFactory</code> for this context.
91 */
92 CommandFactory getCommandFactory();
93
94 /**
95 * Returns an object <code>Factory</code> for given name in this context.
96 *
97 * @param name String name of factory.
98 * @return Factory object <code>Factory</code> for given name in this context or
99 * <code>null</code> if does not exist.
100 */
101 Factory getFactory(String name);
102
103
104 /**
105 * Returns a URL to the resource that is mapped to a specified path.
106 *
107 * @param path String a <code>String</code> specifying the path to the resource.
108 * @return URL the resource located at the named path, or <code>null</code> if
109 * there is no resource at that path.
110 * @throws MalformedURLException if the pathname is not given in the correct form.
111 * @see javax.servlet.ServletContext#getResource(java.lang.String)
112 */
113 URL getResource(String path) throws MalformedURLException;
114
115 /**
116 * Returns the resource located at the named path as an <code>InputStream</code>
117 * object.
118 *
119 * @param path String a <code>String</code> specifying the path to the resource.
120 * @return InputStream the <code>InputStream</code> returned to the servlet, or
121 * <code>null</code> if no resource exists at the specified path.
122 * @see javax.servlet.ServletContext#getResourceAsStream(java.lang.String)
123 */
124 InputStream getResourceAsStream(String path);
125
126 /**
127 * Returns a String containing the real path for a given virtual path.
128 *
129 * @param path String a <code>String</code> specifying the path to the resource.
130 * @return String a <code>String</code> specifying the real path, or
131 * <code>null</code> if the translation cannot be performed
132 * @see javax.servlet.ServletContext#getRealPath(java.lang.String)
133 */
134 String getRealPath(String path);
135
136 }