1 /* 2 * Copyright 2002-2017 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 module hunt.stomp.simp.SimpSessionScope; 18 19 // import hunt.framework.beans.factory.ObjectFactory; 20 // import hunt.framework.beans.factory.config.Scope; 21 22 23 // /** 24 // * A {@link Scope} implementation exposing the attributes of a SiMP session 25 // * (e.g. WebSocket session). 26 // * 27 // * <p>Relies on a thread-bound {@link SimpAttributes} instance exported by 28 // * {@link hunt.stomp.simp.annotation.SimpAnnotationMethodMessageHandler}. 29 // * 30 // * @author Rossen Stoyanchev 31 // * @since 4.1 32 // */ 33 // class SimpSessionScope : Scope { 34 35 // override 36 // Object get(string name, ObjectFactory<?> objectFactory) { 37 // SimpAttributes simpAttributes = SimpAttributesContextHolder.currentAttributes(); 38 // Object scopedObject = simpAttributes.getAttribute(name); 39 // if (scopedObject !is null) { 40 // return scopedObject; 41 // } 42 // synchronized (simpAttributes.getSessionMutex()) { 43 // scopedObject = simpAttributes.getAttribute(name); 44 // if (scopedObject is null) { 45 // scopedObject = objectFactory.getObject(); 46 // simpAttributes.setAttribute(name, scopedObject); 47 // } 48 // return scopedObject; 49 // } 50 // } 51 52 // override 53 54 // Object remove(string name) { 55 // SimpAttributes simpAttributes = SimpAttributesContextHolder.currentAttributes(); 56 // synchronized (simpAttributes.getSessionMutex()) { 57 // Object value = simpAttributes.getAttribute(name); 58 // if (value !is null) { 59 // simpAttributes.removeAttribute(name); 60 // return value; 61 // } 62 // else { 63 // return null; 64 // } 65 // } 66 // } 67 68 // override 69 // void registerDestructionCallback(string name, Runnable callback) { 70 // SimpAttributesContextHolder.currentAttributes().registerDestructionCallback(name, callback); 71 // } 72 73 // override 74 75 // Object resolveContextualObject(string key) { 76 // return null; 77 // } 78 79 // override 80 // string getConversationId() { 81 // return SimpAttributesContextHolder.currentAttributes().getSessionId(); 82 // } 83 84 // }