You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jc...@apache.org on 2006/11/10 22:50:34 UTC
svn commit: r473519 - in
/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket:
protocol/http/portlet/ session/ session/pagemap/ settings/
Author: jcompagner
Date: Fri Nov 10 13:50:33 2006
New Revision: 473519
URL: http://svn.apache.org/viewvc?view=rev&rev=473519
Log:
accessstack changes
Modified:
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/portlet/PortletRequestTargetResolverStrategy.java
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/portlet/PortletSessionStore.java
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/session/ISessionStore.java
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/session/pagemap/LeastRecentlyAccessedEvictionStrategy.java
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/settings/Settings.java
Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/portlet/PortletRequestTargetResolverStrategy.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/portlet/PortletRequestTargetResolverStrategy.java?view=diff&rev=473519&r1=473518&r2=473519
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/portlet/PortletRequestTargetResolverStrategy.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/portlet/PortletRequestTargetResolverStrategy.java Fri Nov 10 13:50:33 2006
@@ -19,6 +19,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import wicket.AccessStackPageMap;
import wicket.Application;
import wicket.Component;
import wicket.IRedirectListener;
@@ -30,7 +31,7 @@
import wicket.RequestListenerInterface;
import wicket.Session;
import wicket.WicketRuntimeException;
-import wicket.PageMap.Access;
+import wicket.AccessStackPageMap.Access;
import wicket.authorization.UnauthorizedActionException;
import wicket.markup.MarkupException;
import wicket.protocol.http.request.WebErrorCodeResponseTarget;
@@ -76,6 +77,8 @@
if (requestParameters.getComponentPath() != null)
{
+ // marks whether or not we will be processing this request
+ boolean processRequest = true;
synchronized (requestCycle.getSession())
{
// we need to check if this request has been flagged as
@@ -83,8 +86,6 @@
// condition
// is met
- // marks whether or not we will be processing this request
- boolean processRequest = true;
if (requestParameters.isOnlyProcessIfPathActive())
{
@@ -100,11 +101,12 @@
// request
processRequest = false;
}
- else
+ else if(pageMap instanceof AccessStackPageMap)
{
- if (pageMap.getAccessStack().size() > 0)
+ AccessStackPageMap accessStackPm = (AccessStackPageMap)pageMap;
+ if (accessStackPm.getAccessStack().size() > 0)
{
- final Access access = (Access)pageMap.getAccessStack().peek();
+ final Access access = (Access)accessStackPm.getAccessStack().peek();
final int pageId = Integer
.parseInt(Strings.firstPathComponent(requestParameters
@@ -129,15 +131,19 @@
}
}
}
+ else
+ {
+ // TODO also this should work.. also forward port to 2.0!!!
+ }
}
- if (processRequest)
- {
- return resolveRenderedPage(requestCycle, requestParameters);
- }
- else
- {
- return EmptyRequestTarget.getInstance();
- }
+ }
+ if (processRequest)
+ {
+ return resolveRenderedPage(requestCycle, requestParameters);
+ }
+ else
+ {
+ return EmptyRequestTarget.getInstance();
}
}
// see whether this request points to a shared resource
Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/portlet/PortletSessionStore.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/portlet/PortletSessionStore.java?view=diff&rev=473519&r1=473518&r2=473519
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/portlet/PortletSessionStore.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/portlet/PortletSessionStore.java Fri Nov 10 13:50:33 2006
@@ -1,325 +1,356 @@
-/*
- * ==============================================================================
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package wicket.protocol.http.portlet;
-
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectOutputStream;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-
-import javax.portlet.PortletSession;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import wicket.Application;
-import wicket.Request;
-import wicket.Session;
-import wicket.WicketRuntimeException;
-import wicket.protocol.http.RequestLogger;
-import wicket.protocol.http.WebRequest;
-import wicket.session.ISessionStore;
-import wicket.util.lang.Bytes;
-
-
-/**
- * Abstract implementation of {@link ISessionStore} that works with portlets
- *
- * @author Janne Hietamäki
- * @author jcompagner
- * @author Eelco Hillenius
- */
-public class PortletSessionStore implements ISessionStore
-{
- //private final static int SCOPE=PortletSession.PORTLET_SCOPE;
- private final static int SCOPE=PortletSession.APPLICATION_SCOPE;
-
- /** log. */
- protected static Log log = LogFactory.getLog(PortletSessionStore.class);
-
- protected final PortletApplication application;
-
- /**
- * Construct.
- */
- public PortletSessionStore()
- {
- // sanity check
- Application app = Application.get();
- if (!(app instanceof PortletApplication))
- {
- throw new IllegalStateException(getClass().getName()
- + " can only operate in the context of portal applications");
- }
- this.application = (PortletApplication)app;
- }
-
- /**
- * @see wicket.session.ISessionStore#invalidate(Request)
- */
- public final void invalidate(Request request)
- {
- WicketPortletRequest webRequest = toPortletRequest(request);
- PortletSession httpSession = getPortletSession(webRequest);
- if (httpSession != null)
- {
- try
- {
- httpSession.invalidate();
- }
- catch (IllegalStateException e)
- {
- // Ignore
- }
- }
- }
-
- /**
- * @see wicket.session.ISessionStore#getSessionId(wicket.Request)
- */
- public final String getSessionId(Request request)
- {
- WicketPortletRequest webRequest = toPortletRequest(request);
- return getPortletSession(webRequest).getId();
- }
-
- /**
- * @see wicket.session.ISessionStore#bind(wicket.Request, wicket.Session)
- */
- public final void bind(Request request, Session newSession)
- {
- // call template method
- onBind(request, newSession);
-
- WicketPortletRequest webRequest = toPortletRequest(request);
- PortletSession httpSession = getPortletSession(webRequest);
-
- // register the session object itself
- setAttribute(webRequest, Session.SESSION_ATTRIBUTE_NAME, newSession);
- }
-
- /**
- * @see wicket.session.ISessionStore#unbind(java.lang.String)
- */
- public final void unbind(String sessionId)
- {
- application.sessionDestroyed(sessionId);
- onUnbind(sessionId);
- }
-
- /**
- * @see wicket.session.ISessionStore#lookup(wicket.Request)
- */
- public Session lookup(Request request)
- {
- WicketPortletRequest webRequest = toPortletRequest(request);
- return (Session)getAttribute(webRequest, Session.SESSION_ATTRIBUTE_NAME);
- }
-
- /**
- * Cast {@link Request} to {@link WebRequest}.
- *
- * @param request
- * The request to cast
- * @return The web request
- */
- protected final WicketPortletRequest toPortletRequest(Request request)
- {
- if (request == null)
- {
- return null;
- }
- if (!(request instanceof WicketPortletRequest))
- {
- throw new IllegalArgumentException(getClass().getName()
- + " can only work with WicketPortletRequest");
- }
- return (WicketPortletRequest)request;
- }
-
- /**
- * Gets the underlying HttpSession object or null.
- * <p>
- * WARNING: it is a bad idea to depend on the http session object directly.
- * Please use the classes and methods that are exposed by Wicket instead.
- * Send an email to the mailing list in case it is not clear how to do
- * things or you think you miss funcionality which causes you to depend on
- * this directly.
- * </p>
- *
- * @param request
- *
- * @return The underlying PortletSession object.
- */
- protected final PortletSession getPortletSession(WicketPortletRequest request)
- {
- PortletSession httpSession = request.getPortletRequest().getPortletSession(true);
- return httpSession;
- }
-
- /**
- * Template method that is called when a session is being bound to the
- * session store. It is called <strong>before</strong> the session object
- * itself is added to this store (which is done by calling
- * {@link ISessionStore#setAttribute(Request, String, Object)} with key
- * {@link Session#SESSION_ATTRIBUTE_NAME}.
- *
- * @param request
- * The request
- * @param newSession
- * The new session
- */
- protected void onBind(Request request, Session newSession)
- {
- }
-
- /**
- * Template method that is called when the session is being detached from
- * the store, which typically happens when the portlet session was invalidated.
- *
- * @param sessionId
- * The session id of the session that was invalidated.
- */
- protected void onUnbind(String sessionId)
- {
- }
-
- /**
- * @see wicket.session.ISessionStore#setAttribute(Request,java.lang.String,
- * java.lang.Object)
- */
- public void setAttribute(Request request, String name, Object value)
- {
- // Do some extra profiling/ debugging. This can be a great help
- // just for testing whether your webbapp will behave when using
- // session replication
- if (Application.get().getDebugSettings().getSerializeSessionAttributes())
- {
- String valueTypeName = (value != null ? value.getClass().getName() : "null");
- try
- {
- final ByteArrayOutputStream out = new ByteArrayOutputStream();
- new ObjectOutputStream(out).writeObject(value);
- log.debug("Stored attribute " + name + "{ " + valueTypeName + "} with size: "
- + Bytes.bytes(out.size()));
- }
- catch (Exception e)
- {
- throw new WicketRuntimeException(
- "Internal error cloning object. Make sure all dependent objects implement Serializable. Class: "
- + valueTypeName, e);
- }
- }
-
- WicketPortletRequest webRequest = toPortletRequest(request);
- PortletSession httpSession = getPortletSession(webRequest);
- if (httpSession != null)
- {
- RequestLogger logger = application.getRequestLogger();
- String attributeName = getSessionAttributePrefix(webRequest) + name;
- if (logger != null)
- {
- if (httpSession.getAttribute(attributeName,SCOPE) == null)
- {
- logger.objectCreated(value);
- }
- else
- {
- logger.objectUpdated(value);
- }
- }
- httpSession.setAttribute(attributeName, value, SCOPE);
- }
- }
-
- /**
- * @see wicket.session.ISessionStore#getAttribute(wicket.Request,
- * java.lang.String)
- */
- public Object getAttribute(Request request, String name)
- {
- WicketPortletRequest webRequest = toPortletRequest(request);
- PortletSession httpSession = getPortletSession(webRequest);
- if (httpSession != null)
- {
- return httpSession.getAttribute(getSessionAttributePrefix(webRequest) + name,
- SCOPE);
- }
- return null;
- }
-
- /**
- * @see wicket.session.ISessionStore#removeAttribute(Request,java.lang.String)
- */
- public void removeAttribute(Request request, String name)
- {
- WicketPortletRequest webRequest = toPortletRequest(request);
- PortletSession httpSession = getPortletSession(webRequest);
- if (httpSession != null)
- {
- String attributeName = getSessionAttributePrefix(webRequest) + name;
- RequestLogger logger = application.getRequestLogger();
- if (logger != null)
- {
- Object value = httpSession.getAttribute(attributeName,SCOPE);
- if (value != null)
- {
- logger.objectRemoved(value);
- }
- }
- httpSession.removeAttribute(attributeName,SCOPE);
- }
- }
-
- /**
- * @see wicket.session.ISessionStore#getAttributeNames(Request)
- */
- public List getAttributeNames(Request request)
- {
- List list = new ArrayList();
- WicketPortletRequest webRequest = toPortletRequest(request);
- PortletSession httpSession = getPortletSession(webRequest);
- if (httpSession != null)
- {
- final Enumeration names = httpSession.getAttributeNames();
- final String prefix = getSessionAttributePrefix(webRequest);
- while (names.hasMoreElements())
- {
- final String name = (String)names.nextElement();
- if (name.startsWith(prefix))
- {
- list.add(name.substring(prefix.length()));
- }
- }
- }
- return list;
- }
-
- /**
- * Gets the prefix for storing variables in the actual session (typically
- * {@link PortletSession} for this application instance.
- *
- * @param request
- * the request
- *
- * @return the prefix for storing variables in the actual session
- */
- private String getSessionAttributePrefix(final WicketPortletRequest request)
- {
- return application.getSessionAttributePrefix(request);
- }
+/*
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package wicket.protocol.http.portlet;
+
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+import javax.portlet.PortletSession;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import wicket.AccessStackPageMap;
+import wicket.Application;
+import wicket.PageMap;
+import wicket.Request;
+import wicket.Session;
+import wicket.WicketRuntimeException;
+import wicket.protocol.http.IRequestLogger;
+import wicket.protocol.http.WebRequest;
+import wicket.session.ISessionStore;
+import wicket.util.lang.Bytes;
+
+
+/**
+ * Abstract implementation of {@link ISessionStore} that works with portlets
+ *
+ * @author Janne Hietamäki
+ */
+public class PortletSessionStore implements ISessionStore
+{
+ private final static int SCOPE = PortletSession.APPLICATION_SCOPE;
+
+ /** log. */
+ protected static Log log = LogFactory.getLog(PortletSessionStore.class);
+
+ protected final PortletApplication application;
+
+ /**
+ * Construct.
+ */
+ public PortletSessionStore()
+ {
+ // sanity check
+ Application app = Application.get();
+ if (!(app instanceof PortletApplication))
+ {
+ throw new IllegalStateException(getClass().getName()
+ + " can only operate in the context of portal applications");
+ }
+ this.application = (PortletApplication)app;
+ }
+
+ /**
+ * @see wicket.session.ISessionStore#invalidate(Request)
+ */
+ public final void invalidate(Request request)
+ {
+ WicketPortletRequest webRequest = toPortletRequest(request);
+ PortletSession httpSession = getPortletSession(webRequest);
+ if (httpSession != null)
+ {
+ try
+ {
+ httpSession.invalidate();
+ }
+ catch (IllegalStateException e)
+ {
+ // Ignore
+ }
+ }
+ }
+
+ /**
+ * Gets the session id.
+ *
+ * @param request
+ * @return The session id
+ * @see wicket.session.ISessionStore#getSessionId(wicket.Request)
+ */
+ public final String getSessionId(Request request)
+ {
+ WicketPortletRequest webRequest = toPortletRequest(request);
+ return getPortletSession(webRequest).getId();
+ }
+
+ /**
+ * @see wicket.session.ISessionStore#bind(wicket.Request, wicket.Session)
+ */
+ public final void bind(Request request, Session newSession)
+ {
+ // call template method
+ onBind(request, newSession);
+
+ WicketPortletRequest webRequest = toPortletRequest(request);
+ PortletSession httpSession = getPortletSession(webRequest);
+
+ // register the session object itself
+ setAttribute(webRequest, Session.SESSION_ATTRIBUTE_NAME, newSession);
+ }
+
+ /**
+ * @see wicket.session.ISessionStore#unbind(java.lang.String)
+ */
+ public final void unbind(String sessionId)
+ {
+ application.sessionDestroyed(sessionId);
+ onUnbind(sessionId);
+ }
+
+ /**
+ * @see wicket.session.ISessionStore#lookup(wicket.Request)
+ */
+ public Session lookup(Request request)
+ {
+ WicketPortletRequest webRequest = toPortletRequest(request);
+ return (Session)getAttribute(webRequest, Session.SESSION_ATTRIBUTE_NAME);
+ }
+
+ /**
+ * Cast {@link Request} to {@link WebRequest}.
+ *
+ * @param request
+ * The request to cast
+ * @return The web request
+ */
+ protected final WicketPortletRequest toPortletRequest(Request request)
+ {
+ if (request == null)
+ {
+ return null;
+ }
+ if (!(request instanceof WicketPortletRequest))
+ {
+ throw new IllegalArgumentException(getClass().getName()
+ + " can only work with WicketPortletRequest");
+ }
+ return (WicketPortletRequest)request;
+ }
+
+ /**
+ * Gets the underlying HttpSession object or null.
+ * <p>
+ * WARNING: it is a bad idea to depend on the http session object directly.
+ * Please use the classes and methods that are exposed by Wicket instead.
+ * Send an email to the mailing list in case it is not clear how to do
+ * things or you think you miss funcionality which causes you to depend on
+ * this directly.
+ * </p>
+ *
+ * @param request
+ *
+ * @return The underlying PortletSession object.
+ */
+ protected final PortletSession getPortletSession(WicketPortletRequest request)
+ {
+ PortletSession httpSession = request.getPortletRequest().getPortletSession(true);
+ return httpSession;
+ }
+
+ /**
+ * Template method that is called when a session is being bound to the
+ * session store. It is called <strong>before</strong> the session object
+ * itself is added to this store (which is done by calling
+ * {@link ISessionStore#setAttribute(Request, String, Object)} with key
+ * {@link Session#SESSION_ATTRIBUTE_NAME}.
+ *
+ * @param request
+ * The request
+ * @param newSession
+ * The new session
+ */
+ protected void onBind(Request request, Session newSession)
+ {
+ }
+
+ /**
+ * Template method that is called when the session is being detached from
+ * the store, which typically happens when the portlet session was
+ * invalidated.
+ *
+ * @param sessionId
+ * The session id of the session that was invalidated.
+ */
+ protected void onUnbind(String sessionId)
+ {
+ }
+
+ /**
+ * @see wicket.session.ISessionStore#setAttribute(Request,java.lang.String,
+ * java.lang.Object)
+ */
+ public void setAttribute(Request request, String name, Object value)
+ {
+ // Do some extra profiling/ debugging. This can be a great help
+ // just for testing whether your webbapp will behave when using
+ // session replication
+ if (Application.get().getDebugSettings().getSerializeSessionAttributes())
+ {
+ String valueTypeName = (value != null ? value.getClass().getName() : "null");
+ try
+ {
+ final ByteArrayOutputStream out = new ByteArrayOutputStream();
+ new ObjectOutputStream(out).writeObject(value);
+ log.debug("Stored attribute " + name + "{ " + valueTypeName + "} with size: "
+ + Bytes.bytes(out.size()));
+ }
+ catch (Exception e)
+ {
+ throw new WicketRuntimeException(
+ "Internal error cloning object. Make sure all dependent objects implement Serializable. Class: "
+ + valueTypeName, e);
+ }
+ }
+
+ WicketPortletRequest webRequest = toPortletRequest(request);
+ PortletSession httpSession = getPortletSession(webRequest);
+ if (httpSession != null)
+ {
+ IRequestLogger logger = application.getRequestLogger();
+ String attributeName = getSessionAttributePrefix(webRequest) + name;
+ if (logger != null)
+ {
+ if (httpSession.getAttribute(attributeName, SCOPE) == null)
+ {
+ logger.objectCreated(value);
+ }
+ else
+ {
+ logger.objectUpdated(value);
+ }
+ }
+ httpSession.setAttribute(attributeName, value, SCOPE);
+ }
+ }
+
+ /**
+ * @see wicket.session.ISessionStore#getAttribute(wicket.Request,
+ * java.lang.String)
+ */
+ public Object getAttribute(Request request, String name)
+ {
+ WicketPortletRequest webRequest = toPortletRequest(request);
+ PortletSession httpSession = getPortletSession(webRequest);
+ if (httpSession != null)
+ {
+ return httpSession.getAttribute(getSessionAttributePrefix(webRequest) + name, SCOPE);
+ }
+ return null;
+ }
+
+ /**
+ * @see wicket.session.ISessionStore#removeAttribute(Request,java.lang.String)
+ */
+ public void removeAttribute(Request request, String name)
+ {
+ WicketPortletRequest webRequest = toPortletRequest(request);
+ PortletSession httpSession = getPortletSession(webRequest);
+ if (httpSession != null)
+ {
+ String attributeName = getSessionAttributePrefix(webRequest) + name;
+ IRequestLogger logger = application.getRequestLogger();
+ if (logger != null)
+ {
+ Object value = httpSession.getAttribute(attributeName, SCOPE);
+ if (value != null)
+ {
+ logger.objectRemoved(value);
+ }
+ }
+ httpSession.removeAttribute(attributeName, SCOPE);
+ }
+ }
+
+ /**
+ * @see wicket.session.ISessionStore#getAttributeNames(Request)
+ */
+ public List getAttributeNames(Request request)
+ {
+ List list = new ArrayList();
+ WicketPortletRequest webRequest = toPortletRequest(request);
+ PortletSession httpSession = getPortletSession(webRequest);
+ if (httpSession != null)
+ {
+ final Enumeration names = httpSession.getAttributeNames();
+ final String prefix = getSessionAttributePrefix(webRequest);
+ while (names.hasMoreElements())
+ {
+ final String name = (String)names.nextElement();
+ if (name.startsWith(prefix))
+ {
+ list.add(name.substring(prefix.length()));
+ }
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Gets the prefix for storing variables in the actual session (typically
+ * {@link PortletSession} for this application instance.
+ *
+ * @param request
+ * the request
+ *
+ * @return the prefix for storing variables in the actual session
+ */
+ private String getSessionAttributePrefix(final WicketPortletRequest request)
+ {
+ return application.getSessionAttributePrefix(request);
+ }
+
+ /**
+ * @see wicket.session.ISessionStore#createPageMap(java.lang.String,
+ * wicket.Session)
+ */
+ public PageMap createPageMap(String name, Session session)
+ {
+ return new AccessStackPageMap(name, session);
+ }
+
+ /**
+ * @see wicket.session.ISessionStore#getSessionId(wicket.Request, boolean)
+ */
+ public final String getSessionId(Request request, boolean create)
+ {
+ WicketPortletRequest webRequest = toPortletRequest(request);
+ PortletSession httpSession = webRequest.getPortletRequest().getPortletSession(create);
+ return (httpSession != null) ? httpSession.getId() : null;
+ }
+
+ public void onBeginRequest(Request request)
+ {
+ }
+
+ public void onEndRequest(Request request)
+ {
+ }
+
}
Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/session/ISessionStore.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/session/ISessionStore.java?view=diff&rev=473519&r1=473518&r2=473519
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/session/ISessionStore.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/session/ISessionStore.java Fri Nov 10 13:50:33 2006
@@ -20,6 +20,9 @@
import java.util.List;
+import javax.servlet.http.HttpSession;
+
+import wicket.PageMap;
import wicket.Request;
import wicket.Session;
@@ -83,13 +86,19 @@
void setAttribute(Request request, String name, Object value);
/**
- * Get the session id for the provided request.
+ * Get the session id for the provided request. It create is false and the
+ * creation of the actual session is deferred, this method should return
+ * null to reflect it doesn't have one.
*
* @param request
* The request
- * @return The session id for the provided request
+ * @param create
+ * Whether to create an actual session (typically an instance of
+ * {@link HttpSession}) when not already done so
+ * @return The session id for the provided request, possibly null if create
+ * is false and the creation of the actual session was deferred
*/
- String getSessionId(Request request);
+ String getSessionId(Request request, boolean create);
/**
* Retrieves the session for the provided request from this facade.
@@ -123,4 +132,29 @@
* The SessionId that must be unbinded.
*/
void unbind(String sessionId);
+
+ /**
+ * Called at the start of a request. It can be used for example to rebuild
+ * server state from the client request.
+ *
+ * @param request
+ * The request object
+ */
+ void onBeginRequest(Request request);
+
+ /**
+ * Called at the end of a request. It can be used for instance to release
+ * temporary server state when using client state saving.
+ *
+ * @param request
+ * The request
+ */
+ void onEndRequest(Request request);
+
+ /**
+ * @param name
+ * @param session
+ * @return The pagemap instances for the session
+ */
+ PageMap createPageMap(String name, Session session);
}
Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/session/pagemap/LeastRecentlyAccessedEvictionStrategy.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/session/pagemap/LeastRecentlyAccessedEvictionStrategy.java?view=diff&rev=473519&r1=473518&r2=473519
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/session/pagemap/LeastRecentlyAccessedEvictionStrategy.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/session/pagemap/LeastRecentlyAccessedEvictionStrategy.java Fri Nov 10 13:50:33 2006
@@ -1,6 +1,7 @@
/*
* $Id: LeastRecentlyAccessedEvictionStrategy.java,v 1.1 2005/12/29 05:30:24
- * jonathanlocke Exp $ $Revision$ $Date$
+ * jonathanlocke Exp $ $Revision$ $Date: 2006-05-20 00:32:57 +0000 (Sat,
+ * 20 May 2006) $
*
* ==============================================================================
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -17,9 +18,11 @@
*/
package wicket.session.pagemap;
+import wicket.AccessStackPageMap;
import wicket.Page;
import wicket.PageMap;
import wicket.Session;
+import wicket.AccessStackPageMap.Access;
/**
* A simple eviction strategy that evicts the least recently accessed page
@@ -54,40 +57,47 @@
*/
public void evict(final PageMap pageMap)
{
- synchronized (Session.get())
+ if (pageMap instanceof AccessStackPageMap)
{
- // Do we need to evict under this strategy?
- if (pageMap.getVersions() > maxVersions)
+ synchronized (Session.get())
{
- // Remove oldest entry from access stack
- final PageMap.Access oldestAccess = (PageMap.Access)pageMap.getAccessStack().remove(0);
- final IPageMapEntry oldestEntry = pageMap.getEntry(oldestAccess.getId());
-
- // If entry is a page (cannot be null if we're evicting)
- if (oldestEntry instanceof Page)
+ AccessStackPageMap accessPM = (AccessStackPageMap)pageMap;
+ // Do we need to evict under this strategy?
+ if (accessPM.getVersions() > maxVersions)
{
- Page page = (Page)oldestEntry;
-
- // If there is more than one version of this page
- if (page.getVersions() > 1)
+ // Remove oldest entry from access stack
+ final AccessStackPageMap.Access oldestAccess = (Access)accessPM.getAccessStack()
+ .remove(0);
+ final IPageMapEntry oldestEntry = pageMap.getEntry(oldestAccess.getId());
+
+ // If entry is a page (cannot be null if we're evicting)
+ if (oldestEntry instanceof Page)
{
- // expire the oldest version
- page.expireOldestVersion();
+ Page page = (Page)oldestEntry;
+
+ // If there is more than one version of this page
+ if (page.getVersions() > 1)
+ {
+ // expire the oldest version
+ page.expireOldestVersion();
+ }
+ else
+ {
+ // expire whole page
+ accessPM.removeEntry(page);
+ }
}
else
{
- // expire whole page
- pageMap.removeEntry(page);
- }
- }
- else
- {
- // If oldestEntry is not an instance of Page, then it is some
- // custom, user-defined IPageMapEntry class and cannot contain
- // versioning information, so we just remove the entry.
- if (oldestEntry != null)
- {
- pageMap.removeEntry(oldestEntry);
+ // If oldestEntry is not an instance of Page, then it is
+ // some
+ // custom, user-defined IPageMapEntry class and cannot
+ // contain
+ // versioning information, so we just remove the entry.
+ if (oldestEntry != null)
+ {
+ accessPM.removeEntry(oldestEntry);
+ }
}
}
}
Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/settings/Settings.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/settings/Settings.java?view=diff&rev=473519&r1=473518&r2=473519
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/settings/Settings.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/settings/Settings.java Fri Nov 10 13:50:33 2006
@@ -288,9 +288,9 @@
/** Determines if pages should be managed by a version manager by default */
private boolean versionPagesByDefault = true;
- private boolean recordSessionSize;
+ private boolean recordSessionSize = true;
- private int requestsWindowSize;
+ private int requestsWindowSize = 2000;
private boolean requestLoggerEnabled;