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.threadpool;
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.ModifiableThreadPoolServiceInterface;
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 TestingFixedThreadPoolModuleFactory implements ModuleFactory {
27 public static final String NAME = "fixed";
28 private static List<Class<? extends TestingThreadPoolServiceInterface>> ifc = Arrays
29 .asList(ModifiableThreadPoolServiceInterface.class, TestingThreadPoolServiceInterface.class);
32 public String getImplementationName() {
37 public TestingFixedThreadPoolModule createModule(String instanceName,
38 DependencyResolver dependencyResolver, BundleContext bundleContext) {
39 return new TestingFixedThreadPoolModule(new ModuleIdentifier(NAME,
40 instanceName), null, null);
44 public Module createModule(String instanceName,
45 DependencyResolver dependencyResolver, DynamicMBeanWithInstance old, BundleContext bundleContext)
47 int threadCount = (Integer) old.getAttribute("ThreadCount");
48 // is the instance compatible?
49 TestingFixedThreadPool oldInstance;
51 // reconfigure existing instance
52 oldInstance = (TestingFixedThreadPool) old.getInstance();
53 } catch (ClassCastException e) {
54 // old instance will be closed, new needs to be created
57 TestingFixedThreadPoolModule result = new TestingFixedThreadPoolModule(
58 new ModuleIdentifier(NAME, instanceName), old.getInstance(),
60 result.setThreadCount(threadCount);
65 public boolean isModuleImplementingServiceInterface(
66 Class<? extends AbstractServiceInterface> serviceInterface) {
67 return ifc.contains(serviceInterface);
71 public Set<Module> getDefaultModules(DependencyResolverFactory dependencyResolverFactory, BundleContext bundleContext) {
72 return new HashSet<Module>();