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.mdsal.dom.api;
10 import com.google.common.util.concurrent.CheckedFuture;
11 import javax.annotation.Nonnull;
12 import javax.annotation.Nullable;
13 import org.opendaylight.yangtools.concepts.ListenerRegistration;
14 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
15 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
18 * A {@link DOMService} which allows clients to invoke RPCs. The conceptual model of this
19 * service is that of a dynamic router, where the set of available RPC services can change
20 * dynamically. The service allows users to add a listener to track the process of
21 * RPCs becoming available.
23 public interface DOMRpcService extends DOMService {
25 * Initiate invocation of an RPC. This method is guaranteed to not block on any external
28 * @param type SchemaPath of the RPC to be invoked
29 * @param input Input arguments, null if the RPC does not take any.
30 * @return A {@link CheckedFuture} which will return either a result structure,
31 * or report a subclass of {@link DOMRpcException} reporting a transport
34 @Nonnull CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull SchemaPath type, @Nullable NormalizedNode<?, ?> input);
37 * Register a {@link DOMRpcAvailabilityListener} with this service to receive notifications
38 * about RPC implementations becoming (un)available. The listener will be invoked with the
39 * current implementations reported and will be kept uptodate as implementations come and go.
41 * Users should note that using a listener does not necessarily mean that
42 * {@link #invokeRpc(SchemaPath, NormalizedNode)} will not report a failure due to
43 * {@link DOMRpcImplementationNotAvailableException} and need to be ready to handle it.
44 * Implementations are encouraged to take reasonable precautions to prevent this scenario from
47 * @param listener {@link DOMRpcAvailabilityListener} instance to register
48 * @return A {@link ListenerRegistration} representing this registration. Performing a
49 * {@link ListenerRegistration#close()} will cancel it. Returned object is guaranteed to
52 @Nonnull <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(@Nonnull T listener);