X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fconfig%2Fconfig-manager%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fmanager%2Fimpl%2Fjmx%2FRootRuntimeBeanRegistratorImpl.java;fp=opendaylight%2Fconfig%2Fconfig-manager%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fmanager%2Fimpl%2Fjmx%2FRootRuntimeBeanRegistratorImpl.java;h=55bfbf56fc3a9eefd9556009ce9438abd4e514df;hb=9fb64948564e252018f9b1e13e7cea2c92f991aa;hp=0000000000000000000000000000000000000000;hpb=1742b3894614be478c333a1043ced8ef1bc5dc84;p=controller.git 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 new file mode 100644 index 0000000000..55bfbf56fc --- /dev/null +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/RootRuntimeBeanRegistratorImpl.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2013 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, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.config.manager.impl.jmx; + +import java.util.Collections; + +import javax.management.InstanceAlreadyExistsException; +import javax.management.ObjectName; + +import org.opendaylight.controller.config.api.ModuleIdentifier; +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 { + private final InternalJMXRegistrator internalJMXRegistrator; + private final ModuleIdentifier moduleIdentifier; + private final ObjectName defaultRuntimeON; + + public RootRuntimeBeanRegistratorImpl( + InternalJMXRegistrator internalJMXRegistrator, + ModuleIdentifier moduleIdentifier) { + this.internalJMXRegistrator = internalJMXRegistrator; + this.moduleIdentifier = moduleIdentifier; + defaultRuntimeON = ObjectNameUtil.createRuntimeBeanName( + moduleIdentifier.getFactoryName(), + moduleIdentifier.getInstanceName(), + Collections. emptyMap()); + } + + @Override + public HierarchicalRuntimeBeanRegistrationImpl registerRoot( + RuntimeBean mxBean) { + try { + internalJMXRegistrator.registerMBean(mxBean, defaultRuntimeON); + } catch (InstanceAlreadyExistsException e) { + throw sanitize(e, moduleIdentifier, defaultRuntimeON); + } + return new HierarchicalRuntimeBeanRegistrationImpl(moduleIdentifier, + internalJMXRegistrator, Collections. emptyMap()); + } + + @Override + public void close() { + 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); + + } +}