2 * Copyright (c) 2014 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.yang.shutdown.impl;
10 import java.util.Arrays;
12 import org.opendaylight.controller.config.api.DependencyResolver;
13 import org.opendaylight.controller.config.api.DependencyResolverFactory;
14 import org.opendaylight.controller.config.api.ModuleIdentifier;
15 import org.osgi.framework.Bundle;
16 import org.osgi.framework.BundleContext;
18 public class ShutdownModuleFactory extends AbstractShutdownModuleFactory {
20 public ShutdownModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
21 ShutdownModule oldModule, AutoCloseable oldInstance,
22 BundleContext bundleContext) {
23 Bundle systemBundle = bundleContext.getBundle(0);
24 return new ShutdownModule(new ModuleIdentifier(NAME, instanceName), oldModule, oldInstance, systemBundle);
28 public ShutdownModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
29 BundleContext bundleContext) {
30 Bundle systemBundle = bundleContext.getBundle(0);
31 return new ShutdownModule(new ModuleIdentifier(NAME, instanceName), systemBundle);
35 public Set<ShutdownModule> getDefaultModules(DependencyResolverFactory dependencyResolverFactory, BundleContext bundleContext) {
36 ModuleIdentifier id = new ModuleIdentifier(NAME, NAME);
37 DependencyResolver dependencyResolver = dependencyResolverFactory.createDependencyResolver(id);
38 ShutdownModule shutdownModule = instantiateModule(NAME, dependencyResolver, bundleContext);
39 return new java.util.HashSet<>(Arrays.asList(shutdownModule));