@Override
@SuppressWarnings("checkstyle:hiddenField")
- public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
-
+ public Object invoke(final Object proxy, final Method method, final Object[] args) {
final RpcInvocationStrategy rpc = rpcNames.get(method);
if (rpc != null) {
- if (method.getParameterCount() == 0) {
- return rpc.invokeEmpty();
- }
if (args.length != 1) {
throw new IllegalArgumentException("Input must be provided.");
}
abstract ContainerNode serialize(DataObject input);
- final ListenableFuture<RpcResult<?>> invokeEmpty() {
- return invoke0(rpcName, null);
- }
-
final SchemaPath getRpcName() {
return rpcName;
}
ListenableFuture<RpcResult<?>> invoke0(final SchemaPath schemaPath, final ContainerNode input) {
- final ListenableFuture<DOMRpcResult> result = delegate.invokeRpc(schemaPath, input);
+ final ListenableFuture<? extends DOMRpcResult> result = delegate.invokeRpc(schemaPath, input);
if (ENABLE_CODEC_SHORTCUT && result instanceof BindingRpcFutureAware) {
return ((BindingRpcFutureAware) result).getBindingFuture();
}
}
private ListenableFuture<RpcResult<?>> transformFuture(final SchemaPath rpc,
- final ListenableFuture<DOMRpcResult> domFuture, final BindingNormalizedNodeSerializer resultCodec) {
+ final ListenableFuture<? extends DOMRpcResult> domFuture,
+ final BindingNormalizedNodeSerializer resultCodec) {
return Futures.transform(domFuture, input -> {
final NormalizedNode<?, ?> domData = input.getResult();
final DataObject bindingResult;
import com.google.common.util.concurrent.ListenableFuture;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
/**
* @return A {@link ListenableFuture} which will return either a result structure,
* or report a subclass of {@link DOMRpcException} reporting a transport
* error.
+ * @throws NullPointerException if any argument is null
*/
- // FIXME: 6.0.0: do not allow null input
- @NonNull ListenableFuture<DOMRpcResult> invokeRpc(@NonNull DOMRpcIdentifier rpc,
- @Nullable NormalizedNode<?, ?> input);
+ @NonNull ListenableFuture<? extends DOMRpcResult> invokeRpc(@NonNull DOMRpcIdentifier rpc,
+ @NonNull NormalizedNode<?, ?> input);
/**
* Return the relative invocation cost of this implementation. Default implementation return 0.
import com.google.common.util.concurrent.ListenableFuture;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
* @return A {@link ListenableFuture} which will return either a result structure, or report a subclass
* of {@link DOMRpcException} reporting a transport error.
*/
- // FIXME: 6.0.0: do not allow null input
- @NonNull ListenableFuture<DOMRpcResult> invokeRpc(@NonNull SchemaPath type, @Nullable NormalizedNode<?, ?> input);
+ @NonNull ListenableFuture<? extends DOMRpcResult> invokeRpc(@NonNull SchemaPath type,
+ @NonNull NormalizedNode<?, ?> input);
/**
* Register a {@link DOMRpcAvailabilityListener} with this service to receive notifications
new DOMActionNotAvailableException("No implementation of Action %s available", type));
}
- return OperationInvocation.invoke(entry, type, path, input);
+ return OperationInvocation.invoke(entry, type, path, requireNonNull(input));
}
}
private final class RpcServiceFacade implements DOMRpcService {
@Override
- public ListenableFuture<DOMRpcResult> invokeRpc(final SchemaPath type, final NormalizedNode<?, ?> input) {
+ public ListenableFuture<? extends DOMRpcResult> invokeRpc(final SchemaPath type,
+ final NormalizedNode<?, ?> input) {
final AbstractDOMRpcRoutingTableEntry entry = (AbstractDOMRpcRoutingTableEntry) routingTable.getEntry(type);
if (entry == null) {
return Futures.immediateFailedFuture(
new DOMRpcImplementationNotAvailableException("No implementation of RPC %s available", type));
}
- return OperationInvocation.invoke(entry, input);
+ return OperationInvocation.invoke(entry, requireNonNull(input));
}
@Override
return entry.getImplementations(path).get(0).invokeAction(type, path, input);
}
- static ListenableFuture<DOMRpcResult> invoke(final AbstractDOMRpcRoutingTableEntry entry,
+ static ListenableFuture<? extends DOMRpcResult> invoke(final AbstractDOMRpcRoutingTableEntry entry,
final NormalizedNode<?, ?> input) {
if (entry instanceof UnknownDOMRpcRoutingTableEntry) {
return Futures.immediateFailedFuture(
new DOMRpcImplementationNotAvailableException("Unsupported RPC entry."));
}
- private static ListenableFuture<DOMRpcResult> invokeRoutedRpc(final RoutedDOMRpcRoutingTableEntry entry,
- final NormalizedNode<?, ?> input) {
+ private static ListenableFuture<? extends DOMRpcResult> invokeRoutedRpc(
+ final RoutedDOMRpcRoutingTableEntry entry, final NormalizedNode<?, ?> input) {
final Optional<NormalizedNode<?, ?>> maybeKey = NormalizedNodes.findNode(input,
entry.getRpcId().getContextReference());
entry.getType()));
}
- private static ListenableFuture<DOMRpcResult> invokeGlobalRpc(final GlobalDOMRpcRoutingTableEntry entry,
- final NormalizedNode<?, ?> input) {
+ private static ListenableFuture<? extends DOMRpcResult> invokeGlobalRpc(
+ final GlobalDOMRpcRoutingTableEntry entry, final NormalizedNode<?, ?> input) {
return entry.getImplementations(YangInstanceIdentifier.empty()).get(0).invokeRpc(entry.getRpcId(), input);
}
}
*/
package org.opendaylight.mdsal.dom.broker;
+import static java.util.Objects.requireNonNull;
import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode;
import com.google.common.util.concurrent.FluentFuture;
private static final class TestRpcImplementation implements DOMRpcImplementation {
private final FluentFuture<DOMRpcResult> unknownRpc;
- private TestRpcImplementation() {
+ TestRpcImplementation() {
unknownRpc = FluentFutures.immediateFailedFluentFuture(
new DOMRpcImplementationNotAvailableException(EXCEPTION_TEXT));
}
@Override
public FluentFuture<DOMRpcResult> invokeRpc(final DOMRpcIdentifier rpc, final NormalizedNode<?, ?> input) {
+ requireNonNull(input);
return unknownRpc;
}
}
protected abstract @NonNull DOMRpcImplementation delegate();
@Override
- public ListenableFuture<DOMRpcResult> invokeRpc(final DOMRpcIdentifier type, final NormalizedNode<?, ?> input) {
+ public ListenableFuture<? extends DOMRpcResult> invokeRpc(final DOMRpcIdentifier type,
+ final NormalizedNode<?, ?> input) {
return delegate().invokeRpc(type, input);
}
}
protected abstract @NonNull DOMRpcService delegate();
@Override
- public ListenableFuture<DOMRpcResult> invokeRpc(final SchemaPath type, final NormalizedNode<?, ?> input) {
+ public ListenableFuture<? extends DOMRpcResult> invokeRpc(final SchemaPath type, final NormalizedNode<?, ?> input) {
return delegate().invokeRpc(type, input);
}