KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > portal > generic > context > WindowContext


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * 3. The end-user documentation included with the redistribution, if
19  * any, must include the following acknowlegement:
20  * "This product includes software developed by the
21  * Caucho Technology (http://www.caucho.com/)."
22  * Alternately, this acknowlegement may appear in the software itself,
23  * if and wherever such third-party acknowlegements normally appear.
24  *
25  * 4. The names "Hessian", "Resin", and "Caucho" must not be used to
26  * endorse or promote products derived from this software without prior
27  * written permission. For written permission, please contact
28  * info@caucho.com.
29  *
30  * 5. Products derived from this software may not be called "Resin"
31  * nor may "Resin" appear in their names without prior written
32  * permission of Caucho Technology.
33  *
34  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
35  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
36  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37  * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS
38  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
39  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
40  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
41  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
42  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
43  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
44  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45  *
46  * @author Sam
47  */

48
49
50 package com.caucho.portal.generic.context;
51
52 import com.caucho.portal.generic.Constraint;
53 import com.caucho.portal.generic.Invocation;
54 import com.caucho.portal.generic.Window;
55
56 import java.util.Locale JavaDoc;
57 import java.util.Map JavaDoc;
58 import java.util.Set JavaDoc;
59
60
61 /**
62  * Some of the state of the Context depends on the current portlet
63  * being rendered. The WindowContect class stores that state.
64  * The ConnectionContext pushes WindowContext objects onto a stack as portlets
65  * are recursively processed, and pops them off of the stack when processing
66  * of them is done.
67  *
68  * This class just has getters and setters, it does not perform operations on
69  * other classes and is just used by the ConnectionContext to store values.
70  */

71 public class WindowContext {
72   private Window _window;
73   private String JavaDoc _namespace;
74   private int _stage;
75
76   private Invocation _invocation;
77   private Map JavaDoc<String JavaDoc, String JavaDoc[]> _actionMap;
78
79   public boolean _didAction;
80
81   private boolean _isExcluded;
82   private int _constraintIndex;
83   private Constraint _constraintFailure;
84   private int _constraintFailureCode;
85   private Exception JavaDoc _exception;
86
87   private Map JavaDoc<String JavaDoc, String JavaDoc> _windowRequestAttributes;
88
89   private boolean _isPrivate;
90   private int _expirationCache;
91
92   private LinkingPortletPreferences _preferences;
93   private Map JavaDoc<String JavaDoc, String JavaDoc> _userAttributeMap;
94
95   private Locale JavaDoc _responseLocale;
96   private Set JavaDoc<Locale JavaDoc> _responseLocales;
97   private String JavaDoc _responseCharacterEncoding;
98   private Set JavaDoc<String JavaDoc> _responseCharacterEncodings;
99   private String JavaDoc _responseContentType;
100   private Set JavaDoc<String JavaDoc> _responseContentTypes;
101
102   private ResponseHandler _parentResponseHandler;
103   private ResponseHandler _responseHandler;
104
105   public void start( Window window,
106                      String JavaDoc namespace )
107   {
108     _window = window;
109     _namespace = namespace;
110   }
111
112   public void finish()
113   {
114     _invocation = null;
115     _actionMap = null;
116     _isExcluded = false;
117     _constraintIndex = 0;
118     _constraintFailure = null;
119     _constraintFailureCode = 0;
120     _exception = null;
121     _isPrivate = false;
122     _expirationCache = 0;
123     _preferences = null;
124
125     _responseLocale = null;
126     _responseLocales = null;
127     _responseCharacterEncoding = null;
128     _responseCharacterEncodings = null;
129     _responseContentType = null;
130     _responseContentTypes = null;
131
132     _responseHandler = null;
133     _parentResponseHandler = null;
134
135     _window = null;
136     _namespace = null;
137   }
138
139   public Window getWindow()
140   {
141     return _window;
142   }
143
144   public String JavaDoc getNamespace()
145   {
146     return _namespace;
147   }
148
149   public void setDidAction()
150   {
151     _didAction = true;
152   }
153
154   public boolean getDidAction()
155   {
156     return _didAction;
157   }
158
159   public void setInvocation(Invocation invocation)
160   {
161     _invocation = invocation;
162   }
163
164   public Invocation getInvocation()
165   {
166     return _invocation;
167   }
168
169   public void setActionMap(Map JavaDoc<String JavaDoc, String JavaDoc[]> actionMap)
170   {
171     _actionMap = actionMap;
172   }
173
174   public Map JavaDoc<String JavaDoc, String JavaDoc[]> getActionMap()
175   {
176     return _actionMap;
177   }
178
179   public void setExcluded()
180   {
181     _isExcluded = true;
182   }
183
184   public boolean isExcluded()
185   {
186     return _isExcluded;
187   }
188
189   public void setConstraintIndex(int constraintIndex)
190   {
191     _constraintIndex = constraintIndex;
192   }
193
194   public int getConstraintIndex()
195   {
196     return _constraintIndex;
197   }
198
199   public void setConstraintFailure(Constraint constraint, int failureCode)
200   {
201     _constraintFailure = constraint;
202     _constraintFailureCode = failureCode;
203   }
204
205   public boolean isConstraintFailure()
206   {
207     return _constraintFailure != null;
208   }
209
210   public Constraint getConstraintFailureConstraint()
211   {
212     return _constraintFailure;
213   }
214
215   public int getConstraintFailureCode()
216   {
217     return _constraintFailureCode;
218   }
219
220   public void setException(Exception JavaDoc ex)
221   {
222     _exception = ex;
223   }
224
225   public boolean isException()
226   {
227     return _exception != null;
228   }
229
230   public Exception JavaDoc getException()
231   {
232     return _exception;
233   }
234
235   public void setPrivate()
236   {
237     _isPrivate = true;
238   }
239
240   public boolean isPrivate()
241   {
242     return _isPrivate;
243   }
244
245   public void setExpirationCache(int expirationCache)
246   {
247     _expirationCache = expirationCache;
248   }
249
250   public int getExpirationCache()
251   {
252     return _expirationCache;
253   }
254
255   public void setPreferences(LinkingPortletPreferences preferences)
256   {
257     _preferences = preferences;
258   }
259
260   public LinkingPortletPreferences getPreferences()
261   {
262     return _preferences;
263   }
264
265   public void setUserAttributeMap(Map JavaDoc<String JavaDoc, String JavaDoc> userAttributeMap)
266   {
267     _userAttributeMap = userAttributeMap;
268   }
269
270   public Map JavaDoc<String JavaDoc, String JavaDoc> getUserAttributeMap()
271   {
272     return _userAttributeMap;
273   }
274
275   public void setResponseLocale(Locale JavaDoc responseLocale)
276   {
277     _responseLocale = responseLocale;
278   }
279   
280   public Locale JavaDoc getResponseLocale()
281   {
282     return _responseLocale;
283   }
284   
285   public void setResponseLocales(Set JavaDoc<Locale JavaDoc> responseLocales)
286   {
287     _responseLocales = responseLocales;
288   }
289   
290   public Set JavaDoc<Locale JavaDoc> getResponseLocales()
291   {
292     return _responseLocales;
293   }
294
295   public void setResponseCharacterEncoding(String JavaDoc responseCharacterEncoding)
296   {
297     _responseCharacterEncoding = responseCharacterEncoding;
298   }
299   
300   public String JavaDoc getResponseCharacterEncoding()
301   {
302     return _responseCharacterEncoding;
303   }
304   
305   public void setResponseCharacterEncodings(Set JavaDoc<String JavaDoc> encodings)
306   {
307     _responseCharacterEncodings = encodings;
308   }
309   
310   public Set JavaDoc<String JavaDoc> getResponseCharacterEncodings()
311   {
312     return _responseCharacterEncodings;
313   }
314
315   public void setResponseContentType(String JavaDoc responseContentType)
316   {
317     _responseContentType = responseContentType;
318   }
319   
320   public String JavaDoc getResponseContentType()
321   {
322     return _responseContentType;
323   }
324   
325   public void setResponseContentTypes(Set JavaDoc<String JavaDoc> responseContentTypes)
326   {
327     _responseContentTypes = responseContentTypes;
328   }
329   
330   public Set JavaDoc<String JavaDoc> getResponseContentTypes()
331   {
332     return _responseContentTypes;
333   }
334
335   public void setParentResponseHandler(ResponseHandler parentResponseHandler)
336   {
337     _parentResponseHandler = parentResponseHandler;
338   }
339
340   public ResponseHandler getParentResponseHandler()
341   {
342     return _parentResponseHandler;
343   }
344
345   public void setResponseHandler(ResponseHandler responseHandler)
346   {
347     _responseHandler = responseHandler;
348   }
349
350   public ResponseHandler getResponseHandler()
351   {
352     return _responseHandler;
353   }
354
355   public void setWindowRequestAttributes(Map JavaDoc<String JavaDoc, String JavaDoc> windowRequestAttributes)
356   {
357     _windowRequestAttributes = windowRequestAttributes;
358
359   }
360
361   public Map JavaDoc<String JavaDoc, String JavaDoc> getWindowRequestAttributes()
362   {
363     return _windowRequestAttributes;
364   }
365 }
366
Popular Tags