Integrate netconf-mapping-api into netconf-server
[netconf.git] / netconf / tools / netconf-testtool / src / main / java / org / opendaylight / netconf / test / tool / rpchandler / SettableOperationRpcProvider.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 package org.opendaylight.netconf.test.tool.rpchandler;
9
10 import java.util.Set;
11 import org.opendaylight.netconf.api.capability.Capability;
12 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
13 import org.opendaylight.netconf.server.api.operations.NetconfOperation;
14 import org.opendaylight.netconf.server.api.operations.NetconfOperationService;
15 import org.opendaylight.netconf.server.api.operations.NetconfOperationServiceFactory;
16 import org.opendaylight.yangtools.concepts.Registration;
17
18 public class SettableOperationRpcProvider implements NetconfOperationServiceFactory {
19     private final RpcHandler rpcHandler;
20
21     public SettableOperationRpcProvider(final RpcHandler rpcHandler) {
22         this.rpcHandler = rpcHandler;
23     }
24
25     @Override
26     public Set<Capability> getCapabilities() {
27         return Set.of();
28     }
29
30     @Override
31     public Registration registerCapabilityListener(final CapabilityListener listener) {
32         return () -> { };
33     }
34
35     @Override
36     public NetconfOperationService createService(final String netconfSessionIdForReporting) {
37         return new SettableOperationService(rpcHandler);
38     }
39
40     private static class SettableOperationService implements NetconfOperationService {
41         private final SettableRpc rpc;
42
43         SettableOperationService(final RpcHandler rpcHandler) {
44             rpc = new SettableRpc(rpcHandler);
45         }
46
47         @Override
48         public Set<NetconfOperation> getNetconfOperations() {
49             return Set.of(rpc);
50         }
51
52         @Override
53         public void close() {
54             // no op
55         }
56     }
57 }