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.List;
13 import org.opendaylight.controller.config.api.DependencyResolver;
14 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
15 import org.opendaylight.controller.config.api.ModuleIdentifier;
16 import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
17 import org.opendaylight.controller.config.manager.testingservices.seviceinterface.ModifiableThreadPoolServiceInterface;
18 import org.opendaylight.controller.config.manager.testingservices.seviceinterface.TestingThreadPoolServiceInterface;
19 import org.opendaylight.controller.config.spi.Module;
20 import org.opendaylight.controller.config.spi.ModuleFactory;
22 public class TestingFixedThreadPoolModuleFactory implements ModuleFactory {
23 public static final String NAME = "fixed";
24 private static List<Class<? extends TestingThreadPoolServiceInterface>> ifc = Arrays
25 .asList(ModifiableThreadPoolServiceInterface.class, TestingThreadPoolServiceInterface.class);
28 public String getImplementationName() {
33 public TestingFixedThreadPoolModule createModule(String instanceName,
34 DependencyResolver dependencyResolver) {
35 return new TestingFixedThreadPoolModule(new ModuleIdentifier(NAME,
36 instanceName), null, null);
40 public Module createModule(String instanceName,
41 DependencyResolver dependencyResolver, DynamicMBeanWithInstance old)
43 int threadCount = (Integer) old.getAttribute("ThreadCount");
44 // is the instance compatible?
45 TestingFixedThreadPool oldInstance;
47 // reconfigure existing instance
48 oldInstance = (TestingFixedThreadPool) old.getInstance();
49 } catch (ClassCastException e) {
50 // old instance will be closed, new needs to be created
53 TestingFixedThreadPoolModule result = new TestingFixedThreadPoolModule(
54 new ModuleIdentifier(NAME, instanceName), old.getInstance(),
56 result.setThreadCount(threadCount);
61 public boolean isModuleImplementingServiceInterface(
62 Class<? extends AbstractServiceInterface> serviceInterface) {
63 return ifc.contains(serviceInterface);