2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.md.sal.dom.broker.impl;
10 import com.google.common.base.Preconditions;
11 import com.google.common.util.concurrent.CheckedFuture;
12 import java.util.List;
14 import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
15 import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
16 import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
17 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
20 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
23 final class GlobalDOMRpcRoutingTableEntry extends AbstractDOMRpcRoutingTableEntry {
24 private final DOMRpcIdentifier rpcId;
26 private GlobalDOMRpcRoutingTableEntry(final DOMRpcIdentifier rpcId,
27 final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
28 super(rpcId.getType(), impls);
29 this.rpcId = Preconditions.checkNotNull(rpcId);
32 // We do not need the RpcDefinition, but this makes sure we do not
33 // forward something we don't know to be an RPC.
34 GlobalDOMRpcRoutingTableEntry(final RpcDefinition def,
35 final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
36 super(def.getPath(), impls);
37 this.rpcId = DOMRpcIdentifier.create(def.getPath());
41 protected CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final NormalizedNode<?, ?> input) {
42 return getImplementations(YangInstanceIdentifier.EMPTY).get(0).invokeRpc(rpcId, input);
46 protected GlobalDOMRpcRoutingTableEntry newInstance(
47 final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
48 return new GlobalDOMRpcRoutingTableEntry(rpcId, impls);