Add blueprint wiring to sal-distributed-datastore
[controller.git] / opendaylight / md-sal / sal-common-util / src / main / java / org / opendaylight / controller / md / sal / common / util / jmx / AbstractMXBean.java
index a2db29d1e81c3d3e505a117bb93cefdd27faf9dc..40e1bd35fcad9ab2a3312130435d39c271c0888f 100644 (file)
@@ -8,8 +8,8 @@
 
 package org.opendaylight.controller.md.sal.common.util.jmx;
 
+import com.google.common.annotations.Beta;
 import java.lang.management.ManagementFactory;
-
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import javax.management.InstanceNotFoundException;
@@ -17,12 +17,9 @@ import javax.management.MBeanRegistrationException;
 import javax.management.MBeanServer;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.annotations.Beta;
-
 /**
  * Abstract base for an MXBean implementation class.
  * <p>
@@ -72,6 +69,14 @@ public abstract class AbstractMXBean {
         return new ObjectName(builder.toString());
     }
 
+    /**
+     * This method is a wrapper for registerMBean with void return type so it can be invoked by dependency
+     * injection frameworks such as Spring and Blueprint.
+     */
+    public void register() {
+        registerMBean();
+    }
+
     /**
      * Registers this bean with the platform MBean server with the domain defined by
      * {@link #BASE_JMX_PREFIX}.
@@ -110,6 +115,14 @@ public abstract class AbstractMXBean {
         return registered;
     }
 
+    /**
+     * This method is a wrapper for unregisterMBean with void return type so it can be invoked by dependency
+     * injection frameworks such as Spring and Blueprint.
+     */
+    public void unregister() {
+        unregisterMBean();
+    }
+
     /**
      * Unregisters this bean with the platform MBean server.
      *
@@ -122,8 +135,7 @@ public abstract class AbstractMXBean {
             unregisterMBean(mbeanName);
             unregister = true;
         } catch(Exception e) {
-
-            LOG.error("Failed when unregistering MBean {}", e);
+            LOG.debug("Failed when unregistering MBean {}", e);
         }
 
         return unregister;