@Override public void sessionCreated(final ClientSession clientSession) { Assert.requireNonNull(clientSession, "clientSession"); final Mutex mutex = new Mutex(); clientSession.setAttribute(SESSION_MUTEX_ATTRIBUTE, mutex); sessionMutexMap.put(clientSession.getId(), new WeakReference<>(mutex)); }
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; }
@Override public Set<String> getAttributesNames() { return getSession().getAttributeNames(); }
@Override public void call(final ClientSession dolphinSession) { onSessionEnds(dolphinSession.getId()); } });
public DolphinContext getContext(final ClientSession clientSession) { Assert.requireNonNull(clientSession, "clientSession"); return clientSession.getAttribute(DOLPHIN_CONTEXT_ATTRIBUTE_NAME); }
private void remove(final ClientSession clientSession) { Assert.requireNonNull(clientSession, "clientSession"); clientSession.removeAttribute(DOLPHIN_CONTEXT_ATTRIBUTE_NAME); }
@Override public void call(final ClientSession dolphinSession) { onSessionEnds(dolphinSession.getId()); } });
public DolphinContext getContext(final ClientSession clientSession) { Assert.requireNonNull(clientSession, "clientSession"); return clientSession.getAttribute(DOLPHIN_CONTEXT_ATTRIBUTE_NAME); }
private void remove(final ClientSession clientSession) { Assert.requireNonNull(clientSession, "clientSession"); clientSession.removeAttribute(DOLPHIN_CONTEXT_ATTRIBUTE_NAME); }
public String getId() { return clientSession.getId(); }
private void add(final ClientSession clientSession, final DolphinContext context) { Assert.requireNonNull(clientSession, "clientSession"); Assert.requireNonNull(context, "context"); clientSession.setAttribute(DOLPHIN_CONTEXT_ATTRIBUTE_NAME, context); weakContextMap.put(clientSession.getId(), new WeakReference<>(context)); }
@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; } } }
@Override public Object getAttribute(String name) { return getSession().getAttribute(name); }
@Override public Set<String> getAttributesNames() { return getSession().getAttributeNames(); }
public String getId() { return clientSession.getId(); }
private void add(final ClientSession clientSession, final DolphinContext context) { Assert.requireNonNull(clientSession, "clientSession"); Assert.requireNonNull(context, "context"); clientSession.setAttribute(DOLPHIN_CONTEXT_ATTRIBUTE_NAME, context); weakContextMap.put(clientSession.getId(), new WeakReference<>(context)); }
@Override public Object getAttribute(String name) { return getSession().getAttribute(name); }
@Override public void sessionDestroyed(final ClientSession clientSession) { Assert.requireNonNull(clientSession, "clientSession"); sessionMutexMap.remove(clientSession.getId()); }
public void destroy() { Object val = getDolphinSession().getAttribute(CLIENT_STORAGE_ATTRIBUTE); if(val != null && val instanceof ContextualStorage) { AbstractContext.destroyAllActive((ContextualStorage) val); } } }
@Override public String getConversationId() { return getClientSession().getId(); }