Refactor DOMYangTextSourceProvider
[mdsal.git] / dom / mdsal-dom-api / src / main / java / org / opendaylight / mdsal / dom / api / DOMRpcService.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.mdsal.dom.api;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.yangtools.concepts.Registration;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
15
16 /**
17  * A {@link DOMService} which allows clients to invoke RPCs. The conceptual model of this service is that of a dynamic
18  * router, where the set of available RPC services can change dynamically. The service allows users to add a listener
19  * to track the process of RPCs becoming available.
20  */
21 // FIXME: once we have a DOMOperationService implementation, deprecate this interface
22 public interface DOMRpcService extends DOMService<DOMRpcService, DOMRpcService.Extension> {
23     /**
24      * Marker interface for an extension to {@link DOMRpcService}.
25      */
26     interface Extension extends DOMService.Extension<DOMRpcService, Extension> {
27         // Marker interface
28     }
29
30     /**
31      * Initiate invocation of an RPC. This method is guaranteed to not block on any external
32      * resources.
33      *
34      * @param type QName of the RPC to be invoked
35      * @param input Input arguments, null if the RPC does not take any.
36      * @return A {@link ListenableFuture} which will return either a result structure, or report a subclass
37      *         of {@link DOMRpcException} reporting a transport error.
38      */
39     @NonNull ListenableFuture<? extends DOMRpcResult> invokeRpc(@NonNull QName type, @NonNull ContainerNode input);
40
41     /**
42      * Register a {@link DOMRpcAvailabilityListener} with this service to receive notifications
43      * about RPC implementations becoming (un)available. The listener will be invoked with the
44      * current implementations reported and will be kept uptodate as implementations come and go.
45      * Users should note that using a listener does not necessarily mean that
46      * {@link #invokeRpc(QName, ContainerNode)} will not report a failure due to
47      * {@link DOMRpcImplementationNotAvailableException} and need to be ready to handle it.
48      * Implementations are encouraged to take reasonable precautions to prevent this scenario from
49      * occurring.
50      *
51      * @param listener {@link DOMRpcAvailabilityListener} instance to register
52      * @return A {@link Registration} representing this registration. Performing a {@link Registration#close()} will
53      *         cancel it. Returned object is guaranteed to be non-null.
54      */
55     @NonNull Registration registerRpcListener(@NonNull DOMRpcAvailabilityListener listener);
56 }