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.testingservices.scheduledthreadpool;
10 import org.opendaylight.controller.config.api.DependencyResolver;
11 import org.opendaylight.controller.config.api.DependencyResolverFactory;
12 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
13 import org.opendaylight.controller.config.api.ModuleIdentifier;
14 import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
15 import org.opendaylight.controller.config.manager.testingservices.seviceinterface.TestingScheduledThreadPoolServiceInterface;
16 import org.opendaylight.controller.config.manager.testingservices.seviceinterface.TestingThreadPoolServiceInterface;
17 import org.opendaylight.controller.config.spi.Module;
18 import org.opendaylight.controller.config.spi.ModuleFactory;
19 import org.osgi.framework.BundleContext;
21 import java.util.Arrays;
22 import java.util.HashSet;
23 import java.util.List;
26 public class TestingScheduledThreadPoolModuleFactory implements ModuleFactory {
27 public static final String NAME = "scheduled";
29 private static List<Class<? extends TestingThreadPoolServiceInterface>> ifc = Arrays
30 .asList(TestingScheduledThreadPoolServiceInterface.class, TestingThreadPoolServiceInterface.class);
33 public boolean isModuleImplementingServiceInterface(
34 Class<? extends AbstractServiceInterface> serviceInterface) {
35 return ifc.contains(serviceInterface);
39 public String getImplementationName() {
44 public Module createModule(String instanceName,
45 DependencyResolver dependencyResolver, BundleContext bundleContext) {
46 return new TestingScheduledThreadPoolModule(new ModuleIdentifier(NAME,
47 instanceName), null, null);
51 public Module createModule(String instanceName,
52 DependencyResolver dependencyResolver, DynamicMBeanWithInstance old, BundleContext bundleContext)
54 TestingScheduledThreadPoolImpl oldInstance;
56 oldInstance = (TestingScheduledThreadPoolImpl) old.getInstance();
57 } catch (ClassCastException e) {// happens after OSGi update
61 TestingScheduledThreadPoolModule configBean = new TestingScheduledThreadPoolModule(
62 new ModuleIdentifier(NAME, instanceName), old.getInstance(),
65 configBean.setRecreate((Boolean) old.getAttribute("Recreate"));
70 public Set<Module> getDefaultModules(DependencyResolverFactory dependencyResolverFactory, BundleContext bundleContext) {
71 return new HashSet<Module>();