X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fbinding%2Fimpl%2FRpcServiceAdapter.java;h=51a4280f5cb895de78b77f427e07b7f9b326f110;hb=4dab19f89e79f43d3b270072f7260128788804ff;hp=5e24c90b192b928d2e192a147de57939d61b9267;hpb=a2c12f815301c4351bebe5ce1370017ba657c503;p=controller.git diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/RpcServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/RpcServiceAdapter.java index 5e24c90b19..51a4280f5c 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/RpcServiceAdapter.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/RpcServiceAdapter.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.md.sal.binding.impl; import com.google.common.base.Preconditions; @@ -19,16 +18,19 @@ import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.Collection; import java.util.Map.Entry; +import java.util.concurrent.Future; import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; import org.opendaylight.controller.md.sal.dom.broker.spi.rpc.RpcRoutingStrategy; +import org.opendaylight.controller.sal.core.compat.LegacyDOMRpcResultFutureAdapter; +import org.opendaylight.mdsal.binding.dom.adapter.BindingRpcFutureAware; import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; +import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; import org.opendaylight.yangtools.yang.binding.DataContainer; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.RpcService; -import org.opendaylight.yangtools.yang.binding.util.BindingReflections; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity; @@ -66,8 +68,14 @@ class RpcServiceAdapter implements InvocationHandler { ListenableFuture> invoke0(final SchemaPath schemaPath, final NormalizedNode input) { final CheckedFuture result = delegate.invokeRpc(schemaPath, input); - if (result instanceof LazyDOMRpcResultFuture) { - return ((LazyDOMRpcResultFuture) result).getBindingFuture(); + if (result instanceof BindingRpcFutureAware) { + return ((BindingRpcFutureAware) result).getBindingFuture(); + } else if (result instanceof LegacyDOMRpcResultFutureAdapter) { + Future delegateFuture = + ((LegacyDOMRpcResultFutureAdapter)result).delegate(); + if (delegateFuture instanceof BindingRpcFutureAware) { + return ((BindingRpcFutureAware) delegateFuture).getBindingFuture(); + } } return transformFuture(schemaPath, result, codec.getCodecFactory()); @@ -86,11 +94,11 @@ class RpcServiceAdapter implements InvocationHandler { } @Override - public Object invoke(final Object proxyObj, final Method method, final Object[] args) throws Throwable { + public Object invoke(final Object proxyObj, final Method method, final Object[] args) { final RpcInvocationStrategy rpc = rpcNames.get(method); if (rpc != null) { - if (method.getParameterTypes().length == 0) { + if (method.getParameterCount() == 0) { return rpc.invokeEmpty(); } if (args.length != 1) { @@ -108,11 +116,11 @@ class RpcServiceAdapter implements InvocationHandler { private static boolean isObjectMethod(final Method method) { switch (method.getName()) { case "toString": - return method.getReturnType().equals(String.class) && method.getParameterTypes().length == 0; + return method.getReturnType().equals(String.class) && method.getParameterCount() == 0; case "hashCode": - return method.getReturnType().equals(int.class) && method.getParameterTypes().length == 0; + return method.getReturnType().equals(int.class) && method.getParameterCount() == 0; case "equals": - return method.getReturnType().equals(boolean.class) && method.getParameterTypes().length == 1 && method + return method.getReturnType().equals(boolean.class) && method.getParameterCount() == 1 && method .getParameterTypes()[0] == Object.class; default: return false; @@ -146,7 +154,7 @@ class RpcServiceAdapter implements InvocationHandler { // DOMRpcResult does not have a notion of success, hence we have to reverse-engineer it by looking // at reported errors and checking whether they are just warnings. - final Collection errors = input.getErrors(); + final Collection errors = input.getErrors(); return RpcResult.class.cast(RpcResultBuilder.status(errors.stream() .noneMatch(error -> error.getSeverity() == ErrorSeverity.ERROR)) .withResult(bindingResult).withRpcErrors(errors).build());