Add blueprint wiring to sal-binding-broker-impl 53/35853/25
authorTom Pantelis <tpanteli@brocade.com>
Sun, 6 Mar 2016 07:17:33 +0000 (02:17 -0500)
committerAnil Vishnoi <vishnoianil@gmail.com>
Wed, 13 Apr 2016 20:09:35 +0000 (20:09 +0000)
Change-Id: Ie333035f44904e20cc3c23052c2f98e9684c8033
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodecFactory.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/resources/org/opendaylight/blueprint/binding-broker.xml [new file with mode: 0644]
opendaylight/md-sal/sal-binding-config/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModule.java

index 38aeb9a..ec27bc7 100644 (file)
@@ -25,7 +25,7 @@ import org.opendaylight.controller.config.manager.impl.osgi.mapping.RefreshingSC
 import org.opendaylight.controller.config.manager.impl.util.OsgiRegistrationUtil;
 import org.opendaylight.controller.config.spi.ModuleFactory;
 import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
+import org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy;
 import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
 import org.osgi.framework.Bundle;
@@ -96,7 +96,7 @@ public class ConfigManagerActivator implements BundleActivator, SynchronousBundl
                     new JMXNotifierConfigRegistry(configRegistry, configMBeanServer);
 
             // register config registry to OSGi
-            AutoCloseable clsReg = registerService(context, moduleInfoBackedContext, GeneratedClassLoadingStrategy.class);
+            AutoCloseable clsReg = registerService(context, moduleInfoBackedContext, ClassLoadingStrategy.class);
             AutoCloseable configRegReg = registerService(context, notifyingConfigRegistry, ConfigRegistry.class);
 
             // register config registry to jmx
index ee60afb..be6459b 100644 (file)
@@ -35,7 +35,7 @@ import org.opendaylight.yangtools.binding.data.codec.api.BindingCodecTreeNode;
 import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
 import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
 import org.opendaylight.yangtools.binding.data.codec.impl.MissingSchemaException;
-import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
+import org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy;
 import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext;
 import org.opendaylight.yangtools.yang.binding.BindingMapping;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
@@ -66,7 +66,7 @@ public final class BindingToNormalizedNodeCodec implements BindingCodecTreeFacto
 
     private final BindingNormalizedNodeCodecRegistry codecRegistry;
 
