/** * Releases the lock for the given session for this service instance. * Typically you want to call {@link VaadinSession#unlock()} instead of this * method. * * @param wrappedSession * The session to unlock */ protected void unlockSession(WrappedSession wrappedSession) { assert getSessionLock(wrappedSession) != null; assert ((ReentrantLock) getSessionLock(wrappedSession)) .isHeldByCurrentThread() : "Trying to unlock the session but it has not been locked by this thread"; getSessionLock(wrappedSession).unlock(); }
/** * Checks if the current thread has exclusive access to the given * WrappedSession. * * @param service * the service to check * @param session * the session to use for checking * @return true if this thread has exclusive access, false otherwise */ protected static boolean hasLock(VaadinService service, WrappedSession session) { ReentrantLock l = (ReentrantLock) service.getSessionLock(session); return l.isHeldByCurrentThread(); }
/** * Updates the transient session lock from VaadinService. */ private void refreshLock() { assert lock == null || lock == service.getSessionLock( session) : "Cannot change the lock from one instance to another"; assert hasLock(service, session); lock = service.getSessionLock(session); }
Lock lock = getSessionLock(wrappedSession); if (lock == null) { lock = getSessionLock(wrappedSession); if (lock == null) { lock = new ReentrantLock();
/** * Creates and registers a new VaadinSession for this service. Assumes * proper locking has been taken care of by the caller. * * @param request * The request which triggered session creation. * @return A new VaadinSession instance */ private VaadinSession createAndRegisterSession(VaadinRequest request) { assert ((ReentrantLock) getSessionLock(request.getWrappedSession())) .isHeldByCurrentThread() : "Session has not been locked by this thread"; VaadinSession session = createVaadinSession(request); VaadinSession.setCurrent(session); storeSession(session, request.getWrappedSession()); // Initial WebBrowser data comes from the request session.getBrowser().updateRequestDetails(request); session.setConfiguration(getDeploymentConfiguration()); // Initial locale comes from the request if (getInstantiator().getI18NProvider() != null) { setLocale(request, session); } onVaadinSessionStarted(request, session); return session; }
assert ((ReentrantLock) getSessionLock(request.getWrappedSession())) .isHeldByCurrentThread() : "Session has not been locked by this thread";