Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||
WebContext |
|
| 1.0;1 |
1 | // Copyright 2005 The Apache Software Foundation |
|
2 | // |
|
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
|
4 | // you may not use this file except in compliance with the License. |
|
5 | // You may obtain a copy of the License at |
|
6 | // |
|
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | // |
|
9 | // Unless required by applicable law or agreed to in writing, software |
|
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
|
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
12 | // See the License for the specific language governing permissions and |
|
13 | // limitations under the License. |
|
14 | ||
15 | package org.apache.tapestry.web; |
|
16 | ||
17 | import java.io.InputStream; |
|
18 | import java.net.URL; |
|
19 | import java.util.Set; |
|
20 | ||
21 | import org.apache.tapestry.describe.Describable; |
|
22 | ||
23 | /** |
|
24 | * A representation of a set of servlets (or portlets) packaged together as a web application |
|
25 | * archive. Attributes stored within the context are global to all 'lets (but not distributed across |
|
26 | * a server cluster). |
|
27 | * |
|
28 | * @author Howard M. Lewis Ship |
|
29 | */ |
|
30 | public interface WebContext extends AttributeHolder, InitializationParameterHolder, Describable |
|
31 | { |
|
32 | /** |
|
33 | * Returns a URL to the resource that is mapped to a specified path. The path must begin with a |
|
34 | * "/" and is interpreted as relative to the current context root. |
|
35 | */ |
|
36 | ||
37 | URL getResource(String path); |
|
38 | ||
39 | /** |
|
40 | * Returns the MIME type of the specified file, or null if the MIME type is not known. |
|
41 | */ |
|
42 | String getMimeType(String resourcePath); |
|
43 | ||
44 | /** |
|
45 | * Returns a directory-like listing of all the paths to resources within |
|
46 | * the web application whose longest sub-path matches the supplied |
|
47 | * path argument. Paths indicating subdirectory paths end with a slash (/). |
|
48 | * The returned paths are all relative to the root of the web application |
|
49 | * and have a leading '/'. |
|
50 | * @param path partial path used to match the resources, which must start with a '/' |
|
51 | * @return a Set containing the directory listing, or null if there are no resources |
|
52 | * in the web application whose path begins with the supplied path. |
|
53 | */ |
|
54 | Set getResourcePaths(String path); |
|
55 | ||
56 | /** |
|
57 | * Returns the resource located at the named path as an <code>InputStream</code> |
|
58 | * object. |
|
59 | * @param path a <code>String</code> specifying the path to the resource |
|
60 | * @return the <code>InputStream</code> returned to the servlet, |
|
61 | * or <code>null</code> if no resource exists at the specified path |
|
62 | */ |
|
63 | InputStream getResourceAsStream(String path); |
|
64 | ||
65 | /** |
|
66 | * Returns a <code>String</code> containing the real path for a given virtual path. |
|
67 | * For example, the path "/index.html" returns the absolute file path |
|
68 | * on the server's filesystem would be served by a request for |
|
69 | * "http://host/contextPath/index.html", where contextPath is the |
|
70 | * context path of this WebContext. |
|
71 | * |
|
72 | * @param path a <code>String</code> specifying a virtual path |
|
73 | * @return a <code>String</code> specifying the real path, or <code>null</code> if the |
|
74 | * translation cannot be performed |
|
75 | */ |
|
76 | String getRealPath(String path); |
|
77 | } |