X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fmanager%2Fimpl%2Fosgi%2FBundleContextBackedModuleFactoriesResolver.java;h=28f512d848f9b03fc5abbd1fc1cb7d3da7660535;hb=f43b01b81319959b1907e3e04537f5169e7f33d8;hp=e8639d588197c146483b434fd83b4fb653a32c49;hpb=ed6019236d78a69577888f60064c3714eaa80f6a;p=controller.git diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BundleContextBackedModuleFactoriesResolver.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BundleContextBackedModuleFactoriesResolver.java index e8639d5881..28f512d848 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BundleContextBackedModuleFactoriesResolver.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BundleContextBackedModuleFactoriesResolver.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, @@ -22,14 +22,11 @@ import org.slf4j.LoggerFactory; /** * Retrieves list of currently registered Module Factories using bundlecontext. */ -public class BundleContextBackedModuleFactoriesResolver implements - ModuleFactoriesResolver { - private static final Logger LOG = LoggerFactory - .getLogger(BundleContextBackedModuleFactoriesResolver.class); +public class BundleContextBackedModuleFactoriesResolver implements ModuleFactoriesResolver { + private static final Logger LOG = LoggerFactory.getLogger(BundleContextBackedModuleFactoriesResolver.class); private final BundleContext bundleContext; - public BundleContextBackedModuleFactoriesResolver( - BundleContext bundleContext) { + public BundleContextBackedModuleFactoriesResolver(final BundleContext bundleContext) { this.bundleContext = bundleContext; } @@ -37,9 +34,8 @@ public class BundleContextBackedModuleFactoriesResolver implements public Map> getAllFactories() { Collection> serviceReferences; try { - serviceReferences = bundleContext.getServiceReferences( - ModuleFactory.class, null); - } catch (InvalidSyntaxException e) { + serviceReferences = bundleContext.getServiceReferences(ModuleFactory.class, null); + } catch (final InvalidSyntaxException e) { throw new IllegalStateException(e); } Map> result = new HashMap<>(serviceReferences.size()); @@ -49,14 +45,14 @@ public class BundleContextBackedModuleFactoriesResolver implements // returned by a ServiceFactory does not // implement the classes under which it was registered or the // ServiceFactory threw an exception. - if(factory == null) { - throw new NullPointerException("ServiceReference of class" + serviceReference.getClass() + "not found."); + if (factory == null) { + throw new NullPointerException( + "ServiceReference of class" + serviceReference.getClass() + "not found."); } String moduleName = factory.getImplementationName(); if (moduleName == null || moduleName.isEmpty()) { - throw new IllegalStateException( - "Invalid implementation name for " + factory); + throw new IllegalStateException("Invalid implementation name for " + factory); } if (serviceReference.getBundle() == null || serviceReference.getBundle().getBundleContext() == null) { throw new NullPointerException("Bundle context of " + factory + " ModuleFactory not found."); @@ -65,15 +61,15 @@ public class BundleContextBackedModuleFactoriesResolver implements Map.Entry conflicting = result.get(moduleName); if (conflicting != null) { - String error = String - .format("Module name is not unique. Found two conflicting factories with same name '%s': '%s' '%s'", - moduleName, conflicting.getKey(), factory); + String error = String.format( + "Module name is not unique. Found two conflicting factories with same name '%s': '%s' '%s'", + moduleName, conflicting.getKey(), factory); LOG.error(error); throw new IllegalArgumentException(error); - } else { - result.put(moduleName, new AbstractMap.SimpleImmutableEntry<>(factory, - serviceReference.getBundle().getBundleContext())); } + + result.put(moduleName, + new AbstractMap.SimpleImmutableEntry<>(factory, serviceReference.getBundle().getBundleContext())); } return result; }