001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.wicket.session;
018:
019: import java.util.List;
020:
021: import javax.servlet.http.HttpSession;
022:
023: import org.apache.wicket.IPageMap;
024: import org.apache.wicket.Page;
025: import org.apache.wicket.Request;
026: import org.apache.wicket.Session;
027: import org.apache.wicket.version.IPageVersionManager;
028:
029: /**
030: * The actual store that is used by {@link org.apache.wicket.Session} to store
031: * its attributes.
032: *
033: * @author Eelco Hillenius
034: * @author Johan Compagner
035: */
036: public interface ISessionStore {
037: /**
038: * Gets the attribute value with the given name
039: *
040: * @param request
041: * the current request
042: * @param name
043: * The name of the attribute to store
044: * @return The value of the attribute
045: */
046: Object getAttribute(Request request, final String name);
047:
048: /**
049: * @param request
050: * the current request
051: *
052: * @return List of attributes for this session
053: */
054: List getAttributeNames(Request request);
055:
056: /**
057: * Invalidates the session.
058: *
059: * @param request
060: * the current request
061: */
062: void invalidate(Request request);
063:
064: /**
065: * Removes the attribute with the given name.
066: *
067: * @param request
068: * the current request
069: * @param name
070: * the name of the attribute to remove
071: */
072: void removeAttribute(Request request, String name);
073:
074: /**
075: * Adds or replaces the attribute with the given name and value.
076: *
077: * @param request
078: * the current request
079: * @param name
080: * the name of the attribute
081: * @param value
082: * the value of the attribute
083: */
084: void setAttribute(Request request, String name, Object value);
085:
086: /**
087: * Get the session id for the provided request. It create is false and the
088: * creation of the actual session is deferred, this method should return
089: * null to reflect it doesn't have one.
090: *
091: * @param request
092: * The request
093: * @param create
094: * Whether to create an actual session (typically an instance of
095: * {@link HttpSession}) when not already done so
096: * @return The session id for the provided request, possibly null if create
097: * is false and the creation of the actual session was deferred
098: */
099: String getSessionId(Request request, boolean create);
100:
101: /**
102: * Retrieves the session for the provided request from this facade.
103: * <p>
104: * This method should return null if it is not bound yet, so that Wicket can
105: * recognize that it should create a session and call
106: * {@link #bind(Request, Session)} right after that.
107: * </p>
108: *
109: * @param request
110: * The current request
111: * @return The session for the provided request or null if the session was
112: * not bound
113: */
114: Session lookup(Request request);
115:
116: /**
117: * Adds the provided new session to this facade using the provided request.
118: *
119: * @param request
120: * The request that triggered making a new sesion
121: * @param newSession
122: * The new session
123: */
124: void bind(Request request, Session newSession);
125:
126: /**
127: * Removes a session from this facade
128: *
129: * @param sessionId
130: * The id of the session that must be unbinded.
131: */
132: void unbind(String sessionId);
133:
134: /**
135: * Called at the start of a request. It can be used for example to rebuild
136: * server state from the client request.
137: *
138: * @param request
139: * The request object
140: */
141: void onBeginRequest(Request request);
142:
143: /**
144: * Called at the end of a request. It can be used for instance to release
145: * temporary server state when using client state saving.
146: *
147: * @param request
148: * The request
149: */
150: void onEndRequest(Request request);
151:
152: /**
153: * @param name
154: * @return The pagemap instance
155: */
156: IPageMap createPageMap(String name);
157:
158: /**
159: * @param page
160: * The page for which this version manager must be created
161: * @return A instance of a IPageVersionManager that the page will use.
162: */
163: IPageVersionManager newVersionManager(Page page);
164:
165: /**
166: * Called when the WebApplication is destroyed.
167: */
168: void destroy();
169: }
|