1 package org.apache.velocity.tools.view;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import java.util.Enumeration;
23 import javax.servlet.ServletContext;
24
25 /**
26 * <p>Because sometimes you don't care about the difference between a
27 * servlet and a filter. Why isn't there a common interface for
28 * {@link FilterConfig} and {@link ServletConfig} already? Sheesh.</p>
29 * </p>
30 * <p>
31 * Anyway, this also adds the ability to fake everything if you don't have
32 * either a FilterConfig or a ServletConfig handy. Just implement it and
33 * override the methods that return things you care about. Oh, and if you don't
34 * have any init-params at all, just use {@link JeeContextConfig} as
35 * {@link ServletContext} is the only really essential thing for creating a
36 * {@link VelocityView}.</p>
37 *
38 * @version $Id$
39 * @since 2.0
40 */
41 public interface JeeConfig
42 {
43 /**
44 * Returns an initialization parameter.
45 *
46 * @param name The name of the initialization parameter.
47 * @return The value of the parameter.
48 */
49 String getInitParameter(String name);
50
51 /**
52 * Looks for the specified init-param in the servlet/filter config
53 * (i.e. calls {@link #getInitParameter}). If no such init-param is
54 * found there, it checks the {@link ServletContext}'s init-params
55 * for the specified parameter.
56 *
57 * @param key The name of the initialization parameter.
58 * @return The value of the initialization parameter.
59 */
60 String findInitParameter(String key);
61
62 /**
63 * Returns all the parameter names.
64 *
65 * @return The enumeration containing the parameter names.
66 */
67 @SuppressWarnings("unchecked")
68 Enumeration getInitParameterNames();
69
70 /**
71 * Returns the name of the servlet (or filter) being used.
72 *
73 * @return The name of the configuration.
74 */
75 String getName();
76
77 /**
78 * Returns the servlet context.
79 *
80 * @return The servlet context.
81 */
82 ServletContext getServletContext();
83
84 }