01: package org.apache.velocity.tools.view.context;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "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 org.apache.velocity.app.VelocityEngine;
23: import org.apache.velocity.context.Context;
24:
25: import javax.servlet.http.HttpServletRequest;
26: import javax.servlet.http.HttpServletResponse;
27: import javax.servlet.ServletContext;
28:
29: /**
30: * <p>Objects implementing this interface are passed to view tools
31: * upon initialization by the
32: * {@link org.apache.velocity.tools.view.servlet.ServletToolboxManager}.</p>
33: *
34: * <p>The interface provides view tools in a servlet environment
35: * access to relevant context information, like servlet request, servlet
36: * context and the velocity context.</p>
37: *
38: * @author <a href="mailto:sidler@teamup.com">Gabe Sidler</a>
39: * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
40: *
41: * @version $Id: ViewContext.java 477914 2006-11-21 21:52:11Z henning $
42: */
43: public interface ViewContext {
44: /** Key used for the HTTP request object. */
45: public static final String REQUEST = "request";
46:
47: /** Key used for the HTTP response object. */
48: public static final String RESPONSE = "response";
49:
50: /** Key used for the HTTP session object. */
51: public static final String SESSION = "session";
52:
53: /** Key used for the servlet context object. */
54: public static final String APPLICATION = "application";
55:
56: /** Key used for XHTML setting (tells tools and macros to output XHTML). */
57: public static final String XHTML = "XHTML";
58:
59: /**
60: * <p>Returns the instance of {@link HttpServletRequest} for this request.</p>
61: */
62: public HttpServletRequest getRequest();
63:
64: /**
65: * <p>Returns the instance of {@link HttpServletResponse} for this request.</p>
66: */
67: public HttpServletResponse getResponse();
68:
69: /**
70: * <p>Returns the instance of {@link ServletContext} for this request.</p>
71: */
72: public ServletContext getServletContext();
73:
74: /**
75: * <p>Searches for the named attribute in request, session (if valid),
76: * and application scope(s) in order and returns the value associated
77: * or null.</p>
78: *
79: * @since VelocityTools 1.1
80: */
81: public Object getAttribute(String key);
82:
83: /**
84: * <p>Returns a reference to the current Velocity context.</p>
85: */
86: public Context getVelocityContext();
87:
88: /**
89: * <p>Returns the current VelocityEngine instance.</p>
90: */
91: public VelocityEngine getVelocityEngine();
92:
93: }
|