Convert blueprint extensions to MDSAL APIs 82/73382/3
authorTom Pantelis <tompantelis@gmail.com>
Sat, 23 Jun 2018 20:00:09 +0000 (16:00 -0400)
committerTom Pantelis <tompantelis@gmail.com>
Mon, 25 Jun 2018 13:32:13 +0000 (09:32 -0400)
Change-Id: Iabbdb2654128f0f473abba224b8c51745a6d2092
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
opendaylight/blueprint/pom.xml
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/AbstractInvokableServiceMetadata.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/ActionProviderBean.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/ActionServiceMetadata.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/NotificationListenerBean.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/OpendaylightNamespaceHandler.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RpcImplementationBean.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RpcServiceMetadata.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RpcUtil.java

index ceebb5b..b6753ac 100644 (file)
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-core-spi</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.mdsal</groupId>
+      <artifactId>mdsal-binding-api</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.mdsal</groupId>
       <artifactId>mdsal-binding-dom-codec</artifactId>
index 3bd7c5e..30ee9aa 100644 (file)
@@ -14,12 +14,12 @@ import java.util.Collection;
 import java.util.Set;
 import java.util.function.Predicate;
 import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
-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.binding.api.RpcProviderRegistry;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener;
+import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
+import org.opendaylight.mdsal.dom.api.DOMRpcService;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
+import org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -30,7 +30,7 @@ abstract class AbstractInvokableServiceMetadata extends AbstractDependentCompone
     private final String interfaceName;
 
     private ListenerRegistration<DOMRpcAvailabilityListener> rpcListenerReg;
-    private RpcProviderRegistry rpcRegistry;
+    private RpcConsumerRegistry rpcRegistry;
     private Class<RpcService> rpcInterface;
     private Set<SchemaPath> rpcSchemaPaths;
 
