private static Map<QName, MethodHandle> createInvokerMap( final Class<? extends NotificationListener> key) { final Builder<QName, MethodHandle> ret = ImmutableMap.<QName, MethodHandle>builder(); for (final Method method : key.getMethods()) { if (BindingReflections.isNotificationCallback(method)) { final Class<?> notification = method.getParameterTypes()[0]; final QName name = BindingReflections.findQName(notification); MethodHandle handle; try { handle = LOOKUP .unreflect(method) .asType( MethodType.methodType( void.class, NotificationListener.class, DataContainer.class)); ret.put(name, handle); } catch (final IllegalAccessException e) { throw new IllegalStateException("Can not access public method.", e); } } } return ret.build(); }
/** * Creates RPCServiceInvoker for specified RpcService type * * @param type RpcService interface, which was generated from model. * @return Cached instance of {@link NotificationListenerInvoker} for supplied RPC type. */ public static NotificationListenerInvoker from(final Class<? extends NotificationListener> type) { Preconditions.checkArgument(type.isInterface()); Preconditions.checkArgument(BindingReflections.isBindingClass(type)); return INVOKERS.getUnchecked(type); }