+ " expected but got " + value.getClass().getName()); setAttribute(type.getName(), value);
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(); }
serviceSession.setAttribute(PRESERVE_UNBOUND_SESSION_ATTRIBUTE, Boolean.TRUE); serviceSession.setAttribute(PRESERVE_UNBOUND_SESSION_ATTRIBUTE, null);
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; }
void destroy() { LOGGER.trace("Destroying [{}]", this); session.setAttribute(BeanStore.class, null); session.getService().removeSessionDestroyListener(this); session.getService().removeServiceDestroyListener(this); for (BeanStore beanStore : new HashSet<BeanStore>(beanStoreMap.values())) { beanStore.destroy(); } Assert.isTrue(beanStoreMap.isEmpty(), "beanStore should have been emptied by the destruction callbacks"); }
@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 void onClick(PointClickEvent event) { Module module = moduleMap.get(event.getCategory()); VaadinSession.getCurrent().setAttribute("module", module); VaadinSession.getCurrent().setAttribute("tab", TopologyViewPanel.CATEGORISED_ERROR_TAB); UI.getCurrent().getNavigator().navigateTo("topologyView"); } });
@Override public void onClick(PointClickEvent event) { Module module = moduleMap.get(event.getCategory()); VaadinSession.getCurrent().setAttribute("module", module); VaadinSession.getCurrent().setAttribute("tab", TopologyViewPanel.CATEGORISED_ERROR_TAB); UI.getCurrent().getNavigator().navigateTo("topologyView"); } });
public BeanStore createBeanStore(UiContextReference key, Map<Key, Object> initialInstances) { final BeanStore beanStore = new BeanStore(); vaadinSession.setAttribute(key.asString(), beanStore); initialInstances.forEach(beanStore::put); eventBus.fireEvent(new BeanStoreLifecycleEvent.Create(key, beanStore)); return beanStore; }
@Override public void set(SecurityContext securityContext) { VaadinSession vaadinSession = VaadinSession.getCurrent(); if (vaadinSession != null && vaadinSession.hasLock()) { vaadinSession.setAttribute(SecurityContext.class, securityContext); } else { super.set(securityContext); } } }
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); }
@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; }
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(); }
public void sessionscope() { // tag::sessionscope[] VaadinSession.getCurrent().setAttribute(LocalizationContext.CONTEXT_KEY, LocalizationContext.builder().withInitialLocale(Locale.US).build()); // <1> LocalizationContext.getCurrent().ifPresent(localizationContext -> { // <2> // LocalizationContext obtained from current Vaadin session }); // end::sessionscope[] }
public void sessionscope() { // tag::sessionscope[] VaadinSession.getCurrent().setAttribute(LocalizationContext.CONTEXT_KEY, LocalizationContext.builder().withInitialLocale(Locale.US).build()); // <1> LocalizationContext.getCurrent().ifPresent(localizationContext -> { // <2> // LocalizationContext obtained from current Vaadin session }); // end::sessionscope[] }
protected void setSessionInternal(ClientUserSession userSession) { VaadinSession.getCurrent().setAttribute(UserSession.class, userSession); if (userSession != null) { AppContext.setSecurityContext(new SecurityContext(userSession)); } else { AppContext.setSecurityContext(null); } }
@Override public void destroy() { try { session.setAttribute(BeanStore.class, null); session.getService().removeSessionDestroyListener(this); session.getService().removeServiceDestroyListener(this); } finally { super.destroy(); } }
UIStore(VaadinSession session) { this.sessionId = session.getSession().getId(); this.session = session; this.session.getService().addSessionDestroyListener(this); this.session.getService().addServiceDestroyListener(this); this.session.setAttribute(UIStore.class, this); }
SessionAwareBeanStore(VaadinSession session) { super("Session:" + session.getSession().getId()); this.session = session; this.session.getService().addSessionDestroyListener(this); this.session.getService().addServiceDestroyListener(this); this.session.setAttribute(BeanStore.class, this); }