Initial code drop of yang model driven configuration system
[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
13 import org.opendaylight.controller.config.api.jmx.ConfigRegistryMXBean;
14 import org.opendaylight.controller.config.manager.impl.ConfigRegistryImplMXBean;
15
16 /**
17  * This registrator is used only to register Config Registry to JMX.
18  *
19  */
20 public class ConfigRegistryJMXRegistrator implements AutoCloseable {
21     private final InternalJMXRegistrator internalJMXRegistrator;
22
23     public ConfigRegistryJMXRegistrator(MBeanServer configMBeanServer) {
24         internalJMXRegistrator = new InternalJMXRegistrator(configMBeanServer);
25     }
26
27     public AutoCloseable registerToJMX(ConfigRegistryImplMXBean configRegistry)
28             throws InstanceAlreadyExistsException {
29         return internalJMXRegistrator.registerMBean(configRegistry,
30                 ConfigRegistryMXBean.OBJECT_NAME);
31     }
32
33     @Override
34     public void close() {
35         internalJMXRegistrator.close();
36     }
37 }