2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.config.manager.impl.util;
12 import javax.management.InstanceNotFoundException;
13 import javax.management.ObjectName;
15 import org.opendaylight.controller.config.api.LookupRegistry;
17 public class LookupBeansUtil {
19 public static ObjectName lookupConfigBean(LookupRegistry lookupRegistry,
20 String moduleName, String instanceName)
21 throws InstanceNotFoundException {
22 Set<ObjectName> objectNames = lookupRegistry.lookupConfigBeans(
23 moduleName, instanceName);
24 if (objectNames.size() == 0) {
25 throw new InstanceNotFoundException("No instance found");
26 } else if (objectNames.size() > 1) {
27 throw new InstanceNotFoundException("Too many instances found");
29 return objectNames.iterator().next();