public DolphinContext getContext(final ClientSession clientSession) { Assert.requireNonNull(clientSession, "clientSession"); return clientSession.getAttribute(DOLPHIN_CONTEXT_ATTRIBUTE_NAME); }
public DolphinContext getContext(final ClientSession clientSession) { Assert.requireNonNull(clientSession, "clientSession"); return clientSession.getAttribute(DOLPHIN_CONTEXT_ATTRIBUTE_NAME); }
@Override public Object getAttribute(String name) { return getSession().getAttribute(name); }
@Override public Object getAttribute(String name) { return getSession().getAttribute(name); }
private Map<String, Object> getLocalStore() { ClientSession session = getClientSession(); if(session == null) { throw new IllegalStateException("No dolphin request found! Looks like you try to use the " + ClientScopeImpl.class.getSimpleName() + " ouside of the dolphin context!"); } Map<String, Object> localStore = session.getAttribute(CLIENT_STORE_ATTRIBUTE); if(localStore == null) { localStore = Collections.synchronizedMap(new HashMap<String, Object>()); session.setAttribute(CLIENT_STORE_ATTRIBUTE, localStore); } return localStore; }
public void destroy() { Object val = getDolphinSession().getAttribute(CLIENT_STORAGE_ATTRIBUTE); if(val != null && val instanceof ContextualStorage) { AbstractContext.destroyAllActive((ContextualStorage) val); } } }
@Override protected ContextualStorage getContextualStorage(Contextual<?> contextual, boolean createIfNotExist) { Object val = getDolphinSession().getAttribute(CLIENT_STORAGE_ATTRIBUTE); if(val != null) { if(val instanceof ContextualStorage) { return (ContextualStorage) val; } else { throw new ContextException("No ClientContext specified!"); } } else { if(createIfNotExist) { ContextualStorage contextualStorage = new ContextualStorage(beanManager, false, false); getDolphinSession().setAttribute(CLIENT_STORAGE_ATTRIBUTE, contextualStorage); return contextualStorage; } else { return null; } } }