001: /*
002: * Copyright 2005 Joe Walker
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.directwebremoting;
017:
018: import java.util.Collection;
019:
020: import javax.servlet.ServletConfig;
021: import javax.servlet.ServletContext;
022:
023: /**
024: * @author Joe Walker [joe at getahead dot ltd dot uk]
025: */
026: public interface ServerContext {
027: /**
028: * Get a list of all ScriptSessions on a given page.
029: * Note that the list of known sessions is continually changing so it is
030: * possible that the list will be out of date by the time it is used. For
031: * this reason you should check that getScriptSession(String id) returns
032: * something non null.
033: * @param url The URL including 'http://', up to (but not including) '?' or '#'
034: * @return A collection of all the ScriptSessions.
035: */
036: Collection<ScriptSession> getScriptSessionsByPage(String url);
037:
038: /**
039: * You can request access to a specific {@link ScriptSession} if you know
040: * it's ID.
041: * <p>Take care with this method because it allows actions from one browser
042: * to affect another which could be a bad thing. It is certainly a VERY BAD
043: * idea to let session id's from one browser escape into another.
044: * <p>Consider that it is entirely possible that the ScriptSession may
045: * timeout while you are holding a reference to it.
046: * @param sessionId The script session ID to lookup
047: * @return The ScriptSession for the given ID, or null if it does not exist
048: */
049: ScriptSession getScriptSessionById(String sessionId);
050:
051: /**
052: * Get a list of all the ScriptSessions known to this server at the given
053: * time.
054: * Note that the list of known sessions is continually changing so it is
055: * possible that the list will be out of date by the time it is used. For
056: * this reason you should check that getScriptSession(String id) returns
057: * something non null.
058: * @return A collection of all the ScriptSessions.
059: */
060: Collection<ScriptSession> getAllScriptSessions();
061:
062: /**
063: * Accessor for the servlet config.
064: * @return Returns the config.
065: */
066: ServletConfig getServletConfig();
067:
068: /**
069: * Returns the ServletContext to which this session belongs.
070: * @return The servlet context information.
071: */
072: ServletContext getServletContext();
073:
074: /**
075: * Returns the portion of the request URI that indicates the context
076: * of the request.
077: * <p>Annoyingly you can't get to this from the {@link ServletContext} so
078: * you need to cache the value from a recent HttpServletRequest.
079: * <p>The context path always comes first in a request URI. The path starts
080: * with a "/" character but does not end with a "/" character.
081: * For servlets in the default (root) context, this method returns "".
082: * The container does not decode this string.
083: * <p>WARNING: This method may return null if DWR has not received any
084: * requests. If this method is called from outside of DWR, as the servlet
085: * environment is starting up you should check for a null reply and try
086: * again later.
087: * @return The portion of the request URI that indicates the context or null
088: * if DWR has not received and requests so far
089: */
090: String getContextPath();
091:
092: /**
093: * Accessor for the IoC container.
094: * @return The IoC container that created the interface implementations.
095: */
096: Container getContainer();
097:
098: /**
099: * Fish the version number out of the dwr.properties file.
100: * @return The current version number.
101: */
102: String getVersion();
103: }
|