3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.vaadin
.util
;
12 import java
.util
.concurrent
.locks
.Lock
;
14 import org
.apache
.log4j
.Logger
;
16 import com
.vaadin
.server
.VaadinSession
;
18 import eu
.etaxonomy
.cdm
.vaadin
.session
.BasicEventService
;
19 import eu
.etaxonomy
.cdm
.vaadin
.session
.CdmDataChangeService
;
20 import eu
.etaxonomy
.cdm
.vaadin
.session
.SelectionService
;
27 public class CdmVaadinSessionUtilities
{
29 private static final Logger logger
= Logger
.getLogger(CdmVaadinSessionUtilities
.class);
31 public static void setCurrentAttribute(String name
, Object value
) {
32 Lock sessionLock
= VaadinSession
.getCurrent().getLockInstance();
34 if(sessionLock
!= null) {
37 VaadinSession
.getCurrent().setAttribute(name
, value
);
39 if(sessionLock
!= null) {
45 public static void initCdmDataChangeService() {
46 if(getCurrentCdmDataChangeService() != null) {
47 logger
.info("replacing data change service with new one");
49 setCurrentAttribute(CdmDataChangeService
.KEY
, new CdmDataChangeService());
52 public static CdmDataChangeService
getCurrentCdmDataChangeService() {
53 return (CdmDataChangeService
) VaadinSession
.getCurrent().getAttribute(CdmDataChangeService
.KEY
);
56 public static void initSelectionService() {
57 if(getCurrentSelectionService() != null) {
58 logger
.info("replacing selection service with new one");
60 setCurrentAttribute(SelectionService
.KEY
, new SelectionService());
63 public static SelectionService
getCurrentSelectionService() {
64 return (SelectionService
) VaadinSession
.getCurrent().getAttribute(SelectionService
.KEY
);
67 public static void initBasicEventService() {
68 if(getCurrentBasicEventService() != null) {
69 logger
.info("replacing basic event service with new one");
71 setCurrentAttribute(BasicEventService
.KEY
, new BasicEventService());
74 public static BasicEventService
getCurrentBasicEventService() {
75 return (BasicEventService
) VaadinSession
.getCurrent().getAttribute(BasicEventService
.KEY
);