2 * Copyright (c) 2014 Brocade Communications 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.controller.sal.restconf.rpc.impl;
10 import java.util.concurrent.ExecutionException;
12 import javax.ws.rs.core.Response.Status;
14 import org.opendaylight.controller.sal.core.api.mount.MountInstance;
15 import org.opendaylight.controller.sal.restconf.impl.ResponseException;
16 import org.opendaylight.yangtools.yang.common.RpcResult;
17 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
18 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
20 import com.google.common.base.Preconditions;
21 import com.google.common.util.concurrent.ListenableFuture;
24 * Provides an implementation which invokes rpc methods via a mounted yang data model.
28 public class MountPointRpcExecutor extends AbstractRpcExecutor {
29 private final MountInstance mountPoint;
31 public MountPointRpcExecutor(RpcDefinition rpcDef, MountInstance mountPoint) {
33 this.mountPoint = mountPoint;
34 Preconditions.checkNotNull( mountPoint, "MountInstance can not be null." );
38 public RpcResult<CompositeNode> invokeRpc( CompositeNode rpcRequest ) throws ResponseException {
39 ListenableFuture<RpcResult<CompositeNode>> rpcFuture =
40 mountPoint.rpc( getRpcDefinition().getQName(), rpcRequest);
42 return rpcFuture.get();
43 } catch (InterruptedException | ExecutionException e) {
44 throw new ResponseException(Status.INTERNAL_SERVER_ERROR,
45 e.getCause().getMessage() );