Merge "Implement cluster wide topology notifications and let routing use it"
[controller.git] / opendaylight / web / root / src / main / java / org / opendaylight / controller / web / ControllerUISessionManager.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.web;
10
11 import javax.servlet.http.HttpSessionEvent;
12 import javax.servlet.http.HttpSessionListener;
13
14 import org.opendaylight.controller.sal.utils.ServiceHelper;
15 import org.opendaylight.controller.usermanager.IUserManager;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 public class ControllerUISessionManager implements HttpSessionListener {
20
21     private static final Logger logger = LoggerFactory.getLogger(ControllerUISessionManager.class);
22
23     @Override
24     public void sessionCreated(HttpSessionEvent se) {
25         IUserManager userManager = (IUserManager) ServiceHelper.getGlobalInstance(IUserManager.class, this);
26         if (userManager != null) {
27             ((HttpSessionListener) userManager.getSessionManager()).sessionCreated(se);
28         } else {
29             logger.warn("User Manager is currently unavailable. Unable to register UI session.");
30         }
31     }
32
33     @Override
34     public void sessionDestroyed(HttpSessionEvent se) {
35         IUserManager userManager = (IUserManager) ServiceHelper.getGlobalInstance(IUserManager.class, this);
36         if (userManager != null) {
37             ((HttpSessionListener) userManager.getSessionManager()).sessionDestroyed(se);
38         } else {
39             logger.warn("User Manager is currently unavailable. Unable to destroy UI session.");
40         }
41     }
42
43 }