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 java.util.Arrays;
11 import java.util.HashSet;
12 import java.util.List;
15 import org.opendaylight.controller.config.api.DependencyResolver;
16 import org.opendaylight.controller.config.api.DependencyResolverFactory;
17 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
18 import org.opendaylight.controller.config.api.ModuleIdentifier;
19 import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
20 import org.opendaylight.controller.config.manager.testingservices.seviceinterface.ModifiableThreadPoolServiceInterface;
21 import org.opendaylight.controller.config.manager.testingservices.seviceinterface.TestingThreadPoolServiceInterface;
22 import org.opendaylight.controller.config.spi.Module;
23 import org.opendaylight.controller.config.spi.ModuleFactory;
25 public class TestingFixedThreadPoolModuleFactory implements ModuleFactory {
26 public static final String NAME = "fixed";
27 private static List<Class<? extends TestingThreadPoolServiceInterface>> ifc = Arrays
28 .asList(ModifiableThreadPoolServiceInterface.class, TestingThreadPoolServiceInterface.class);
31 public String getImplementationName() {
36 public TestingFixedThreadPoolModule createModule(String instanceName,
37 DependencyResolver dependencyResolver) {
38 return new TestingFixedThreadPoolModule(new ModuleIdentifier(NAME,
39 instanceName), null, null);
43 public Module createModule(String instanceName,
44 DependencyResolver dependencyResolver, DynamicMBeanWithInstance old)
46 int threadCount = (Integer) old.getAttribute("ThreadCount");
47 // is the instance compatible?
48 TestingFixedThreadPool oldInstance;
50 // reconfigure existing instance
51 oldInstance = (TestingFixedThreadPool) old.getInstance();
52 } catch (ClassCastException e) {
53 // old instance will be closed, new needs to be created
56 TestingFixedThreadPoolModule result = new TestingFixedThreadPoolModule(
57 new ModuleIdentifier(NAME, instanceName), old.getInstance(),
59 result.setThreadCount(threadCount);
64 public boolean isModuleImplementingServiceInterface(
65 Class<? extends AbstractServiceInterface> serviceInterface) {
66 return ifc.contains(serviceInterface);
70 public Set<Module> getDefaultModules(DependencyResolverFactory dependencyResolverFactory) {
71 return new HashSet<Module>();