ref #6190 removing svn property place holder in first line of code
[cdm-vaadin.git] / src / main / java / eu / etaxonomy / cdm / vaadin / util / CdmVaadinSessionUtilities.java
index d61e382f3966415b65925eb0a2b0918ba8c6c798..51b15f31e08655b64ff64d82e79ba069773dd90f 100644 (file)
@@ -1,4 +1,3 @@
-// $Id$
 /**
 * Copyright (C) 2015 EDIT
 * European Distributed Institute of Taxonomy
@@ -9,6 +8,8 @@
 */
 package eu.etaxonomy.cdm.vaadin.util;
 
+import java.util.concurrent.locks.Lock;
+
 import org.apache.log4j.Logger;
 
 import com.vaadin.server.VaadinSession;
@@ -27,18 +28,23 @@ public class CdmVaadinSessionUtilities {
     private static final Logger logger = Logger.getLogger(CdmVaadinSessionUtilities.class);
 
     public static void setCurrentAttribute(String name, Object value) {
+        Lock sessionLock = VaadinSession.getCurrent().getLockInstance();
         try {
-            VaadinSession.getCurrent().getLockInstance().lock();
+            if(sessionLock != null) {
+                sessionLock.lock();
+            }
             VaadinSession.getCurrent().setAttribute(name, value);
         } finally {
-            VaadinSession.getCurrent().getLockInstance().unlock();
+            if(sessionLock != null) {
+                sessionLock.unlock();
+            }
         }
     }
 
     public static void initCdmDataChangeService() {
-        if(getCurrentCdmDataChangeService() != null) {
-           logger.warn("replacing data change service with new one");
-        }
+//        if(getCurrentCdmDataChangeService() != null) {
+//           logger.info("replacing data change service with new one");
+//        }
         setCurrentAttribute(CdmDataChangeService.KEY, new CdmDataChangeService());
     }
 
@@ -47,9 +53,9 @@ public class CdmVaadinSessionUtilities {
     }
 
     public static void initSelectionService() {
-        if(getCurrentSelectionService() != null) {
-            logger.warn("replacing selection service with new one");
-        }
+//        if(getCurrentSelectionService() != null) {
+//            logger.info("replacing selection service with new one");
+//        }
         setCurrentAttribute(SelectionService.KEY, new SelectionService());
     }
 
@@ -58,9 +64,9 @@ public class CdmVaadinSessionUtilities {
     }
 
     public static void initBasicEventService() {
-        if(getCurrentBasicEventService() != null) {
-            logger.warn("replacing basic event service with new one");
-        }
+//        if(getCurrentBasicEventService() != null) {
+//            logger.info("replacing basic event service with new one");
+//        }
         setCurrentAttribute(BasicEventService.KEY, new BasicEventService());
     }