2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
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
8 package org.opendaylight.vpnservice.interfacemgr.statusanddiag;
10 import java.lang.management.ManagementFactory;
12 import javax.management.InstanceAlreadyExistsException;
13 import javax.management.MBeanRegistrationException;
14 import javax.management.MBeanServer;
15 import javax.management.MalformedObjectNameException;
16 import javax.management.NotCompliantMBeanException;
17 import javax.management.ObjectName;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
22 public class InterfaceStatusMonitor implements InterfaceStatusMonitorMBean{
24 private String serviceStatus;
25 private static InterfaceStatusMonitor interfaceStatusMonitor = new InterfaceStatusMonitor();
26 private static final String JMX_INTERFACE_OBJ_NAME = "com.ericsson.sdncp.services.status:type=SvcInterfaceService";
27 private static final Logger log = LoggerFactory.getLogger(InterfaceStatusMonitor.class);
29 private InterfaceStatusMonitor () {
32 public void registerMbean() {
33 MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
35 ObjectName objName = new ObjectName(JMX_INTERFACE_OBJ_NAME);
36 log.debug("MXBean Object-Name framed");
37 mbs.registerMBean(interfaceStatusMonitor, objName);
38 log.info("MXBean registration SUCCESSFUL!!! {}", JMX_INTERFACE_OBJ_NAME);
39 } catch (InstanceAlreadyExistsException iaeEx) {
40 log.error("MXBean registration FAILED with InstanceAlreadyExistsException", iaeEx);
41 } catch (MBeanRegistrationException mbrEx) {
42 log.error("MXBean registration FAILED with MBeanRegistrationException", mbrEx);
43 } catch (NotCompliantMBeanException ncmbEx) {
44 log.error("MXBean registration FAILED with NotCompliantMBeanException", ncmbEx);
45 } catch (MalformedObjectNameException monEx) {
46 log.error("MXBean registration failed with MalformedObjectNameException", monEx);
50 public static InterfaceStatusMonitor getInstance() {
51 return interfaceStatusMonitor;
55 public String acquireServiceStatus() {
59 public void reportStatus (String serviceStatus) {
60 this.serviceStatus = serviceStatus;