X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-common-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fcommon%2Futil%2Fjmx%2FAbstractMXBean.java;h=53d7a2f22a95b65d003a4a2d7e836bc100162143;hb=8cd71c8e5e09003ecf37c1161429cd8f3f156ce9;hp=d60623aba09a279e688b255d97855a3fb1cae9b8;hpb=6cf8d0045fd9f41dc6fbb32ebee2fc8c2dcf78e2;p=controller.git diff --git a/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/md/sal/common/util/jmx/AbstractMXBean.java b/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/md/sal/common/util/jmx/AbstractMXBean.java index d60623aba0..53d7a2f22a 100644 --- a/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/md/sal/common/util/jmx/AbstractMXBean.java +++ b/opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/md/sal/common/util/jmx/AbstractMXBean.java @@ -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 type property in the bean's ObjectName. * @param beanCategory Used as the Category 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,