2 * Copyright (c) 2015 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.itm.snd;
10 import java.lang.management.ManagementFactory;
11 import javax.management.InstanceAlreadyExistsException;
12 import javax.management.MBeanRegistrationException;
13 import javax.management.MBeanServer;
14 import javax.management.MalformedObjectNameException;
15 import javax.management.NotCompliantMBeanException;
16 import javax.management.ObjectName;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 public class ITMStatusMonitor implements ITMStatusMonitorMBean {
23 private String serviceStatus;
24 private static ITMStatusMonitor itmStatusMonitor = new ITMStatusMonitor();
25 private static final String JMX_ITM_OBJ_NAME = "com.ericsson.sdncp.services.status:type=SvcItmService";
26 private static final Logger log = LoggerFactory.getLogger(ITMStatusMonitor.class);
28 private ITMStatusMonitor () {
31 public void registerMbean() {
32 MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
34 ObjectName objName = new ObjectName(JMX_ITM_OBJ_NAME);
35 mbs.registerMBean(itmStatusMonitor, objName);
36 log.info("itm MXBean registration SUCCESSFUL!!! {}", JMX_ITM_OBJ_NAME);
37 } catch (InstanceAlreadyExistsException iaeEx) {
38 log.error("itm MXBean registration FAILED with InstanceAlreadyExistsException", iaeEx);
39 } catch (MBeanRegistrationException mbrEx) {
40 log.error("itm MXBean registration FAILED with MBeanRegistrationException", mbrEx);
41 } catch (NotCompliantMBeanException ncmbEx) {
42 log.error("itm MXBean registration FAILED with NotCompliantMBeanException", ncmbEx);
43 } catch (MalformedObjectNameException monEx) {
44 log.error("itm MXBean registration failed with MalformedObjectNameException", monEx);
48 public static ITMStatusMonitor getInstance() {
49 return itmStatusMonitor;
53 public String acquireServiceStatus() {
57 public void reportStatus (String serviceStatus) {
58 this.serviceStatus = serviceStatus;