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 {
19 private static final MethodType INVOCATION_SIGNATURE = MethodType.methodType(Future.class, RpcService.class,
22 private final MethodHandle handle;
24 RpcMethodInvokerWithInput(final MethodHandle methodHandle) {
25 this.handle = methodHandle.asType(INVOCATION_SIGNATURE);
29 @SuppressWarnings("checkstyle:illegalCatch")
30 public Future<RpcResult<?>> invokeOn(final RpcService impl, final DataObject input) {
32 return (Future<RpcResult<?>>) handle.invokeExact(impl,input);
33 } catch (Throwable e) {
34 Throwables.throwIfUnchecked(e);
35 throw new RuntimeException(e);