2 * Copyright (c) 2013, 2017 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.testingservices.scheduledthreadpool;
10 import com.google.common.collect.ImmutableSet;
11 import java.util.HashSet;
13 import org.opendaylight.controller.config.api.DependencyResolver;
14 import org.opendaylight.controller.config.api.DependencyResolverFactory;
15 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
16 import org.opendaylight.controller.config.api.ModuleIdentifier;
17 import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
18 import org.opendaylight.controller.config.manager.testingservices.seviceinterface.TestingScheduledThreadPoolServiceInterface;
19 import org.opendaylight.controller.config.manager.testingservices.seviceinterface.TestingThreadPoolServiceInterface;
20 import org.opendaylight.controller.config.spi.Module;
21 import org.opendaylight.controller.config.spi.ModuleFactory;
22 import org.osgi.framework.BundleContext;
24 public class TestingScheduledThreadPoolModuleFactory implements ModuleFactory {
25 public static final String NAME = "scheduled";
27 private static Set<Class<? extends AbstractServiceInterface>> ifc = ImmutableSet.of(
28 (Class<? extends AbstractServiceInterface>) TestingScheduledThreadPoolServiceInterface.class,
29 TestingThreadPoolServiceInterface.class);
32 public boolean isModuleImplementingServiceInterface(
33 final Class<? extends AbstractServiceInterface> serviceInterface) {
34 return ifc.contains(serviceInterface);
38 public String getImplementationName() {
43 public Module createModule(final String instanceName, final DependencyResolver dependencyResolver,
44 final BundleContext bundleContext) {
45 return new TestingScheduledThreadPoolModule(new ModuleIdentifier(NAME, instanceName), null, null);
49 public Module createModule(final String instanceName, final DependencyResolver dependencyResolver,
50 final DynamicMBeanWithInstance old, final BundleContext bundleContext) throws Exception {
51 TestingScheduledThreadPoolImpl oldInstance;
53 oldInstance = (TestingScheduledThreadPoolImpl) old.getInstance();
54 } catch (final ClassCastException e) {
55 // happens after OSGi update
59 TestingScheduledThreadPoolModule configBean = new TestingScheduledThreadPoolModule(
60 new ModuleIdentifier(NAME, instanceName), old.getInstance(), oldInstance);
62 configBean.setRecreate((Boolean) old.getAttribute("Recreate"));
67 public Set<Module> getDefaultModules(final DependencyResolverFactory dependencyResolverFactory,
68 final BundleContext bundleContext) {
69 return new HashSet<>();
73 public Set<Class<? extends AbstractServiceInterface>> getImplementedServiceIntefaces() {