X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fdom%2Fbroker%2Fimpl%2FSchemaAwareRpcBroker.java;h=22319abb17df7d1dec301105a59c50fad2cb1164;hp=28d5ae914fc686a8cd41032755b77db529f9a85b;hb=1f2754487ab1e3a37c830909806f90cd54180c7b;hpb=4467f6e1ac869d390b607db90cd7e540118a4c6e diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareRpcBroker.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareRpcBroker.java index 28d5ae914f..22319abb17 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareRpcBroker.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareRpcBroker.java @@ -19,6 +19,7 @@ import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener import org.opendaylight.controller.md.sal.common.impl.routing.RoutingUtils; import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration; import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration; +import org.opendaylight.controller.sal.core.api.RoutedRpcDefaultImplementation; import org.opendaylight.controller.sal.core.api.RpcImplementation; import org.opendaylight.controller.sal.core.api.RpcRegistrationListener; import org.opendaylight.controller.sal.core.api.RpcRoutingContext; @@ -44,7 +45,7 @@ import org.slf4j.LoggerFactory; import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; -public class SchemaAwareRpcBroker implements RpcRouter, Identifiable { +public class SchemaAwareRpcBroker implements RpcRouter, Identifiable, RoutedRpcDefaultImplementation { private static final Logger LOG = LoggerFactory.getLogger(SchemaAwareRpcBroker.class); @@ -58,6 +59,7 @@ public class SchemaAwareRpcBroker implements RpcRouter, Identifiable { private final ConcurrentMap implementations = new ConcurrentHashMap<>(); private RpcImplementation defaultImplementation; private SchemaContextProvider schemaProvider; + private RoutedRpcDefaultImplementation defaultDelegate; public SchemaAwareRpcBroker(String identifier, SchemaContextProvider schemaProvider) { super(); @@ -81,7 +83,16 @@ public class SchemaAwareRpcBroker implements RpcRouter, Identifiable { this.schemaProvider = schemaProvider; } + public RoutedRpcDefaultImplementation getRoutedRpcDefaultDelegate() { + return defaultDelegate; + } + @Override + public void setRoutedRpcDefaultDelegate(RoutedRpcDefaultImplementation defaultDelegate) { + this.defaultDelegate = defaultDelegate; + } + + @Override public RoutedRpcRegistration addRoutedRpcImplementation(QName rpcType, RpcImplementation implementation) { checkArgument(rpcType != null, "RPC Type should not be null"); checkArgument(implementation != null, "RPC Implementatoin should not be null"); @@ -221,6 +232,12 @@ public class SchemaAwareRpcBroker implements RpcRouter, Identifiable { return ret; } + @Override + public RpcResult invokeRpc(QName rpc, InstanceIdentifier identifier, CompositeNode input) { + checkState(defaultDelegate != null); + return defaultDelegate.invokeRpc(rpc, identifier, input); + } + private static abstract class RoutingStrategy implements Identifiable { private final QName identifier; @@ -304,6 +321,7 @@ public class SchemaAwareRpcBroker implements RpcRouter, Identifiable { SimpleNode routeContainer = inputContainer.getFirstSimpleByName(strategy.getLeaf()); checkArgument(routeContainer != null, "Leaf %s must be set with value", strategy.getLeaf()); Object route = routeContainer.getValue(); + checkArgument(route instanceof InstanceIdentifier); RpcImplementation potential = null; if (route != null) { RoutedRpcRegImpl potentialReg = implementations.get(route); @@ -312,7 +330,7 @@ public class SchemaAwareRpcBroker implements RpcRouter, Identifiable { } } if (potential == null) { - potential = defaultDelegate; + return router.invokeRpc(rpc, (InstanceIdentifier) route, input); } checkState(potential != null, "No implementation is available for rpc:%s path:%s", rpc, route); return potential.invokeRpc(rpc, input);