Decouple config and netconf subsystems.
[controller.git] / opendaylight / config / config-manager / src / main / java / org / opendaylight / controller / config / manager / impl / jmx / ConfigRegistryJMXRegistrator.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 package org.opendaylight.controller.config.manager.impl.jmx;
9
10 import javax.management.InstanceAlreadyExistsException;
11 import javax.management.MBeanServer;
12 import org.opendaylight.controller.config.api.jmx.ConfigRegistryMXBean;
13 import org.opendaylight.controller.config.manager.impl.ConfigRegistryImplMXBean;
14
15 /**
16  * This registrator is used only to register Config Registry to JMX.
17  *
18  */
19 public class ConfigRegistryJMXRegistrator implements AutoCloseable {
20     private final InternalJMXRegistrator internalJMXRegistrator;
21
22     public ConfigRegistryJMXRegistrator(MBeanServer configMBeanServer) {
23         internalJMXRegistrator = new InternalJMXRegistrator(configMBeanServer);
24     }
25
26     public AutoCloseable registerToJMX(ConfigRegistryImplMXBean configRegistry)
27             throws InstanceAlreadyExistsException {
28         return internalJMXRegistrator.registerMBean(configRegistry,
29                 ConfigRegistryMXBean.OBJECT_NAME);
30     }
31
32     public AutoCloseable registerToJMXNoNotifications(ConfigRegistryImplMXBean configRegistry)
33             throws InstanceAlreadyExistsException {
34         return internalJMXRegistrator.registerMBean(configRegistry,
35                 ConfigRegistryMXBean.OBJECT_NAME_NO_NOTIFICATIONS);
36     }
37
38     @Override
39     public void close() {
40         internalJMXRegistrator.close();
41     }
42 }