0a53d75c4006c2eed47029ebe0bc214596e915d4
[controller.git] / opendaylight / config / config-manager / src / test / java / org / opendaylight / controller / config / manager / testingservices / parallelapsp / TestingParallelAPSPModuleFactory.java
1 /*
2  * Copyright (c) 2013 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 javax.annotation.concurrent.ThreadSafe;
11 import javax.management.ObjectName;
12
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.spi.ModuleFactory;
18
19 @ThreadSafe
20 public class TestingParallelAPSPModuleFactory implements ModuleFactory {
21
22     public static final String NAME = "parallel";
23
24     @Override
25     public String getImplementationName() {
26         return NAME;
27     }
28
29     @Override
30     public TestingParallelAPSPModule createModule(String instanceName,
31             DependencyResolver dependencyResolver) {
32         return new TestingParallelAPSPModule(new ModuleIdentifier(NAME,
33                 instanceName), dependencyResolver, null, null);
34     }
35
36     @Override
37     public TestingParallelAPSPModule createModule(String instanceName,
38             DependencyResolver dependencyResolver, DynamicMBeanWithInstance old)
39             throws Exception {
40         TestingParallelAPSPImpl oldInstance;
41         try {
42             oldInstance = (TestingParallelAPSPImpl) old.getInstance();
43         } catch (ClassCastException e) {
44             oldInstance = null;
45         }
46         TestingParallelAPSPModule result = new TestingParallelAPSPModule(
47                 new ModuleIdentifier(NAME, instanceName), dependencyResolver,
48                 old.getInstance(), oldInstance);
49         // copy attributes
50         String someParam = (String) old.getAttribute("SomeParam");
51         result.setSomeParam(someParam);
52         ObjectName threadPool = (ObjectName) old.getAttribute("ThreadPool");
53         result.setThreadPool(threadPool);
54         return result;
55     }
56
57     @Override
58     public boolean isModuleImplementingServiceInterface(
59             Class<? extends AbstractServiceInterface> serviceInterface) {
60         return false;
61     }
62 }