Fix checkstyle issues to enforce it
[controller.git] / opendaylight / config / config-manager / src / test / java / org / opendaylight / controller / config / manager / testingservices / parallelapsp / TestingParallelAPSPModuleFactory.java
1 /*
2  * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.config.manager.testingservices.parallelapsp;
9
10 import java.util.Collections;
11 import java.util.HashSet;
12 import java.util.Set;
13 import javax.annotation.concurrent.ThreadSafe;
14 import javax.management.ObjectName;
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.spi.Module;
21 import org.opendaylight.controller.config.spi.ModuleFactory;
22 import org.osgi.framework.BundleContext;
23
24 @ThreadSafe
25 public class TestingParallelAPSPModuleFactory implements ModuleFactory {
26
27     public static final String NAME = "parallel";
28
29     @Override
30     public String getImplementationName() {
31         return NAME;
32     }
33
34     @Override
35     public TestingParallelAPSPModule createModule(final String instanceName,
36             final DependencyResolver dependencyResolver, final BundleContext bundleContext) {
37         return new TestingParallelAPSPModule(new ModuleIdentifier(NAME, instanceName), dependencyResolver, null, null);
38     }
39
40     @Override
41     public TestingParallelAPSPModule createModule(final String instanceName,
42             final DependencyResolver dependencyResolver, final DynamicMBeanWithInstance old,
43             final BundleContext context) throws Exception {
44         TestingParallelAPSPImpl oldInstance;
45         try {
46             oldInstance = (TestingParallelAPSPImpl) old.getInstance();
47         } catch (final ClassCastException e) {
48             oldInstance = null;
49         }
50         TestingParallelAPSPModule result = new TestingParallelAPSPModule(new ModuleIdentifier(NAME, instanceName),
51                 dependencyResolver, old.getInstance(), oldInstance);
52         // copy attributes
53         String someParam = (String) old.getAttribute("SomeParam");
54         result.setSomeParam(someParam);
55         ObjectName threadPool = (ObjectName) old.getAttribute("ThreadPool");
56         result.setThreadPool(threadPool);
57         return result;
58     }
59
60     @Override
61     public boolean isModuleImplementingServiceInterface(
62             final Class<? extends AbstractServiceInterface> serviceInterface) {
63         return false;
64     }
65
66     @Override
67     public Set<Module> getDefaultModules(final DependencyResolverFactory dependencyResolverFactory,
68             final BundleContext context) {
69         return new HashSet<>();
70     }
71
72     @Override
73     public Set<Class<? extends AbstractServiceInterface>> getImplementedServiceIntefaces() {
74         return Collections.emptySet();
75     }
76 }