@@ -67,12 +67,12 @@ abstract class AbstractInvokableServiceMetadata extends AbstractDependentCompone
     @Override
     protected final void startTracking() {
         // Request RpcProviderRegistry first ...
-        retrieveService("RpcProviderRegistry", RpcProviderRegistry.class, this::onRpcRegistry);
+        retrieveService("RpcConsumerRegistry", RpcConsumerRegistry.class, this::onRpcRegistry);
     }
 
     private void onRpcRegistry(final Object service) {
         log.debug("{}: Retrieved RpcProviderRegistry {}", logName(), service);
-        rpcRegistry = (RpcProviderRegistry)service;
+        rpcRegistry = (RpcConsumerRegistry)service;
 
         // Now acquire SchemaService...
         retrieveService("SchemaService", DOMSchemaService.class, this::onSchemaService);
index d2d3ddc..1a0c712 100644 (file)
@@ -12,12 +12,12 @@ import com.google.common.collect.ImmutableSet;
 import com.google.common.util.concurrent.Futures;
 import java.util.Collection;
 import java.util.Set;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
-import org.opendaylight.controller.md.sal.dom.broker.spi.rpc.RpcRoutingStrategy;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException;
+import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
+import org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
@@ -32,7 +32,7 @@ import org.slf4j.LoggerFactory;
  *
  * <p>
  * This bean has two distinct facets:
- * - if a reference bean is provided, it registers it with {@link RpcProviderRegistry}
+ * - if a reference bean is provided, it registers it with {@link RpcProviderService}
  * - if a reference bean is not provided, it registers the corresponding no-op implementation with
  *   {@link DOMRpcProviderService} for all action (Routed RPC) elements in the provided interface
  *
@@ -43,8 +43,8 @@ public class ActionProviderBean {
 
     private static final Logger LOG = LoggerFactory.getLogger(ActionProviderBean.class);
 
-    private DOMRpcProviderService rpcProviderService;
-    private RpcProviderRegistry rpcRegistry;
+    private DOMRpcProviderService domRpcProvider;
+    private RpcProviderService bindingRpcProvider;
     private DOMSchemaService schemaService;
     private RpcService implementation;
     private String interfaceName;
@@ -63,12 +63,12 @@ public class ActionProviderBean {
         this.implementation = implementation;
     }
 
-    public void setRpcProviderService(final DOMRpcProviderService rpcProviderService) {
-        this.rpcProviderService = rpcProviderService;
+    public void setDomRpcProvider(final DOMRpcProviderService rpcProviderService) {
+        this.domRpcProvider = rpcProviderService;
     }
 
-    public void setRpcRegistry(final RpcProviderRegistry rpcRegistry) {
-        this.rpcRegistry = rpcRegistry;
+    public void setBindingRpcProvider(final RpcProviderService rpcProvider) {
+        this.bindingRpcProvider = rpcProvider;
     }
 
     public void setSchemaService(final DOMSchemaService schemaService) {
@@ -129,7 +129,7 @@ public class ActionProviderBean {
         }
 
         final Set<DOMRpcIdentifier> rpcs = ImmutableSet.copyOf(Collections2.transform(paths, DOMRpcIdentifier::create));
-        reg = rpcProviderService.registerRpcImplementation((rpc, input) -> {
+        reg = domRpcProvider.registerRpcImplementation((rpc, input) -> {
             return Futures.immediateFailedCheckedFuture(new DOMRpcImplementationNotAvailableException(
                 "Action %s has no instance matching %s", rpc, input));
         }, rpcs);
@@ -143,7 +143,7 @@ public class ActionProviderBean {
                 interfaceName, ACTION_PROVIDER, implementation.getClass()));
         }
 
-        reg = rpcRegistry.addRpcImplementation(interfaceClass, implementation);
+        reg = bindingRpcProvider.registerRpcImplementation(interfaceClass, implementation);
         LOG.debug("Registered implementation {} for {}", implementation, interfaceName);
     }
 }
index a760e69..5bb3f14 100644 (file)
@@ -8,8 +8,7 @@
 package org.opendaylight.controller.blueprint.ext;
 
 import java.util.function.Predicate;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.md.sal.dom.broker.spi.rpc.RpcRoutingStrategy;
+import org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy;
 
 /**
  * Factory metadata corresponding to the "action-service" element. It waits for a DOM promise of registration
index 3a2a0b8..74c2956 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.blueprint.ext;
 
-import org.opendaylight.controller.md.sal.binding.api.NotificationService;
+import org.opendaylight.mdsal.binding.api.NotificationService;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.NotificationListener;
 import org.osgi.framework.Bundle;
index 7ce521e..3673b24 100644 (file)
@@ -25,9 +25,10 @@ import org.apache.aries.blueprint.mutable.MutableServiceMetadata;
 import org.apache.aries.blueprint.mutable.MutableServiceReferenceMetadata;
 import org.apache.aries.blueprint.mutable.MutableValueMetadata;
 import org.opendaylight.controller.blueprint.BlueprintContainerRestartService;
-import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.mdsal.binding.api.NotificationService;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
 import org.opendaylight.yangtools.util.xml.UntrustedXML;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
@@ -56,8 +57,9 @@ import org.xml.sax.SAXException;
 public final class OpendaylightNamespaceHandler implements NamespaceHandler {
     public static final String NAMESPACE_1_0_0 = "http://opendaylight.org/xmlns/blueprint/v1.0.0";
     static final String ROUTED_RPC_REG_CONVERTER_NAME = "org.opendaylight.blueprint.RoutedRpcRegConverter";
-    static final String RPC_PROVIDER_SERVICE_NAME = "org.opendaylight.blueprint.DOMRpcProviderService";
+    static final String DOM_RPC_PROVIDER_SERVICE_NAME = "org.opendaylight.blueprint.DOMRpcProviderService";
     static final String RPC_REGISTRY_NAME = "org.opendaylight.blueprint.RpcRegistry";
+    static final String BINDING_RPC_PROVIDER_SERVICE_NAME = "org.opendaylight.blueprint.RpcProviderService";
     static final String SCHEMA_SERVICE_NAME = "org.opendaylight.blueprint.SchemaService";
     static final String NOTIFICATION_SERVICE_NAME = "org.opendaylight.blueprint.NotificationService";
     static final String TYPE_ATTR = "type";
@@ -239,15 +241,15 @@ public final class OpendaylightNamespaceHandler implements NamespaceHandler {
     }
 
     private static Metadata parseActionProvider(final Element element, final ParserContext context) {
-        registerRpcProviderServiceRefBean(context);
-        registerRpcRegistryServiceRefBean(context);
+        registerDomRpcProviderServiceRefBean(context);
+        registerBindingRpcProviderServiceRefBean(context);
         registerSchemaServiceRefBean(context);
 
         MutableBeanMetadata metadata = createBeanMetadata(context, context.generateId(), ActionProviderBean.class,
                 true, true);
         addBlueprintBundleRefProperty(context, metadata);
-        metadata.addProperty("rpcProviderService", createRef(context, RPC_PROVIDER_SERVICE_NAME));
-        metadata.addProperty("rpcRegistry", createRef(context, RPC_REGISTRY_NAME));
+        metadata.addProperty("domRpcProvider", createRef(context, DOM_RPC_PROVIDER_SERVICE_NAME));
+        metadata.addProperty("bindingRpcProvider", createRef(context, BINDING_RPC_PROVIDER_SERVICE_NAME));
         metadata.addProperty("schemaService", createRef(context, SCHEMA_SERVICE_NAME));
         metadata.addProperty("interfaceName", createValue(context, element.getAttribute(INTERFACE)));
 
@@ -261,12 +263,12 @@ public final class OpendaylightNamespaceHandler implements NamespaceHandler {
 
 
     private static Metadata parseRpcImplementation(final Element element, final ParserContext context) {
-        registerRpcRegistryServiceRefBean(context);
+        registerBindingRpcProviderServiceRefBean(context);
 
         MutableBeanMetadata metadata = createBeanMetadata(context, context.generateId(), RpcImplementationBean.class,
                 true, true);
         addBlueprintBundleRefProperty(context, metadata);
-        metadata.addProperty("rpcRegistry", createRef(context, RPC_REGISTRY_NAME));
+        metadata.addProperty("rpcProvider", createRef(context, BINDING_RPC_PROVIDER_SERVICE_NAME));
         metadata.addProperty("implementation", createRef(context, element.getAttribute(REF_ATTR)));
 
         if (element.hasAttribute(INTERFACE)) {
@@ -278,7 +280,7 @@ public final class OpendaylightNamespaceHandler implements NamespaceHandler {
     }
 
     private static Metadata parseRoutedRpcImplementation(final Element element, final ParserContext context) {
-        registerRpcRegistryServiceRefBean(context);
+        registerRefBean(context, RPC_REGISTRY_NAME, RpcProviderRegistry.class);
         registerRoutedRpcRegistrationConverter(context);
 
         ComponentFactoryMetadata metadata = new RoutedRpcMetadata(getId(context, element),
@@ -317,12 +319,12 @@ public final class OpendaylightNamespaceHandler implements NamespaceHandler {
         }
     }
 
-    private static void registerRpcProviderServiceRefBean(final ParserContext context) {
-        registerRefBean(context, RPC_PROVIDER_SERVICE_NAME, DOMRpcProviderService.class);
+    private static void registerDomRpcProviderServiceRefBean(final ParserContext context) {
+        registerRefBean(context, DOM_RPC_PROVIDER_SERVICE_NAME, DOMRpcProviderService.class);
     }
 
-    private static void registerRpcRegistryServiceRefBean(final ParserContext context) {
-        registerRefBean(context, RPC_REGISTRY_NAME, RpcProviderRegistry.class);
+    private static void registerBindingRpcProviderServiceRefBean(final ParserContext context) {
+        registerRefBean(context, BINDING_RPC_PROVIDER_SERVICE_NAME, RpcProviderService.class);
     }
 
     private static void registerSchemaServiceRefBean(final ParserContext context) {
index 338d0a2..94d5b3b 100644 (file)
@@ -11,8 +11,8 @@ import com.google.common.base.Strings;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.osgi.framework.Bundle;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
@@ -29,14 +29,14 @@ public class RpcImplementationBean {
     private static final Logger LOG = LoggerFactory.getLogger(RpcImplementationBean.class);
     static final String RPC_IMPLEMENTATION = "rpc-implementation";
 
-    private RpcProviderRegistry rpcRegistry;
+    private RpcProviderService rpcProvider;
     private Bundle bundle;
     private String interfaceName;
     private RpcService implementation;
-    private final List<RpcRegistration<RpcService>> rpcRegistrations = new ArrayList<>();
+    private final List<ObjectRegistration<RpcService>> rpcRegistrations = new ArrayList<>();
 
-    public void setRpcRegistry(final RpcProviderRegistry rpcRegistry) {
-        this.rpcRegistry = rpcRegistry;
+    public void setRpcProvider(final RpcProviderService rpcProvider) {
+        this.rpcProvider = rpcProvider;
     }
 
     public void setBundle(final Bundle bundle) {
@@ -61,7 +61,7 @@ public class RpcImplementationBean {
                     implementation, rpcInterfaces);
 
             for (Class<RpcService> rpcInterface : rpcInterfaces) {
-                rpcRegistrations.add(rpcRegistry.addRpcImplementation(rpcInterface, implementation));
+                rpcRegistrations.add(rpcProvider.registerRpcImplementation(rpcInterface, implementation));
             }
         } catch (final ComponentDefinitionException e) {
             throw e;
@@ -72,7 +72,7 @@ public class RpcImplementationBean {
     }
 
     public void destroy() {
-        for (RpcRegistration<RpcService> reg: rpcRegistrations) {
+        for (ObjectRegistration<RpcService> reg: rpcRegistrations) {
             reg.close();
         }
     }
index ffc7940..4ab3867 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.controller.blueprint.ext;
 
 import java.util.function.Predicate;
-import org.opendaylight.controller.md.sal.dom.broker.spi.rpc.RpcRoutingStrategy;
+import org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy;
 
 /**
  * Factory metadata corresponding to the "rpc-service" element that gets an RPC service implementation from
index dc65d9b..9dbd019 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.controller.blueprint.ext;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.function.Predicate;
-import org.opendaylight.controller.md.sal.dom.broker.spi.rpc.RpcRoutingStrategy;
+import org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
 import org.opendaylight.yangtools.yang.common.QNameModule;

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.