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.ListenableFuture;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.eclipse.jdt.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 service is that of a dynamic
19 * router, where the set of available RPC services can change dynamically. The service allows users to add a listener
20 * to track the process of RPCs becoming available.
22 // FIXME: once we have a DOMOperationService implementation, deprecate this interface
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 ListenableFuture} which will return either a result structure, or report a subclass
31 * of {@link DOMRpcException} reporting a transport error.
33 // FIXME: 5.0.0: do not allow null input
34 @NonNull ListenableFuture<DOMRpcResult> 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.
40 * Users should note that using a listener does not necessarily mean that
41 * {@link #invokeRpc(SchemaPath, NormalizedNode)} will not report a failure due to
42 * {@link DOMRpcImplementationNotAvailableException} and need to be ready to handle it.
43 * Implementations are encouraged to take reasonable precautions to prevent this scenario from
46 * @param listener {@link DOMRpcAvailabilityListener} instance to register
47 * @return A {@link ListenerRegistration} representing this registration. Performing a
48 * {@link ListenerRegistration#close()} will cancel it. Returned object is guaranteed to be non-null.
50 @NonNull <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(@NonNull T listener);