/** * Checks if the current thread has exclusive access to the given * WrappedSession. * * @return true if this thread has exclusive access, false otherwise * @since 7.6 */ protected static boolean hasLock(VaadinService service, WrappedSession session) { ReentrantLock l = (ReentrantLock) service.getSessionLock(session); return l.isHeldByCurrentThread(); }
/** * 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(); }
/** * 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();
/** * 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. * * @return true if this thread has exclusive access, false otherwise * @since 7.6 */ 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); }
boolean requestCanCreateSession) throws SessionExpiredException, ServiceException { assert ((ReentrantLock) getSessionLock(request.getWrappedSession())) .isHeldByCurrentThread() : "Session has not been locked by this thread";
/** * 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 * @throws ServiceException */ private VaadinSession createAndRegisterSession(VaadinRequest request) throws ServiceException { 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); // Initial locale comes from the request Locale locale = request.getLocale(); session.setLocale(locale); session.setConfiguration(getDeploymentConfiguration()); session.setCommunicationManager( new LegacyCommunicationManager(session)); ServletPortletHelper.initDefaultUIProvider(session, this); onVaadinSessionStarted(request, session); return 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 * @throws ServiceException */ private VaadinSession createAndRegisterSession(VaadinRequest request) throws ServiceException { 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); // Initial locale comes from the request Locale locale = request.getLocale(); session.setLocale(locale); session.setConfiguration(getDeploymentConfiguration()); onVaadinSessionStarted(request, session); return session; }
boolean requestCanCreateSession) throws SessionExpiredException, ServiceException { assert ((ReentrantLock) getSessionLock(request.getWrappedSession())) .isHeldByCurrentThread() : "Session has not been locked by this thread";