X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Fimpl%2Fconnect%2Fdom%2FBindingIndependentConnector.java;h=aaed12f740ea7224c540fdc936f544308ccb1a3e;hp=d2295c49de06871ed01719c10e29d8b9433578c8;hb=bf8cca4f590ce0a8bece21f0f1a81f6823ee3d65;hpb=065ef4acddbae75329e75562c533120d2d615efe diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java index d2295c49de..aaed12f740 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java @@ -89,6 +89,8 @@ public class BindingIndependentConnector implements // Provider, // AutoCloseable { + + private final Logger LOG = LoggerFactory.getLogger(BindingIndependentConnector.class); @SuppressWarnings( "deprecation") @@ -589,7 +591,7 @@ public class BindingIndependentConnector implements // } } catch (Exception e) { - LOG.error("Could not forward Rpcs of type {}", service.getName()); + LOG.error("Could not forward Rpcs of type {}", service.getName(),e); } registrations = ImmutableSet.of(); } @@ -721,8 +723,10 @@ public class BindingIndependentConnector implements // } else { strategy = new NoInputNoOutputInvocationStrategy(rpc,targetMethod); } + } else if(inputClass.isPresent()){ + strategy = new NoOutputInvocationStrategy(rpc,targetMethod, inputClass.get()); } else { - strategy = null; + strategy = new NoInputNoOutputInvocationStrategy(rpc,targetMethod); } return strategy; } @@ -814,6 +818,46 @@ public class BindingIndependentConnector implements // return Futures.immediateFuture(null); } } + + private class NoOutputInvocationStrategy extends RpcInvocationStrategy { + + + @SuppressWarnings("rawtypes") + private WeakReference inputClass; + + @SuppressWarnings({ "rawtypes", "unchecked" }) + public NoOutputInvocationStrategy(QName rpc, Method targetMethod, + Class inputClass) { + super(rpc,targetMethod); + this.inputClass = new WeakReference(inputClass); + } + + + @Override + public RpcResult uncheckedInvoke(RpcService rpcService, CompositeNode domInput) throws Exception { + DataContainer bindingInput = mappingService.dataObjectFromDataDom(inputClass.get(), domInput); + Future> result = (Future>) targetMethod.invoke(rpcService, bindingInput); + if (result == null) { + return Rpcs.getRpcResult(false); + } + RpcResult bindingResult = result.get(); + return Rpcs.getRpcResult(true); + } + + @Override + public Future> forwardToDomBroker(DataObject input) { + if(biRouter != null) { + CompositeNode xml = mappingService.toDataDom(input); + CompositeNode wrappedXml = ImmutableCompositeNode.create(rpc,ImmutableList.>of(xml)); + RpcResult result = biRouter.invokeRpc(rpc, wrappedXml); + Object baResultValue = null; + RpcResult baResult = Rpcs.getRpcResult(result.isSuccessful(), null, result.getErrors()); + return Futures.>immediateFuture(baResult); + } + return Futures.>immediateFuture(Rpcs.getRpcResult(false)); + } + + } public boolean isRpcForwarding() { return rpcForwarding; @@ -824,7 +868,6 @@ public class BindingIndependentConnector implements // } public boolean isNotificationForwarding() { - // TODO Auto-generated method stub return notificationForwarding; }