Fixed deployment of mount points (dynamic instances of MD-SAL) 74/4274/3
authorTony Tkacik <ttkacik@cisco.com>
Wed, 15 Jan 2014 13:36:35 +0000 (14:36 +0100)
committerTony Tkacik <ttkacik@cisco.com>
Wed, 15 Jan 2014 18:03:26 +0000 (19:03 +0100)
  - Converted some xtend sources into Java classes
  - Added mount point deployer - service responsible for
    deploying dynamic instances of MD-SAL, which have
    separate context and could be created and retrieved via
    MountService.

Change-Id: I9c0798e2f5f0af647d97b22a2da2f6c46bf9b72d
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
50 files changed:
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/RpcConsumerRegistry.java
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/RpcProviderRegistry.java
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/mount/MountProviderService.java
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/rpc/RpcContextIdentifier.java [moved from opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcContextIdentifier.java with 97% similarity]
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/rpc/RpcRouter.java [moved from opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcRouter.java with 98% similarity]
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/rpc/RpcRoutingContext.java [moved from opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcRoutingContext.java with 82% similarity]
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/rpc/RpcRoutingTable.java [moved from opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcRoutingTable.java with 96% similarity]
opendaylight/md-sal/sal-binding-broker/pom.xml
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModule.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/DataBrokerImplModule.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/NotificationBrokerImplModule.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/statistics/DataBrokerRuntimeMXBeanImpl.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeGenerator.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcRouterCodegenInstance.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcRoutingTableImpl.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/SingletonHolder.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/DataBrokerImpl.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/MountPointManagerImpl.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiConsumerContext.xtend [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootDataBrokerImpl.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProviderRegistryImpl.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingDomConnectorDeployer.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentMountPointForwarder.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentRpcConnector.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/CommitHandlersTransactions.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardedBindingBrokerImpl.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardedBroker.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardedDataBrokerImpl.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardingUtils.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/osgi/Constants.xtend [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/osgi/PropertiesUtils.xtend [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/osgi/package-info.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RoutingContext.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/yang/opendaylight-binding-broker-impl.yang
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/RuntimeCodeGeneratorTest.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/ChangeOriginatedInDomBrokerTest.java
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerMountPointTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java
opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/NoficationTest.java
opendaylight/md-sal/sal-binding-util/pom.xml
opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalConsumerInstance.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalProviderInstance.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/BindingContextUtils.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/TypeSafeDataReader.java

index e20640d..72c6b1d 100644 (file)
@@ -7,7 +7,7 @@ import org.opendaylight.yangtools.yang.binding.RpcService;
  * version of RpcServices
  * 
  */
-public interface RpcConsumerRegistry {
+public interface RpcConsumerRegistry extends BindingAwareService {
     /**
      * Returns a session specific instance (implementation) of requested
      * YANG module implentation / service provided by consumer.
index 972e64f..cc76488 100644 (file)
@@ -1,18 +1,22 @@
 package org.opendaylight.controller.sal.binding.api;
 
+import org.opendaylight.controller.md.sal.common.api.routing.RouteChangePublisher;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 
 /**
- * Interface defining provider's access to the Rpc Registry
- * which could be used to register their implementations of service to the MD-SAL.
+ * Interface defining provider's access to the Rpc Registry which could be used
+ * to register their implementations of service to the MD-SAL.
  * 
  * @author ttkacik
- *
+ * 
  */
-public interface RpcProviderRegistry extends RpcConsumerRegistry {
+public interface RpcProviderRegistry extends //
+        RpcConsumerRegistry, //
+        RouteChangePublisher<RpcContextIdentifier, InstanceIdentifier<?>> {
     /**
      * Registers an global RpcService implementation.
      * 
@@ -25,12 +29,16 @@ public interface RpcProviderRegistry extends RpcConsumerRegistry {
 
     /**
      * 
-     * Register an Routed RpcService where routing is determined on annotated (in YANG model)
-     * context-reference and value of annotated leaf.
+     * Register an Routed RpcService where routing is determined on annotated
+     * (in YANG model) context-reference and value of annotated leaf.
      * 
-     * @param type Type of RpcService, use generated interface class, not your implementation clas
-     * @param implementation Implementation of RpcService
-     * @return Registration object for routed Rpc which could be used to close an 
+     * @param type
+     *            Type of RpcService, use generated interface class, not your
+     *            implementation clas
+     * @param implementation
+     *            Implementation of RpcService
+     * @return Registration object for routed Rpc which could be used to close
+     *         an
      * 
      * @throws IllegalStateException
      */
index d91a216..194c431 100644 (file)
@@ -1,18 +1,36 @@
 package org.opendaylight.controller.sal.binding.api.mount;
 
+import java.util.EventListener;
+
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 /**
- * Provider MountProviderService, this version allows access to MD-SAL
- * services specific for this mountpoint and registration / provision of
- * interfaces for mount point.
+ * Provider MountProviderService, this version allows access to MD-SAL services
+ * specific for this mountpoint and registration / provision of interfaces for
+ * mount point.
  * 
  * @author ttkacik
  * 
  */
-public interface MountProviderService extends MountInstance {
+public interface MountProviderService extends MountService {
+    
+    @Override
+    public MountProviderInstance getMountPoint(InstanceIdentifier<?> path);
 
     MountProviderInstance createMountPoint(InstanceIdentifier<?> path);
+
+    MountProviderInstance createOrGetMountPoint(InstanceIdentifier<?> path);
+
+    ListenerRegistration<MountProvisionListener> registerProvisionListener(MountProvisionListener listener);
+
+    public interface MountProvisionListener extends EventListener {
+
+        void onMountPointCreated(InstanceIdentifier<?> path);
+
+        void onMountPointRemoved(InstanceIdentifier<?> path);
+
+    }
 }
index 1b0f783..29357c0 100644 (file)
             <artifactId>sal-binding-api</artifactId>
             <version>1.0-SNAPSHOT</version>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-binding-util</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
index c46b0dd..cd45f2c 100644 (file)
@@ -1,48 +1,85 @@
 /**\r
-* Generated file\r
+ * Generated file\r
 \r
-* Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-broker-impl\r
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator\r
-* Generated at: Wed Nov 20 17:33:01 CET 2013\r
-*\r
-* Do not modify this file unless it is present under src/main directory\r
-*/\r
+ * Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-broker-impl\r
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator\r
+ * Generated at: Wed Nov 20 17:33:01 CET 2013\r
+ *\r
+ * Do not modify this file unless it is present under src/main directory\r
+ */\r
 package org.opendaylight.controller.config.yang.md.sal.binding.impl;\r
 \r
-import org.opendaylight.controller.sal.binding.impl.BindingAwareBrokerImpl;\r
+import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;\r
+import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker;\r
+import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl;\r
+import org.opendaylight.controller.sal.binding.impl.forward.DomForwardedBindingBrokerImpl;\r
+import org.opendaylight.controller.sal.binding.impl.forward.DomForwardingUtils;\r
 import org.osgi.framework.BundleContext;\r
 \r
-import com.google.common.base.Preconditions;\r
+import com.google.common.util.concurrent.MoreExecutors;\r
 \r
 /**\r
 *\r
 */\r
-public final class BindingBrokerImplModule extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplModule {\r
+public final class BindingBrokerImplModule extends\r
+        org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplModule {\r
 \r
     private BundleContext bundleContext;\r
 \r
-    public BindingBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {\r
+    public BindingBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,\r
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {\r
         super(identifier, dependencyResolver);\r
     }\r
 \r
-    public BindingBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, BindingBrokerImplModule oldModule, java.lang.AutoCloseable oldInstance) {\r
+    public BindingBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,\r
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,\r
+            BindingBrokerImplModule oldModule, java.lang.AutoCloseable oldInstance) {\r
         super(identifier, dependencyResolver, oldModule, oldInstance);\r
     }\r
 \r
     @Override\r
-    public void validate(){\r
+    public void validate() {\r
         super.validate();\r
     }\r
 \r
     @Override\r
     public java.lang.AutoCloseable createInstance() {\r
-        BindingAwareBrokerImpl broker = new BindingAwareBrokerImpl(getIdentifier().getInstanceName(),getBundleContext());\r
-        broker.setDataBroker(getDataBrokerDependency());\r
-        broker.setNotifyBroker(getNotificationServiceDependency());\r
+\r
+        RootBindingAwareBroker broker;\r
+        if (DomForwardingUtils.isDomForwardedBroker(getDataBrokerDependency())) {\r
+            broker = createForwardedBroker();\r
+        } else {\r
+            broker = createStandaloneBroker();\r
+        }\r
         broker.start();\r
         return broker;\r
     }\r
 \r
+    private RootBindingAwareBroker createStandaloneBroker() {\r
+        RootBindingAwareBroker broker = new RootBindingAwareBroker(getIdentifier().getInstanceName());\r
+\r
+        broker.setDataBroker(getDataBrokerDependency());\r
+        broker.setNotificationBroker(getNotificationServiceDependency());\r
+        broker.setRpcBroker(new RpcProviderRegistryImpl(broker.getIdentifier()));\r
+        return broker;\r
+    }\r
+\r
+    private RootBindingAwareBroker createForwardedBroker() {\r
+        DomForwardedBindingBrokerImpl broker = new DomForwardedBindingBrokerImpl(getIdentifier().getInstanceName());\r
+\r
+        broker.setDataBroker(getDataBrokerDependency());\r
+        broker.setNotificationBroker(getNotificationServiceDependency());\r
+        broker.setRpcBroker(new RpcProviderRegistryImpl(broker.getIdentifier()));\r
+\r
+        broker.getMountManager().setDataCommitExecutor(SingletonHolder.getDefaultCommitExecutor());\r
+        broker.getMountManager().setNotificationExecutor(SingletonHolder.getDefaultNotificationExecutor());\r
+\r
+\r
+        DomForwardingUtils.reuseForwardingFrom(broker, broker.getDataBroker());\r
+        broker.startForwarding();\r
+        return broker;\r
+    }\r
+\r
     public BundleContext getBundleContext() {\r
         return bundleContext;\r
     }\r
index 01dc6b8..185b37b 100644 (file)
@@ -13,12 +13,16 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;\r
 import java.util.concurrent.ScheduledExecutorService;\r
 \r
-import org.opendaylight.controller.config.yang.md.sal.binding.statistics.DataBrokerRuntimeMXBeanImpl;\r
 import org.opendaylight.controller.md.sal.common.impl.routing.AbstractDataReadRouter;\r
+import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;\r
 import org.opendaylight.controller.sal.binding.impl.DataBrokerImpl;\r
+import org.opendaylight.controller.sal.binding.impl.RootDataBrokerImpl;\r
+import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingDomConnectorDeployer;\r
 import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentConnector;\r
 import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentMappingService;\r
+import org.opendaylight.controller.sal.binding.impl.forward.DomForwardedDataBrokerImpl;\r
 import org.opendaylight.controller.sal.core.api.Broker;\r
+import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;\r
 import org.opendaylight.controller.sal.core.api.data.DataProviderService;\r
 import org.opendaylight.yangtools.yang.binding.DataObject;\r
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;\r
@@ -52,25 +56,38 @@ public final class DataBrokerImplModule extends
 \r
     @Override\r
     public java.lang.AutoCloseable createInstance() {\r
-        DataBrokerRuntimeMXBeanImpl dataBindingBroker = new DataBrokerRuntimeMXBeanImpl();\r
+        RootDataBrokerImpl dataBindingBroker;\r
         \r
-        // FIXME: obtain via dependency management\r
-        ExecutorService executor = Executors.newCachedThreadPool();\r
-        ExecutorService listeningExecutor = MoreExecutors.listeningDecorator(executor);\r
-        dataBindingBroker.setExecutor(listeningExecutor);\r
-\r
-        Broker domBroker = getDomBrokerDependency();\r
-        BindingIndependentMappingService mappingService = getMappingServiceDependency();\r
         \r
-        if (domBroker != null && mappingService != null) {\r
-            BindingIndependentConnector runtimeMapping = new BindingIndependentConnector();\r
-            runtimeMapping.setMappingService(mappingService);\r
-            runtimeMapping.setBaDataService(dataBindingBroker);\r
-            domBroker.registerProvider(runtimeMapping, getBundleContext());\r
+        ExecutorService listeningExecutor = SingletonHolder.getDefaultCommitExecutor();\r
+        \r
+        if (getDomBrokerDependency() != null && getMappingServiceDependency() != null) {\r
+            \r
+            dataBindingBroker = createDomConnectedBroker(listeningExecutor);\r
+        } else {\r
+            dataBindingBroker = createStandAloneBroker(listeningExecutor);\r
         }\r
-        getRootRuntimeBeanRegistratorWrapper().register(dataBindingBroker);\r
+        dataBindingBroker.registerRuntimeBean(getRootRuntimeBeanRegistratorWrapper());\r
+\r
         return dataBindingBroker;\r
     }\r
+    private RootDataBrokerImpl createStandAloneBroker(ExecutorService listeningExecutor) {\r
+        RootDataBrokerImpl broker = new RootDataBrokerImpl();\r
+        broker.setExecutor(listeningExecutor);\r
+        return broker;\r
+    }\r
+\r
+    private RootDataBrokerImpl createDomConnectedBroker(ExecutorService listeningExecutor) {\r
+        DomForwardedDataBrokerImpl forwardedBroker = new DomForwardedDataBrokerImpl();\r
+        forwardedBroker.setExecutor(listeningExecutor);\r
+        BindingIndependentConnector connector = BindingDomConnectorDeployer.createConnector(getMappingServiceDependency());\r
+        getDomBrokerDependency().registerProvider(forwardedBroker, getBundleContext());\r
+        ProviderSession domContext = forwardedBroker.getDomProviderContext();\r
+        forwardedBroker.setConnector(connector);\r
+        forwardedBroker.setDomProviderContext(domContext);\r
+        forwardedBroker.startForwarding();\r
+        return forwardedBroker;\r
+    }\r
 \r
     public BundleContext getBundleContext() {\r
         return bundleContext;\r
index e4f74de..6448605 100644 (file)
@@ -13,6 +13,7 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 
+import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
 import org.opendaylight.controller.sal.binding.impl.NotificationBrokerImpl;
 
 import com.google.common.util.concurrent.ListeningExecutorService;
@@ -43,8 +44,7 @@ public final class NotificationBrokerImplModule extends
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-        ExecutorService executor = Executors.newFixedThreadPool(5);
-        ListeningExecutorService listeningExecutor = MoreExecutors.listeningDecorator(executor);
+        ListeningExecutorService listeningExecutor = SingletonHolder.getDefaultNotificationExecutor();
         NotificationBrokerImpl broker = new NotificationBrokerImpl(listeningExecutor);
         return broker;
     }
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/statistics/DataBrokerRuntimeMXBeanImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/statistics/DataBrokerRuntimeMXBeanImpl.java
deleted file mode 100644 (file)
index 5da084e..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.opendaylight.controller.config.yang.md.sal.binding.statistics;\r
-\r
-import org.opendaylight.controller.config.yang.md.sal.binding.impl.Data;\r
-import org.opendaylight.controller.config.yang.md.sal.binding.impl.DataBrokerImplRuntimeMXBean;\r
-import org.opendaylight.controller.config.yang.md.sal.binding.impl.Transactions;\r
-import org.opendaylight.controller.sal.binding.impl.DataBrokerImpl;\r
-\r
-public class DataBrokerRuntimeMXBeanImpl extends DataBrokerImpl implements DataBrokerImplRuntimeMXBean {\r
-    \r
-    private final Transactions transactions = new Transactions();\r
-    private final Data data = new Data();\r
-    \r
-    public Transactions getTransactions() {\r
-        transactions.setCreated(getCreatedTransactionsCount().get());\r
-        transactions.setSubmitted(getSubmittedTransactionsCount().get());\r
-        transactions.setSuccessful(getFinishedTransactionsCount().get());\r
-        transactions.setFailed(getFailedTransactionsCount().get());\r
-        return transactions;\r
-    }\r
-\r
-    @Override\r
-    public Data getData() {\r
-        transactions.setCreated(getCreatedTransactionsCount().get());\r
-        transactions.setSubmitted(getSubmittedTransactionsCount().get());\r
-        transactions.setSuccessful(getFinishedTransactionsCount().get());\r
-        transactions.setFailed(getFailedTransactionsCount().get());\r
-        data.setTransactions(transactions);\r
-        return data;\r
-    }\r
-}\r
index 7789a06..8aff12b 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.controller.sal.binding.codegen;
 
+import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
 import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory;
-import org.opendaylight.controller.sal.binding.spi.RpcRouter;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext;
index 8b2db8b..d976a0c 100644 (file)
@@ -3,7 +3,8 @@ package org.opendaylight.controller.sal.binding.codegen.impl;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
-import org.opendaylight.controller.sal.binding.spi.RpcRouter;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcRoutingTable;
 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
@@ -13,7 +14,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.HashMap;
 
-import org.opendaylight.controller.sal.binding.spi.RpcRoutingTable;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
 import org.opendaylight.yangtools.yang.binding.RpcImplementation;
 import org.opendaylight.controller.md.sal.common.api.routing.MutableRoutingTable;
@@ -147,7 +147,6 @@ public class RpcRouterCodegenInstance<T extends RpcService> implements //
         @Override
         public void unregisterPath(Class<? extends BaseIdentity> context, InstanceIdentifier<?> path) {
             routingTables.get(context).removeRoute(path, getInstance());
-
         }
 
         @Override
index 808358f..76318ae 100644 (file)
@@ -1,6 +1,6 @@
 package org.opendaylight.controller.sal.binding.codegen.impl;
 
-import org.opendaylight.controller.sal.binding.spi.RpcRoutingTable;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcRoutingTable;
 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
index 266293f..446a9ca 100644 (file)
@@ -1,14 +1,49 @@
 package org.opendaylight.controller.sal.binding.codegen.impl;
 
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
+
 import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator;
 import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory;
 
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+
 import javassist.ClassPool;
 
 public class SingletonHolder {
 
-    public static final ClassPool CLASS_POOL = new ClassPool(); 
-    public static final org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator RPC_GENERATOR_IMPL = new org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator(CLASS_POOL);
+    public static final ClassPool CLASS_POOL = new ClassPool();
+    public static final org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator RPC_GENERATOR_IMPL = new org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator(
+            CLASS_POOL);
     public static final RuntimeCodeGenerator RPC_GENERATOR = RPC_GENERATOR_IMPL;
     public static final NotificationInvokerFactory INVOKER_FACTORY = RPC_GENERATOR_IMPL.getInvokerFactory();
+    private static ListeningExecutorService NOTIFICATION_EXECUTOR = null;
+    private static ListeningExecutorService COMMIT_EXECUTOR = null;
+
+    public static synchronized final ListeningExecutorService getDefaultNotificationExecutor() {
+        if (NOTIFICATION_EXECUTOR == null) {
+            NOTIFICATION_EXECUTOR = createNamedExecutor("md-sal-binding-notification-%d");
+        }
+        return NOTIFICATION_EXECUTOR;
+    }
+
+    public static synchronized final ListeningExecutorService getDefaultCommitExecutor() {
+        if (COMMIT_EXECUTOR == null) {
+            COMMIT_EXECUTOR = createNamedExecutor("md-sal-binding-commit-%d");
+        }
+
+        return COMMIT_EXECUTOR;
+    }
+
+    private static ListeningExecutorService createNamedExecutor(String format) {
+        ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat(format).build();
+        ExecutorService executor = Executors.newCachedThreadPool(factory);
+        return MoreExecutors.listeningDecorator(executor);
+
+    }
+
 }
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend
deleted file mode 100644 (file)
index b4bf3f5..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco 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.sal.binding.impl
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider
-import org.osgi.framework.BundleContext
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener
-import org.opendaylight.controller.sal.binding.spi.RpcContextIdentifier
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService
-import org.slf4j.LoggerFactory
-
-class BindingAwareBrokerImpl extends RpcProviderRegistryImpl implements BindingAwareBroker, AutoCloseable {
-    private static val log = LoggerFactory.getLogger(BindingAwareBrokerImpl)
-
-    private InstanceIdentifier<? extends DataObject> root = InstanceIdentifier.builder().toInstance();
-
-    @Property
-    private var NotificationProviderService notifyBroker
-
-    @Property
-    private var DataProviderService dataBroker
-
-    @Property
-    var BundleContext brokerBundleContext
-
-    public new(String name,BundleContext bundleContext) {
-        super(name);
-        _brokerBundleContext = bundleContext;
-    }
-
-    def start() {
-        log.info("Starting MD-SAL: Binding Aware Broker");
-    }
-
-
-
-    override registerConsumer(BindingAwareConsumer consumer, BundleContext bundleCtx) {
-        val ctx = consumer.createContext(bundleCtx)
-        consumer.onSessionInitialized(ctx)
-        return ctx
-    }
-
-    override registerProvider(BindingAwareProvider provider, BundleContext bundleCtx) {
-        val ctx = provider.createContext(bundleCtx)
-        provider.onSessionInitialized(ctx)
-        provider.onSessionInitiated(ctx as ProviderContext)
-        return ctx
-    }
-
-    private def createContext(BindingAwareConsumer consumer, BundleContext consumerCtx) {
-        new OsgiConsumerContext(consumerCtx, this)
-    }
-
-    private def createContext(BindingAwareProvider provider, BundleContext providerCtx) {
-        new OsgiProviderContext(providerCtx, this)
-    }
-
-    override <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> registerRouteChangeListener(L listener) {
-        super.<L>registerRouteChangeListener(listener)
-    }
-    
-    override close() throws Exception {
-        
-    }
-}
\ No newline at end of file
index 5db522f..0069de9 100644 (file)
@@ -3,7 +3,7 @@ package org.opendaylight.controller.sal.binding.impl;
 import java.util.Set;
 import java.util.concurrent.Future;\r
 import java.util.concurrent.atomic.AtomicLong;\r
-
+\r
 import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataBroker;\r
 import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;\r
 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;\r
@@ -11,12 +11,13 @@ import org.opendaylight.controller.sal.binding.impl.util.BindingAwareDataReaderR
 import org.opendaylight.controller.sal.common.DataStoreIdentifier;\r
 import org.opendaylight.yangtools.yang.binding.DataObject;\r
 import org.opendaylight.yangtools.yang.binding.DataRoot;\r
+import org.opendaylight.yangtools.yang.binding.Identifiable;\r
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;\r
 import org.opendaylight.yangtools.yang.common.RpcResult;\r
 \r
 \r
-public class DataBrokerImpl extends AbstractDataBroker<InstanceIdentifier<? extends DataObject>, DataObject, DataChangeListener> implements\r
-        DataProviderService, AutoCloseable {\r
+public class DataBrokerImpl extends AbstractDataBroker<InstanceIdentifier<? extends DataObject>, DataObject, DataChangeListener> //\r
+       implements DataProviderService, AutoCloseable {\r
 \r
     private final AtomicLong nextTransaction = new AtomicLong();\r
     private final AtomicLong createdTransactionsCount = new AtomicLong();\r
@@ -114,7 +115,6 @@ public class DataBrokerImpl extends AbstractDataBroker<InstanceIdentifier<? exte
                 return true;
             }
         }
-
         return false;
     }\r
 }
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/MountPointManagerImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/MountPointManagerImpl.java
new file mode 100644 (file)
index 0000000..f8059fe
--- /dev/null
@@ -0,0 +1,120 @@
+package org.opendaylight.controller.sal.binding.impl;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.opendaylight.controller.md.sal.binding.util.AbstractBindingSalProviderInstance;
+import org.opendaylight.yangtools.concepts.util.ListenerRegistry;
+import org.opendaylight.controller.sal.binding.api.mount.MountProviderInstance;
+import org.opendaylight.controller.sal.binding.api.mount.MountProviderService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.ListeningExecutorService;
+
+public class MountPointManagerImpl implements MountProviderService {
+
+    public final Logger LOG = LoggerFactory.getLogger(MountPointManagerImpl.class);
+
+    private final ConcurrentMap<InstanceIdentifier<?>, BindingMountPointImpl> mountPoints;
+    private final ListenerRegistry<MountProvisionListener> listeners = ListenerRegistry.create();
+    
+    private ListeningExecutorService notificationExecutor;
+    private ListeningExecutorService dataCommitExecutor;
+
+    public MountPointManagerImpl() {
+        mountPoints = new ConcurrentHashMap<>();
+    }
+
+    public ListeningExecutorService getNotificationExecutor() {
+        return notificationExecutor;
+    }
+
+    public void setNotificationExecutor(ListeningExecutorService notificationExecutor) {
+        this.notificationExecutor = notificationExecutor;
+    }
+
+    public ListeningExecutorService getDataCommitExecutor() {
+        return dataCommitExecutor;
+    }
+
+    public void setDataCommitExecutor(ListeningExecutorService dataCommitExecutor) {
+        this.dataCommitExecutor = dataCommitExecutor;
+    }
+
+    @Override
+    public synchronized BindingMountPointImpl createMountPoint(InstanceIdentifier<?> path) {
+        BindingMountPointImpl potential = mountPoints.get(path);
+        if (potential != null) {
+            throw new IllegalStateException("Mount point already exists.");
+        }
+        return createOrGetMountPointImpl(path);
+    }
+
+    @Override
+    public BindingMountPointImpl createOrGetMountPoint(InstanceIdentifier<?> path) {
+        BindingMountPointImpl potential = getMountPoint(path);
+        if (potential != null) {
+            return potential;
+        }
+        return createOrGetMountPointImpl(path);
+    }
+
+    @Override
+    public BindingMountPointImpl getMountPoint(InstanceIdentifier<?> path) {
+        return mountPoints.get(path);
+    }
+
+    private synchronized BindingMountPointImpl createOrGetMountPointImpl(InstanceIdentifier<?> path) {
+        BindingMountPointImpl potential = getMountPoint(path);
+        if (potential != null) {
+            return potential;
+        }
+        RpcProviderRegistryImpl rpcRegistry = new RpcProviderRegistryImpl("mount");
+        NotificationBrokerImpl notificationBroker = new NotificationBrokerImpl();
+        notificationBroker.setExecutor(getNotificationExecutor());
+        DataBrokerImpl dataBroker = new DataBrokerImpl();
+        dataBroker.setExecutor(getDataCommitExecutor());
+        BindingMountPointImpl mountInstance = new BindingMountPointImpl(path, rpcRegistry, notificationBroker,
+                dataBroker);
+        mountPoints.putIfAbsent(path, mountInstance);
+        notifyMountPointCreated(path);
+        return mountInstance;
+    }
+
+    private void notifyMountPointCreated(InstanceIdentifier<?> path) {
+        for (ListenerRegistration<MountProvisionListener> listener : listeners) {
+            try {
+                listener.getInstance().onMountPointCreated(path);
+            } catch (Exception e) {
+                LOG.error("Unhandled exception during invoking listener.", e);
+            }
+        }
+    }
+
+    @Override
+    public ListenerRegistration<MountProvisionListener> registerProvisionListener(MountProvisionListener listener) {
+        return listeners.register(listener);
+    }
+
+    public class BindingMountPointImpl extends
+            AbstractBindingSalProviderInstance<DataBrokerImpl, NotificationBrokerImpl, RpcProviderRegistryImpl>
+    implements MountProviderInstance {
+
+        private InstanceIdentifier<?> identifier;
+
+        public BindingMountPointImpl(org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?> identifier,
+                RpcProviderRegistryImpl rpcRegistry, NotificationBrokerImpl notificationBroker,
+                DataBrokerImpl dataBroker) {
+            super(rpcRegistry, notificationBroker, dataBroker);
+            this.identifier = identifier;
+        }
+        
+        @Override
+        public InstanceIdentifier<?> getIdentifier() {
+            return this.identifier;
+        }
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiConsumerContext.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiConsumerContext.xtend
deleted file mode 100644 (file)
index 644c50b..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco 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.sal.binding.impl;
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareService;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.slf4j.LoggerFactory
-import static org.opendaylight.controller.sal.binding.impl.osgi.Constants.*
-
-class OsgiConsumerContext implements ConsumerContext {
-
-    static val log = LoggerFactory.getLogger(OsgiConsumerContext)
-    protected val BundleContext bundleContext;
-    protected val BindingAwareBrokerImpl broker;
-
-    new(BundleContext ctx, BindingAwareBrokerImpl broker) {
-        this.bundleContext = ctx;
-        this.broker = broker;
-    }
-
-    override def <T extends BindingAwareService> getSALService(Class<T> service) {
-
-        // SAL Services are global
-        var ref = bundleContext.getServiceReference(service);
-        return bundleContext.getService(ref) as T;
-    }
-
-    override def <T extends RpcService> T getRpcService(Class<T> module) {
-        try {
-
-            val services = bundleContext.getServiceReferences(module, getProxyFilter());
-
-            // Proxy service found / using first implementation
-            // FIXME: Add advanced logic to retrieve service with right set of models
-            if (false == services.empty) {
-                val ref = services.iterator().next() as ServiceReference<T>;
-                return bundleContext.getService(ref) as T;
-            } else {
-                return broker.getRpcService(module);
-            }
-        } catch (InvalidSyntaxException e) {
-            log.error("Created filter was invalid:", e.message, e)
-        }
-        return null;
-
-    }
-
-    private def getProxyFilter() {
-        return '''(«SAL_SERVICE_TYPE»=«SAL_SERVICE_TYPE_CONSUMER_PROXY»)'''
-    }
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend
deleted file mode 100644 (file)
index d1ec351..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco 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.sal.binding.impl;
-
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Map;
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.osgi.framework.BundleContext;
-
-import static org.opendaylight.controller.sal.binding.impl.osgi.Constants.*;
-import static extension org.opendaylight.controller.sal.binding.impl.osgi.PropertiesUtils.*;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality
-import static com.google.common.base.Preconditions.*
-
-class OsgiProviderContext extends OsgiConsumerContext implements ProviderContext {
-
-    @Property
-    val Map<Class<? extends RpcService>, RpcRegistration<? extends RpcService>> registeredServices
-
-    new(BundleContext ctx, BindingAwareBrokerImpl broker) {
-        super(ctx, broker);
-        _registeredServices = new HashMap();
-    }
-
-    override <T extends RpcService> addRpcImplementation(Class<T> type, T implementation) {
-        val salReg = broker.addRpcImplementation(type, implementation)
-        registeredServices.put(type, salReg)
-        return salReg;
-    }
-
-    override <T extends RpcService> addRoutedRpcImplementation(Class<T> type, T implementation) throws IllegalStateException {
-        val salReg = broker.addRoutedRpcImplementation(type, implementation)
-        registeredServices.put(type, salReg)
-        return salReg;
-    }
-
-    override registerFunctionality(ProviderFunctionality functionality) {
-        // NOOP for now
-    }
-
-    override unregisterFunctionality(ProviderFunctionality functionality) {
-        // NOOP for now
-    }
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java
new file mode 100644 (file)
index 0000000..35c2bee
--- /dev/null
@@ -0,0 +1,174 @@
+package org.opendaylight.controller.sal.binding.impl;
+
+import static com.google.common.base.Preconditions.checkState;
+
+import org.opendaylight.controller.md.sal.binding.util.AbstractBindingSalProviderInstance;
+import org.opendaylight.controller.md.sal.binding.util.BindingContextUtils;
+import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.controller.sal.binding.api.BindingAwareService;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.NotificationService;
+import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.controller.sal.binding.api.mount.MountProviderService;
+import org.opendaylight.controller.sal.binding.api.mount.MountService;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
+import org.opendaylight.yangtools.concepts.Identifiable;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Mutable;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableClassToInstanceMap;
+
+public class RootBindingAwareBroker implements //
+        Mutable, //
+        Identifiable<String>, //
+        BindingAwareBroker, AutoCloseable,
+        RpcProviderRegistry {
+
+    private final static Logger LOG = LoggerFactory.getLogger(RootBindingAwareBroker.class);
+
+    RootSalInstance controllerRoot;
+
+    private final String identifier;
+
+    private RpcProviderRegistry rpcBroker;
+
+    private NotificationProviderService notificationBroker;
+
+    private DataProviderService dataBroker;
+
+    private MountPointManagerImpl mountManager;
+
+    public MountPointManagerImpl getMountManager() {
+        return mountManager;
+    }
+
+    public void setMountManager(MountPointManagerImpl mountManager) {
+        this.mountManager = mountManager;
+    }
+
+    private ImmutableClassToInstanceMap<BindingAwareService> supportedConsumerServices;
+
+    private ImmutableClassToInstanceMap<BindingAwareService> supportedProviderServices;
+
+    public RootBindingAwareBroker(String instanceName) {
+        this.identifier = instanceName;
+        mountManager = new MountPointManagerImpl();
+    }
+
+    public String getIdentifier() {
+        return identifier;
+    }
+
+    public RootSalInstance getRoot() {
+        return controllerRoot;
+    }
+
+    public DataProviderService getDataBroker() {
+        return this.dataBroker;
+    }
+
+    public NotificationProviderService getNotificationBroker() {
+        return this.notificationBroker;
+    }
+
+    public RpcProviderRegistry getRpcProviderRegistry() {
+        return this.rpcBroker;
+    }
+
+    public RpcProviderRegistry getRpcBroker() {
+        return rpcBroker;
+    }
+
+    public void setRpcBroker(RpcProviderRegistry rpcBroker) {
+        this.rpcBroker = rpcBroker;
+    }
+
+    public void setNotificationBroker(NotificationProviderService notificationBroker) {
+        this.notificationBroker = notificationBroker;
+    }
+
+    public void setDataBroker(DataProviderService dataBroker) {
+        this.dataBroker = dataBroker;
+    }
+
+    public void start() {
+        checkState(controllerRoot == null, "Binding Aware Broker was already started.");
+        LOG.info("Starting Binding Aware Broker: {}", identifier);
+
+        controllerRoot = new RootSalInstance(getRpcProviderRegistry(), getNotificationBroker(), getDataBroker());
+        
+
+        supportedConsumerServices = ImmutableClassToInstanceMap.<BindingAwareService> builder()
+                .put(NotificationService.class, getRoot()) //
+                .put(DataBrokerService.class, getRoot()) //
+                .put(RpcConsumerRegistry.class, getRoot()) //
+                .put(MountService.class, mountManager).build();
+
+        supportedProviderServices = ImmutableClassToInstanceMap.<BindingAwareService> builder()
+                .putAll(supportedConsumerServices)
+                .put(NotificationProviderService.class, getRoot()) //
+                .put(DataProviderService.class, getRoot()) //
+                .put(RpcProviderRegistry.class, getRoot()) //
+                .put(MountProviderService.class, mountManager).build();
+    }
+
+    @Override
+    public ConsumerContext registerConsumer(BindingAwareConsumer consumer, BundleContext ctx) {
+        checkState(supportedConsumerServices != null, "Broker is not initialized.");
+        return BindingContextUtils.createConsumerContextAndInitialize(consumer, supportedConsumerServices);
+    }
+
+    @Override
+    public ProviderContext registerProvider(BindingAwareProvider provider, BundleContext ctx) {
+        checkState(supportedProviderServices != null, "Broker is not initialized.");
+        return BindingContextUtils.createProviderContextAndInitialize(provider, supportedProviderServices);
+    }
+
+    @Override
+    public void close() throws Exception {
+        // FIXME: Close all sessions
+    }
+    
+    @Override
+    public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> type, T implementation)
+            throws IllegalStateException {
+        return getRoot().addRoutedRpcImplementation(type, implementation);
+    }
+    
+    @Override
+    public <T extends RpcService> RpcRegistration<T> addRpcImplementation(Class<T> type, T implementation)
+            throws IllegalStateException {
+        return getRoot().addRpcImplementation(type, implementation);
+    }
+    
+    @Override
+    public <T extends RpcService> T getRpcService(Class<T> module) {
+        return getRoot().getRpcService(module);
+    }
+    @Override
+    public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
+            L arg0) {
+        return getRoot().registerRouteChangeListener(arg0);
+    }
+    
+
+    public class RootSalInstance extends
+            AbstractBindingSalProviderInstance<DataProviderService, NotificationProviderService, RpcProviderRegistry> {
+
+        public RootSalInstance(RpcProviderRegistry rpcRegistry, NotificationProviderService notificationBroker,
+                DataProviderService dataBroker) {
+            super(rpcRegistry, notificationBroker, dataBroker);
+        }
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootDataBrokerImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootDataBrokerImpl.java
new file mode 100644 (file)
index 0000000..1b6c56d
--- /dev/null
@@ -0,0 +1,43 @@
+package org.opendaylight.controller.sal.binding.impl;\r
+\r
+import org.opendaylight.controller.config.yang.md.sal.binding.impl.Data;\r
+import org.opendaylight.controller.config.yang.md.sal.binding.impl.DataBrokerImplRuntimeMXBean;\r
+import org.opendaylight.controller.config.yang.md.sal.binding.impl.DataBrokerImplRuntimeRegistration;\r
+import org.opendaylight.controller.config.yang.md.sal.binding.impl.DataBrokerImplRuntimeRegistrator;\r
+import org.opendaylight.controller.config.yang.md.sal.binding.impl.Transactions;\r
+import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentConnector;\r
+\r
+public class RootDataBrokerImpl extends DataBrokerImpl implements DataBrokerImplRuntimeMXBean {\r
+\r
+    private final Transactions transactions = new Transactions();\r
+    private final Data data = new Data();\r
+    private BindingIndependentConnector bindingIndependentConnector;\r
+    private DataBrokerImplRuntimeRegistration runtimeBeanRegistration;\r
+\r
+    public BindingIndependentConnector getBindingIndependentConnector() {\r
+        return bindingIndependentConnector;\r
+    }\r
+\r
+    public Transactions getTransactions() {\r
+        transactions.setCreated(getCreatedTransactionsCount().get());\r
+        transactions.setSubmitted(getSubmittedTransactionsCount().get());\r
+        transactions.setSuccessful(getFinishedTransactionsCount().get());\r
+        transactions.setFailed(getFailedTransactionsCount().get());\r
+        return transactions;\r
+    }\r
+\r
+    @Override\r
+    public Data getData() {\r
+        data.setTransactions(getTransactions());\r
+        return data;\r
+    }\r
+\r
+    public void setBindingIndependentConnector(BindingIndependentConnector runtimeMapping) {\r
+        this.bindingIndependentConnector = runtimeMapping;\r
+    }\r
+\r
+    public void registerRuntimeBean(DataBrokerImplRuntimeRegistrator rootRegistrator) {\r
+        runtimeBeanRegistration = rootRegistrator.register(this);\r
+    }\r
+\r
+}\r
index 6a17007..8773476 100644 (file)
@@ -15,11 +15,11 @@ import org.opendaylight.controller.md.sal.common.impl.routing.RoutingUtils;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
 import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator;
 import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper;
 import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
-import org.opendaylight.controller.sal.binding.spi.RpcContextIdentifier;
-import org.opendaylight.controller.sal.binding.spi.RpcRouter;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
 import org.opendaylight.yangtools.concepts.Identifiable;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingDomConnectorDeployer.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingDomConnectorDeployer.java
new file mode 100644 (file)
index 0000000..f200b4d
--- /dev/null
@@ -0,0 +1,103 @@
+package org.opendaylight.controller.sal.binding.impl.connect.dom;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker;
+import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
+import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
+import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService;
+
+public class BindingDomConnectorDeployer {
+
+    private static BindingIndependentMappingService mappingService;
+
+    public static BindingIndependentConnector tryToDeployConnector(RootBindingAwareBroker baBroker,
+            ProviderSession domSession) {
+        checkNotNull(baBroker);
+        checkNotNull(domSession);
+        BindingIndependentConnector connector = createConnector(mappingService);
+        return connector;
+    }
+
+    public static BindingIndependentConnector createConnector(BindingIndependentMappingService mappingService) {
+        BindingIndependentConnector connector = new BindingIndependentConnector();
+        connector.setMappingService(mappingService);
+        return connector;
+    }
+
+    public static BindingIndependentConnector createConnector(BindingIndependentConnector source) {
+        BindingIndependentConnector connector = new BindingIndependentConnector();
+        connector.setMappingService(source.getMappingService());
+        return connector;
+    }
+    
+    public static void startDataForwarding(BindingIndependentConnector connector, DataProviderService baService,
+            ProviderSession domContext) {
+        startDataForwarding(connector, baService,
+                domContext.getService(org.opendaylight.controller.sal.core.api.data.DataProviderService.class));
+    }
+
+    public static void startRpcForwarding(BindingIndependentConnector connector,
+            RpcProviderRegistry rpcProviderRegistry, ProviderSession domProviderContext) {
+        startRpcForwarding(connector, rpcProviderRegistry, domProviderContext.getService(RpcProvisionRegistry.class));
+
+    }
+    
+    public static void startNotificationForwarding(BindingIndependentConnector connector, NotificationProviderService provider,ProviderSession domProviderContext) {
+        startNotificationForwarding(connector, provider, domProviderContext.getService(NotificationPublishService.class));
+    }
+
+    public static void startRpcForwarding(BindingIndependentConnector connector, RpcProviderRegistry baService,
+            RpcProvisionRegistry domService) {
+        if (connector.isRpcForwarding()) {
+            return;
+        }
+
+        connector.setDomRpcRegistry(domService);
+        connector.setBindingRpcRegistry(baService);
+        connector.startRpcForwarding();
+    }
+
+    public static void startDataForwarding(BindingIndependentConnector connector, DataProviderService baService,
+            org.opendaylight.controller.sal.core.api.data.DataProviderService domService) {
+        if (connector.isDataForwarding()) {
+            return;
+        }
+
+        connector.setBindingDataService(baService);
+        connector.setDomDataService(domService);
+        connector.startDataForwarding();
+    }
+    
+    public static void startNotificationForwarding(BindingIndependentConnector connector, NotificationProviderService baService, NotificationPublishService domService) {
+        if(connector.isNotificationForwarding()) {
+            return;
+        }
+        
+        // FIXME
+    }
+
+    //
+    // public static BindingIndependentMappingService getGlobalMappingService()
+    // {
+    // return mappingService;
+    // }
+    //
+    // protected static BindingIndependentMappingService
+    // setGlobalMappingService(BindingIndependentMappingService service) {
+    // mappingService= service;
+    // return mappingService;
+    // }
+    //
+    // public static BindingIndependentConnector
+    // tryToDeployConnector(MountProviderInstance baMount,MountProvisionInstance
+    // domMount) {
+    //
+    //
+    // return null;
+    // }
+
+}
index 0a76992..75b0138 100644 (file)
@@ -1,12 +1,9 @@
 package org.opendaylight.controller.sal.binding.impl.connect.dom;
 
 import java.lang.ref.WeakReference;
-import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -18,21 +15,23 @@ import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 
-
 import org.opendaylight.controller.md.sal.common.api.RegistrationListener;
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandlerRegistration;
 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
+import org.opendaylight.controller.md.sal.common.api.data.DataReader;
 import org.opendaylight.controller.md.sal.common.api.routing.RouteChange;
 import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
+import org.opendaylight.controller.md.sal.common.api.routing.RouteChangePublisher;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
 import org.opendaylight.controller.sal.binding.api.data.RuntimeDataProvider;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
 import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl;
-import org.opendaylight.controller.sal.binding.spi.RpcContextIdentifier;
-import org.opendaylight.controller.sal.binding.spi.RpcRouter;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
+import org.opendaylight.controller.sal.common.util.CommitHandlerTransactions;
 import org.opendaylight.controller.sal.common.util.Rpcs;
 import org.opendaylight.controller.sal.core.api.Provider;
 import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
@@ -49,7 +48,6 @@ import org.opendaylight.yangtools.yang.binding.BindingMapping;
 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.RpcInput;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -65,7 +63,6 @@ import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableSet;
 
 import static com.google.common.base.Preconditions.*;
-import static org.opendaylight.yangtools.concepts.util.ClassLoaderUtils.*;
 
 public class BindingIndependentConnector implements //
         RuntimeDataProvider, //
@@ -96,7 +93,7 @@ public class BindingIndependentConnector implements //
     private Registration<DataCommitHandler<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode>> biCommitHandlerRegistration;
 
     private RpcProvisionRegistry biRpcRegistry;
-    private RpcProviderRegistryImpl baRpcRegistry;
+    private RpcProviderRegistry baRpcRegistry;
 
     private ListenerRegistration<DomToBindingRpcForwardingManager> domToBindingRpcManager;
     // private ListenerRegistration<BindingToDomRpcForwardingManager>
@@ -111,6 +108,14 @@ public class BindingIndependentConnector implements //
 
     };
 
+    private Registration<DataReader<InstanceIdentifier<? extends DataObject>, DataObject>> baDataReaderRegistration;
+
+    private boolean rpcForwarding = false;
+
+    private boolean dataForwarding = false;
+
+    private boolean notificationForwarding = false;
+
     @Override
     public DataObject readOperationalData(InstanceIdentifier<? extends DataObject> path) {
         try {
@@ -222,7 +227,7 @@ public class BindingIndependentConnector implements //
         return biDataService;
     }
 
-    public void setBiDataService(org.opendaylight.controller.sal.core.api.data.DataProviderService biDataService) {
+    protected void setDomDataService(org.opendaylight.controller.sal.core.api.data.DataProviderService biDataService) {
         this.biDataService = biDataService;
     }
 
@@ -230,7 +235,7 @@ public class BindingIndependentConnector implements //
         return baDataService;
     }
 
-    public void setBaDataService(DataProviderService baDataService) {
+    protected void setBindingDataService(DataProviderService baDataService) {
         this.baDataService = baDataService;
     }
 
@@ -238,23 +243,33 @@ public class BindingIndependentConnector implements //
         return baRpcRegistry;
     }
 
-    public void setRpcRegistry(RpcProviderRegistryImpl rpcRegistry) {
+    protected void setBindingRpcRegistry(RpcProviderRegistry rpcRegistry) {
         this.baRpcRegistry = rpcRegistry;
     }
 
-    public void start() {
-        baDataService.registerDataReader(ROOT, this);
+    public void startDataForwarding() {
+        checkState(!dataForwarding, "Connector is already forwarding data.");
+        baDataReaderRegistration = baDataService.registerDataReader(ROOT, this);
         baCommitHandlerRegistration = baDataService.registerCommitHandler(ROOT, bindingToDomCommitHandler);
         biCommitHandlerRegistration = biDataService.registerCommitHandler(ROOT_BI, domToBindingCommitHandler);
         baDataService.registerCommitHandlerListener(domToBindingCommitHandler);
-
-        if (baRpcRegistry != null && biRpcRegistry != null) {
+        dataForwarding = true;
+    }
+    
+    public void startRpcForwarding() {
+        if (baRpcRegistry != null && biRpcRegistry != null && baRpcRegistry instanceof RouteChangePublisher<?, ?>) {
+            checkState(!rpcForwarding,"Connector is already forwarding RPCs");
             domToBindingRpcManager = baRpcRegistry.registerRouteChangeListener(new DomToBindingRpcForwardingManager());
-
+            rpcForwarding = true;
         }
     }
+    
+    public void startNotificationForwarding() {
+        checkState(!notificationForwarding, "Connector is already forwarding notifications.");
+        notificationForwarding = true;
+    }
 
-    public void setMappingService(BindingIndependentMappingService mappingService) {
+    protected void setMappingService(BindingIndependentMappingService mappingService) {
         this.mappingService = mappingService;
     }
 
@@ -265,8 +280,9 @@ public class BindingIndependentConnector implements //
 
     @Override
     public void onSessionInitiated(ProviderSession session) {
-        setBiDataService(session.getService(org.opendaylight.controller.sal.core.api.data.DataProviderService.class));
-        start();
+        setDomDataService(session.getService(org.opendaylight.controller.sal.core.api.data.DataProviderService.class));
+        setDomRpcRegistry(session.getService(RpcProvisionRegistry.class));
+        
     }
 
     public <T extends RpcService> void onRpcRouterCreated(Class<T> serviceType, RpcRouter<T> router) {
@@ -381,7 +397,7 @@ public class BindingIndependentConnector implements //
              */
             if (bindingOpenedTransactions.containsKey(bindingTransaction.getIdentifier())) {
 
-                return CommitHandlersTransactions.allwaysSuccessfulTransaction(bindingTransaction);
+                return CommitHandlerTransactions.allwaysSuccessfulTransaction(bindingTransaction);
             }
             DataModificationTransaction domTransaction = createBindingToDomTransaction(bindingTransaction);
             BindingToDomTransaction wrapped = new BindingToDomTransaction(domTransaction, bindingTransaction);
@@ -420,7 +436,7 @@ public class BindingIndependentConnector implements //
              * duplicating data.
              */
             if (domOpenedTransactions.containsKey(identifier)) {
-                return CommitHandlersTransactions.allwaysSuccessfulTransaction(domTransaction);
+                return CommitHandlerTransactions.allwaysSuccessfulTransaction(domTransaction);
             }
 
             org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction baTransaction = createDomToBindingTransaction(domTransaction);
@@ -597,6 +613,7 @@ public class BindingIndependentConnector implements //
         @SuppressWarnings("rawtypes")
         private WeakReference<Class> outputClass;
 
+        @SuppressWarnings({ "rawtypes", "unchecked" })
         public DefaultInvocationStrategy(Method targetMethod, Class<?> outputClass,
                 Class<? extends DataContainer> inputClass) {
             super(targetMethod);
@@ -624,10 +641,27 @@ public class BindingIndependentConnector implements //
         }
 
         public RpcResult<CompositeNode> uncheckedInvoke(RpcService rpcService, CompositeNode domInput) throws Exception {
+            @SuppressWarnings("unchecked")
             Future<RpcResult<Void>> result = (Future<RpcResult<Void>>) targetMethod.invoke(rpcService);
             RpcResult<Void> bindingResult = result.get();
             return Rpcs.getRpcResult(bindingResult.isSuccessful(), bindingResult.getErrors());
         }
+    }
+
+    public boolean isRpcForwarding() {
+        return rpcForwarding;
+    }
+
+    public boolean isDataForwarding() {
+        return dataForwarding;
+    }
+
+    public boolean isNotificationForwarding() {
+        // TODO Auto-generated method stub
+        return notificationForwarding;
+    }
 
+    public BindingIndependentMappingService getMappingService() {
+        return mappingService;
     }
 }
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentMountPointForwarder.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentMountPointForwarder.java
new file mode 100644 (file)
index 0000000..630b5fa
--- /dev/null
@@ -0,0 +1,128 @@
+package org.opendaylight.controller.sal.binding.impl.connect.dom;
+
+import java.util.concurrent.ConcurrentMap;
+
+import org.opendaylight.controller.sal.binding.api.mount.MountProviderInstance;
+import org.opendaylight.controller.sal.binding.api.mount.MountProviderService;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionService.MountProvisionListener;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class BindingIndependentMountPointForwarder {
+
+    private MountProvisionService domMountService;
+    private MountProviderService baMountService;
+    private BindingIndependentMappingService mappingService;
+    
+    private final DomMountPointForwardingManager domForwardingManager = new DomMountPointForwardingManager();
+    private final BindingMountPointForwardingManager bindingForwardingManager = new BindingMountPointForwardingManager();
+
+    private ConcurrentMap<InstanceIdentifier<?>, BindingIndependentConnector> connectors;
+    private ConcurrentMap<InstanceIdentifier<?>, org.opendaylight.yangtools.yang.data.api.InstanceIdentifier> forwarded;
+    private ListenerRegistration<MountProvisionListener> domListenerRegistration;
+    private ListenerRegistration<org.opendaylight.controller.sal.binding.api.mount.MountProviderService.MountProvisionListener> baListenerRegistration;
+
+    public MountProvisionService getDomMountService() {
+        return domMountService;
+    }
+
+    public void setDomMountService(MountProvisionService domMountService) {
+        this.domMountService = domMountService;
+    }
+
+    public void start() {
+        if(domMountService != null && baMountService != null) {
+            domListenerRegistration = domMountService.registerProvisionListener(domForwardingManager);
+            baListenerRegistration = baMountService.registerProvisionListener(bindingForwardingManager);
+        }
+    }
+
+    private void tryToDeployConnector(InstanceIdentifier<?> baPath,
+            org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biPath) {
+        org.opendaylight.yangtools.yang.data.api.InstanceIdentifier previous = forwarded.putIfAbsent(baPath, biPath);
+        if(previous != null) {
+            return;
+        }
+        MountProviderInstance baMountPoint = baMountService.getMountPoint(baPath);
+        MountProvisionInstance domMountPoint = domMountService.getMountPoint(biPath);
+        BindingIndependentConnector connector = createForwarder(baPath, baMountPoint, domMountPoint);
+        connectors.put(baPath, connector);
+        connector.startDataForwarding();
+        connector.startRpcForwarding();
+        connector.startNotificationForwarding();
+    }
+
+    private BindingIndependentConnector createForwarder(InstanceIdentifier<?> path, MountProviderInstance baMountPoint,
+            MountProvisionInstance domMountPoint) {
+        BindingIndependentConnector connector = new BindingIndependentConnector();
+        
+        connector.setBindingDataService(baMountPoint);
+        connector.setBindingRpcRegistry(baMountPoint);
+        //connector.setBindingNotificationBroker(baMountPoint);
+        
+        connector.setDomDataService(domMountPoint);
+        connector.setDomRpcRegistry(domMountPoint);
+        //connector.setDomNotificationBroker(domMountPoint);
+        return connector;
+    }
+
+    public synchronized void tryToDeployDomForwarder(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath) {
+        InstanceIdentifier<?> baPath;
+        try {
+            baPath = mappingService.fromDataDom(domPath);
+            BindingIndependentConnector potentialConnector = connectors.get(baPath);
+            if(potentialConnector != null) {
+                return;
+            }
+            tryToDeployConnector(baPath,domPath);
+        } catch (DeserializationException e) {
+            
+        }
+    }
+
+    public synchronized void tryToDeployBindingForwarder(InstanceIdentifier<?> baPath) {
+        BindingIndependentConnector potentialConnector =connectors.get(baPath);
+        if(potentialConnector != null) {
+            return;
+        }
+        org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath = mappingService.toDataDom(baPath);
+        tryToDeployConnector(baPath, domPath);
+    }
+
+    public synchronized void undeployBindingForwarder(InstanceIdentifier<?> baPath) {
+        // FIXME: Implement closeMountPoint
+    }
+
+    public synchronized void undeployDomForwarder(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biPath) {
+        // FIXME: Implement closeMountPoint
+    }
+
+    private class DomMountPointForwardingManager implements MountProvisionListener {
+
+        @Override
+        public void onMountPointCreated(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier path) {
+            tryToDeployDomForwarder(path);
+        }
+
+        @Override
+        public void onMountPointRemoved(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier path) {
+            undeployDomForwarder(path);
+        }
+    }
+
+    private class BindingMountPointForwardingManager implements
+            org.opendaylight.controller.sal.binding.api.mount.MountProviderService.MountProvisionListener {
+
+        @Override
+        public void onMountPointCreated(InstanceIdentifier<?> path) {
+            tryToDeployBindingForwarder(path);
+        }
+
+        @Override
+        public void onMountPointRemoved(InstanceIdentifier<?> path) {
+            undeployBindingForwarder(path);
+        }
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentRpcConnector.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentRpcConnector.java
deleted file mode 100644 (file)
index d22da30..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.opendaylight.controller.sal.binding.impl.connect.dom;
-
-public class BindingIndependentRpcConnector {
-
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/CommitHandlersTransactions.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/CommitHandlersTransactions.java
deleted file mode 100644 (file)
index 254b872..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.opendaylight.controller.sal.binding.impl.connect.dom;
-
-import java.util.Collections;
-
-import org.opendaylight.controller.md.sal.common.api.data.DataModification;
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction;
-import org.opendaylight.controller.sal.common.util.Rpcs;
-import org.opendaylight.yangtools.concepts.Path;
-import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-
-public class CommitHandlersTransactions {
-
-    private static class AllwaysSuccessfulTransaction<P extends Path<P>,D> implements DataCommitTransaction<P, D> {
-        
-        private final  DataModification<P, D> modification;
-
-        public AllwaysSuccessfulTransaction(DataModification<P, D> modification) {
-            this.modification = modification;
-        }
-        @Override
-        public RpcResult<Void> rollback() throws IllegalStateException {
-            return Rpcs.<Void>getRpcResult(true, null, Collections.<RpcError>emptyList());
-        }
-        @Override
-        public RpcResult<Void> finish() throws IllegalStateException {
-            return Rpcs.<Void>getRpcResult(true, null, Collections.<RpcError>emptyList());
-        }
-        
-        @Override
-        public DataModification<P, D> getModification() {
-            return modification;
-        }
-    }
-    
-    
-    public static final <P extends Path<P>,D> AllwaysSuccessfulTransaction<P, D> allwaysSuccessfulTransaction(DataModification<P, D> modification)  {
-        return new AllwaysSuccessfulTransaction<>(modification);
-    }
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardedBindingBrokerImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardedBindingBrokerImpl.java
new file mode 100644 (file)
index 0000000..c715c67
--- /dev/null
@@ -0,0 +1,166 @@
+package org.opendaylight.controller.sal.binding.impl.forward;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.opendaylight.controller.sal.binding.api.mount.MountProviderInstance;
+import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker;
+import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingDomConnectorDeployer;
+import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentConnector;
+import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentMappingService;
+import org.opendaylight.controller.sal.binding.impl.connect.dom.DeserializationException;
+import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionService.MountProvisionListener;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class DomForwardedBindingBrokerImpl extends RootBindingAwareBroker implements DomForwardedBroker {
+
+    private ProviderSession domProviderContext;
+    private BindingIndependentConnector connector;
+    
+    private MountProvisionService domMountService;
+
+    private final DomMountPointForwardingManager domForwardingManager = new DomMountPointForwardingManager();
+    private final BindingMountPointForwardingManager bindingForwardingManager = new BindingMountPointForwardingManager();
+
+    private ConcurrentMap<InstanceIdentifier<?>, BindingIndependentConnector> connectors = new ConcurrentHashMap<>();
+    private ConcurrentMap<InstanceIdentifier<?>, org.opendaylight.yangtools.yang.data.api.InstanceIdentifier> forwarded = new ConcurrentHashMap<>();
+    private ListenerRegistration<MountProvisionListener> domListenerRegistration;
+    private ListenerRegistration<org.opendaylight.controller.sal.binding.api.mount.MountProviderService.MountProvisionListener> baListenerRegistration;
+
+
+    public DomForwardedBindingBrokerImpl(String instanceName) {
+        super(instanceName);
+    }
+
+    @Override
+    public BindingIndependentConnector getConnector() {
+        return connector;
+    }
+
+    @Override
+    public ProviderSession getDomProviderContext() {
+        return domProviderContext;
+    }
+
+    @Override
+    public void setConnector(BindingIndependentConnector connector) {
+        this.connector = connector;
+    }
+
+    @Override
+    public void setDomProviderContext(ProviderSession domProviderContext) {
+        this.domProviderContext = domProviderContext;
+    }
+
+    @Override
+    public void startForwarding() {
+        BindingDomConnectorDeployer.startDataForwarding(getConnector(), getDataBroker(), getDomProviderContext());
+        BindingDomConnectorDeployer.startRpcForwarding(getConnector(), getRpcProviderRegistry(),
+                getDomProviderContext());
+        BindingDomConnectorDeployer.startNotificationForwarding(getConnector(), getNotificationBroker(),
+                getDomProviderContext());
+        startMountpointForwarding();
+    }
+
+    private void startMountpointForwarding() {
+        domMountService = getDomProviderContext().getService(MountProvisionService.class);
+        if (domMountService != null && getMountManager() != null) {
+            domListenerRegistration = domMountService.registerProvisionListener(domForwardingManager);
+            baListenerRegistration = getMountManager().registerProvisionListener(bindingForwardingManager);
+        }
+    }
+
+    public MountProvisionService getDomMountService() {
+        return domMountService;
+    }
+
+    public void setDomMountService(MountProvisionService domMountService) {
+        this.domMountService = domMountService;
+    }
+
+    private void tryToDeployConnector(InstanceIdentifier<?> baPath,
+            org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biPath) {
+        org.opendaylight.yangtools.yang.data.api.InstanceIdentifier previous = forwarded.putIfAbsent(baPath, biPath);
+        if (previous != null) {
+            return;
+        }
+        MountProviderInstance baMountPoint = getMountManager().createOrGetMountPoint(baPath);
+        MountProvisionInstance domMountPoint = domMountService.createOrGetMountPoint(biPath);
+        BindingIndependentConnector connector = createForwarder(baPath, baMountPoint, domMountPoint);
+        connectors.put(baPath, connector);
+    }
+
+    private BindingIndependentConnector createForwarder(InstanceIdentifier<?> path, MountProviderInstance baMountPoint,
+            MountProvisionInstance domMountPoint) {
+        BindingIndependentConnector mountConnector = BindingDomConnectorDeployer.createConnector(getConnector());
+
+        BindingDomConnectorDeployer.startDataForwarding(mountConnector, baMountPoint, domMountPoint);
+        BindingDomConnectorDeployer.startRpcForwarding(mountConnector, baMountPoint, domMountPoint);
+        BindingDomConnectorDeployer.startNotificationForwarding(mountConnector, baMountPoint, domMountPoint);
+        // connector.setDomNotificationBroker(domMountPoint);
+        return connector;
+    }
+
+    public synchronized void tryToDeployDomForwarder(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath) {
+        InstanceIdentifier<?> baPath;
+        try {
+            baPath = connector.getMappingService().fromDataDom(domPath);
+            BindingIndependentConnector potentialConnector = connectors.get(baPath);
+            if (potentialConnector != null) {
+                return;
+            }
+            tryToDeployConnector(baPath, domPath);
+        } catch (DeserializationException e) {
+
+        }
+    }
+
+    public synchronized void tryToDeployBindingForwarder(InstanceIdentifier<?> baPath) {
+        BindingIndependentConnector potentialConnector = connectors.get(baPath);
+        if (potentialConnector != null) {
+            return;
+        }
+        org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath = connector.getMappingService().toDataDom(baPath);
+        tryToDeployConnector(baPath, domPath);
+    }
+
+    public synchronized void undeployBindingForwarder(InstanceIdentifier<?> baPath) {
+        // FIXME: Implement closeMountPoint
+    }
+
+    public synchronized void undeployDomForwarder(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biPath) {
+        // FIXME: Implement closeMountPoint
+    }
+
+    private class DomMountPointForwardingManager implements MountProvisionListener {
+
+        @Override
+        public void onMountPointCreated(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier path) {
+            tryToDeployDomForwarder(path);
+        }
+
+        @Override
+        public void onMountPointRemoved(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier path) {
+            undeployDomForwarder(path);
+        }
+    }
+
+    private class BindingMountPointForwardingManager implements
+            org.opendaylight.controller.sal.binding.api.mount.MountProviderService.MountProvisionListener {
+
+        @Override
+        public void onMountPointCreated(InstanceIdentifier<?> path) {
+            tryToDeployBindingForwarder(path);
+        }
+
+        @Override
+        public void onMountPointRemoved(InstanceIdentifier<?> path) {
+            undeployBindingForwarder(path);
+        }
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardedBroker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardedBroker.java
new file mode 100644 (file)
index 0000000..c7dbcd4
--- /dev/null
@@ -0,0 +1,17 @@
+package org.opendaylight.controller.sal.binding.impl.forward;
+
+import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentConnector;
+import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
+
+interface DomForwardedBroker {
+
+    public BindingIndependentConnector getConnector();
+    
+    public void setConnector(BindingIndependentConnector connector);
+    
+    public void setDomProviderContext(ProviderSession domProviderContext);
+
+    public ProviderSession getDomProviderContext();
+
+    void startForwarding();
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardedDataBrokerImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardedDataBrokerImpl.java
new file mode 100644 (file)
index 0000000..f90a4ac
--- /dev/null
@@ -0,0 +1,49 @@
+package org.opendaylight.controller.sal.binding.impl.forward;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.opendaylight.controller.sal.binding.impl.RootDataBrokerImpl;
+import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingDomConnectorDeployer;
+import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentConnector;
+import org.opendaylight.controller.sal.core.api.Provider;
+import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
+
+public class DomForwardedDataBrokerImpl extends RootDataBrokerImpl implements Provider, DomForwardedBroker {
+
+    private BindingIndependentConnector connector;
+    private ProviderSession domProviderContext;
+
+    public void setConnector(BindingIndependentConnector connector) {
+        this.connector = connector;
+    }
+
+    @Override
+    public void onSessionInitiated(ProviderSession session) {
+        this.setDomProviderContext(session);
+    }
+
+    @Override
+    public Collection<ProviderFunctionality> getProviderFunctionality() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public BindingIndependentConnector getConnector() {
+        return connector;
+    }
+
+    @Override
+    public ProviderSession getDomProviderContext() {
+        return domProviderContext;
+    }
+
+    public void setDomProviderContext(ProviderSession domProviderContext) {
+        this.domProviderContext = domProviderContext;
+    }
+
+    @Override
+    public void startForwarding() {
+        BindingDomConnectorDeployer.startDataForwarding(getConnector(), this, getDomProviderContext());
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardingUtils.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardingUtils.java
new file mode 100644 (file)
index 0000000..581b217
--- /dev/null
@@ -0,0 +1,25 @@
+package org.opendaylight.controller.sal.binding.impl.forward;
+
+import com.google.common.base.Preconditions;
+
+public class DomForwardingUtils {
+
+    public static boolean isDomForwardedBroker(Object obj) {
+        return obj instanceof DomForwardedBroker;
+    }
+
+    public static void reuseForwardingFrom(Object target,Object source) {
+        Preconditions.checkArgument(isDomForwardedBroker(source));
+        Preconditions.checkArgument(isDomForwardedBroker(target));
+        DomForwardedBroker forwardedSource = (DomForwardedBroker) source;
+        DomForwardedBroker forwardedTarget = (DomForwardedBroker) target;
+        reuseForwardingFrom(forwardedTarget, forwardedSource);
+        
+    }
+
+    private static void reuseForwardingFrom(DomForwardedBroker target, DomForwardedBroker source) {
+        target.setConnector(source.getConnector());
+        target.setDomProviderContext(source.getDomProviderContext());
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/osgi/Constants.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/osgi/Constants.xtend
deleted file mode 100644 (file)
index 9fb2140..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco 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.sal.binding.impl.osgi
-
-class Constants {
-
-    private new() {
-    }
-
-    public static val SAL_SERVICE_TYPE = "salServiceType"
-    public static val SAL_SERVICE_TYPE_CONSUMER_PROXY = "consumerProxy"
-    public static val SAL_SERVICE_TYPE_PROVIDER = "provider"
-    public static val SAL_SERVICE_TYPE_CONNECTOR = "connector"
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/osgi/PropertiesUtils.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/osgi/PropertiesUtils.xtend
deleted file mode 100644 (file)
index d04ca7f..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco 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.sal.binding.impl.osgi
-
-import java.util.Hashtable
-import static org.opendaylight.controller.sal.binding.impl.osgi.Constants.*
-
-class PropertiesUtils {
-
-    private new() {
-    }
-
-    static def setSalServiceType(Hashtable<String, String> properties, String value) {
-        properties.put(SAL_SERVICE_TYPE, value)
-        return properties
-    }
-
-    static def getSalServiceType(Hashtable<String, String> properties) {
-        return properties.get(SAL_SERVICE_TYPE)
-    }
-
-    static def newProperties() {
-        new Hashtable<String, String>()
-    }
-
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/osgi/package-info.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/osgi/package-info.java
deleted file mode 100644 (file)
index d788ccf..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco 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.sal.binding.impl.osgi;
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RoutingContext.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RoutingContext.java
deleted file mode 100644 (file)
index 49e056b..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.opendaylight.controller.sal.binding.spi;
-
-public class RoutingContext {
-
-}
index b040aa0..b0d1629 100644 (file)
@@ -85,10 +85,10 @@ module opendaylight-sal-binding-broker-impl {
                         config:required-identity sal:binding-notification-service;
                     }
                 }
-            } 
+            }
         }
     }
-    
+
     augment "/config:modules/config:module/config:configuration" {
         case binding-data-broker {
             when "/config:modules/config:module/config:type = 'binding-data-broker'";
@@ -100,6 +100,7 @@ module opendaylight-sal-binding-broker-impl {
                     }
                 }
             }
+
             container mapping-service {
                 uses config:service-ref {
                     refine type {
index 6f0db4c..20181a6 100644 (file)
@@ -16,11 +16,11 @@ import org.junit.Test;
 import static org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper.*;
 
 import org.opendaylight.controller.sal.binding.api.NotificationListener;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcRoutingTable;
 import org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator;
 import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory;
 import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory.NotificationInvoker;
-import org.opendaylight.controller.sal.binding.spi.RpcRouter;
-import org.opendaylight.controller.sal.binding.spi.RpcRoutingTable;
 import org.opendaylight.controller.sal.binding.test.mock.BarListener;
 import org.opendaylight.controller.sal.binding.test.mock.BarUpdate;
 import org.opendaylight.controller.sal.binding.test.mock.CompositeListener;
index d4d27a1..c03d851 100644 (file)
@@ -4,26 +4,44 @@ import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.Future;
 
 import javassist.ClassPool;
 
+import org.eclipse.xtext.xbase.lib.Pure;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.controller.sal.binding.api.mount.MountProviderService;
 import org.opendaylight.controller.sal.binding.dom.serializer.impl.RuntimeGeneratedMappingServiceImpl;
-import org.opendaylight.controller.sal.binding.impl.BindingAwareBrokerImpl;
 import org.opendaylight.controller.sal.binding.impl.DataBrokerImpl;
 import org.opendaylight.controller.sal.binding.impl.NotificationBrokerImpl;
+import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker;
+import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl;
+import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingDomConnectorDeployer;
 import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentConnector;
 import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentMappingService;
+import org.opendaylight.controller.sal.binding.impl.forward.DomForwardedBindingBrokerImpl;
 import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
+import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
+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.BrokerService;
 import org.opendaylight.controller.sal.core.api.RpcImplementation;
 import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
+import org.opendaylight.controller.sal.core.api.RpcRegistrationListener;
 import org.opendaylight.controller.sal.core.api.data.DataStore;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
+import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService;
 import org.opendaylight.controller.sal.dom.broker.BrokerImpl;
+import org.opendaylight.controller.sal.dom.broker.MountPointManagerImpl;
 import org.opendaylight.controller.sal.dom.broker.impl.DataStoreStatsWrapper;
 import org.opendaylight.controller.sal.dom.broker.impl.HashMapDataStore;
 import org.opendaylight.controller.sal.dom.broker.impl.RpcRouterImpl;
 import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareDataStoreAdapter;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
@@ -33,26 +51,26 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Predicate;
+import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.ImmutableClassToInstanceMap;
 import com.google.common.util.concurrent.ListeningExecutorService;
 import com.google.common.util.concurrent.MoreExecutors;
 
 import static com.google.common.base.Preconditions.*;
 
 public class BindingTestContext implements AutoCloseable {
-    
-    
+
     public static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier TREE_ROOT = org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
             .builder().toInstance();
 
     private static final Logger LOG = LoggerFactory.getLogger(BindingTestContext.class);
-    
+
     private RuntimeGeneratedMappingServiceImpl mappingServiceImpl;
-    
-    
-    private BindingAwareBrokerImpl baBrokerImpl;
+
+    private DomForwardedBindingBrokerImpl baBrokerImpl;
     private DataBrokerImpl baDataImpl;
     private NotificationBrokerImpl baNotifyImpl;
-    private BindingIndependentConnector baConnectDataServiceImpl;
+    private BindingIndependentConnector baConnectImpl;
 
     private org.opendaylight.controller.sal.dom.broker.DataBrokerImpl biDataImpl;
     private BrokerImpl biBrokerImpl;
@@ -61,15 +79,15 @@ public class BindingTestContext implements AutoCloseable {
     private DataStoreStatsWrapper dataStoreStats;
     private DataStore dataStore;
 
-    
     private boolean dataStoreStatisticsEnabled = false;
-    
+
     private final ListeningExecutorService executor;
     private final ClassPool classPool;
 
     private final boolean startWithSchema;
 
-    
+    private MountPointManagerImpl biMountImpl;
+
     protected BindingTestContext(ListeningExecutorService executor, ClassPool classPool, boolean startWithSchema) {
         this.executor = executor;
         this.classPool = classPool;
@@ -82,74 +100,133 @@ public class BindingTestContext implements AutoCloseable {
         rawDataStore = new HashMapDataStore();
         schemaAwareDataStore = new SchemaAwareDataStoreAdapter();
         schemaAwareDataStore.changeDelegate(rawDataStore);
-        if(dataStoreStatisticsEnabled) {
-        dataStoreStats = new DataStoreStatsWrapper(schemaAwareDataStore);
-        dataStore = dataStoreStats;
+        if (dataStoreStatisticsEnabled) {
+            dataStoreStats = new DataStoreStatsWrapper(schemaAwareDataStore);
+            dataStore = dataStoreStats;
         } else {
             dataStore = schemaAwareDataStore;
         }
-        
+
         biDataImpl.registerConfigurationReader(TREE_ROOT, dataStore);
         biDataImpl.registerOperationalReader(TREE_ROOT, dataStore);
         biDataImpl.registerCommitHandler(TREE_ROOT, dataStore);
     }
-    
+
     public void startDomDataBroker() {
-        checkState(executor != null,"Executor needs to be set");
+        checkState(executor != null, "Executor needs to be set");
         biDataImpl = new org.opendaylight.controller.sal.dom.broker.DataBrokerImpl();
         biDataImpl.setExecutor(executor);
     }
-    
+
     public void startBindingDataBroker() {
-        checkState(executor != null,"Executor needs to be set");
+        checkState(executor != null, "Executor needs to be set");
         baDataImpl = new DataBrokerImpl();
         baDataImpl.setExecutor(executor);
     }
-    
+
     public void startBindingBroker() {
-        checkState(executor != null,"Executor needs to be set");
-        checkState(baDataImpl != null,"Binding Data Broker must be started");
+        checkState(executor != null, "Executor needs to be set");
+        checkState(baDataImpl != null, "Binding Data Broker must be started");
         checkState(baNotifyImpl != null, "Notification Service must be started");
-        baBrokerImpl = new BindingAwareBrokerImpl("test",null);
-        
+        baBrokerImpl = new DomForwardedBindingBrokerImpl("test");
+
+        baBrokerImpl.getMountManager().setDataCommitExecutor(executor);
+        baBrokerImpl.getMountManager().setNotificationExecutor(executor);
+        baBrokerImpl.setRpcBroker(new RpcProviderRegistryImpl("test"));
         baBrokerImpl.setDataBroker(baDataImpl);
-        baBrokerImpl.setNotifyBroker(baNotifyImpl);
-        
+        baBrokerImpl.setNotificationBroker(baNotifyImpl);
         baBrokerImpl.start();
     }
-    
-    public void startBindingToDomDataConnector() {
-        checkState(baDataImpl != null,"Binding Data Broker needs to be started");
-        checkState(biDataImpl != null,"DOM Data Broker needs to be started.");
-        checkState(mappingServiceImpl != null,"DOM Mapping Service needs to be started.");
-        baConnectDataServiceImpl = new BindingIndependentConnector();
-        baConnectDataServiceImpl.setRpcRegistry(baBrokerImpl);
-        baConnectDataServiceImpl.setDomRpcRegistry(getDomRpcRegistry());
-        baConnectDataServiceImpl.setBaDataService(baDataImpl);
-        baConnectDataServiceImpl.setBiDataService(biDataImpl);
-        baConnectDataServiceImpl.setMappingService(mappingServiceImpl);
-        baConnectDataServiceImpl.start();
+
+    public void startForwarding() {
+        checkState(baDataImpl != null, "Binding Data Broker needs to be started");
+        checkState(biDataImpl != null, "DOM Data Broker needs to be started.");
+        checkState(mappingServiceImpl != null, "DOM Mapping Service needs to be started.");
+
+        baConnectImpl = BindingDomConnectorDeployer.createConnector(getBindingToDomMappingService());
+        baConnectImpl.setDomRpcRegistry(getDomRpcRegistry());
+        baBrokerImpl.setConnector(baConnectImpl);
+        baBrokerImpl.setDomProviderContext(createMockContext());
+        baBrokerImpl.startForwarding();
     }
-    
+
+    private ProviderSession createMockContext() {
+        // TODO Auto-generated method stub
+        final ClassToInstanceMap<BrokerService> domBrokerServices = ImmutableClassToInstanceMap
+                .<BrokerService> builder()
+                //
+                .put(org.opendaylight.controller.sal.core.api.data.DataProviderService.class, biDataImpl) //
+                .put(RpcProvisionRegistry.class, biBrokerImpl.getRouter()) //
+                .put(MountProvisionService.class, biMountImpl) //
+                .build();
+
+        return new ProviderSession() {
+
+            @Override
+            public Future<RpcResult<CompositeNode>> rpc(QName rpc, CompositeNode input) {
+                throw new UnsupportedOperationException();
+            }
+
+            @Override
+            public <T extends BrokerService> T getService(Class<T> service) {
+                return domBrokerServices.getInstance(service);
+            }
+
+            @Override
+            public boolean isClosed() {
+                return false;
+            }
+
+            @Override
+            public Set<QName> getSupportedRpcs() {
+                return null;
+            }
+
+            @Override
+            public void close() {
+            }
+
+            @Override
+            public ListenerRegistration<RpcRegistrationListener> addRpcRegistrationListener(
+                    RpcRegistrationListener listener) {
+                return null;
+            }
+
+            @Override
+            public RpcRegistration addRpcImplementation(QName rpcType, RpcImplementation implementation)
+                    throws IllegalArgumentException {
+                return null;
+            }
+
+            @Override
+            public RoutedRpcRegistration addRoutedRpcImplementation(QName rpcType, RpcImplementation implementation) {
+                return null;
+            }
+
+            @Override
+            public RoutedRpcRegistration addMountedRpcImplementation(QName rpcType, RpcImplementation implementation) {
+                return null;
+            }
+        };
+    }
+
     public void startBindingToDomMappingService() {
-        checkState(classPool != null,"ClassPool needs to be present");
+        checkState(classPool != null, "ClassPool needs to be present");
         mappingServiceImpl = new RuntimeGeneratedMappingServiceImpl();
         mappingServiceImpl.setPool(classPool);
         mappingServiceImpl.start(null);
     }
-    
-    
+
     public void updateYangSchema(String[] files) {
         SchemaContext context = getContext(files);
-        if(schemaAwareDataStore != null) {
+        if (schemaAwareDataStore != null) {
             schemaAwareDataStore.onGlobalContextUpdated(context);
         }
-        if(mappingServiceImpl != null) {
+        if (mappingServiceImpl != null) {
             mappingServiceImpl.onGlobalContextUpdated(context);
         }
     }
-    
-    
+
     public static String[] getAllYangFilesOnClasspath() {
         Predicate<String> predicate = new Predicate<String>() {
             @Override
@@ -161,7 +238,7 @@ public class BindingTestContext implements AutoCloseable {
         Set<String> result = reflection.getResources(predicate);
         return (String[]) result.toArray(new String[result.size()]);
     }
-    
+
     private static SchemaContext getContext(String[] yangFiles) {
         ClassLoader loader = BindingTestContext.class.getClassLoader();
         List<InputStream> streams = new ArrayList<>();
@@ -173,7 +250,7 @@ public class BindingTestContext implements AutoCloseable {
         Set<Module> modules = parser.parseYangModelsFromStreams(streams);
         return parser.resolveSchemaContext(modules);
     }
-    
+
     public void start() {
         startBindingDataBroker();
         startBindingNotificationBroker();
@@ -181,13 +258,19 @@ public class BindingTestContext implements AutoCloseable {
         startDomDataBroker();
         startDomDataStore();
         startDomBroker();
+        startDomMountPoint();
         startBindingToDomMappingService();
-        startBindingToDomDataConnector();
-        if(startWithSchema) {
+        startForwarding();
+        if (startWithSchema) {
             loadYangSchemaFromClasspath();
         }
     }
 
+    private void startDomMountPoint() {
+        biMountImpl = new MountPointManagerImpl();
+        biMountImpl.setDataBroker(getDomDataBroker());
+    }
+
     private void startDomBroker() {
         checkState(executor != null);
         biBrokerImpl = new BrokerImpl();
@@ -198,7 +281,7 @@ public class BindingTestContext implements AutoCloseable {
     public void startBindingNotificationBroker() {
         checkState(executor != null);
         baNotifyImpl = new NotificationBrokerImpl(executor);
-        
+
     }
 
     public void loadYangSchemaFromClasspath() {
@@ -223,10 +306,10 @@ public class BindingTestContext implements AutoCloseable {
     }
 
     public void logDataStoreStatistics() {
-        if(dataStoreStats == null) {
+        if (dataStoreStats == null) {
             return;
         }
-        
+
         LOG.info("BIDataStore Statistics: Configuration Read Count: {} TotalTime: {} ms AverageTime (ns): {} ms",
                 dataStoreStats.getConfigurationReadCount(), dataStoreStats.getConfigurationReadTotalTime(),
                 dataStoreStats.getConfigurationReadAverageTime());
@@ -241,22 +324,30 @@ public class BindingTestContext implements AutoCloseable {
     }
 
     public RpcProviderRegistry getBindingRpcRegistry() {
-        return baBrokerImpl;
+        return baBrokerImpl.getRoot();
     }
 
     public RpcProvisionRegistry getDomRpcRegistry() {
-        if(biBrokerImpl == null) {
+        if (biBrokerImpl == null) {
             return null;
         }
         return biBrokerImpl.getRouter();
     }
-    
+
     public RpcImplementation getDomRpcInvoker() {
         return biBrokerImpl.getRouter();
     }
-    
+
     @Override
     public void close() throws Exception {
-        
+
+    }
+
+    public MountProviderService getBindingMountProviderService() {
+        return baBrokerImpl.getMountManager();
+    }
+
+    public MountProvisionService getDomMountProviderService() {
+        return biMountImpl;
     }
 }
index 55bff1a..0258c3e 100644 (file)
@@ -5,7 +5,7 @@ import org.junit.Test;
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
-import org.opendaylight.controller.sal.binding.impl.connect.dom.CommitHandlersTransactions;
+import org.opendaylight.controller.sal.common.util.CommitHandlerTransactions;
 import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
 import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpVersion;
@@ -136,7 +136,7 @@ public class ChangeOriginatedInDomBrokerTest extends AbstractDataServiceTest {
             public org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> requestCommit(
                     DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification) {
                 modificationCapture = modification;
-                return CommitHandlersTransactions.allwaysSuccessfulTransaction(modification);
+                return CommitHandlerTransactions.allwaysSuccessfulTransaction(modification);
             }
 
         };
diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerMountPointTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerMountPointTest.java
new file mode 100644 (file)
index 0000000..a99d80f
--- /dev/null
@@ -0,0 +1,154 @@
+package org.opendaylight.controller.sal.binding.test.connect.dom;
+
+import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+
+import java.math.BigInteger;
+import java.util.Collections;
+import java.util.Map;
+
+import javax.management.Notification;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.md.sal.common.api.data.DataModification;
+import org.opendaylight.controller.md.sal.common.api.data.DataReader;
+import org.opendaylight.controller.sal.binding.api.mount.MountProviderInstance;
+import org.opendaylight.controller.sal.binding.api.mount.MountProviderService;
+import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory;
+import org.opendaylight.controller.sal.binding.test.util.BindingTestContext;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.statistics.GroupStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode;
+import org.opendaylight.yangtools.yang.data.impl.util.CompositeNodeBuilder;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.util.concurrent.MoreExecutors;
+
+public class CrossBrokerMountPointTest {
+
+    private static final QName NODE_ID_QNAME = QName.create(Node.QNAME, "id");
+    private static final QName FLOW_ID_QNAME = QName.create(Flow.QNAME, "id");
+    private static final QName FLOW_NODE_QNAME = QName.create(Flow.QNAME, "node");
+    private static final QName TABLE_ID_QNAME = QName.create(Table.QNAME, "id");
+
+    private static final String NODE_ID = "node:1";
+
+    private static final NodeKey NODE_KEY = new NodeKey(new NodeId(NODE_ID));
+
+    private static final Map<QName, Object> NODE_KEY_BI = Collections.<QName, Object> singletonMap(NODE_ID_QNAME,
+            NODE_ID);
+
+    private static final InstanceIdentifier<Node> NODE_INSTANCE_ID_BA = InstanceIdentifier.builder(Nodes.class) //
+            .child(Node.class, NODE_KEY).toInstance();
+    private static GroupKey GROUP_KEY = new GroupKey(new GroupId(0L));
+
+    private static final InstanceIdentifier<GroupStatistics> GROUP_STATISTICS_ID_BA = InstanceIdentifier
+            .builder(NODE_INSTANCE_ID_BA).augmentation(FlowCapableNode.class) //
+            .child(Group.class, GROUP_KEY) //
+            .augmentation(NodeGroupStatistics.class) //
+            .child(GroupStatistics.class) //
+            .toInstance();
+
+    private static final QName AUGMENTED_GROUP_STATISTICS = QName.create(NodeGroupStatistics.QNAME,
+            GroupStatistics.QNAME.getLocalName());
+
+    private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODE_INSTANCE_ID_BI = //
+    org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() //
+            .node(Nodes.QNAME) //
+            .nodeWithKey(Node.QNAME, NODE_KEY_BI) //
+            .toInstance();
+
+    private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier GROUP_STATISTICS_ID_BI = org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
+            //
+            .builder(NODE_INSTANCE_ID_BI)
+            .nodeWithKey(QName.create(FlowCapableNode.QNAME, "group"), QName.create(FlowCapableNode.QNAME, "group-id"),
+                    0L).node(AUGMENTED_GROUP_STATISTICS).toInstance();
+
+    private static final NodeRef NODE_REF = new NodeRef(NODE_INSTANCE_ID_BA);
+
+    private BindingTestContext testContext;
+    private MountProviderService bindingMountPointService;
+    private MountProvisionService domMountPointService;
+
+    @Before
+    public void setup() {
+        BindingBrokerTestFactory testFactory = new BindingBrokerTestFactory();
+        testFactory.setExecutor(MoreExecutors.sameThreadExecutor());
+        testFactory.setStartWithParsedSchema(true);
+        testContext = testFactory.getTestContext();
+
+        testContext.start();
+        bindingMountPointService = testContext.getBindingMountProviderService();
+        domMountPointService = testContext.getDomMountProviderService();
+
+        // biRpcInvoker = testContext.getDomRpcInvoker();
+        assertNotNull(bindingMountPointService);
+        assertNotNull(domMountPointService);
+
+        // flowService = MessageCapturingFlowService.create(baRpcRegistry);
+    }
+
+    @Test
+    public void testMountPoint() {
+
+        testContext.getBindingDataBroker().readOperationalData(NODE_INSTANCE_ID_BA);
+
+        MountProvisionInstance domMountPoint = domMountPointService.createMountPoint(NODE_INSTANCE_ID_BI);
+        assertNotNull(domMountPoint);
+        MountProviderInstance bindingMountPoint = bindingMountPointService.getMountPoint(NODE_INSTANCE_ID_BA);
+        assertNotNull(bindingMountPoint);
+
+        final BigInteger packetCount = BigInteger.valueOf(500L);
+        
+        
+        DataReader<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> simpleReader = new DataReader<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode>() {
+
+            @Override
+            public CompositeNode readConfigurationData(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier arg0) {
+                return null;
+            }
+
+            
+            @Override
+            public CompositeNode readOperationalData(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier arg0) {
+                if (arg0.equals(GROUP_STATISTICS_ID_BI)) {
+                    ImmutableCompositeNode data = ImmutableCompositeNode
+                            .builder()
+                            .setQName(AUGMENTED_GROUP_STATISTICS)
+                            .addLeaf(QName.create(AUGMENTED_GROUP_STATISTICS, "packet-count"), packetCount) //
+                            .toInstance();
+
+                    return data;
+                }
+                return null;
+            }
+
+        };
+        domMountPoint.registerOperationalReader(NODE_INSTANCE_ID_BI, simpleReader);
+        
+        GroupStatistics data = (GroupStatistics) bindingMountPoint.readOperationalData(GROUP_STATISTICS_ID_BA);
+        assertNotNull(data);
+        assertEquals(packetCount,data.getPacketCount().getValue());
+    }
+}
index 112b57c..c943226 100644 (file)
@@ -87,6 +87,7 @@ public class TestHelper {
                 mavenBundle(CONTROLLER, "sal-binding-api").versionAsInProject(), // //
                 mavenBundle(CONTROLLER, "sal-binding-config").versionAsInProject(), //
                 mavenBundle(CONTROLLER, "sal-binding-broker-impl").versionAsInProject(), // //
+                mavenBundle(CONTROLLER, "sal-binding-util").versionAsInProject(), //
                 mavenBundle("org.javassist", "javassist").versionAsInProject(), // //
                 mavenBundle(CONTROLLER, "sal-common-util").versionAsInProject(), // //
 
index 6fec180..2f86ee4 100644 (file)
@@ -5,13 +5,16 @@ import static org.junit.Assert.assertNotNull;
 
 import java.math.BigInteger;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality;
 import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.controller.sal.binding.api.NotificationService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
@@ -24,6 +27,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalF
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemoved;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.opendaylight.yangtools.yang.binding.RpcService;
 
 public class NoficationTest extends AbstractTest {
 
@@ -95,16 +99,36 @@ public class NoficationTest extends AbstractTest {
          * The registration of the Consumer 2. SalFlowListener is registered
          * registered as notification listener.
          */
-        BindingAwareConsumer consumer2 = new BindingAwareConsumer() {
+        BindingAwareProvider provider = new BindingAwareProvider() {
+            
             @Override
-            public void onSessionInitialized(ConsumerContext session) {
+            public void onSessionInitiated(ProviderContext session) {
                 listener2Reg = session.getSALService(NotificationProviderService.class).registerNotificationListener(
                         listener2);
             }
+            
+            @Override
+            public void onSessionInitialized(ConsumerContext session) {
+                // TODO Auto-generated method stub
+                
+            }
+            
+            @Override
+            public Collection<? extends RpcService> getImplementations() {
+                // TODO Auto-generated method stub
+                return null;
+            }
+            
+            @Override
+            public Collection<? extends ProviderFunctionality> getFunctionality() {
+                // TODO Auto-generated method stub
+                return null;
+            }
+            
         };
 
         // registerConsumer method calls onSessionInitialized method above
-        broker.registerConsumer(consumer2, getBundleContext());
+        broker.registerProvider(provider, getBundleContext());
 
         /**
          * 3 notifications are published
index 26041ea..67c10f4 100644 (file)
             <artifactId>sal-binding-api</artifactId>
             <version>1.0-SNAPSHOT</version>
         </dependency>
-        <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.apache.felix.dependencymanager</artifactId>
-            <version>3.1.0</version>
-        </dependency>
     </dependencies>
 </project>
diff --git a/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalConsumerInstance.java b/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalConsumerInstance.java
new file mode 100644 (file)
index 0000000..ff6f618
--- /dev/null
@@ -0,0 +1,178 @@
+package org.opendaylight.controller.md.sal.binding.util;
+
+import java.util.concurrent.Future;
+import java.util.zip.Checksum;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
+import org.opendaylight.controller.sal.binding.api.NotificationListener;
+import org.opendaylight.controller.sal.binding.api.NotificationService;
+import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
+import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
+import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
+import org.opendaylight.controller.sal.binding.api.mount.MountInstance;
+import org.opendaylight.controller.sal.common.DataStoreIdentifier;
+import org.opendaylight.yangtools.concepts.Identifiable;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.DataRoot;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.Notification;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+import com.google.common.base.Preconditions;
+
+public abstract class AbstractBindingSalConsumerInstance<D extends DataBrokerService, N extends NotificationService, R extends RpcConsumerRegistry> //
+        implements //
+        RpcConsumerRegistry, //
+        NotificationService, //
+        DataBrokerService {
+
+    private final R rpcRegistry;
+    private final N notificationBroker;
+    private final D dataBroker;
+
+    protected final R getRpcRegistry() {
+        return rpcRegistry;
+    }
+
+    protected final N getNotificationBroker() {
+        return notificationBroker;
+    }
+
+    protected final D getDataBroker() {
+        return dataBroker;
+    }
+    
+    protected final R getRpcRegistryChecked() {
+        Preconditions.checkState(rpcRegistry != null,"Rpc Registry is not available.");
+        return rpcRegistry;
+    }
+
+    protected final N getNotificationBrokerChecked() {
+        Preconditions.checkState(notificationBroker != null,"Notification Broker is not available.");
+        return notificationBroker;
+    }
+
+    protected final D getDataBrokerChecked() {
+        Preconditions.checkState(dataBroker != null, "Data Broker is not available");
+        return dataBroker;
+    }
+    
+
+    protected AbstractBindingSalConsumerInstance(R rpcRegistry, N notificationBroker, D dataBroker) {
+        this.rpcRegistry = rpcRegistry;
+        this.notificationBroker = notificationBroker;
+        this.dataBroker = dataBroker;
+    }
+
+    public <T extends RpcService> T getRpcService(Class<T> module) {
+        return getRpcRegistryChecked().getRpcService(module);
+    }
+
+    @Deprecated
+    public <T extends Notification> void addNotificationListener(Class<T> notificationType,
+            NotificationListener<T> listener) {
+        getNotificationBrokerChecked().addNotificationListener(notificationType, listener);
+    }
+
+    @Deprecated
+    public void addNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
+        getNotificationBrokerChecked().addNotificationListener(listener);
+    }
+
+    @Deprecated
+    public void removeNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
+        getNotificationBrokerChecked().removeNotificationListener(listener);
+    }
+
+    @Deprecated
+    public <T extends Notification> void removeNotificationListener(Class<T> notificationType,
+            NotificationListener<T> listener) {
+        getNotificationBrokerChecked().removeNotificationListener(notificationType, listener);
+    }
+
+    public <T extends Notification> Registration<NotificationListener<T>> registerNotificationListener(
+            Class<T> notificationType, NotificationListener<T> listener) {
+        return getNotificationBrokerChecked().registerNotificationListener(notificationType, listener);
+    }
+
+    public Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> registerNotificationListener(
+            org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
+        return getNotificationBrokerChecked().registerNotificationListener(listener);
+    }
+
+    @Deprecated
+    public <T extends DataRoot> T getData(DataStoreIdentifier store, Class<T> rootType) {
+        return getDataBrokerChecked().getData(store, rootType);
+    }
+
+    @Deprecated
+    public <T extends DataRoot> T getData(DataStoreIdentifier store, T filter) {
+        return getDataBrokerChecked().getData(store, filter);
+    }
+
+    @Deprecated
+    public <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, Class<T> rootType) {
+        return getDataBrokerChecked().getCandidateData(store, rootType);
+    }
+
+    @Deprecated
+    public <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, T filter) {
+        return getDataBrokerChecked().getCandidateData(store, filter);
+    }
+
+    @Deprecated
+    public RpcResult<DataRoot> editCandidateData(DataStoreIdentifier store, DataRoot changeSet) {
+        return getDataBrokerChecked().editCandidateData(store, changeSet);
+    }
+
+    @Deprecated
+    public Future<RpcResult<Void>> commit(DataStoreIdentifier store) {
+        return getDataBrokerChecked().commit(store);
+    }
+
+    @Deprecated
+    public DataObject getData(InstanceIdentifier<? extends DataObject> data) {
+        return getDataBrokerChecked().getData(data);
+    }
+
+    @Deprecated
+    public DataObject getConfigurationData(InstanceIdentifier<?> data) {
+        return getDataBrokerChecked().getConfigurationData(data);
+    }
+
+    public DataModificationTransaction beginTransaction() {
+        return getDataBrokerChecked().beginTransaction();
+    }
+
+    @Deprecated
+    public void registerChangeListener(InstanceIdentifier<? extends DataObject> path, DataChangeListener changeListener) {
+        getDataBrokerChecked().registerChangeListener(path, changeListener);
+    }
+
+    @Deprecated
+    public void unregisterChangeListener(InstanceIdentifier<? extends DataObject> path,
+            DataChangeListener changeListener) {
+        getDataBrokerChecked().unregisterChangeListener(path, changeListener);
+    }
+
+    @Deprecated
+    public DataObject readConfigurationData(InstanceIdentifier<? extends DataObject> path) {
+        return getDataBrokerChecked().readConfigurationData(path);
+    }
+
+    public DataObject readOperationalData(InstanceIdentifier<? extends DataObject> path) {
+        return getDataBrokerChecked().readOperationalData(path);
+    }
+
+    @Deprecated
+    public ListenerRegistration<DataChangeListener> registerDataChangeListener(
+            InstanceIdentifier<? extends DataObject> path, DataChangeListener listener) {
+        return getDataBrokerChecked().registerDataChangeListener(path, listener);
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalProviderInstance.java b/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalProviderInstance.java
new file mode 100644 (file)
index 0000000..278e90e
--- /dev/null
@@ -0,0 +1,95 @@
+package org.opendaylight.controller.md.sal.binding.util;
+
+import java.util.concurrent.ExecutorService;
+
+import org.opendaylight.controller.md.sal.common.api.RegistrationListener;
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandlerRegistration;
+import org.opendaylight.controller.md.sal.common.api.data.DataReader;
+import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.controller.sal.binding.api.mount.MountProviderInstance;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.Notification;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+public abstract class AbstractBindingSalProviderInstance<D extends DataProviderService, N extends NotificationProviderService, R extends RpcProviderRegistry> //
+        extends AbstractBindingSalConsumerInstance<D, N, R> //
+        implements //
+        DataProviderService, //
+        RpcProviderRegistry, //
+        NotificationProviderService {
+
+    public AbstractBindingSalProviderInstance(R rpcRegistry, N notificationBroker,
+            D dataBroker) {
+        super(rpcRegistry, notificationBroker, dataBroker);
+    }
+
+    @Override
+    public Registration<DataReader<InstanceIdentifier<? extends DataObject>, DataObject>> registerDataReader(
+            InstanceIdentifier<? extends DataObject> path,
+            DataReader<InstanceIdentifier<? extends DataObject>, DataObject> reader) {
+        return getDataBrokerChecked().registerDataReader(path, reader);
+    }
+
+    @Override
+    public Registration<DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject>> registerCommitHandler(
+            InstanceIdentifier<? extends DataObject> path,
+            DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> commitHandler) {
+        return getDataBrokerChecked().registerCommitHandler(path, commitHandler);
+    }
+
+    @Override
+    public ListenerRegistration<RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier<? extends DataObject>, DataObject>>> registerCommitHandlerListener(
+            RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier<? extends DataObject>, DataObject>> commitHandlerListener) {
+        return getDataBrokerChecked().registerCommitHandlerListener(commitHandlerListener);
+    }
+
+    @Override
+    public <T extends RpcService> RpcRegistration<T> addRpcImplementation(Class<T> type, T implementation)
+            throws IllegalStateException {
+        return getRpcRegistryChecked().addRpcImplementation(type, implementation);
+    }
+
+    @Override
+    public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> type, T implementation)
+            throws IllegalStateException {
+        return getRpcRegistryChecked().addRoutedRpcImplementation(type, implementation);
+    }
+
+    @Override
+    @Deprecated
+    public void notify(Notification notification) {
+        getNotificationBrokerChecked().notify(notification);
+    }
+
+    @Override
+    @Deprecated
+    public void notify(Notification notification, ExecutorService service) {
+        getNotificationBrokerChecked().notify(notification, service);
+    }
+
+    @Override
+    public void publish(Notification notification) {
+        getNotificationBrokerChecked().publish(notification);
+    }
+
+    @Override
+    public void publish(Notification notification, ExecutorService service) {
+        getNotificationBrokerChecked().publish(notification, service);
+    }
+
+    @Override
+    public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
+            L listener) {
+        return getRpcRegistryChecked().registerRouteChangeListener(listener);
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/BindingContextUtils.java b/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/BindingContextUtils.java
new file mode 100644 (file)
index 0000000..6f2186b
--- /dev/null
@@ -0,0 +1,143 @@
+package org.opendaylight.controller.md.sal.binding.util;
+
+import java.awt.image.SinglePixelPackedSampleModel;
+
+import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
+import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
+import org.opendaylight.controller.sal.binding.api.BindingAwareService;
+import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+import static com.google.common.base.Preconditions.*;
+
+import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.MutableClassToInstanceMap;
+
+public class BindingContextUtils {
+
+    public static ConsumerContext createConsumerContext(BindingAwareConsumer consumer,
+            ClassToInstanceMap<BindingAwareService> serviceProvider) {
+        checkNotNull(consumer,"Consumer should not be null");
+        checkNotNull(serviceProvider,"Service map should not be null");
+        return new SingleConsumerContextImpl(serviceProvider);
+    }
+    
+    public static ProviderContext createProviderContext(BindingAwareProvider provider,
+            ClassToInstanceMap<BindingAwareService> serviceProvider) {
+        checkNotNull(provider,"Provider should not be null");
+        checkNotNull(serviceProvider,"Service map should not be null");
+        return new SingleProviderContextImpl(serviceProvider);
+    }
+
+    public static ConsumerContext createConsumerContextAndInitialize(BindingAwareConsumer consumer,
+            ClassToInstanceMap<BindingAwareService> serviceProvider) {
+        ConsumerContext context = createConsumerContext(consumer, serviceProvider);
+        consumer.onSessionInitialized(context);
+        return context;
+    }
+    
+    public static ProviderContext createProviderContextAndInitialize(BindingAwareProvider provider,
+            ClassToInstanceMap<BindingAwareService> serviceProvider) {
+        ProviderContext context = createProviderContext(provider, serviceProvider);
+        provider.onSessionInitiated(context);
+        return context;
+    }
+
+    public static <T extends BindingAwareService> T createContextProxyOrReturnService(Class<T> service, T instance) {
+        // FIXME: Create Proxy
+        return instance;
+    }
+    
+    private static class SingleConsumerContextImpl implements ConsumerContext, AutoCloseable {
+        
+        private ClassToInstanceMap<BindingAwareService> alreadyRetrievedServices;
+        private ClassToInstanceMap<BindingAwareService> serviceProvider;
+
+        public SingleConsumerContextImpl(ClassToInstanceMap<BindingAwareService> serviceProvider) {
+            this.alreadyRetrievedServices = MutableClassToInstanceMap.create();
+            this.serviceProvider = serviceProvider;
+        }
+
+        @Override
+        public final <T extends RpcService> T getRpcService(Class<T> module) {
+            return getSALService(RpcConsumerRegistry.class).getRpcService(module);
+        }
+        
+        @Override
+        public final <T extends BindingAwareService> T getSALService(Class<T> service) {
+            checkNotNull(service,"Service class should not be null.");
+            T potential = alreadyRetrievedServices.getInstance(service);
+            if(potential != null) {
+                return potential;
+            }
+            return tryToRetrieveSalService(service);
+        }
+        
+        private synchronized <T extends BindingAwareService> T tryToRetrieveSalService(Class<T> service) {
+            final T potential = alreadyRetrievedServices.getInstance(service);
+            if(potential != null) {
+                return potential;
+            }
+            final T requested = serviceProvider.getInstance(service);
+            if(requested == null) {
+                throw new IllegalArgumentException("Requested service "+service.getName() +" is not available.");
+            }
+            final T retrieved = BindingContextUtils.createContextProxyOrReturnService(service,requested);
+            alreadyRetrievedServices.put(service, retrieved);
+            return retrieved;
+        }
+        
+        @Override
+        public final void close() throws Exception {
+            alreadyRetrievedServices = null;
+            serviceProvider = null;
+        }
+    }
+    
+    private static class SingleProviderContextImpl extends SingleConsumerContextImpl implements ProviderContext {
+
+        public SingleProviderContextImpl(ClassToInstanceMap<BindingAwareService> serviceProvider) {
+            super(serviceProvider);
+        }
+        
+        @Override
+        public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
+                L listener) {
+            return getSALService(RpcProviderRegistry.class).registerRouteChangeListener(listener);
+        }
+        
+        @Override
+        public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> type,
+                T implementation) throws IllegalStateException {
+            return getSALService(RpcProviderRegistry.class).addRoutedRpcImplementation(type, implementation);
+        }
+        
+        @Override
+        public <T extends RpcService> RpcRegistration<T> addRpcImplementation(Class<T> type, T implementation)
+                throws IllegalStateException {
+            return getSALService(RpcProviderRegistry.class).addRpcImplementation(type, implementation);
+        }
+        
+        @Deprecated
+        @Override
+        public void registerFunctionality(ProviderFunctionality functionality) {
+            // NOOP
+        }
+        
+        @Deprecated
+        @Override
+        public void unregisterFunctionality(ProviderFunctionality functionality) {
+            // NOOP
+        }
+    }
+}
index fd81af3..17de595 100644 (file)
@@ -6,32 +6,26 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public final class TypeSafeDataReader {
 
-    
-    private final DataReader<InstanceIdentifier<? extends DataObject>,DataObject> delegate;
-    
-    
-    
+    private final DataReader<InstanceIdentifier<? extends DataObject>, DataObject> delegate;
+
     public DataReader<InstanceIdentifier<?>, DataObject> getDelegate() {
         return delegate;
     }
 
-
     public TypeSafeDataReader(DataReader<InstanceIdentifier<? extends DataObject>, DataObject> delegate) {
         this.delegate = delegate;
     }
 
-
     @SuppressWarnings("unchecked")
     public <D extends DataObject> D readConfigurationData(InstanceIdentifier<D> path) {
         return (D) delegate.readConfigurationData(path);
     }
-    
-    
+
     @SuppressWarnings("unchecked")
-    public <D extends DataObject> D  readOperationalData(InstanceIdentifier<D> path) {
+    public <D extends DataObject> D readOperationalData(InstanceIdentifier<D> path) {
         return (D) delegate.readOperationalData(path);
     }
-    
+
     public static TypeSafeDataReader forReader(DataReader<InstanceIdentifier<? extends DataObject>, DataObject> delegate) {
         return new TypeSafeDataReader(delegate);
     }

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