BUG-4514: clean children in InternalJMXRegistrator
[controller.git] / opendaylight / config / config-manager / src / main / java / org / opendaylight / controller / config / manager / impl / jmx / RootRuntimeBeanRegistratorImpl.java
index d9ee3d322582637b66699ce8b9962ce4571eac14..8bccef3b8168c6030964017a5b29ba927c8e6166 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.config.manager.impl.jmx;
 
+import com.google.common.base.Preconditions;
 import java.util.Collections;
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.ObjectName;
@@ -21,10 +22,9 @@ public class RootRuntimeBeanRegistratorImpl implements
     private final ModuleIdentifier moduleIdentifier;
     private final ObjectName defaultRuntimeON;
 
-    public RootRuntimeBeanRegistratorImpl(
-            InternalJMXRegistrator internalJMXRegistrator,
-            ModuleIdentifier moduleIdentifier) {
-        this.internalJMXRegistrator = internalJMXRegistrator;
+    RootRuntimeBeanRegistratorImpl(final InternalJMXRegistrator internalJMXRegistrator,
+            final ModuleIdentifier moduleIdentifier) {
+        this.internalJMXRegistrator = Preconditions.checkNotNull(internalJMXRegistrator);
         this.moduleIdentifier = moduleIdentifier;
         defaultRuntimeON = ObjectNameUtil.createRuntimeBeanName(
                 moduleIdentifier.getFactoryName(),
@@ -33,8 +33,7 @@ public class RootRuntimeBeanRegistratorImpl implements
     }
 
     @Override
-    public HierarchicalRuntimeBeanRegistrationImpl registerRoot(
-            RuntimeBean mxBean) {
+    public HierarchicalRuntimeBeanRegistrationImpl registerRoot(final RuntimeBean mxBean) {
         try {
             internalJMXRegistrator.registerMBean(mxBean, defaultRuntimeON);
         } catch (InstanceAlreadyExistsException e) {
@@ -49,8 +48,8 @@ public class RootRuntimeBeanRegistratorImpl implements
         internalJMXRegistrator.close();
     }
 
-    static IllegalStateException sanitize(InstanceAlreadyExistsException e,
-            ModuleIdentifier moduleIdentifier, ObjectName on) {
+    static IllegalStateException sanitize(final InstanceAlreadyExistsException e,
+            final ModuleIdentifier moduleIdentifier, final ObjectName on) {
         throw new IllegalStateException("Could not register runtime bean in "
                 + moduleIdentifier + " under name " + on, e);