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 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
18 .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;
23 public class TestingScheduledThreadPoolModuleFactory implements ModuleFactory {
24 public static final String NAME = "scheduled";
26 private static List<Class<? extends TestingThreadPoolServiceInterface>> ifc = Arrays
27 .asList(TestingScheduledThreadPoolServiceInterface.class, TestingThreadPoolServiceInterface.class);
30 public boolean isModuleImplementingServiceInterface(
31 Class<? extends AbstractServiceInterface> serviceInterface) {
32 return ifc.contains(serviceInterface);
36 public String getImplementationName() {
41 public Module createModule(String instanceName,
42 DependencyResolver dependencyResolver) {
43 return new TestingScheduledThreadPoolModule(new ModuleIdentifier(NAME,
44 instanceName), null, null);
48 public Module createModule(String instanceName,
49 DependencyResolver dependencyResolver, DynamicMBeanWithInstance old)
51 TestingScheduledThreadPoolImpl oldInstance;
53 oldInstance = (TestingScheduledThreadPoolImpl) old.getInstance();
54 } catch (ClassCastException e) {// happens after OSGi update
58 TestingScheduledThreadPoolModule configBean = new TestingScheduledThreadPoolModule(
59 new ModuleIdentifier(NAME, instanceName), old.getInstance(),
62 configBean.setRecreate((Boolean) old.getAttribute("Recreate"));