1
2
3 /*
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5 *
6 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
7 *
8 * Portions Copyright Apache Software Foundation.
9 *
10 * The contents of this file are subject to the terms of either the GNU
11 * General Public License Version 2 only ("GPL") or the Common Development
12 * and Distribution License("CDDL") (collectively, the "License"). You
13 * may not use this file except in compliance with the License. You can obtain
14 * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
15 * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
16 * language governing permissions and limitations under the License.
17 *
18 * When distributing the software, include this License Header Notice in each
19 * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
20 * Sun designates this particular file as subject to the "Classpath" exception
21 * as provided by Sun in the GPL Version 2 section of the License file that
22 * accompanied this code. If applicable, add the following below the License
23 * Header, with the fields enclosed by brackets [] replaced by your own
24 * identifying information: "Portions Copyrighted [year]
25 * [name of copyright owner]"
26 *
27 * Contributor(s):
28 *
29 * If you wish your version of this file to be governed by only the CDDL or
30 * only the GPL Version 2, indicate your decision by adding "[Contributor]
31 * elects to include this software in this distribution under the [CDDL or GPL
32 * Version 2] license." If you don't indicate a single choice of license, a
33 * recipient has the option to distribute your version of this file under
34 * either the CDDL, the GPL Version 2 or to extend the choice of license to
35 * its licensees as provided above. However, if you add GPL Version 2 code
36 * and therefore, elected the GPL Version 2 license, then the option applies
37 * only if the new code is made subject to such option by the copyright
38 * holder.
39 */
40
41
42 package org.apache.catalina;
43
44
45 import java.beans.PropertyChangeListener;
46 import java.io.IOException;
47
48 //START OF RIMOD# 4820359
49 import javax.servlet.http.HttpSession;
50 //END OF RIMOD# 4820359
51 //START OF 6364900
52 import javax.servlet.ServletException;
53 import javax.servlet.ServletRequest;
54 import javax.servlet.ServletResponse;
55 //END OF 6364900
56
57 /**
58 * A <b>Manager</b> manages the pool of Sessions that are associated with a
59 * particular Container. Different Manager implementations may support
60 * value-added features such as the persistent storage of session data,
61 * as well as migrating sessions for distributable web applications.
62 * <p>
63 * In order for a <code>Manager</code> implementation to successfully operate
64 * with a <code>Context</code> implementation that implements reloading, it
65 * must obey the following constraints:
66 * <ul>
67 * <li>Must implement <code>Lifecycle</code> so that the Context can indicate
68 * that a restart is required.
69 * <li>Must allow a call to <code>stop()</code> to be followed by a call to
70 * <code>start()</code> on the same <code>Manager</code> instance.
71 * </ul>
72 *
73 * @author Craig R. McClanahan
74 * @version $Revision: 1.7 $ $Date: 2007/05/05 05:31:51 $
75 */
76
77 public interface Manager {
78
79
80 // ------------------------------------------------------------- Properties
81
82
83 /**
84 * Return the Container with which this Manager is associated.
85 */
86 public Container getContainer();
87
88
89 /**
90 * Set the Container with which this Manager is associated.
91 *
92 * @param container The newly associated Container
93 */
94 public void setContainer(Container container);
95
96
97 /**
98 * Return the DefaultContext with which this Manager is associated.
99 */
100 public DefaultContext getDefaultContext();
101
102
103 /**
104 * Set the DefaultContext with which this Manager is associated.
105 *
106 * @param defaultContext The newly associated DefaultContext
107 */
108 public void setDefaultContext(DefaultContext defaultContext);
109
110
111 /**
112 * Return the distributable flag for the sessions supported by
113 * this Manager.
114 */
115 public boolean getDistributable();
116
117
118 /**
119 * Set the distributable flag for the sessions supported by this
120 * Manager. If this flag is set, all user data objects added to
121 * sessions associated with this manager must implement Serializable.
122 *
123 * @param distributable The new distributable flag
124 */
125 public void setDistributable(boolean distributable);
126
127
128 /**
129 * Return descriptive information about this Manager implementation and
130 * the corresponding version number, in the format
131 * <code><description>/<version></code>.
132 */
133 public String getInfo();
134
135
136 /**
137 * Same as getMaxInactiveIntervalSeconds
138 */
139 public int getMaxInactiveInterval();
140
141
142 /**
143 * Return the default maximum inactive interval (in seconds)
144 * for Sessions created by this Manager.
145 */
146 public int getMaxInactiveIntervalSeconds();
147
148
149 /**
150 * Same as setMaxInactiveIntervalSeconds
151 */
152 public void setMaxInactiveInterval(int interval);
153
154
155 /**
156 * Set the default maximum inactive interval (in seconds)
157 * for Sessions created by this Manager.
158 *
159 * @param interval The new default value
160 */
161 public void setMaxInactiveIntervalSeconds(int interval);
162
163
164 /**
165 * Gets the session id length (in bytes) of Sessions created by
166 * this Manager.
167 *
168 * @return The session id length
169 */
170 public int getSessionIdLength();
171
172
173 /**
174 * Sets the session id length (in bytes) for Sessions created by this
175 * Manager.
176 *
177 * @param sessionIdLength The session id length
178 */
179 public void setSessionIdLength(int idLength);
180
181
182 /**
183 * Same as getSessionCount
184 */
185 public int getSessionCounter();
186
187
188 /**
189 * Returns the total number of sessions created by this manager.
190 *
191 * @return Total number of sessions created by this manager.
192 */
193 public int getSessionCount();
194
195
196 /**
197 * Same as setSessionCount
198 */
199 public void setSessionCounter(int sessionCounter);
200
201
202 /**
203 * Sets the total number of sessions created by this manager.
204 *
205 * @param sessionCounter Total number of sessions created by this manager.
206 */
207 public void setSessionCount(int sessionCounter);
208
209
210 /**
211 * Gets the maximum number of sessions that have been active at the same
212 * time.
213 *
214 * @return Maximum number of sessions that have been active at the same
215 * time
216 */
217 public int getMaxActive();
218
219
220 /**
221 * (Re)sets the maximum number of sessions that have been active at the
222 * same time.
223 *
224 * @param maxActive Maximum number of sessions that have been active at
225 * the same time.
226 */
227 public void setMaxActive(int maxActive);
228
229
230 /**
231 * Gets the number of currently active sessions.
232 *
233 * @return Number of currently active sessions
234 */
235 public int getActiveSessions();
236
237
238 /**
239 * Gets the number of sessions that have expired.
240 *
241 * @return Number of sessions that have expired
242 */
243 public int getExpiredSessions();
244
245
246 /**
247 * Sets the number of sessions that have expired.
248 *
249 * @param expiredSessions Number of sessions that have expired
250 */
251 public void setExpiredSessions(int expiredSessions);
252
253
254 /**
255 * Gets the number of sessions that were not created because the maximum
256 * number of active sessions was reached.
257 *
258 * @return Number of rejected sessions
259 */
260 public int getRejectedSessions();
261
262
263 /**
264 * Sets the number of sessions that were not created because the maximum
265 * number of active sessions was reached.
266 *
267 * @param rejectedSessions Number of rejected sessions
268 */
269 public void setRejectedSessions(int rejectedSessions);
270
271
272 /**
273 * Same as getSessionMaxAliveTimeSeconds
274 */
275 public int getSessionMaxAliveTime();
276
277
278 /**
279 * Gets the longest time (in seconds) that an expired session had been
280 * alive.
281 *
282 * @return Longest time (in seconds) that an expired session had been
283 * alive.
284 */
285 public int getSessionMaxAliveTimeSeconds();
286
287
288 /**
289 * Same as setSessionMaxAliveTimeSeconds
290 */
291 public void setSessionMaxAliveTime(int sessionMaxAliveTime);
292
293
294 /**
295 * Sets the longest time (in seconds) that an expired session had been
296 * alive.
297 *
298 * @param sessionMaxAliveTime Longest time (in seconds) that an expired
299 * session had been alive.
300 */
301 public void setSessionMaxAliveTimeSeconds(int sessionMaxAliveTime);
302
303
304 /**
305 * Same as getSessionAverageAliveTimeSeconds
306 */
307 public int getSessionAverageAliveTime();
308
309
310 /**
311 * Gets the average time (in seconds) that expired sessions had been
312 * alive.
313 *
314 * @return Average time (in seconds) that expired sessions had been
315 * alive.
316 */
317 public int getSessionAverageAliveTimeSeconds();
318
319
320 /**
321 * Same as setSessionAverageAliveTimeSeconds
322 */
323 public void setSessionAverageAliveTime(int sessionAverageAliveTime);
324
325
326 /**
327 * Sets the average time (in seconds) that expired sessions had been
328 * alive.
329 *
330 * @param sessionAverageAliveTime Average time (in seconds) that expired
331 * sessions had been alive.
332 */
333 public void setSessionAverageAliveTimeSeconds(int sessionAverageAliveTime);
334
335
336 // --------------------------------------------------------- Public Methods
337
338
339 /**
340 * Add this Session to the set of active Sessions for this Manager.
341 *
342 * @param session Session to be added
343 */
344 public void add(Session session);
345
346
347 /**
348 * Add a property change listener to this component.
349 *
350 * @param listener The listener to add
351 */
352 public void addPropertyChangeListener(PropertyChangeListener listener);
353
354 /**
355 * Get a session from the recycled ones or create a new empty one.
356 * The PersistentManager manager does not need to create session data
357 * because it reads it from the Store.
358 */
359 public Session createEmptySession();
360
361 /**
362 * Construct and return a new session object, based on the default
363 * settings specified by this Manager's properties. The session
364 * id will be assigned by this method, and available via the getId()
365 * method of the returned session. If a new session cannot be created
366 * for any reason, return <code>null</code>.
367 *
368 * @exception IllegalStateException if a new session cannot be
369 * instantiated for any reason
370 */
371 public Session createSession();
372
373
374 // START S1AS8PE 4817642
375 /**
376 * Construct and return a new session object, based on the default
377 * settings specified by this Manager's properties, using the specified
378 * session id.
379 *
380 * @param sessionId the session id to assign to the new session
381 *
382 * @exception IllegalStateException if a new session cannot be
383 * instantiated for any reason
384 *
385 * @return the new session, or <code>null</code> if a session with the
386 * requested id already exists
387 */
388 public Session createSession(String sessionId);
389 // END S1AS8PE 4817642
390
391
392 /**
393 * Return the active Session, associated with this Manager, with the
394 * specified session id (if any); otherwise return <code>null</code>.
395 *
396 * @param id The session id for the session to be returned
397 *
398 * @exception IllegalStateException if a new session cannot be
399 * instantiated for any reason
400 * @exception IOException if an input/output error occurs while
401 * processing this request
402 */
403 public Session findSession(String id) throws IOException;
404
405
406 /**
407 * Finds and returns the session with the given id that also satisfies
408 * the given version requirement.
409 *
410 * This overloaded version of findSession() will be invoked only if
411 * isSessionVersioningSupported() returns true. By default, this method
412 * delegates to the version of findSession() that does not take any
413 * session version number.
414 *
415 * @param id The session id to match
416 * @param version The session version requirement to satisfy
417 *
418 * @return The session that matches the given id and also satisfies the
419 * given version requirement, or null if no such session could be found
420 * by this session manager
421 *
422 * @exception IOException if an IO error occurred
423 */
424 public Session findSession(String id, String version) throws IOException;
425
426
427 /**
428 * Returns true if this session manager supports session versioning, false
429 * otherwise.
430 *
431 * @return true if this session manager supports session versioning, false
432 * otherwise.
433 */
434 public boolean isSessionVersioningSupported();
435
436
437 /**
438 * Return the set of active Sessions associated with this Manager.
439 * If this Manager has no active Sessions, a zero-length array is returned.
440 */
441 public Session[] findSessions();
442
443
444 /**
445 * Load any currently active sessions that were previously unloaded
446 * to the appropriate persistence mechanism, if any. If persistence is not
447 * supported, this method returns without doing anything.
448 *
449 * @exception ClassNotFoundException if a serialized class cannot be
450 * found during the reload
451 * @exception IOException if an input/output error occurs
452 */
453 public void load() throws ClassNotFoundException, IOException;
454
455
456 /**
457 * Remove this Session from the active Sessions for this Manager.
458 *
459 * @param session Session to be removed
460 */
461 public void remove(Session session);
462
463
464 /**
465 * Remove a property change listener from this component.
466 *
467 * @param listener The listener to remove
468 */
469 public void removePropertyChangeListener(PropertyChangeListener listener);
470
471
472 /**
473 * Save any currently active sessions in the appropriate persistence
474 * mechanism, if any. If persistence is not supported, this method
475 * returns without doing anything.
476 *
477 * @exception IOException if an input/output error occurs
478 */
479 public void unload() throws IOException;
480
481
482 //PWC Extension
483 //START OF RIMOD# 4820359 -- Support for iWS6.0 session managers
484 /**
485 * Perform any operations when the request is finished.
486 */
487 public void update(HttpSession session) throws Exception;
488 //END OF RIMOD# 4820359
489
490 //START OF RIMOD# 5056989 -- Support for iWS6.0 style session ids
491 /**
492 * Allow the caller to add a prefix to the session id.
493 */
494 public void setSessionIDPrefix(String prefix);
495 //END OF RIMOD# 5056989
496
497 //START OF 6364900
498 public boolean lockSession(ServletRequest request) throws ServletException;
499 public void unlockSession(ServletRequest request);
500 public void preRequestDispatcherProcess(ServletRequest request, ServletResponse response);
501 public void postRequestDispatcherProcess(ServletRequest request, ServletResponse response);
502 //END OF 6364900
503 }