@Override public void checkUIAccess() { VaadinSession vaadinSession = VaadinSession.getCurrent(); if (vaadinSession == null || !vaadinSession.hasLock()) { throw new IllegalConcurrentAccessException(); } }
public void clearCache() { VaadinSession session = VaadinSession.getCurrent(); if (session == null || !session.hasLock()) { throw new IllegalConcurrentAccessException("Illegal access to settings client from background thread"); } session.setAttribute(SettingsClient.NAME, null); }
protected Map<String, Optional<String>> getCache() { VaadinSession session = VaadinSession.getCurrent(); if (session == null || !session.hasLock()) { throw new IllegalConcurrentAccessException("Illegal access to settings client from background thread"); } @SuppressWarnings("unchecked") Map<String, Optional<String>> settings = (Map<String, Optional<String>>) session.getAttribute(SettingsClient.NAME); if (settings == null) { settings = new HashMap<>(); session.setAttribute(SettingsClient.NAME, settings); } return settings; } }