Teach sal-remoterpc-connector to route actions
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / src / main / java / org / opendaylight / controller / remote / rpc / RemoteDOMRpcFuture.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.remote.rpc;
9
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.controller.remote.rpc.messages.RpcResponse;
12 import org.opendaylight.mdsal.dom.api.DOMRpcException;
13 import org.opendaylight.mdsal.dom.api.DOMRpcResult;
14 import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
15 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
16 import scala.concurrent.Future;
17
18 final class RemoteDOMRpcFuture extends AbstractRemoteFuture<DOMRpcResult, DOMRpcException> {
19     RemoteDOMRpcFuture(final @NonNull SchemaPath type, final @NonNull Future<Object> requestFuture) {
20         super(type, requestFuture);
21     }
22
23     @Override
24     DOMRpcResult processReply(final Object reply) {
25         return reply instanceof RpcResponse ? new DefaultDOMRpcResult(((RpcResponse) reply).getOutput()) : null;
26     }
27
28     @Override
29     Class<DOMRpcException> exceptionClass() {
30         return DOMRpcException.class;
31     }
32
33     @Override
34     DOMRpcException wrapCause(final Throwable cause) {
35         return new RemoteDOMRpcException("Exception during invoking RPC", cause);
36     }
37 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.