Adjust to yangtools-2.0.0/odlparent-3.0.0 changes
[netconf.git] / netconf / tools / netconf-testtool / src / main / java / org / opendaylight / netconf / test / tool / customrpc / SettableOperationProvider.java
1 /*
2  * Copyright (c) 2016 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
9 package org.opendaylight.netconf.test.tool.customrpc;
10
11 import java.io.File;
12 import java.util.Collections;
13 import java.util.Set;
14 import org.opendaylight.controller.config.util.capability.Capability;
15 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
16 import org.opendaylight.netconf.mapping.api.NetconfOperation;
17 import org.opendaylight.netconf.mapping.api.NetconfOperationService;
18 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
19
20 public class SettableOperationProvider implements NetconfOperationServiceFactory {
21
22     private final File rpcConfig;
23
24     public SettableOperationProvider(final File rpcConfig) {
25         this.rpcConfig = rpcConfig;
26     }
27
28     @Override
29     public Set<Capability> getCapabilities() {
30         return Collections.emptySet();
31     }
32
33     @Override
34     public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
35         return () -> {
36             //no op
37         };
38     }
39
40     @Override
41     public NetconfOperationService createService(final String netconfSessionIdForReporting) {
42         return new SettableOperationService(rpcConfig);
43     }
44
45     private static class SettableOperationService implements NetconfOperationService {
46
47         private final SettableRpc rpc;
48
49         SettableOperationService(final File rpcConfig) {
50             this.rpc = new SettableRpc(rpcConfig);
51         }
52
53         @Override
54         public Set<NetconfOperation> getNetconfOperations() {
55             return Collections.singleton(rpc);
56         }
57
58         @Override
59         public void close() {
60             // no op
61         }
62     }
63 }