2 * Copyright (C) 2015 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.cdm
.vaadin
.util
;
11 import java
.util
.concurrent
.locks
.Lock
;
13 import org
.apache
.log4j
.Logger
;
15 import com
.vaadin
.server
.VaadinSession
;
17 import eu
.etaxonomy
.cdm
.vaadin
.session
.BasicEventService
;
18 import eu
.etaxonomy
.cdm
.vaadin
.session
.CdmDataChangeService
;
19 import eu
.etaxonomy
.cdm
.vaadin
.session
.SelectionService
;
26 public class CdmVaadinSessionUtilities
{
28 private static final Logger logger
= Logger
.getLogger(CdmVaadinSessionUtilities
.class);
30 public static void setCurrentAttribute(String name
, Object value
) {
31 Lock sessionLock
= VaadinSession
.getCurrent().getLockInstance();
33 if(sessionLock
!= null) {
36 VaadinSession
.getCurrent().setAttribute(name
, value
);
38 if(sessionLock
!= null) {
44 public static void initCdmDataChangeService() {
45 // if(getCurrentCdmDataChangeService() != null) {
46 // logger.info("replacing data change service with new one");
48 setCurrentAttribute(CdmDataChangeService
.KEY
, new CdmDataChangeService());
51 public static CdmDataChangeService
getCurrentCdmDataChangeService() {
52 return (CdmDataChangeService
) VaadinSession
.getCurrent().getAttribute(CdmDataChangeService
.KEY
);
55 public static void initSelectionService() {
56 // if(getCurrentSelectionService() != null) {
57 // logger.info("replacing selection service with new one");
59 setCurrentAttribute(SelectionService
.KEY
, new SelectionService());
62 public static SelectionService
getCurrentSelectionService() {
63 return (SelectionService
) VaadinSession
.getCurrent().getAttribute(SelectionService
.KEY
);
66 public static void initBasicEventService() {
67 // if(getCurrentBasicEventService() != null) {
68 // logger.info("replacing basic event service with new one");
70 setCurrentAttribute(BasicEventService
.KEY
, new BasicEventService());
73 public static BasicEventService
getCurrentBasicEventService() {
74 return (BasicEventService
) VaadinSession
.getCurrent().getAttribute(BasicEventService
.KEY
);