private void removeDestructionCallback(String name) { synchronized (getSessionMutex()) { this.attributes.remove(DESTRUCTION_CALLBACK_NAME_PREFIX + name); } }
/** * Invoked when the session is completed. Executed completion callbacks. */ public void sessionCompleted() { synchronized (getSessionMutex()) { if (!isSessionCompleted()) { executeDestructionCallbacks(); this.attributes.put(SESSION_COMPLETED_NAME, Boolean.TRUE); } } }
/** * Register a callback to execute on destruction of the specified attribute. * The callback is executed when the session is closed. * @param name the name of the attribute to register the callback for * @param callback the destruction callback to be executed */ public void registerDestructionCallback(String name, Runnable callback) { synchronized (getSessionMutex()) { if (isSessionCompleted()) { throw new IllegalStateException("Session id=" + getSessionId() + " already completed"); } this.attributes.put(DESTRUCTION_CALLBACK_NAME_PREFIX + name, callback); } }
@Override @Nullable public Object remove(String name) { SimpAttributes simpAttributes = SimpAttributesContextHolder.currentAttributes(); synchronized (simpAttributes.getSessionMutex()) { Object value = simpAttributes.getAttribute(name); if (value != null) { simpAttributes.removeAttribute(name); return value; } else { return null; } } }
@Override public Object get(String name, ObjectFactory<?> objectFactory) { SimpAttributes simpAttributes = SimpAttributesContextHolder.currentAttributes(); Object scopedObject = simpAttributes.getAttribute(name); if (scopedObject != null) { return scopedObject; } synchronized (simpAttributes.getSessionMutex()) { scopedObject = simpAttributes.getAttribute(name); if (scopedObject == null) { scopedObject = objectFactory.getObject(); simpAttributes.setAttribute(name, scopedObject); } return scopedObject; } }
@Test public void getSessionMutex() { assertThat(this.simpAttributes.getSessionMutex(), sameInstance(this.map)); }
@Test public void getSessionMutexExplicit() { Object mutex = new Object(); this.simpAttributes.setAttribute(SimpAttributes.SESSION_MUTEX_NAME, mutex); assertThat(this.simpAttributes.getSessionMutex(), sameInstance(mutex)); }
private void removeDestructionCallback(String name) { synchronized (getSessionMutex()) { this.attributes.remove(DESTRUCTION_CALLBACK_NAME_PREFIX + name); } }
/** * Register a callback to execute on destruction of the specified attribute. * The callback is executed when the session is closed. * @param name the name of the attribute to register the callback for * @param callback the destruction callback to be executed */ public void registerDestructionCallback(String name, Runnable callback) { synchronized (getSessionMutex()) { if (isSessionCompleted()) { throw new IllegalStateException("Session id=" + getSessionId() + " already completed"); } this.attributes.put(DESTRUCTION_CALLBACK_NAME_PREFIX + name, callback); } }
/** * Invoked when the session is completed. Executed completion callbacks. */ public void sessionCompleted() { synchronized (getSessionMutex()) { if (!isSessionCompleted()) { executeDestructionCallbacks(); this.attributes.put(SESSION_COMPLETED_NAME, Boolean.TRUE); } } }
@Override @Nullable public Object remove(String name) { SimpAttributes simpAttributes = SimpAttributesContextHolder.currentAttributes(); synchronized (simpAttributes.getSessionMutex()) { Object value = simpAttributes.getAttribute(name); if (value != null) { simpAttributes.removeAttribute(name); return value; } else { return null; } } }
@Override public Object get(String name, ObjectFactory<?> objectFactory) { SimpAttributes simpAttributes = SimpAttributesContextHolder.currentAttributes(); Object scopedObject = simpAttributes.getAttribute(name); if (scopedObject != null) { return scopedObject; } synchronized (simpAttributes.getSessionMutex()) { scopedObject = simpAttributes.getAttribute(name); if (scopedObject == null) { scopedObject = objectFactory.getObject(); simpAttributes.setAttribute(name, scopedObject); } return scopedObject; } }
private void removeDestructionCallback(String name) { synchronized (getSessionMutex()) { this.attributes.remove(DESTRUCTION_CALLBACK_NAME_PREFIX + name); } }
private void removeDestructionCallback(String name) { synchronized (getSessionMutex()) { this.attributes.remove(DESTRUCTION_CALLBACK_NAME_PREFIX + name); } }
/** * Register a callback to execute on destruction of the specified attribute. * The callback is executed when the session is closed. * @param name the name of the attribute to register the callback for * @param callback the destruction callback to be executed */ public void registerDestructionCallback(String name, Runnable callback) { synchronized (getSessionMutex()) { if (isSessionCompleted()) { throw new IllegalStateException("Session id=" + getSessionId() + " already completed"); } this.attributes.put(DESTRUCTION_CALLBACK_NAME_PREFIX + name, callback); } }
/** * Invoked when the session is completed. Executed completion callbacks. */ public void sessionCompleted() { synchronized (getSessionMutex()) { if (!isSessionCompleted()) { executeDestructionCallbacks(); this.attributes.put(SESSION_COMPLETED_NAME, Boolean.TRUE); } } }
/** * Register a callback to execute on destruction of the specified attribute. * The callback is executed when the session is closed. * @param name the name of the attribute to register the callback for * @param callback the destruction callback to be executed */ public void registerDestructionCallback(String name, Runnable callback) { synchronized (getSessionMutex()) { if (isSessionCompleted()) { throw new IllegalStateException("Session id=" + getSessionId() + " already completed"); } this.attributes.put(DESTRUCTION_CALLBACK_NAME_PREFIX + name, callback); } }
/** * Invoked when the session is completed. Executed completion callbacks. */ public void sessionCompleted() { synchronized (getSessionMutex()) { if (!isSessionCompleted()) { executeDestructionCallbacks(); this.attributes.put(SESSION_COMPLETED_NAME, Boolean.TRUE); } } }
@Override @Nullable public Object remove(String name) { SimpAttributes simpAttributes = SimpAttributesContextHolder.currentAttributes(); synchronized (simpAttributes.getSessionMutex()) { Object value = simpAttributes.getAttribute(name); if (value != null) { simpAttributes.removeAttribute(name); return value; } else { return null; } } }
@Override public Object get(String name, ObjectFactory<?> objectFactory) { SimpAttributes simpAttributes = SimpAttributesContextHolder.currentAttributes(); Object scopedObject = simpAttributes.getAttribute(name); if (scopedObject != null) { return scopedObject; } synchronized (simpAttributes.getSessionMutex()) { scopedObject = simpAttributes.getAttribute(name); if (scopedObject == null) { scopedObject = objectFactory.getObject(); simpAttributes.setAttribute(name, scopedObject); } return scopedObject; } }