netty-timer-config: final parameters
[controller.git] / opendaylight / config / shutdown-impl / src / main / java / org / opendaylight / controller / config / yang / shutdown / impl / ShutdownModuleFactory.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.config.yang.shutdown.impl;
9
10 import java.util.Arrays;
11 import java.util.Set;
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;
17
18 public class ShutdownModuleFactory extends AbstractShutdownModuleFactory {
19
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);
25     }
26
27
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);
32     }
33
34     @Override
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));
40     }
41 }