Improve NETCONF session ID handling
[netconf.git] / plugins / netconf-server-mdsal / src / main / java / org / opendaylight / netconf / mdsal / connector / MdsalNetconfOperationService.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.netconf.mdsal.connector;
9
10 import com.google.common.collect.ImmutableSet;
11 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
12 import org.opendaylight.mdsal.dom.api.DOMRpcService;
13 import org.opendaylight.netconf.mdsal.connector.ops.Commit;
14 import org.opendaylight.netconf.mdsal.connector.ops.CopyConfig;
15 import org.opendaylight.netconf.mdsal.connector.ops.DiscardChanges;
16 import org.opendaylight.netconf.mdsal.connector.ops.EditConfig;
17 import org.opendaylight.netconf.mdsal.connector.ops.Lock;
18 import org.opendaylight.netconf.mdsal.connector.ops.RuntimeRpc;
19 import org.opendaylight.netconf.mdsal.connector.ops.Unlock;
20 import org.opendaylight.netconf.mdsal.connector.ops.Validate;
21 import org.opendaylight.netconf.mdsal.connector.ops.get.Get;
22 import org.opendaylight.netconf.mdsal.connector.ops.get.GetConfig;
23 import org.opendaylight.netconf.server.api.operations.NetconfOperation;
24 import org.opendaylight.netconf.server.api.operations.NetconfOperationService;
25 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.SessionIdType;
26
27 final class MdsalNetconfOperationService implements NetconfOperationService {
28     private final ImmutableSet<NetconfOperation> operations;
29     private final TransactionProvider transactionProvider;
30
31     MdsalNetconfOperationService(final CurrentSchemaContext schemaContext, final SessionIdType sessionId,
32             final DOMDataBroker dataBroker, final DOMRpcService rpcService) {
33         transactionProvider = new TransactionProvider(dataBroker, sessionId);
34         operations = ImmutableSet.of(
35             new Commit(sessionId, transactionProvider),
36             new DiscardChanges(sessionId, transactionProvider),
37             new EditConfig(sessionId, schemaContext, transactionProvider),
38             new CopyConfig(sessionId, schemaContext, transactionProvider),
39             new Get(sessionId, schemaContext, transactionProvider),
40             new GetConfig(sessionId, schemaContext, transactionProvider),
41             new Lock(sessionId),
42             new Unlock(sessionId),
43             new RuntimeRpc(sessionId, schemaContext, rpcService),
44             new Validate(sessionId, transactionProvider));
45     }
46
47     @Override
48     public ImmutableSet<NetconfOperation> getNetconfOperations() {
49         return operations;
50     }
51
52     @Override
53     public void close() {
54         // No-op
55     }
56 }