Migrate OSGI compendium reference
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / md / sal / dom / broker / impl / GlobalDOMRpcRoutingTableEntry.java
1 /*
2  * Copyright (c) 2015 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.md.sal.dom.broker.impl;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.util.concurrent.CheckedFuture;
13 import java.util.List;
14 import java.util.Map;
15 import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
16 import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
17 import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
18 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
21 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
22
23 @Deprecated(forRemoval = true)
24 final class GlobalDOMRpcRoutingTableEntry extends AbstractDOMRpcRoutingTableEntry {
25     private final DOMRpcIdentifier rpcId;
26
27     private GlobalDOMRpcRoutingTableEntry(final DOMRpcIdentifier rpcId,
28                                           final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
29         super(rpcId.getType(), impls);
30         this.rpcId = requireNonNull(rpcId);
31     }
32
33     // We do not need the RpcDefinition, but this makes sure we do not
34     // forward something we don't know to be an RPC.
35     GlobalDOMRpcRoutingTableEntry(final RpcDefinition def,
36                                   final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
37         super(def.getPath(), impls);
38         this.rpcId = DOMRpcIdentifier.create(def.getPath());
39     }
40
41     @Override
42     protected CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final NormalizedNode<?, ?> input) {
43         return getImplementations(YangInstanceIdentifier.empty()).get(0).invokeRpc(rpcId, input);
44     }
45
46     @Override
47     protected GlobalDOMRpcRoutingTableEntry newInstance(
48             final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
49         return new GlobalDOMRpcRoutingTableEntry(rpcId, impls);
50     }
51 }