aboutsummaryrefslogtreecommitdiffstats
path: root/common/openecomp-common-configuration-management/openecomp-configuration-management-core/src/main/java/org/openecomp/config/impl/ContextListener.java
blob: 06652c0843cd059e11d3f9f67ef802ac4b1ff4d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package org.openecomp.config.impl;

import static org.openecomp.config.Constants.MBEAN_NAME;

import java.lang.management.ManagementFactory;
import javax.management.ObjectName;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import org.openecomp.config.api.ConfigurationManager;

@WebListener
public class ContextListener implements ServletContextListener {

  @Override
  public void contextDestroyed(ServletContextEvent arg0) {
    try {
      ManagementFactory.getPlatformMBeanServer().unregisterMBean(new ObjectName(MBEAN_NAME));
    } catch (Exception exception) {
      exception.printStackTrace();
    }
  }

  @Override
  public void contextInitialized(ServletContextEvent arg0) {
    ConfigurationManager.lookup();
  }
}