01: // Copyright 2006, 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // 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.services;
16:
17: import java.net.URL;
18: import java.util.List;
19:
20: /**
21: * An API agnostic version of {@link javax.servlet.ServletContext}, used to bridge the gaps between
22: * the Servlet API and the Portlet API.
23: */
24: public interface Context {
25: /**
26: * Returns a URL to a resource stored within the context. The path should start with a leading
27: * slash.
28: *
29: * @param path
30: * @return the URL for the path, or null if the path does not correspond to a file.
31: */
32: URL getResource(String path);
33:
34: /** Returns an initial parameter value defined by servlet. */
35: String getInitParameter(String name);
36:
37: /**
38: * Looks for resources within the web application within the supplied path. The list will be
39: * recurively expanded, as necessary. The path must start with a leading slash, and usually ends
40: * with a slash as well.
41: *
42: * @param path
43: * to search for (should start with a leading slash)
44: * @return the matches, sorted alphabetically
45: */
46: List<String> getResourcePaths(String path);
47:
48: /**
49: * Returns an attribute previously stored into the context with the given name.
50: *
51: * @param name
52: * used to retrieve the attribute
53: * @return the attribute, or null if not found
54: */
55: Object getAttribute(String name);
56: }
|