001: /*
002: * The Apache Software License, Version 1.1
003: *
004: * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions
008: * are met:
009: *
010: * 1. Redistributions of source code must retain the above copyright
011: * notice, this list of conditions and the following disclaimer.
012: *
013: * 2. Redistributions in binary form must reproduce the above copyright
014: * notice, this list of conditions and the following disclaimer in
015: * the documentation and/or other materials provided with the
016: * distribution.
017: *
018: * 3. The end-user documentation included with the redistribution, if
019: * any, must include the following acknowlegement:
020: * "This product includes software developed by the
021: * Caucho Technology (http://www.caucho.com/)."
022: * Alternately, this acknowlegement may appear in the software itself,
023: * if and wherever such third-party acknowlegements normally appear.
024: *
025: * 4. The names "Hessian", "Resin", and "Caucho" must not be used to
026: * endorse or promote products derived from this software without prior
027: * written permission. For written permission, please contact
028: * info@caucho.com.
029: *
030: * 5. Products derived from this software may not be called "Resin"
031: * nor may "Resin" appear in their names without prior written
032: * permission of Caucho Technology.
033: *
034: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
035: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
036: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
037: * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS
038: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
039: * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
040: * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
041: * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
042: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
043: * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
044: * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
045: *
046: * @author Sam
047: */
048:
049: package com.caucho.portal.generic.context;
050:
051: import com.caucho.portal.generic.Constraint;
052: import com.caucho.portal.generic.Invocation;
053: import com.caucho.portal.generic.Window;
054:
055: import java.util.Locale;
056: import java.util.Map;
057: import java.util.Set;
058:
059: /**
060: * Some of the state of the Context depends on the current portlet
061: * being rendered. The WindowContect class stores that state.
062: * The ConnectionContext pushes WindowContext objects onto a stack as portlets
063: * are recursively processed, and pops them off of the stack when processing
064: * of them is done.
065: *
066: * This class just has getters and setters, it does not perform operations on
067: * other classes and is just used by the ConnectionContext to store values.
068: */
069: public class WindowContext {
070: private Window _window;
071: private String _namespace;
072: private int _stage;
073:
074: private Invocation _invocation;
075: private Map<String, String[]> _actionMap;
076:
077: public boolean _didAction;
078:
079: private boolean _isExcluded;
080: private int _constraintIndex;
081: private Constraint _constraintFailure;
082: private int _constraintFailureCode;
083: private Exception _exception;
084:
085: private Map<String, String> _windowRequestAttributes;
086:
087: private boolean _isPrivate;
088: private int _expirationCache;
089:
090: private LinkingPortletPreferences _preferences;
091: private Map<String, String> _userAttributeMap;
092:
093: private Locale _responseLocale;
094: private Set<Locale> _responseLocales;
095: private String _responseCharacterEncoding;
096: private Set<String> _responseCharacterEncodings;
097: private String _responseContentType;
098: private Set<String> _responseContentTypes;
099:
100: private ResponseHandler _parentResponseHandler;
101: private ResponseHandler _responseHandler;
102:
103: public void start(Window window, String namespace) {
104: _window = window;
105: _namespace = namespace;
106: }
107:
108: public void finish() {
109: _invocation = null;
110: _actionMap = null;
111: _isExcluded = false;
112: _constraintIndex = 0;
113: _constraintFailure = null;
114: _constraintFailureCode = 0;
115: _exception = null;
116: _isPrivate = false;
117: _expirationCache = 0;
118: _preferences = null;
119:
120: _responseLocale = null;
121: _responseLocales = null;
122: _responseCharacterEncoding = null;
123: _responseCharacterEncodings = null;
124: _responseContentType = null;
125: _responseContentTypes = null;
126:
127: _responseHandler = null;
128: _parentResponseHandler = null;
129:
130: _window = null;
131: _namespace = null;
132: }
133:
134: public Window getWindow() {
135: return _window;
136: }
137:
138: public String getNamespace() {
139: return _namespace;
140: }
141:
142: public void setDidAction() {
143: _didAction = true;
144: }
145:
146: public boolean getDidAction() {
147: return _didAction;
148: }
149:
150: public void setInvocation(Invocation invocation) {
151: _invocation = invocation;
152: }
153:
154: public Invocation getInvocation() {
155: return _invocation;
156: }
157:
158: public void setActionMap(Map<String, String[]> actionMap) {
159: _actionMap = actionMap;
160: }
161:
162: public Map<String, String[]> getActionMap() {
163: return _actionMap;
164: }
165:
166: public void setExcluded() {
167: _isExcluded = true;
168: }
169:
170: public boolean isExcluded() {
171: return _isExcluded;
172: }
173:
174: public void setConstraintIndex(int constraintIndex) {
175: _constraintIndex = constraintIndex;
176: }
177:
178: public int getConstraintIndex() {
179: return _constraintIndex;
180: }
181:
182: public void setConstraintFailure(Constraint constraint,
183: int failureCode) {
184: _constraintFailure = constraint;
185: _constraintFailureCode = failureCode;
186: }
187:
188: public boolean isConstraintFailure() {
189: return _constraintFailure != null;
190: }
191:
192: public Constraint getConstraintFailureConstraint() {
193: return _constraintFailure;
194: }
195:
196: public int getConstraintFailureCode() {
197: return _constraintFailureCode;
198: }
199:
200: public void setException(Exception ex) {
201: _exception = ex;
202: }
203:
204: public boolean isException() {
205: return _exception != null;
206: }
207:
208: public Exception getException() {
209: return _exception;
210: }
211:
212: public void setPrivate() {
213: _isPrivate = true;
214: }
215:
216: public boolean isPrivate() {
217: return _isPrivate;
218: }
219:
220: public void setExpirationCache(int expirationCache) {
221: _expirationCache = expirationCache;
222: }
223:
224: public int getExpirationCache() {
225: return _expirationCache;
226: }
227:
228: public void setPreferences(LinkingPortletPreferences preferences) {
229: _preferences = preferences;
230: }
231:
232: public LinkingPortletPreferences getPreferences() {
233: return _preferences;
234: }
235:
236: public void setUserAttributeMap(Map<String, String> userAttributeMap) {
237: _userAttributeMap = userAttributeMap;
238: }
239:
240: public Map<String, String> getUserAttributeMap() {
241: return _userAttributeMap;
242: }
243:
244: public void setResponseLocale(Locale responseLocale) {
245: _responseLocale = responseLocale;
246: }
247:
248: public Locale getResponseLocale() {
249: return _responseLocale;
250: }
251:
252: public void setResponseLocales(Set<Locale> responseLocales) {
253: _responseLocales = responseLocales;
254: }
255:
256: public Set<Locale> getResponseLocales() {
257: return _responseLocales;
258: }
259:
260: public void setResponseCharacterEncoding(
261: String responseCharacterEncoding) {
262: _responseCharacterEncoding = responseCharacterEncoding;
263: }
264:
265: public String getResponseCharacterEncoding() {
266: return _responseCharacterEncoding;
267: }
268:
269: public void setResponseCharacterEncodings(Set<String> encodings) {
270: _responseCharacterEncodings = encodings;
271: }
272:
273: public Set<String> getResponseCharacterEncodings() {
274: return _responseCharacterEncodings;
275: }
276:
277: public void setResponseContentType(String responseContentType) {
278: _responseContentType = responseContentType;
279: }
280:
281: public String getResponseContentType() {
282: return _responseContentType;
283: }
284:
285: public void setResponseContentTypes(Set<String> responseContentTypes) {
286: _responseContentTypes = responseContentTypes;
287: }
288:
289: public Set<String> getResponseContentTypes() {
290: return _responseContentTypes;
291: }
292:
293: public void setParentResponseHandler(
294: ResponseHandler parentResponseHandler) {
295: _parentResponseHandler = parentResponseHandler;
296: }
297:
298: public ResponseHandler getParentResponseHandler() {
299: return _parentResponseHandler;
300: }
301:
302: public void setResponseHandler(ResponseHandler responseHandler) {
303: _responseHandler = responseHandler;
304: }
305:
306: public ResponseHandler getResponseHandler() {
307: return _responseHandler;
308: }
309:
310: public void setWindowRequestAttributes(
311: Map<String, String> windowRequestAttributes) {
312: _windowRequestAttributes = windowRequestAttributes;
313:
314: }
315:
316: public Map<String, String> getWindowRequestAttributes() {
317: return _windowRequestAttributes;
318: }
319: }
|