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.Sets;
11 import org.opendaylight.controller.config.api.DependencyResolver;
12 import org.opendaylight.controller.config.api.DependencyResolverFactory;
13 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
14 import org.opendaylight.controller.config.api.ModuleIdentifier;
15 import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
16 import org.opendaylight.controller.config.manager.testingservices.seviceinterface.TestingScheduledThreadPoolServiceInterface;
17 import org.opendaylight.controller.config.manager.testingservices.seviceinterface.TestingThreadPoolServiceInterface;
18 import org.opendaylight.controller.config.spi.Module;
19 import org.opendaylight.controller.config.spi.ModuleFactory;
20 import org.osgi.framework.BundleContext;
22 import java.util.Collections;
23 import java.util.HashSet;
26 public class TestingScheduledThreadPoolModuleFactory implements ModuleFactory {
27 public static final String NAME = "scheduled";
29 private static Set<Class<? extends AbstractServiceInterface>> ifc = Collections.unmodifiableSet(Sets.newHashSet(
30 (Class<? extends AbstractServiceInterface>) TestingScheduledThreadPoolServiceInterface.class,
31 TestingThreadPoolServiceInterface.class));
34 public boolean isModuleImplementingServiceInterface(
35 Class<? extends AbstractServiceInterface> serviceInterface) {
36 return ifc.contains(serviceInterface);
40 public String getImplementationName() {
45 public Module createModule(String instanceName,
46 DependencyResolver dependencyResolver, BundleContext bundleContext) {
47 return new TestingScheduledThreadPoolModule(new ModuleIdentifier(NAME,
48 instanceName), null, null);
52 public Module createModule(String instanceName,
53 DependencyResolver dependencyResolver, DynamicMBeanWithInstance old, BundleContext bundleContext)
55 TestingScheduledThreadPoolImpl oldInstance;
57 oldInstance = (TestingScheduledThreadPoolImpl) old.getInstance();
58 } catch (ClassCastException e) {// happens after OSGi update
62 TestingScheduledThreadPoolModule configBean = new TestingScheduledThreadPoolModule(
63 new ModuleIdentifier(NAME, instanceName), old.getInstance(),
66 configBean.setRecreate((Boolean) old.getAttribute("Recreate"));
71 public Set<Module> getDefaultModules(DependencyResolverFactory dependencyResolverFactory, BundleContext bundleContext) {
72 return new HashSet<Module>();
76 public Set<Class<? extends AbstractServiceInterface>> getImplementedServiceIntefaces() {