X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fmanager%2Fimpl%2Fjmx%2FRootRuntimeBeanRegistratorImpl.java;h=e84d2ee953efdc2c46bd8e4ee465500fac146653;hp=d9ee3d322582637b66699ce8b9962ce4571eac14;hb=f43b01b81319959b1907e3e04537f5169e7f33d8;hpb=d70f418d19fa09b1efc8fa4ce4ed35f0cf59b73b diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/RootRuntimeBeanRegistratorImpl.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/RootRuntimeBeanRegistratorImpl.java index d9ee3d3225..e84d2ee953 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/RootRuntimeBeanRegistratorImpl.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/RootRuntimeBeanRegistratorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -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; @@ -15,33 +16,28 @@ import org.opendaylight.controller.config.api.jmx.ObjectNameUtil; import org.opendaylight.controller.config.api.runtime.RootRuntimeBeanRegistrator; import org.opendaylight.controller.config.api.runtime.RuntimeBean; -public class RootRuntimeBeanRegistratorImpl implements - RootRuntimeBeanRegistrator { +public class RootRuntimeBeanRegistratorImpl implements RootRuntimeBeanRegistrator { private final InternalJMXRegistrator internalJMXRegistrator; 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(), - moduleIdentifier.getInstanceName(), - Collections. emptyMap()); + defaultRuntimeON = ObjectNameUtil.createRuntimeBeanName(moduleIdentifier.getFactoryName(), + moduleIdentifier.getInstanceName(), Collections.emptyMap()); } @Override - public HierarchicalRuntimeBeanRegistrationImpl registerRoot( - RuntimeBean mxBean) { + public HierarchicalRuntimeBeanRegistrationImpl registerRoot(final RuntimeBean mxBean) { try { internalJMXRegistrator.registerMBean(mxBean, defaultRuntimeON); - } catch (InstanceAlreadyExistsException e) { + } catch (final InstanceAlreadyExistsException e) { throw sanitize(e, moduleIdentifier, defaultRuntimeON); } - return new HierarchicalRuntimeBeanRegistrationImpl(moduleIdentifier, - internalJMXRegistrator, Collections. emptyMap()); + return new HierarchicalRuntimeBeanRegistrationImpl(moduleIdentifier, internalJMXRegistrator, + Collections.emptyMap()); } @Override @@ -49,10 +45,9 @@ public class RootRuntimeBeanRegistratorImpl implements internalJMXRegistrator.close(); } - static IllegalStateException sanitize(InstanceAlreadyExistsException e, - ModuleIdentifier moduleIdentifier, ObjectName on) { - throw new IllegalStateException("Could not register runtime bean in " - + moduleIdentifier + " under name " + on, e); - + static IllegalStateException sanitize(final InstanceAlreadyExistsException exception, + final ModuleIdentifier moduleIdentifier, final ObjectName on) { + throw new IllegalStateException("Could not register runtime bean in " + moduleIdentifier + " under name " + on, + exception); } }