X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.server%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fweb%2Fmvc%2FWebSlcEventListenerRegister.java;h=f01a2560decf75cd850415aa2668c2a61c0b69e4;hb=e6e892ed3c2351212e16f2f404511ff5a8ce3c98;hp=7cc6e8b9dcd89439ff68ceb6604eb41c7b7042d9;hpb=304125ea23a3570c78149816d76951bbb258707d;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/web/mvc/WebSlcEventListenerRegister.java b/runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/web/mvc/WebSlcEventListenerRegister.java index 7cc6e8b9d..f01a2560d 100644 --- a/runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/web/mvc/WebSlcEventListenerRegister.java +++ b/runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/web/mvc/WebSlcEventListenerRegister.java @@ -1,29 +1,37 @@ +/* + * Copyright (C) 2010 Mathieu Baudier + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.argeo.slc.web.mvc; import java.io.Serializable; +import java.util.ArrayList; import java.util.List; import java.util.Vector; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.slc.SlcException; -import org.argeo.slc.msg.event.SlcEvent; -import org.argeo.slc.msg.event.SlcEventListener; import org.argeo.slc.msg.event.SlcEventListenerDescriptor; import org.argeo.slc.msg.event.SlcEventListenerRegister; import org.springframework.web.context.request.RequestContextHolder; public class WebSlcEventListenerRegister implements SlcEventListenerRegister, Serializable { - private final static Log log = LogFactory - .getLog(WebSlcEventListenerRegister.class); public final static String ATTR_EVENT_LISTENER = "slcEventListener"; static final long serialVersionUID = 1l; - transient private SlcEventListener eventListener = null; - - private String clientId = null; + // private String clientId = UUID.randomUUID().toString(); /** Synchronized */ private List descriptors = new Vector(); @@ -40,47 +48,41 @@ public class WebSlcEventListenerRegister implements SlcEventListenerRegister, descriptors.remove(eventListenerDescriptor); } - // public synchronized List getDescriptorsCopy() - // { - // return new ArrayList(descriptors); - // } - - public SlcEvent listen(SlcEventListener eventListener, Long timeout) { - checkClientId(); - this.eventListener = eventListener; - return this.eventListener.listen(clientId, descriptors, timeout); - } - - public void init() { - clientId = getSessionId(); - checkClientId(); - - if (log.isDebugEnabled()) - log.debug("Initialized web event listener " + clientId); - } - - public void close() { - checkClientId(); - if (eventListener != null) - eventListener.close(clientId); - - if (log.isDebugEnabled()) - log.debug("Closed web event listener " + clientId); + public synchronized List getDescriptorsCopy() { + return new ArrayList(descriptors); } - protected void checkClientId() { - String sessionId = getSessionId(); - if (clientId == null || !clientId.equals(sessionId)) - throw new SlcException("Client id " + clientId - + " not consistent with web session id " + sessionId); - } - - protected String getSessionId() { + public String getId() { return RequestContextHolder.currentRequestAttributes().getSessionId(); } - public String getClientId() { - return clientId; - } + // public SlcEvent listen(SlcEventListener eventListener, Long timeout) { + // return eventListener.listen(clientId, getDescriptorsCopy(), timeout); + // } + // public void init() { + // clientId = getSessionId(); + // checkClientId(); + // + // if (log.isDebugEnabled()) + // log.debug("Initialized web event listener " + clientId); + // } + // + // public void close() { + // checkClientId(); + // if (log.isDebugEnabled()) + // log.debug("Closed web event listener " + clientId); + // } + + // protected void checkClientId() { + // String sessionId = getSessionId(); + // if (clientId == null || !clientId.equals(sessionId)) + // throw new SlcException("Client id " + clientId + // + " not consistent with web session id " + sessionId); + // } + // + // protected String getSessionId() { + // return RequestContextHolder.currentRequestAttributes().getSessionId(); + // } + // }