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 com.google.common.collect.ImmutableSet;
11 import java.util.HashSet;
13 import org.opendaylight.controller.config.api.DependencyResolver;
14 import org.opendaylight.controller.config.api.DependencyResolverFactory;
15 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
16 import org.opendaylight.controller.config.api.ModuleIdentifier;
17 import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
18 import org.opendaylight.controller.config.manager.testingservices.seviceinterface.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;
22 import org.osgi.framework.BundleContext;
24 public class TestingScheduledThreadPoolModuleFactory implements ModuleFactory {
25 public static final String NAME = "scheduled";
27 private static Set<Class<? extends AbstractServiceInterface>> ifc = ImmutableSet.of(
28 (Class<? extends AbstractServiceInterface>) TestingScheduledThreadPoolServiceInterface.class,
29 TestingThreadPoolServiceInterface.class);
32 public boolean isModuleImplementingServiceInterface(
33 final Class<? extends AbstractServiceInterface> serviceInterface) {
34 return ifc.contains(serviceInterface);
38 public String getImplementationName() {
43 public Module createModule(final String instanceName,
44 final DependencyResolver dependencyResolver, final BundleContext bundleContext) {
45 return new TestingScheduledThreadPoolModule(new ModuleIdentifier(NAME,
46 instanceName), null, null);
50 public Module createModule(final String instanceName,
51 final DependencyResolver dependencyResolver, final DynamicMBeanWithInstance old, final BundleContext bundleContext)
53 TestingScheduledThreadPoolImpl oldInstance;
55 oldInstance = (TestingScheduledThreadPoolImpl) old.getInstance();
56 } catch (ClassCastException e) {// happens after OSGi update
60 TestingScheduledThreadPoolModule configBean = new TestingScheduledThreadPoolModule(
61 new ModuleIdentifier(NAME, instanceName), old.getInstance(),
64 configBean.setRecreate((Boolean) old.getAttribute("Recreate"));
69 public Set<Module> getDefaultModules(final DependencyResolverFactory dependencyResolverFactory, final BundleContext bundleContext) {
70 return new HashSet<>();
74 public Set<Class<? extends AbstractServiceInterface>> getImplementedServiceIntefaces() {