/** * Performs the actual read of the VaadinSession from the underlying HTTP * session after sanity checks have been performed. * <p> * Called by {@link #loadSession(WrappedSession)}. * * @param wrappedSession * the underlying HTTP session * @return the VaadinSession or null if no session was found */ protected VaadinSession readFromHttpSession(WrappedSession wrappedSession) { return (VaadinSession) wrappedSession .getAttribute(getSessionAttributeName()); }
Map<String, Object> attrs = new HashMap<>(attributeNames.size() * 2); for (String name : attributeNames) { Object value = oldSession.getAttribute(name); if (value instanceof VaadinSession) {
/** * Gets the lock instance used to lock the VaadinSession associated with the * given wrapped session. * <p> * This method uses the wrapped session instead of VaadinSession to be able * to lock even before the VaadinSession has been initialized. * </p> * * @param wrappedSession * The wrapped session * @return A lock instance used for locking access to the wrapped session */ protected Lock getSessionLock(WrappedSession wrappedSession) { Object lock = wrappedSession.getAttribute(getLockAttributeName()); if (lock instanceof ReentrantLock) { return (ReentrantLock) lock; } if (lock == null) { return null; } throw new RuntimeException( "Something else than a ReentrantLock was stored in the " + getLockAttributeName() + " in the session"); }
/** * Associates the given lock with this service and the given wrapped * session. This method should not be called more than once when the lock is * initialized for the session. * * @param wrappedSession * The wrapped session the lock is associated with * @param lock * The lock object * @see #getSessionLock(WrappedSession) */ private void setSessionLock(WrappedSession wrappedSession, Lock lock) { if (wrappedSession == null) { throw new IllegalArgumentException( "Can't set a lock for a null session"); } Object currentSessionLock = wrappedSession .getAttribute(getLockAttributeName()); assert (currentSessionLock == null || currentSessionLock == lock) : "Changing the lock for a session is not allowed"; wrappedSession.setAttribute(getLockAttributeName(), lock); }
wrappedSession.getAttribute(getLockAttributeName()); } catch (IllegalStateException e) { lock.unlock();