Bump versions 9.0.4-SNAPSHOT
[controller.git] / opendaylight / md-sal / sal-common-util / src / main / java / org / opendaylight / controller / md / sal / common / util / jmx / AbstractMXBean.java
index d60623aba09a279e688b255d97855a3fb1cae9b8..53d7a2f22a95b65d003a4a2d7e836bc100162143 100644 (file)
@@ -5,13 +5,9 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 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.InstanceAlreadyExistsException;
 import javax.management.InstanceNotFoundException;
 import javax.management.MBeanRegistrationException;
@@ -19,6 +15,8 @@ import javax.management.MBeanServer;
 import javax.management.MalformedObjectNameException;
 import javax.management.NotCompliantMBeanException;
 import javax.management.ObjectName;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -33,12 +31,10 @@ import org.slf4j.LoggerFactory;
  *
  * @author Thomas Pantelis
  */
-@Beta
 public abstract class AbstractMXBean {
-
     private static final Logger LOG = LoggerFactory.getLogger(AbstractMXBean.class);
 
-    public static String BASE_JMX_PREFIX = "org.opendaylight.controller:";
+    public static final String BASE_JMX_PREFIX = "org.opendaylight.controller:";
 
     private final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
 
@@ -53,7 +49,7 @@ public abstract class AbstractMXBean {
      * @param beanType Used as the <code>type</code> property in the bean's ObjectName.
      * @param beanCategory Used as the <code>Category</code> property in the bean's ObjectName.
      */
-    protected AbstractMXBean(@Nonnull String beanName, @Nonnull String beanType,
+    protected AbstractMXBean(@NonNull String beanName, @NonNull String beanType,
             @Nullable String beanCategory) {
         this.beanName = beanName;
         this.beanType = beanType;
@@ -90,7 +86,7 @@ public abstract class AbstractMXBean {
         boolean registered = false;
         try {
             // Object to identify MBean
-            final ObjectName mbeanName = this.getMBeanObjectName();
+            final ObjectName mbeanName = getMBeanObjectName();
 
             LOG.debug("Register MBean {}", mbeanName);
 
@@ -102,7 +98,7 @@ public abstract class AbstractMXBean {
                 try {
                     unregisterMBean(mbeanName);
                 } catch (MBeanRegistrationException | InstanceNotFoundException e) {
-                    LOG.warn("unregister mbean {} resulted in exception {} ", mbeanName, e);
+                    LOG.warn("unregister mbean {} resulted in exception", mbeanName, e);
                 }
             }
             server.registerMBean(this, mbeanName);
@@ -111,7 +107,7 @@ public abstract class AbstractMXBean {
             LOG.debug("MBean {} registered successfully", mbeanName.getCanonicalName());
         } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException
                 | MalformedObjectNameException e) {
-            LOG.error("registration failed {}", e);
+            LOG.error("registration failed", e);
         }
         return registered;
     }
@@ -130,16 +126,13 @@ public abstract class AbstractMXBean {
      * @return true is successfully unregistered, false otherwise.
      */
     public boolean unregisterMBean() {
-        boolean unregister = false;
         try {
-            ObjectName mbeanName = this.getMBeanObjectName();
-            unregisterMBean(mbeanName);
-            unregister = true;
+            unregisterMBean(getMBeanObjectName());
+            return true;
         } catch (MBeanRegistrationException | InstanceNotFoundException | MalformedObjectNameException e) {
-            LOG.debug("Failed when unregistering MBean {}", e);
+            LOG.debug("Failed when unregistering MBean", e);
+            return false;
         }
-
-        return unregister;
     }
 
     private void unregisterMBean(ObjectName mbeanName) throws MBeanRegistrationException,