1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.workflow.web;
18
19
20 import java.util.EmptyStackException;
21 import javax.servlet.ServletContext;
22 import javax.servlet.ServletRequest;
23 import javax.servlet.ServletResponse;
24 import javax.servlet.http.HttpSession;
25 import org.apache.commons.collections.ArrayStack;
26 import org.apache.commons.workflow.Context;
27 import org.apache.commons.workflow.Scope;
28 import org.apache.commons.workflow.base.BaseContext;
29
30
31
32
33
34
35
36
37
38
39
40
41
42 public class WebContext extends BaseContext {
43
44
45
46
47
48
49
50
51
52 public static final int REQUEST_SCOPE = 2;
53
54
55
56
57
58
59 public static final String REQUEST_SCOPE_NAME = "request";
60
61
62
63
64
65
66 public static final int SESSION_SCOPE = 4;
67
68
69
70
71
72
73 public static final String SESSION_SCOPE_NAME = "session";
74
75
76
77
78
79
80 public static final int APPLICATION_SCOPE = 6;
81
82
83
84
85
86
87 public static final String APPLICATION_SCOPE_NAME = "application";
88
89
90
91
92
93
94
95
96 protected HttpSession httpSession = null;
97
98 public HttpSession getHttpSession() {
99
100 return (this.httpSession);
101
102 }
103
104 public void setHttpSession(HttpSession httpSession) {
105
106 this.httpSession = httpSession;
107 Scope oldScope = getScope(SESSION_SCOPE);
108 if ((oldScope != null) && (oldScope instanceof HttpSessionScope))
109 ((HttpSessionScope) oldScope).setHttpSession(httpSession);
110 else
111 addScope(SESSION_SCOPE, SESSION_SCOPE_NAME,
112 new HttpSessionScope(httpSession));
113
114 }
115
116
117
118
119
120 protected ServletContext servletContext = null;
121
122 public ServletContext getServletContext() {
123
124 return (this.servletContext);
125
126 }
127
128 public void setServletContext(ServletContext servletContext) {
129
130 this.servletContext = servletContext;
131 Scope oldScope = getScope(APPLICATION_SCOPE);
132 if ((oldScope != null) && (oldScope instanceof ServletContextScope))
133 ((ServletContextScope) oldScope).setServletContext(servletContext);
134 else
135 addScope(APPLICATION_SCOPE, APPLICATION_SCOPE_NAME,
136 new ServletContextScope(servletContext));
137
138 }
139
140
141
142
143
144 protected ServletRequest servletRequest = null;
145
146 public ServletRequest getServletRequest() {
147
148 return (this.servletRequest);
149
150 }
151
152 public void setServletRequest(ServletRequest servletRequest) {
153
154 this.servletRequest = servletRequest;
155 Scope oldScope = getScope(REQUEST_SCOPE);
156 if ((oldScope != null) && (oldScope instanceof ServletRequestScope))
157 ((ServletRequestScope) oldScope).setServletRequest(servletRequest);
158 else
159 addScope(REQUEST_SCOPE, REQUEST_SCOPE_NAME,
160 new ServletRequestScope(servletRequest));
161
162
163
164
165 }
166
167
168
169
170
171
172 protected ServletResponse servletResponse = null;
173
174 public ServletResponse getServletResponse() {
175
176 return (this.servletResponse);
177
178 }
179
180 public void setServletResponse(ServletResponse servletResponse) {
181
182 this.servletResponse = servletResponse;
183
184 }
185
186
187 }