4f4f99027d147eb73c2c514c4c34591a9de73039
[controller.git] / opendaylight / config / config-manager / src / main / java / org / opendaylight / controller / config / manager / impl / jmx / InternalJMXRegistration.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 com.google.common.base.Preconditions;
11 import javax.management.ObjectName;
12
13 final class InternalJMXRegistration implements AutoCloseable {
14     private final InternalJMXRegistrator internalJMXRegistrator;
15     private final ObjectName on;
16
17     InternalJMXRegistration(final InternalJMXRegistrator internalJMXRegistrator, final ObjectName on) {
18         this.internalJMXRegistrator = Preconditions.checkNotNull(internalJMXRegistrator);
19         this.on = on;
20     }
21
22     @Override
23     public void close() {
24         internalJMXRegistrator.unregisterMBean(on);
25     }
26 }