-    private final GeneratedClassLoadingStrategy classLoadingStrategy;
+    private final ClassLoadingStrategy classLoadingStrategy;
     private final FutureSchema futureSchema;
     private final LoadingCache<InstanceIdentifier<?>, YangInstanceIdentifier> iiCache = CacheBuilder.newBuilder()
             .softValues().build(new CacheLoader<InstanceIdentifier<?>, YangInstanceIdentifier>() {
@@ -80,13 +80,13 @@ public final class BindingToNormalizedNodeCodec implements BindingCodecTreeFacto
 
     private DataNormalizer legacyToNormalized;
 
-    public BindingToNormalizedNodeCodec(final GeneratedClassLoadingStrategy classLoadingStrategy,
+    public BindingToNormalizedNodeCodec(final ClassLoadingStrategy classLoadingStrategy,
             final BindingNormalizedNodeCodecRegistry codecRegistry) {
         this(classLoadingStrategy,codecRegistry,false);
 
     }
 
-    public BindingToNormalizedNodeCodec(final GeneratedClassLoadingStrategy classLoadingStrategy,
+    public BindingToNormalizedNodeCodec(final ClassLoadingStrategy classLoadingStrategy,
             final BindingNormalizedNodeCodecRegistry codecRegistry,final boolean waitForSchema) {
         this.classLoadingStrategy = Preconditions.checkNotNull(classLoadingStrategy,"classLoadingStrategy");
         this.codecRegistry = Preconditions.checkNotNull(codecRegistry,"codecRegistry");
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodecFactory.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodecFactory.java
new file mode 100644 (file)
index 0000000..a68ace7
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * 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 java.util.concurrent.atomic.AtomicBoolean;
+import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
+import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
+import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
+import org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy;
+
+/**
+ * Factory class for creating and initializing the global BindingToNormalizedNodeCodec instance.
+ *
+ * @author Thomas Pantelis
+ */
+public class BindingToNormalizedNodeCodecFactory {
+    private static final AtomicBoolean INSTANCE_CREATED = new AtomicBoolean();
+    private static volatile BindingToNormalizedNodeCodec instance;
+
+    /**
+     * Returns the global BindingToNormalizedNodeCodec instance, creating if necessary. The returned instance
+     * is registered with tthe SchemaService as a SchemaContextListener.
+     *
+     * @param classLoadingStrategy
+     * @param schemaService
+     * @return the BindingToNormalizedNodeCodec instance
+     */
+    public static BindingToNormalizedNodeCodec getOrCreateInstance(ClassLoadingStrategy classLoadingStrategy,
+            SchemaService schemaService) {
+        if(!INSTANCE_CREATED.compareAndSet(false, true)) {
+            return instance;
+        }
+
+        BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(
+                StreamWriterGenerator.create(SingletonHolder.JAVASSIST));
+        instance = new BindingToNormalizedNodeCodec(classLoadingStrategy, codecRegistry, true);
+
+        schemaService.registerSchemaContextListener(instance);
+
+        return instance;
+    }
+
+    public static BindingToNormalizedNodeCodec getInstance() {
+        return instance;
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/resources/org/opendaylight/blueprint/binding-broker.xml b/opendaylight/md-sal/sal-binding-broker/src/main/resources/org/opendaylight/blueprint/binding-broker.xml
new file mode 100644 (file)
index 0000000..db405e0
--- /dev/null
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
+
+  <!-- Runtime binding/normalized mapping service -->
+
+  <reference id="classLoadingStrategy" interface="org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy"/>
+  <reference id="schemaService" interface="org.opendaylight.controller.sal.core.api.model.SchemaService" />
+
+  <bean id="mappingCodec" class="org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodecFactory"
+         factory-method="getOrCreateInstance">
+    <argument ref="classLoadingStrategy"/>
+    <argument ref="schemaService"/>
+  </bean>
+
+  <service ref="mappingCodec" odl:type="default">
+    <interfaces>
+      <value>org.opendaylight.yangtools.binding.data.codec.api.BindingCodecTreeFactory</value>
+      <value>org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer</value>
+    </interfaces>
+  </service>
+
+  <!-- Binding RPC Registry Service -->
+
+  <reference id="domRpcService" interface="org.opendaylight.controller.md.sal.dom.api.DOMRpcService"/>
+
+  <bean id="bindingRpcServiceAdapter" class="org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcServiceAdapter" >
+    <argument ref="domRpcService"/>
+    <argument ref="mappingCodec"/>
+  </bean>
+
+  <reference id="domRpcRegistry" interface="org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService"/>
+
+  <bean id="bindingRpcProviderAdapter" class="org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcProviderServiceAdapter" >
+    <argument ref="domRpcRegistry"/>
+    <argument ref="mappingCodec"/>
+  </bean>
+
+  <bean id="bindingRpcRegistry" class="org.opendaylight.controller.md.sal.binding.compat.HeliumRpcProviderRegistry" >
+    <argument ref="bindingRpcServiceAdapter"/>
+    <argument ref="bindingRpcProviderAdapter"/>
+  </bean>
+
+  <service ref="bindingRpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"
+          odl:type="default"/>
+
+  <!-- Binding MountPoint Service -->
+
+  <reference id="domMountPointService" interface="org.opendaylight.controller.md.sal.dom.api.DOMMountPointService"/>
+
+  <bean id="bindingMountPointService" class="org.opendaylight.controller.md.sal.binding.impl.BindingDOMMountPointServiceAdapter" >
+    <argument ref="domMountPointService"/>
+    <argument ref="mappingCodec"/>
+  </bean>
+
+  <service ref="bindingMountPointService" interface="org.opendaylight.controller.md.sal.binding.api.MountPointService"
+          odl:type="default"/>
+
+  <!-- Binding Notification Service -->
+
+  <reference id="domNotificationService" interface="org.opendaylight.controller.md.sal.dom.api.DOMNotificationService"/>
+
+  <bean id="bindingNotificationServiceAdapter" class="org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationServiceAdapter">
+    <argument>
+      <bean factory-ref="mappingCodec" factory-method="getCodecRegistry"/>
+    </argument>
+    <argument ref="domNotificationService"/>
+  </bean>
+
+  <service ref="bindingNotificationServiceAdapter" interface="org.opendaylight.controller.md.sal.binding.api.NotificationService"
+          odl:type="default"/>
+
+  <reference id="domNotificationPublishService" interface="org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService"/>
+
+  <bean id="bindingNotificationPublishAdapter" class="org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationPublishServiceAdapter">
+    <argument ref="mappingCodec"/>
+    <argument ref="domNotificationPublishService"/>
+  </bean>
+
+  <service ref="bindingNotificationPublishAdapter" interface="org.opendaylight.controller.md.sal.binding.api.NotificationPublishService"
+          odl:type="default"/>
+
+  <reference id="domNotificationListenerRegistry" interface="org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListenerRegistry"/>
+
+  <bean id="bindingNotificationProviderService" class="org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceWithInterestListeners">
+    <argument ref="bindingNotificationPublishAdapter"/>
+    <argument ref="bindingNotificationServiceAdapter"/>
+    <argument ref="domNotificationListenerRegistry"/>
+  </bean>
+
+  <service ref="bindingNotificationProviderService" odl:type="default">
+    <interfaces>
+      <value>org.opendaylight.controller.sal.binding.api.NotificationProviderService</value>
+      <value>org.opendaylight.controller.sal.binding.api.NotificationService</value>
+    </interfaces>
+  </service>
+
+  <!-- Binding DataBroker -->
+
+  <reference id="domDefaultDataBroker" interface="org.opendaylight.controller.md.sal.dom.api.DOMDataBroker"
+          odl:type="default"/>
+
+  <bean id="bindingDataBroker" class="org.opendaylight.controller.md.sal.binding.impl.BindingDOMDataBrokerAdapter">
+    <argument ref="domDefaultDataBroker"/>
+    <argument ref="mappingCodec"/>
+  </bean>
+
+  <service ref="bindingDataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+          odl:type="default"/>
+
+  <!-- Binding PingPong DataBroker -->
+
+  <reference id="domPingPongDataBroker" interface="org.opendaylight.controller.md.sal.dom.api.DOMDataBroker"
+          odl:type="pingpong"/>
+
+  <bean id="bindingPingPongDataBroker" class="org.opendaylight.controller.md.sal.binding.impl.BindingDOMDataBrokerAdapter">
+    <argument ref="domPingPongDataBroker"/>
+    <argument ref="mappingCodec"/>
+  </bean>
+
+  <service ref="bindingPingPongDataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+          odl:type="pingpong"/>
+
+</blueprint>
index 87ce27d..e2d942e 100644 (file)
@@ -13,7 +13,7 @@ import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCo
 import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
 import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
 import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
+import org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy;
 import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -50,15 +50,15 @@ public final class RuntimeMappingModule extends AbstractRuntimeMappingModule {
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-        final GeneratedClassLoadingStrategy classLoading = getGlobalClassLoadingStrategy();
+        final ClassLoadingStrategy classLoading = getGlobalClassLoadingStrategy();
         final BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(SingletonHolder.JAVASSIST));
         final BindingToNormalizedNodeCodec instance = new BindingToNormalizedNodeCodec(classLoading, codecRegistry,getWaitForSchema());
         bundleContext.registerService(SchemaContextListener.class, instance, new Hashtable<String,String>());
         return instance;
     }
 
-    private GeneratedClassLoadingStrategy getGlobalClassLoadingStrategy() {
-        final ServiceReference<GeneratedClassLoadingStrategy> ref = bundleContext.getServiceReference(GeneratedClassLoadingStrategy.class);
+    private ClassLoadingStrategy getGlobalClassLoadingStrategy() {
+        final ServiceReference<ClassLoadingStrategy> ref = bundleContext.getServiceReference(ClassLoadingStrategy.class);
         return bundleContext.getService(ref);
     }
 

©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.