/** * @see org.apache.wicket.session.ISessionStore#lookup(org.apache.wicket.Request) */ public Session lookup(Request request) { String sessionId = getSessionId(request, false); if (sessionId != null) { WebRequest webRequest = toWebRequest(request); return (Session)getAttribute(webRequest, Session.SESSION_ATTRIBUTE_NAME); } return null; }
/** * 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 functionality which causes you to * depend on this directly. * </p> * * @param request * * @return The underlying HttpSession object. */ protected final HttpSession getHttpSession(WebRequest request) { return getHttpSession(request, false); }
/** * @see org.apache.wicket.session.ISessionStore#bind(org.apache.wicket.Request, * org.apache.wicket.Session) */ public final void bind(Request request, Session newSession) { // call template method onBind(request, newSession); WebRequest webRequest = toWebRequest(request); HttpSession httpSession = getHttpSession(webRequest, true); // register an unbinding listener for cleaning up String applicationKey = application.getApplicationKey(); httpSession.setAttribute("Wicket:SessionUnbindingListener-" + applicationKey, new SessionBindingListener(applicationKey, httpSession.getId())); // register the session object itself setAttribute(webRequest, Session.SESSION_ATTRIBUTE_NAME, newSession); }
/** * @see org.apache.wicket.session.ISessionStore#invalidate(Request) */ public final void invalidate(Request request) { WebRequest webRequest = toWebRequest(request); HttpSession httpSession = getHttpSession(webRequest); if (httpSession != null) { String applicationKey = application.getApplicationKey(); try { SessionBindingListener l = (SessionBindingListener)httpSession .getAttribute("Wicket:SessionUnbindingListener-" + applicationKey); if (l != null) { l.unbound = true; } // call unbind unbind(httpSession.getId()); // tell the app server the session is no longer valid httpSession.invalidate(); } catch (IllegalStateException e) { // can safely be ignored } } }
/** * @see org.apache.wicket.session.ISessionStore#unbind(java.lang.String) */ public final void unbind(String sessionId) { onUnbind(sessionId); application.sessionDestroyed(sessionId); }
/** * @see org.apache.wicket.session.ISessionStore#getSessionId(org.apache.wicket.Request, boolean) */ public String getSessionId(final Request request, final boolean create) { String id = null; WebRequest webRequest = toWebRequest(request); HttpSession httpSession = webRequest.getHttpServletRequest().getSession(false); if (httpSession != null) { id = httpSession.getId(); } else if (create) { httpSession = webRequest.getHttpServletRequest().getSession(true); id = httpSession.getId(); IRequestLogger logger = application.getRequestLogger(); if (logger != null) { logger.sessionCreated(id); } } return id; }
/** * @see org.apache.wicket.session.ISessionStore#bind(org.apache.wicket.Request, * org.apache.wicket.Session) */ public final void bind(Request request, Session newSession) { // call template method onBind(request, newSession); WebRequest webRequest = toWebRequest(request); HttpSession httpSession = getHttpSession(webRequest); // register an unbinding listener for cleaning up String applicationKey = application.getApplicationKey(); httpSession.setAttribute("Wicket:SessionUnbindingListener-" + applicationKey, new SessionBindingListener(applicationKey, httpSession.getId())); // register the session object itself setAttribute(webRequest, Session.SESSION_ATTRIBUTE_NAME, newSession); }
WebRequest webRequest = toWebRequest(request); HttpSession httpSession = getHttpSession(webRequest); if (httpSession != null) unbind(httpSession.getId());
/** * @see org.apache.wicket.session.ISessionStore#unbind(java.lang.String) */ public final void unbind(String sessionId) { onUnbind(sessionId); application.sessionDestroyed(sessionId); }
/** * @see org.apache.wicket.session.ISessionStore#getSessionId(org.apache.wicket.Request, boolean) */ public final String getSessionId(Request request, boolean create) { String id = null; WebRequest webRequest = toWebRequest(request); HttpSession httpSession = webRequest.getHttpServletRequest().getSession(false); if (httpSession != null) { id = httpSession.getId(); } else if (create) { httpSession = webRequest.getHttpServletRequest().getSession(true); id = httpSession.getId(); IRequestLogger logger = application.getRequestLogger(); if (logger != null) { logger.sessionCreated(id); } } return id; }
/** * @see org.apache.wicket.session.ISessionStore#lookup(org.apache.wicket.Request) */ public Session lookup(Request request) { String sessionId = getSessionId(request, false); if (sessionId != null) { WebRequest webRequest = toWebRequest(request); return (Session)getAttribute(webRequest, Session.SESSION_ATTRIBUTE_NAME); } return null; }