2 * Copyright (c) 2013 Cisco 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.yangtools.yang.binding.util;
10 import com.google.common.base.Throwables;
11 import java.lang.invoke.MethodHandle;
12 import java.lang.invoke.MethodType;
13 import java.util.concurrent.Future;
14 import org.opendaylight.yangtools.yang.binding.DataObject;
15 import org.opendaylight.yangtools.yang.binding.RpcService;
16 import org.opendaylight.yangtools.yang.common.RpcResult;
18 class RpcMethodInvokerWithInput extends RpcMethodInvoker {
20 private static final MethodType INVOCATION_SIGNATURE =
21 MethodType.methodType(Future.class, RpcService.class, DataObject.class);
22 private final MethodHandle handle;
24 RpcMethodInvokerWithInput(MethodHandle methodHandle) {
25 this.handle = methodHandle.asType(INVOCATION_SIGNATURE);
29 public Future<RpcResult<?>> invokeOn(RpcService impl, DataObject input) {
31 return (Future<RpcResult<?>>) handle.invokeExact(impl,input);
32 } catch (Throwable e) {
33 throw Throwables.propagate(e);