Merge "Removing { } from NormalizedNodeJsonBodyWriter"
[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 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;
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 public interface DOMRpcService extends DOMService {
24     /**
25      * Initiate invocation of an RPC. This method is guaranteed to not block on any external
26      * resources.
27      *
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
32      *         error.
33      */
34     @Nonnull CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull SchemaPath type, @Nullable NormalizedNode<?, ?> input);
35
36     /**
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      *
41      * Users should note that using a listener does not necessarily mean that {@link #invokeRpc(SchemaPath, NormalizedNode)}
42      * will not report a failure due to {@link DOMRpcImplementationNotAvailableException} and
43      * need to be ready to handle it. Implementations are encouraged to take reasonable precautions
44      * to prevent this scenario from occurring.
45      *
46      * @param listener {@link DOMRpcAvailabilityListener} instance to register
47      * @return A {@link DOMRpcAvailabilityListenerRegistration} representing this registration. Performing
48      *         a {@link DOMRpcAvailabilityListenerRegistration#close()} will cancel it. Returned object
49      *         is guaranteed to be non-null.
50      */
51     @Nonnull <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(@Nonnull T listener);
52 }