01: /*
02: * Copyright 2005 Joe Walker
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.directwebremoting.extend;
17:
18: import java.util.Collection;
19:
20: import org.directwebremoting.ScriptSession;
21: import org.directwebremoting.event.ScriptSessionListener;
22:
23: /**
24: * A ScriptSessionManager looks after a number of sessions (keyed using a
25: * Javascript variable)
26: * @author Joe Walker [joe at getahead dot ltd dot uk]
27: */
28: public interface ScriptSessionManager {
29: /**
30: * Get a list of all the currently known ScriptSessions by id.
31: * Note that the list of known sessions is continually changing so it is
32: * possible that the list will be out of date by the time it is used. For
33: * this reason you should check that getScriptSession(String id) returns
34: * something non null.
35: * @return An iterator over the currently known sessions, by id
36: */
37: Collection<ScriptSession> getAllScriptSessions();
38:
39: /**
40: * For a given script session id, either create a new ScriptSession object
41: * or retrieve an existing one if one exists.
42: * @param url The URL including 'http://', up to (but not including) '?' or '#'
43: * @return A ScriptSession.
44: */
45: Collection<ScriptSession> getScriptSessionsByPage(String url);
46:
47: /**
48: * For a given script session id, return the related ScriptSession object
49: * or null if the id is not known.
50: * @param id The id to get a ScriptSession object for
51: * @param url The URL including 'http://', up to (but not including) '?' or '#' (or null if not known)
52: * @param httpSessionId The session ID (or null if not known)
53: * @return A ScriptSession to match the ID, or null if a match is not found.
54: */
55: RealScriptSession getScriptSession(String id, String url,
56: String httpSessionId);
57:
58: /**
59: * When a new client page-loads, we create a script session.
60: * @param url The URL including 'http://', up to (but not including) '?' or '#'
61: * @param httpSessionId The session ID (or null if not known)
62: * @return The new script session id
63: */
64: RealScriptSession createScriptSession(String url,
65: String httpSessionId);
66:
67: /**
68: * Accessor for the time (in milliseconds) when unused ScriptSessions will expire
69: * @return the scriptSessionTimeout
70: */
71: long getScriptSessionTimeout();
72:
73: /**
74: * Maintain the list of {@link ScriptSessionListener}s
75: * @param li the ScriptSessionListener to add
76: */
77: public void addScriptSessionListener(ScriptSessionListener li);
78:
79: /**
80: * Maintain the list of {@link ScriptSessionListener}s
81: * @param li the ScriptSessionListener to remove
82: */
83: public void removeScriptSessionListener(ScriptSessionListener li);
84:
85: /**
86: * The default length of time a session can go unused before it
87: * automatically becomes invalid and is recycled.
88: * The default is 5mins
89: */
90: static final long DEFAULT_TIMEOUT_MILLIS = 5 * 60 * 1000;
91: }
|