throw new IllegalArgumentException("type can not be null"); Object value = getAttribute(type.getName()); if (value == null) { return null;
@SuppressWarnings("unchecked") private ArrayBlockingQueue<Color> getColorHistory() { if (isAttached()) { Object colorHistory = getSession() .getAttribute("colorPickerHistory"); if (colorHistory instanceof ArrayBlockingQueue<?>) { return (ArrayBlockingQueue<Color>) colorHistory; } } return tempHistory; }
private void createColorHistoryIfNecessary() { List<Color> tempColors = new ArrayList<>(tempHistory); if (getSession().getAttribute("colorPickerHistory") == null) { getSession().setAttribute("colorPickerHistory", new ArrayBlockingQueue<Color>(ROWS * COLUMNS)); } for (Color color : tempColors) { setValue(color); } tempHistory.clear(); }
if (getAttribute( VaadinService.PRESERVE_UNBOUND_SESSION_ATTRIBUTE) == Boolean.TRUE) { return;
/** * Returns {@link SessionStore} corresponding to provided {@link VaadinSession}. */ public static SessionStore access(VaadinSession session) { return session.getAttribute(SessionStore.class); }
/** * {@inheritDoc} */ @Override public UserSession session() { return vaadinSession.getAttribute(UserSession.class); }
@Override public Object getProperty(String name) { return instance.getAttribute(name); }
private LegacyApplication getApplication() { LegacyApplication application = VaadinSession.getCurrent() .getAttribute(LegacyApplication.class); if (application == null) { application = createApplication(); if (application == null) { return null; } VaadinSession.getCurrent().setAttribute(LegacyApplication.class, application); URL applicationUrl; try { applicationUrl = VaadinService.getCurrent() .getApplicationUrl(VaadinService.getCurrentRequest()); } catch (MalformedURLException e) { throw new RuntimeException(e); } application.doInit(applicationUrl); } if (application != null && !application.isRunning()) { VaadinSession.getCurrent().setAttribute(LegacyApplication.class, null); // Run again without a current application return getApplication(); } return application; }
/** * Finds a bean store which corresponds to a scope key. * If such store does not exist - creates one. */ public BeanStore getBeanStore(UiContextReference uiContextReference) { return (BeanStore) vaadinSession.getAttribute(uiContextReference.asString()); }
protected boolean isTryLoginOnStart() { Object attribute = VaadinSession.getCurrent().getAttribute(LOGIN_ON_START_ATTRIBUTE); if (attribute != null) { return (Boolean) attribute; } return true; }
public Locale getLocale() { String locale = (String) VaadinSession.getCurrent().getAttribute( LOCALE_SESSION_ATTRIBUTE); if (locale != null) { return Locale.forLanguageTag(locale); } else if (bestLocaleByAcceptHeader != null) { return bestLocaleByAcceptHeader; } else { return supportedLocales.get(0); } }
@SuppressWarnings("unchecked") private ArrayBlockingQueue<Color> getColorHistory() { if (isAttached()) { Object colorHistory = getSession() .getAttribute("colorPickerHistory"); if (colorHistory instanceof ArrayBlockingQueue<?>) { return (ArrayBlockingQueue<Color>) colorHistory; } } return tempHistory; }
/** * @return true if an {@link App} instance is currently bound and can be safely obtained by {@link #getInstance()} */ public static boolean isBound() { VaadinSession vSession = VaadinSession.getCurrent(); return vSession != null && vSession.hasLock() && vSession.getAttribute(App.class) != null; }
@Override public Object remove(String name) { VaadinSession session = VaadinSession.getCurrent(); if (session == null || !session.hasLock()) { throw new IllegalStateException("Unable to use VaadinSessionScope from non-Vaadin thread"); } Object bean = session.getAttribute(name); session.setAttribute(name, null); return bean; }
@Override public boolean remove(String resourceKey) throws UnsupportedOperationException { ObjectUtils.argumentNotNull(resourceKey, "Resource key must be not null"); final VaadinSession session = VaadinSession.getCurrent(); if (session == null) { throw new IllegalStateException("Current VaadinSession not available"); } Object exist = session.getAttribute(resourceKey); session.setAttribute(resourceKey, null); return exist != null; }
@Override public boolean remove(String resourceKey) throws UnsupportedOperationException { ObjectUtils.argumentNotNull(resourceKey, "Resource key must be not null"); final VaadinSession session = VaadinSession.getCurrent(); if (session == null) { throw new IllegalStateException("Current VaadinSession not available"); } Object exist = session.getAttribute(resourceKey); session.setAttribute(resourceKey, null); return exist != null; }
@Override public SecurityContext get() { VaadinSession vaadinSession = VaadinSession.getCurrent(); if (vaadinSession != null && vaadinSession.hasLock()) { return vaadinSession.getAttribute(SecurityContext.class); } return super.get(); }
private void createColorHistoryIfNecessary() { List<Color> tempColors = new ArrayList<Color>(tempHistory); if (getSession().getAttribute("colorPickerHistory") == null) { getSession().setAttribute("colorPickerHistory", new ArrayBlockingQueue<Color>(ROWS * COLUMNS)); } for (Color color : tempColors) { setColor(color); } tempHistory.clear(); }
@Override public SecurityContext getContext() { VaadinSession session = getSession(); SecurityContext context = session.getAttribute(SecurityContext.class); if (context == null) { context = createEmptyContext(); session.setAttribute(SecurityContext.class, context); } return context; }
@Override public void enter(ViewChangeEvent event) { TopologyStateCache cache = (TopologyStateCache)VaadinSession.getCurrent().getAttribute (DashboardSessionValueConstants.TOPOLOGY_STATE_CACHE); stateMap = cache.getStateMap(); setStatusLabel(); populate(stateMap); }