-// $Id$
/**
* Copyright (C) 2015 EDIT
* European Distributed Institute of Taxonomy
*/
package eu.etaxonomy.cdm.vaadin.util;
+import java.util.concurrent.locks.Lock;
+
import org.apache.log4j.Logger;
import com.vaadin.server.VaadinSession;
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.info("replacing data change service with new one");
- }
+// if(getCurrentCdmDataChangeService() != null) {
+// logger.info("replacing data change service with new one");
+// }
setCurrentAttribute(CdmDataChangeService.KEY, new CdmDataChangeService());
}
}
public static void initSelectionService() {
- if(getCurrentSelectionService() != null) {
- logger.info("replacing selection service with new one");
- }
+// if(getCurrentSelectionService() != null) {
+// logger.info("replacing selection service with new one");
+// }
setCurrentAttribute(SelectionService.KEY, new SelectionService());
}
}
public static void initBasicEventService() {
- if(getCurrentBasicEventService() != null) {
- logger.info("replacing basic event service with new one");
- }
+// if(getCurrentBasicEventService() != null) {
+// logger.info("replacing basic event service with new one");
+// }
setCurrentAttribute(BasicEventService.KEY, new BasicEventService());
}