Reduce JSR305 proliferation
[controller.git] / opendaylight / md-sal / sal-dom-api / src / main / java / org / opendaylight / controller / md / sal / 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.controller.md.sal.dom.api;
9
10 import com.google.common.util.concurrent.CheckedFuture;
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;
16
17 /**
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.
22  *
23  * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMRpcService} instead
24  */
25 @Deprecated
26 public interface DOMRpcService extends DOMService {
27     /**
28      * Initiate invocation of an RPC. This method is guaranteed to not block on any external
29      * resources.
30      *
31      * @param type SchemaPath of the RPC to be invoked
32      * @param input Input arguments, null if the RPC does not take any.
33      * @return A {@link CheckedFuture} which will return either a result structure,
34      *         or report a subclass of {@link DOMRpcException} reporting a transport
35      *         error.
36      */
37     @NonNull CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@NonNull SchemaPath type,
38             @Nullable NormalizedNode<?, ?> input);
39
40     /**
41      * Register a {@link DOMRpcAvailabilityListener} with this service to receive notifications
42      * about RPC implementations becoming (un)available. The listener will be invoked with the
43      * current implementations reported and will be kept uptodate as implementations come and go.
44      *
45      * <p>
46      * Users should note that using a listener does not necessarily mean that
47      * {@link #invokeRpc(SchemaPath, NormalizedNode)} will not report a failure due to
48      * {@link DOMRpcImplementationNotAvailableException} and need to be ready to handle it.
49      *
50      * <p>
51      * Implementations of this interface are encouraged to take reasonable precautions to prevent this scenario from
52      * occurring.
53      *
54      * @param listener {@link DOMRpcAvailabilityListener} instance to register
55      * @return A {@link ListenerRegistration} representing this registration. Performing
56      *         a {@link ListenerRegistration#close()} will cancel it. Returned object
57      *         is guaranteed to be non-null.
58      */
59     @NonNull <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(@NonNull T listener);
60 }