Merge "Devices dashlet show port total numbers, modal shows collapsible list Replaced...
authorAndrew Kim <andrekim@cisco.com>
Fri, 16 Aug 2013 15:33:46 +0000 (15:33 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 16 Aug 2013 15:33:46 +0000 (15:33 +0000)
82 files changed:
opendaylight/sal/yang-prototype/pom.xml
opendaylight/sal/yang-prototype/sal/pom.xml
opendaylight/sal/yang-prototype/sal/sal-binding-api/pom.xml
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareBroker.java
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareConsumer.java
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareProvider.java
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareService.java
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationListener.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationProviderService.java
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationService.java
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataBrokerService.java [moved from opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/DataBrokerService.java with 91% similarity]
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataCommitHandler.java [moved from opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/DataCommitHandler.java with 92% similarity]
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataConsumerService.java [moved from opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/DataProviderService.java with 76% similarity]
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataRefresher.java [moved from opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/DataRefresher.java with 68% similarity]
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataValidator.java [moved from opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/DataValidator.java with 67% similarity]
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/RuntimeDataProvider.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/package-info.java
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/pom.xml
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingBrokerImpl.java [deleted file]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/BrokerActivator.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/Constants.xtend [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/DataModule.java [deleted file]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.xtend [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationInvoker.java [deleted file]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationModule.java [deleted file]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationServiceImpl.xtend [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiConsumerContext.xtend [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProxyContext.xtend [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcServiceRegistrationImpl.xtend [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/utils/GeneratorUtils.xtend [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/utils/PropertiesUtils.xtend [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/utils/package-info.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-spi/pom.xml
opendaylight/sal/yang-prototype/sal/sal-binding-spi/src/main/java/org/opendaylight/controller/sal/binding/spi/DataDomToJavaTransformer.java
opendaylight/sal/yang-prototype/sal/sal-binding-spi/src/main/java/org/opendaylight/controller/sal/binding/spi/JavaToDataDomTransformer.java
opendaylight/sal/yang-prototype/sal/sal-binding-spi/src/main/java/org/opendaylight/controller/sal/binding/spi/Mapper.java
opendaylight/sal/yang-prototype/sal/sal-binding-spi/src/main/java/org/opendaylight/controller/sal/binding/spi/MappingProvider.java
opendaylight/sal/yang-prototype/sal/sal-binding-spi/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcMapper.java
opendaylight/sal/yang-prototype/sal/sal-binding-spi/src/main/java/org/opendaylight/controller/sal/binding/spi/SALBindingModule.java [deleted file]
opendaylight/sal/yang-prototype/sal/sal-broker-impl/pom.xml
opendaylight/sal/yang-prototype/sal/sal-broker-impl/src/main/java/org/opendaylight/controller/sal/core/impl/BrokerImpl.java
opendaylight/sal/yang-prototype/sal/sal-broker-impl/src/main/java/org/opendaylight/controller/sal/core/impl/DataBrokerModule.java
opendaylight/sal/yang-prototype/sal/sal-broker-impl/src/main/java/org/opendaylight/controller/sal/core/impl/NotificationModule.java
opendaylight/sal/yang-prototype/sal/sal-common-util/pom.xml
opendaylight/sal/yang-prototype/sal/sal-common-util/src/main/java/org/opendaylight/controller/sal/common/util/Futures.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-common-util/src/main/java/org/opendaylight/controller/sal/common/util/Rpcs.java
opendaylight/sal/yang-prototype/sal/sal-common/pom.xml
opendaylight/sal/yang-prototype/sal/sal-core-api/pom.xml
opendaylight/sal/yang-prototype/sal/sal-core-api/src/main/java/org/opendaylight/controller/sal/core/api/Broker.java
opendaylight/sal/yang-prototype/sal/sal-core-api/src/main/java/org/opendaylight/controller/sal/core/api/BrokerService.java
opendaylight/sal/yang-prototype/sal/sal-core-api/src/main/java/org/opendaylight/controller/sal/core/api/Consumer.java
opendaylight/sal/yang-prototype/sal/sal-core-api/src/main/java/org/opendaylight/controller/sal/core/api/Provider.java
opendaylight/sal/yang-prototype/sal/sal-core-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcImplementation.java
opendaylight/sal/yang-prototype/sal/sal-core-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataBrokerService.java
opendaylight/sal/yang-prototype/sal/sal-core-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataCommitHandler.java
opendaylight/sal/yang-prototype/sal/sal-core-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataProviderService.java
opendaylight/sal/yang-prototype/sal/sal-core-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataValidator.java
opendaylight/sal/yang-prototype/sal/sal-core-api/src/main/java/org/opendaylight/controller/sal/core/api/data/package-info.java
opendaylight/sal/yang-prototype/sal/sal-core-api/src/main/java/org/opendaylight/controller/sal/core/api/model/SchemaService.java
opendaylight/sal/yang-prototype/sal/sal-core-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationListener.java
opendaylight/sal/yang-prototype/sal/sal-core-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationProviderService.java
opendaylight/sal/yang-prototype/sal/sal-core-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationService.java
opendaylight/sal/yang-prototype/sal/sal-core-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/package-info.java
opendaylight/sal/yang-prototype/sal/sal-core-api/src/main/java/org/opendaylight/controller/sal/core/api/package-info.java
opendaylight/sal/yang-prototype/sal/sal-core-demo/pom.xml
opendaylight/sal/yang-prototype/sal/sal-core-spi/pom.xml
opendaylight/sal/yang-prototype/sal/sal-data-api/pom.xml
opendaylight/sal/yang-prototype/sal/sal-schema-repository-api/pom.xml
opendaylight/sal/yang-prototype/sal/samples/pom.xml [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/samples/toaster-consumer/pom.xml [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/toaster/provider/api/ToastConsumer.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/toaster/provider/impl/ToastConsumerImpl.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/samples/toaster-it/pom.xml [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/samples/toaster-it/src/test/java/org/opendaylight/controller/sample/toaster/it/ToasterTest.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/samples/toaster-provider/pom.xml [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/OpendaylightToaster.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/ToasterActivator.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/ToasterProvider.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/samples/toaster/pom.xml [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/samples/toaster/src/main/yang/toaster.yang [new file with mode: 0644]

index 6cd785c..525d8d1 100644 (file)
@@ -12,6 +12,7 @@
     </description>
 
     <modules>
+        <module>sal</module>
         <module>concepts-lang</module>
     </modules>
 
     </properties>
 
     <pluginRepositories>
+        <pluginRepository>
+            <id>central</id>
+            <name>central</name>
+            <url>${nexusproxy}/repositories/central/</url>
+        </pluginRepository>
         <pluginRepository>
             <id>central2</id>
             <name>central2</name>
index 677372e..a3d95bd 100644 (file)
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <groupId>org.opendaylight.controller</groupId>
-    <artifactId>sal</artifactId>
-    <version>1.0-SNAPSHOT</version>
-    <packaging>pom</packaging>
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <groupId>org.opendaylight.controller</groupId>
+       <artifactId>sal-parent</artifactId>
+       <version>1.0-SNAPSHOT</version>
+       <packaging>pom</packaging>
 
-    <modules>
-        <module>sal-common</module>
-        <module>sal-common-util</module>
-        <module>sal-core-api</module>
-        <module>sal-data-api</module>
-        <module>sal-binding-api</module>
-        <module>sal-binding-spi</module>
-        <module>sal-binding-broker-impl</module>
-        <module>sal-schema-repository-api</module>
-        <module>sal-core-spi</module>
-        <module>sal-broker-impl</module>
-    </modules>
+       <modules>
+               <module>sal-common</module>
+               <module>sal-common-util</module>
+               <module>sal-data-api</module>
+               <module>sal-binding-api</module>
+               <module>sal-binding-broker-impl</module>
+        <module>samples</module>
+       </modules>
 
-    <properties>
-        <yang.version>0.5.5-SNAPSHOT</yang.version>
-    </properties>
+       <properties>
+               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+               <slf4j.version>1.7.2</slf4j.version>
+               <nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>
+               <yang.version>0.5.7-SNAPSHOT</yang.version>
+               <maven.bundle.version>2.4.0</maven.bundle.version>
+       </properties>
 
-    <dependencyManagement>
-        <dependencies>
-            <dependency>
-                <groupId>com.google.guava</groupId>
-                <artifactId>guava</artifactId>
-                <version>14.0.1</version>
-                <type>jar</type>
-            </dependency>
-            <dependency>
-                <groupId>org.slf4j</groupId>
-                <artifactId>slf4j-api</artifactId>
-                <version>1.7.2</version>
-            </dependency>
-            <dependency>
-                <groupId>junit</groupId>
-                <artifactId>junit</artifactId>
-                <version>4.10</version>
-            </dependency>
-            <dependency>
-                <groupId>org.opendaylight.yangtools</groupId>
-                <artifactId>yang-binding</artifactId>
-                <version>${yang.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.opendaylight.yangtools</groupId>
-                <artifactId>yang-common</artifactId>
-                <version>${yang.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.opendaylight.yangtools</groupId>
-                <artifactId>yang-data-api</artifactId>
-                <version>${yang.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.opendaylight.yangtools</groupId>
-                <artifactId>yang-model-api</artifactId>
-                <version>${yang.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.opendaylight.yangtools</groupId>
-                <artifactId>yang-data-util</artifactId>
-                <version>${yang.version}</version>
-            </dependency>
-        </dependencies>
+    <pluginRepositories>
+        <pluginRepository>
+            <id>central</id>
+            <name>central</name>
+            <url>${nexusproxy}/repositories/central/</url>
+        </pluginRepository>
+        <pluginRepository>
+            <id>central2</id>
+            <name>central2</name>
+            <url>${nexusproxy}/repositories/central2/</url>
+        </pluginRepository>
+        <pluginRepository>
+            <id>opendaylight.snapshot</id>
+            <name>opendaylight.snapshot</name>
+            <url>${nexusproxy}/repositories/opendaylight.snapshot/</url>
+        </pluginRepository>
+    </pluginRepositories>
 
-    </dependencyManagement>
 
-    <dependencies>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-            <optional>true</optional>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-all</artifactId>
-            <version>1.9.5</version>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>2.0</version>
-                <inherited>true</inherited>
-                <configuration>
-                    <source>1.7</source>
-                    <target>1.7</target>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-javadoc-plugin</artifactId>
-                <version>2.8.1</version>
-                <configuration>
-                    <stylesheet>maven</stylesheet>
-                </configuration>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>aggregate</goal>
-                        </goals>
-                        <phase>site</phase>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-    <reporting>
-        <plugins>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>findbugs-maven-plugin</artifactId>
-                <version>2.4.0</version>
-                <configuration>
-                    <effort>Max</effort>
-                    <threshold>Low</threshold>
-                    <goal>site</goal>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>jdepend-maven-plugin</artifactId>
-                <version>2.0-beta-2</version>
-            </plugin>
-        </plugins>
-    </reporting>
+       <repositories>
+               <!-- EBR release -->
+               <!-- http://repository.springsource.com/maven/bundles/release -->
+               <repository>
+                       <id>ebr-bundles-release</id>
+                       <name>ebr-bundles-release</name>
+                       <url>${nexusproxy}/repositories/ebr-bundles-release/</url>
+               </repository>
+               <!-- EBR external -->
+               <!-- http://repository.springsource.com/maven/bundles/external -->
+               <repository>
+                       <id>ebr-bundles-external</id>
+                       <name>ebr-bundles-external</name>
+                       <url>${nexusproxy}/repositories/ebr-bundles-external/</url>
+               </repository>
+               <!-- Maven repo2 mirror -->
+               <!-- http://repo2.maven.org/maven2 -->
+               <repository>
+                       <id>central2</id>
+                       <name>central2</name>
+                       <url>${nexusproxy}/repositories/central2/</url>
+               </repository>
+               <!-- Maven repo1 mirror -->
+               <!-- http://repo1.maven.org/maven2 -->
+               <repository>
+                       <id>central</id>
+                       <name>central</name>
+                       <url>${nexusproxy}/repositories/central/</url>
+               </repository>
+               <!-- Pax mirror -->
+               <!-- https://oss.sonatype.org/content/repositories/ops4j-releases -->
+               <repository>
+                       <id>ops4j-releases</id>
+                       <name>ops4j-releases</name>
+                       <url>${nexusproxy}/repositories/ops4j-releases/</url>
+               </repository>
+               <!-- Third Packages hosted in local maven because not available in other 
+                       places -->
+               <repository>
+                       <id>thirdparty</id>
+                       <name>thirdparty</name>
+                       <url>${nexusproxy}/repositories/thirdparty/</url>
+               </repository>
+               <!-- Jboss mirror -->
+               <!-- https://repository.jboss.org/nexus/content/repositories/releases -->
+               <repository>
+                       <id>jboss.releases</id>
+                       <name>jboss.releases</name>
+                       <url>${nexusproxy}/repositories/jboss.releases/</url>
+               </repository>
+               <!-- OpenDayLight Released artifact -->
+               <repository>
+                       <id>opendaylight-release</id>
+                       <name>opendaylight-release</name>
+                       <url>${nexusproxy}/repositories/opendaylight.release/</url>
+               </repository>
+               <!-- OpenDayLight Snapshot artifact -->
+               <repository>
+                       <id>opendaylight-snapshot</id>
+                       <name>opendaylight-snapshot</name>
+                       <url>${nexusproxy}/repositories/opendaylight.snapshot/</url>
+               </repository>
+       </repositories>
+
+
+
+       <dependencyManagement>
+               <dependencies>
+                       <dependency>
+                               <groupId>com.google.guava</groupId>
+                               <artifactId>guava</artifactId>
+                               <version>14.0.1</version>
+                               <type>jar</type>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.slf4j</groupId>
+                               <artifactId>slf4j-api</artifactId>
+                               <version>1.7.2</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>junit</groupId>
+                               <artifactId>junit</artifactId>
+                               <version>4.10</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.opendaylight.yangtools</groupId>
+                               <artifactId>yang-binding</artifactId>
+                               <version>${yang.version}</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.opendaylight.yangtools</groupId>
+                               <artifactId>yang-common</artifactId>
+                               <version>${yang.version}</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.opendaylight.yangtools</groupId>
+                               <artifactId>yang-data-api</artifactId>
+                               <version>${yang.version}</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.opendaylight.yangtools</groupId>
+                               <artifactId>yang-model-api</artifactId>
+                               <version>${yang.version}</version>
+                       </dependency>
+                       <dependency>
+                               <groupId>org.opendaylight.yangtools</groupId>
+                               <artifactId>yang-data-util</artifactId>
+                               <version>${yang.version}</version>
+                       </dependency>
+               </dependencies>
+
+       </dependencyManagement>
+
+       <dependencies>
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <scope>test</scope>
+                       <optional>true</optional>
+               </dependency>
+               <dependency>
+                       <groupId>org.mockito</groupId>
+                       <artifactId>mockito-all</artifactId>
+                       <version>1.9.5</version>
+                       <scope>test</scope>
+               </dependency>
+       </dependencies>
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+                               <version>${maven.bundle.version}</version>
+                               <extensions>true</extensions>
+                               <configuration>
+                                       <instructions>
+                                               <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+                                       </instructions>
+                                       <manifestLocation>${project.basedir}/META-INF</manifestLocation>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-compiler-plugin</artifactId>
+                               <version>2.0</version>
+                               <inherited>true</inherited>
+                               <configuration>
+                                       <source>1.7</source>
+                                       <target>1.7</target>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-javadoc-plugin</artifactId>
+                               <version>2.8.1</version>
+                               <configuration>
+                                       <stylesheet>maven</stylesheet>
+                               </configuration>
+                               <executions>
+                                       <execution>
+                                               <goals>
+                                                       <goal>aggregate</goal>
+                                               </goals>
+                                               <phase>site</phase>
+                                       </execution>
+                               </executions>
+                       </plugin>
+               </plugins>
+       </build>
+       <reporting>
+               <plugins>
+                       <plugin>
+                               <groupId>org.codehaus.mojo</groupId>
+                               <artifactId>findbugs-maven-plugin</artifactId>
+                               <version>2.4.0</version>
+                               <configuration>
+                                       <effort>Max</effort>
+                                       <threshold>Low</threshold>
+                                       <goal>site</goal>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.codehaus.mojo</groupId>
+                               <artifactId>jdepend-maven-plugin</artifactId>
+                               <version>2.0-beta-2</version>
+                       </plugin>
+               </plugins>
+       </reporting>
 </project>
index 92cfc3b..d94a659 100644 (file)
@@ -1,28 +1,32 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
-    <modelVersion>4.0.0</modelVersion>\r
-    <parent>\r
-        <groupId>org.opendaylight.controller</groupId>\r
-        <artifactId>sal</artifactId>\r
-        <version>1.0-SNAPSHOT</version>\r
-    </parent>\r
-    <artifactId>sal-binding-api</artifactId>\r
-\r
-    <dependencies>\r
-        <dependency>\r
-            <groupId>org.opendaylight.controller</groupId>\r
-            <artifactId>yang-common</artifactId>\r
-\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>org.opendaylight.controller</groupId>\r
-            <artifactId>yang-binding</artifactId>\r
-\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>org.opendaylight.controller</groupId>\r
-            <artifactId>sal-common</artifactId>\r
-            <version>1.0-SNAPSHOT</version>\r
-        </dependency>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>sal-parent</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>sal-binding-api</artifactId>
+    <packaging>bundle</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-common</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-binding</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-common</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>5.0.0</version>
+        </dependency>
     </dependencies>
 </project>
\ No newline at end of file
index 24f5b25..fa10488 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.api;\r
-\r
-import org.opendaylight.controller.yang.binding.RpcService;\r
-\r
-/**\r
- * Binding-aware core of the SAL layer responsible for wiring the SAL consumers.\r
- * \r
- * The responsibility of the broker is to maintain registration of SAL\r
- * functionality {@link Consumer}s and {@link Provider}s, store provider and\r
- * consumer specific context and functionality registration via\r
- * {@link ConsumerSession} and provide access to infrastructure services, which\r
- * removes direct dependencies between providers and consumers.\r
- * \r
- * The Binding-aware broker is also responsible for translation from Java\r
- * classes modeling the functionality and data to binding-indpenedent form which\r
- * is used in SAL Core.\r
- * \r
- * \r
- * <h3>Infrastructure services</h3> Some examples of infrastructure services:\r
- * \r
- * <ul>\r
- * <li>YANG Module service - see {@link ConsumerSession#getRpcService(Class)},\r
- * {@link ProviderSession}\r
- * <li>Notification Service - see {@link NotificationService} and\r
- * {@link NotificationProviderService}\r
- * <li>Functionality and Data model\r
- * <li>Data Store access and modification - see {@link DataBrokerService} and\r
- * {@link DataProviderService}\r
- * </ul>\r
- * \r
- * The services are exposed via session.\r
- * \r
- * <h3>Session-based access</h3>\r
- * \r
- * The providers and consumers needs to register in order to use the\r
- * binding-independent SAL layer and to expose functionality via SAL layer.\r
- * \r
- * For more information about session-based access see {@link ConsumerSession}\r
- * and {@link ProviderSession}\r
- * \r
- * \r
-\r
- * \r
- */\r
-public interface BindingAwareBroker {\r
-    /**\r
-     * Registers the {@link BindingAwareConsumer}, which will use the SAL layer.\r
-     * \r
-     * <p>\r
-     * Note that consumer could register additional functionality at later point\r
-     * by using service and functionality specific APIs.\r
-     * \r
-     * <p>\r
-     * The consumer is required to use returned session for all communication\r
-     * with broker or one of the broker services. The session is announced to\r
-     * the consumer by invoking\r
-     * {@link Consumer#onSessionInitiated(ConsumerSession)}.\r
-     * \r
-     * @param cons\r
-     *            Consumer to be registered.\r
-     * @return a session specific to consumer registration\r
-     * @throws IllegalArgumentException\r
-     *             If the consumer is <code>null</code>.\r
-     * @throws IllegalStateException\r
-     *             If the consumer is already registered.\r
-     */\r
-    ConsumerSession registerConsumer(BindingAwareConsumer consumer);\r
-\r
-    /**\r
-     * Registers the {@link BindingAwareProvider}, which will use the SAL layer.\r
-     * \r
-     * <p>\r
-     * During the registration, the broker obtains the initial functionality\r
-     * from consumer, using the\r
-     * {@link BindingAwareProvider#getImplementations()}, and register that\r
-     * functionality into system and concrete infrastructure services.\r
-     * \r
-     * <p>\r
-     * Note that provider could register additional functionality at later point\r
-     * by using service and functionality specific APIs.\r
-     * \r
-     * <p>\r
-     * The consumer is <b>required to use</b> returned session for all\r
-     * communication with broker or one of the broker services. The session is\r
-     * announced to the consumer by invoking\r
-     * {@link BindingAwareProvider#onSessionInitiated(ProviderSession)}.\r
-     * \r
-     * \r
-     * @param prov\r
-     *            Provider to be registered.\r
-     * @return a session unique to the provider registration.\r
-     * @throws IllegalArgumentException\r
-     *             If the provider is <code>null</code>.\r
-     * @throws IllegalStateException\r
-     *             If the consumer is already registered.\r
-     */\r
-    ProviderSession registerProvider(BindingAwareProvider provider);\r
-\r
-    /**\r
-     * {@link BindingAwareConsumer} specific access to the SAL functionality.\r
-     * \r
-     * <p>\r
-     * ConsumerSession is {@link BindingAwareConsumer}-specific access to the\r
-     * SAL functionality and infrastructure services.\r
-     * \r
-     * <p>\r
-     * The session serves to store SAL context (e.g. registration of\r
-     * functionality) for the consumer and provides access to the SAL\r
-     * infrastructure services and other functionality provided by\r
-     * {@link Provider}s.\r
-     * \r
-\r
-     * \r
-     */\r
-    public interface ConsumerSession {\r
-\r
-        /**\r
-         * Returns a session specific instance (implementation) of requested\r
-         * binding-aware infrastructural service\r
-         * \r
-         * @param service\r
-         *            Broker service\r
-         * @return Session specific implementation of service\r
-         */\r
-        <T extends BindingAwareService> T getSALService(Class<T> service);\r
-\r
-        /**\r
-         * Returns a session specific instance (implementation) of requested\r
-         * YANG module implentation / service provided by consumer.\r
-         * \r
-         * @param service\r
-         *            Broker service\r
-         * @return Session specific implementation of service\r
-         */\r
-        <T extends RpcService> T getRpcService(Class<T> module);\r
-    }\r
-\r
-    /**\r
-     * {@link BindingAwareProvider} specific access to the SAL functionality.\r
-     * \r
-     * <p>\r
-     * ProviderSession is {@link BindingAwareProvider}-specific access to the\r
-     * SAL functionality and infrastructure services, which also allows for\r
-     * exposing the provider's functionality to the other\r
-     * {@link BindingAwareConsumer}s.\r
-     * \r
-     * <p>\r
-     * The session serves to store SAL context (e.g. registration of\r
-     * functionality) for the providers and exposes access to the SAL\r
-     * infrastructure services, dynamic functionality registration and any other\r
-     * functionality provided by other {@link BindingAwareConsumer}s.\r
-     * \r
-     */\r
-    public interface ProviderSession extends ConsumerSession {\r
-\r
-        void addRpcImplementation(RpcService implementation);\r
-\r
-        void removeRpcImplementation(RpcService implementation);\r
-    }\r
-}\r
+/*
+ * 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.api;
 
+import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
+import org.opendaylight.controller.sal.binding.api.data.DataConsumerService;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Binding-aware core of the SAL layer responsible for wiring the SAL consumers.
+ * 
+ * The responsibility of the broker is to maintain registration of SAL
+ * functionality {@link Consumer}s and {@link Provider}s, store provider and
+ * consumer specific context and functionality registration via
+ * {@link ConsumerContext} and provide access to infrastructure services, which
+ * removes direct dependencies between providers and consumers.
+ * 
+ * The Binding-aware broker is also responsible for translation from Java
+ * classes modeling the functionality and data to binding-indpenedent form which
+ * is used in SAL Core.
+ * 
+ * 
+ * <h3>Infrastructure services</h3> Some examples of infrastructure services:
+ * 
+ * <ul>
+ * <li>YANG Module service - see {@link ConsumerContext#getRpcService(Class)},
+ * {@link ProviderContext}
+ * <li>Notification Service - see {@link NotificationService} and
+ * {@link NotificationProviderService}
+ * <li>Functionality and Data model
+ * <li>Data Store access and modification - see {@link DataBrokerService} and
+ * {@link DataConsumerService}
+ * </ul>
+ * 
+ * The services are exposed via session.
+ * 
+ * <h3>Session-based access</h3>
+ * 
+ * The providers and consumers needs to register in order to use the
+ * binding-independent SAL layer and to expose functionality via SAL layer.
+ * 
+ * For more information about session-based access see {@link ConsumerContext}
+ * and {@link ProviderContext}
+ * 
+ * 
+ * 
+ */
+public interface BindingAwareBroker {
+    /**
+     * Registers the {@link BindingAwareConsumer}, which will use the SAL layer.
+     * 
+     * <p>
+     * Note that consumer could register additional functionality at later point
+     * by using service and functionality specific APIs.
+     * 
+     * <p>
+     * The consumer is required to use returned session for all communication
+     * with broker or one of the broker services. The session is announced to
+     * the consumer by invoking
+     * {@link Consumer#onSessionInitiated(ConsumerContext)}.
+     * 
+     * @param cons
+     *            Consumer to be registered.
+     * @return a session specific to consumer registration
+     * @throws IllegalArgumentException
+     *             If the consumer is <code>null</code>.
+     * @throws IllegalStateException
+     *             If the consumer is already registered.
+     */
+    ConsumerContext registerConsumer(BindingAwareConsumer consumer, BundleContext ctx);
+
+    /**
+     * Registers the {@link BindingAwareProvider}, which will use the SAL layer.
+     * 
+     * <p>
+     * During the registration, the broker obtains the initial functionality
+     * from consumer, using the
+     * {@link BindingAwareProvider#getImplementations()}, and register that
+     * functionality into system and concrete infrastructure services.
+     * 
+     * <p>
+     * Note that provider could register additional functionality at later point
+     * by using service and functionality specific APIs.
+     * 
+     * <p>
+     * The consumer is <b>required to use</b> returned session for all
+     * communication with broker or one of the broker services. The session is
+     * announced to the consumer by invoking
+     * {@link BindingAwareProvider#onSessionInitiated(ProviderContext)}.
+     * 
+     * 
+     * @param prov
+     *            Provider to be registered.
+     * @return a session unique to the provider registration.
+     * @throws IllegalArgumentException
+     *             If the provider is <code>null</code>.
+     * @throws IllegalStateException
+     *             If the consumer is already registered.
+     */
+    ProviderContext registerProvider(BindingAwareProvider provider, BundleContext ctx);
+
+    /**
+     * {@link BindingAwareConsumer} specific access to the SAL functionality.
+     * 
+     * <p>
+     * ConsumerSession is {@link BindingAwareConsumer}-specific access to the
+     * SAL functionality and infrastructure services.
+     * 
+     * <p>
+     * The session serves to store SAL context (e.g. registration of
+     * functionality) for the consumer and provides access to the SAL
+     * infrastructure services and other functionality provided by
+     * {@link Provider}s.
+     * 
+     * 
+     * 
+     */
+    public interface ConsumerContext {
+
+        /**
+         * Returns a session specific instance (implementation) of requested
+         * binding-aware infrastructural service
+         * 
+         * @param service
+         *            Broker service
+         * @return Session specific implementation of service
+         */
+        <T extends BindingAwareService> T getSALService(Class<T> service);
+
+        /**
+         * Returns a session specific instance (implementation) of requested
+         * YANG module implentation / service provided by consumer.
+         * 
+         * @param service
+         *            Broker service
+         * @return Session specific implementation of service
+         */
+        <T extends RpcService> T getRpcService(Class<T> module);
+    }
+
+    /**
+     * {@link BindingAwareProvider} specific access to the SAL functionality.
+     * 
+     * <p>
+     * ProviderSession is {@link BindingAwareProvider}-specific access to the
+     * SAL functionality and infrastructure services, which also allows for
+     * exposing the provider's functionality to the other
+     * {@link BindingAwareConsumer}s.
+     * 
+     * <p>
+     * The session serves to store SAL context (e.g. registration of
+     * functionality) for the providers and exposes access to the SAL
+     * infrastructure services, dynamic functionality registration and any other
+     * functionality provided by other {@link BindingAwareConsumer}s.
+     * 
+     */
+    public interface ProviderContext extends ConsumerContext {
+
+        <T extends RpcService> RpcServiceRegistration<T> addRpcImplementation(Class<T> type, T implementation);
+    }
+
+    public interface RpcServiceRegistration<T extends RpcService> {
+
+        T getService();
+
+        void unregister();
+    }
+}
index e32f8bc..fc29726 100644 (file)
@@ -1,40 +1,40 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.api;\r
-\r
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerSession;\r
-\r
-/**\r
- * \r
- * Defines the component of controller and supplies additional metadata. A\r
- * component of the controller or application supplies a concrete implementation\r
- * of this interface.\r
- * \r
- * A user-implemented component (application) which faciliates the SAL and SAL\r
- * services to access infrastructure services or providers' functionality.\r
- * \r
-\r
- * \r
- */\r
-public interface BindingAwareConsumer {\r
-\r
-    /**\r
-     * Callback signaling initialization of the consumer session to the SAL.\r
-     * \r
-     * The consumer MUST use the session for all communication with SAL or\r
-     * retrieving SAL infrastructure services.\r
-     * \r
-     * This method is invoked by\r
-     * {@link BindingAwareBroker#registerConsumer(BindingAwareConsumer)}\r
-     * \r
-     * @param session\r
-     *            Unique session between consumer and SAL.\r
-     */\r
-    void onSessionInitialized(ConsumerSession session);\r
-\r
-}\r
+/*
+ * 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.api;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
+
+/**
+ * 
+ * Defines the component of controller and supplies additional metadata. A
+ * component of the controller or application supplies a concrete implementation
+ * of this interface.
+ * 
+ * A user-implemented component (application) which faciliates the SAL and SAL
+ * services to access infrastructure services or providers' functionality.
+ * 
+ * 
+ * 
+ */
+public interface BindingAwareConsumer {
+
+    /**
+     * Callback signaling initialization of the consumer session to the SAL.
+     * 
+     * The consumer MUST use the session for all communication with SAL or
+     * retrieving SAL infrastructure services.
+     * 
+     * This method is invoked by
+     * {@link BindingAwareBroker#registerConsumer(BindingAwareConsumer)}
+     * 
+     * @param session
+     *            Unique session between consumer and SAL.
+     */
+    void onSessionInitialized(ConsumerContext session);
+
+}
index d324b83..3641d76 100644 (file)
@@ -1,72 +1,69 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.api;\r
-\r
-import java.util.Collection;\r
-\r
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerSession;\r
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderSession;\r
-import org.opendaylight.controller.yang.binding.RpcService;\r
-\r
-\r
-/**\r
- * \r
- * Defines the component of controller and supplies additional metadata. A\r
- * component of the controller or application supplies a concrete implementation\r
- * of this interface.\r
- * \r
- * <p>\r
- * A user-implemented component (application) which facilitates the SAL and SAL\r
- * services to access infrastructure services and to provide functionality to\r
- * {@link Consumer}s and other providers.\r
- * \r
-\r
- * \r
- */\r
-public interface BindingAwareProvider {\r
-\r
-    void onSessionInitialized(ConsumerSession session);\r
-\r
-    /**\r
-     * Returns a set of provided implementations of YANG modules and their rpcs.\r
-     * \r
-     * \r
-     * @return Set of provided implementation of YANG modules and their Rpcs\r
-     */\r
-    Collection<? extends RpcService> getImplementations();\r
-\r
-    /**\r
-     * Gets a set of implementations of provider functionality to be registered\r
-     * into system during the provider registration to the SAL.\r
-     * \r
-     * <p>\r
-     * This method is invoked by {@link Broker#registerProvider(Provider)} to\r
-     * learn the initial provided functionality\r
-     * \r
-     * @return Set of provider's functionality.\r
-     */\r
-    Collection<? extends ProviderFunctionality> getFunctionality();\r
-\r
-    /**\r
-     * Functionality provided by the {@link BindingAwareProvider}\r
-     * \r
-     * <p>\r
-     * Marker interface used to mark the interfaces describing specific\r
-     * functionality which could be exposed by providers to other components.\r
-     * \r
-\r
-     * \r
-     */\r
-    public interface ProviderFunctionality {\r
-\r
-    }\r
-\r
-    void onSessionInitiated(ProviderSession session);\r
-\r
-}\r
+/*
+ * 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.api;
 
+import java.util.Collection;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+/**
+ * 
+ * Defines the component of controller and supplies additional metadata. A
+ * component of the controller or application supplies a concrete implementation
+ * of this interface.
+ * 
+ * <p>
+ * A user-implemented component (application) which facilitates the SAL and SAL
+ * services to access infrastructure services and to provide functionality to
+ * {@link Consumer}s and other providers.
+ * 
+ * 
+ */
+public interface BindingAwareProvider {
+
+    void onSessionInitialized(ConsumerContext session);
+
+    /**
+     * Returns a set of provided implementations of YANG modules and their rpcs.
+     * 
+     * 
+     * @return Set of provided implementation of YANG modules and their Rpcs
+     */
+    Collection<? extends RpcService> getImplementations();
+
+    /**
+     * Gets a set of implementations of provider functionality to be registered
+     * into system during the provider registration to the SAL.
+     * 
+     * <p>
+     * This method is invoked by {@link Broker#registerProvider(Provider)} to
+     * learn the initial provided functionality
+     * 
+     * @return Set of provider's functionality.
+     */
+    Collection<? extends ProviderFunctionality> getFunctionality();
+
+    /**
+     * Functionality provided by the {@link BindingAwareProvider}
+     * 
+     * <p>
+     * Marker interface used to mark the interfaces describing specific
+     * functionality which could be exposed by providers to other components.
+     * 
+     * 
+     * 
+     */
+    public interface ProviderFunctionality {
+
+    }
+
+    void onSessionInitiated(ProviderContext session);
+
+}
index e4d86e7..b368056 100644 (file)
@@ -1,40 +1,40 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.api;\r
-\r
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerSession;\r
-\r
-/**\r
- * \r
- * Session-specific instance of the broker functionality.\r
- * \r
- * <p>\r
- * BindingAwareService is marker interface for infrastructure services provided\r
- * by the SAL. These services are session-specific, each\r
- * {@link BindingAwareConsumer} and {@link BindingAwareProvider} usually has own\r
- * instance of the service with it's own context.\r
- * \r
- * <p>\r
- * The consumer's (or provider's) instance of specific service could be obtained\r
- * by invoking {@link ConsumerSession#getSALService(Class)} method on session\r
- * assigned to the consumer.\r
- * \r
- * <p>\r
- * {@link BindingAwareService} and {@link BindingAwareProvider} may seem\r
- * similar, but provider provides YANG model-based functionality and\r
- * {@link BindingAwareProvider} exposes the necessary supporting functionality\r
- * to implement specific functionality of YANG and to reuse it in the\r
- * development of {@link BindingAwareConsumer}s and {@link BindingAwareProvider}\r
- * s.\r
- * \r
-\r
- * \r
- */\r
-public interface BindingAwareService {\r
-\r
-}\r
+/*
+ * 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.api;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
+
+/**
+ * 
+ * Session-specific instance of the broker functionality.
+ * 
+ * <p>
+ * BindingAwareService is marker interface for infrastructure services provided
+ * by the SAL. These services are session-specific, each
+ * {@link BindingAwareConsumer} and {@link BindingAwareProvider} usually has own
+ * instance of the service with it's own context.
+ * 
+ * <p>
+ * The consumer's (or provider's) instance of specific service could be obtained
+ * by invoking {@link ConsumerContext#getSALService(Class)} method on session
+ * assigned to the consumer.
+ * 
+ * <p>
+ * {@link BindingAwareService} and {@link BindingAwareProvider} may seem
+ * similar, but provider provides YANG model-based functionality and
+ * {@link BindingAwareProvider} exposes the necessary supporting functionality
+ * to implement specific functionality of YANG and to reuse it in the
+ * development of {@link BindingAwareConsumer}s and {@link BindingAwareProvider}
+ * s.
+ * 
+ * 
+ * 
+ */
+public interface BindingAwareService {
+
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationListener.java b/opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationListener.java
new file mode 100644 (file)
index 0000000..ccc7391
--- /dev/null
@@ -0,0 +1,6 @@
+package org.opendaylight.controller.sal.binding.api;
+
+public interface NotificationListener<T> {
+
+    void onNotification(T notification);
+}
index c5fc405..86c9eeb 100644 (file)
@@ -1,15 +1,15 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.api;\r
-\r
-import org.opendaylight.controller.yang.binding.Notification;\r
-\r
-public interface NotificationProviderService extends NotificationService {\r
-\r
-    void notify(Notification notification);\r
-}\r
+/*
+ * 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.api;
+
+import org.opendaylight.yangtools.yang.binding.Notification;
+
+public interface NotificationProviderService extends NotificationService {
+
+    void notify(Notification notification);
+}
index 92e30a5..3723c70 100644 (file)
@@ -1,22 +1,17 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.api;\r
-\r
-import org.opendaylight.controller.yang.binding.Notification;\r
-import org.opendaylight.controller.yang.binding.NotificationListener;\r
-\r
-public interface NotificationService extends BindingAwareService {\r
-\r
-    void addNotificationListener(\r
-            Class<? extends Notification> notificationType,\r
-            NotificationListener listener);\r
-\r
-    void removeNotificationListener(\r
-            Class<? extends Notification> notificationType,\r
-            NotificationListener listener);\r
-}\r
+/*
+ * 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.api;
+
+import org.opendaylight.yangtools.yang.binding.Notification;
+
+public interface NotificationService extends BindingAwareService {
+
+    <T extends Notification> void addNotificationListener(Class<T> notificationType, NotificationListener<T> listener);
+
+    <T extends Notification> void removeNotificationListener(Class<T> notificationType, NotificationListener<T> listener);
+}
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.api;\r
-\r
-import java.util.concurrent.Future;\r
-\r
-import org.opendaylight.controller.sal.common.DataStoreIdentifier;\r
-import org.opendaylight.controller.yang.binding.DataRoot;\r
-import org.opendaylight.controller.yang.common.RpcResult;\r
-\r
-\r
-/**\r
- * DataBrokerService provides unified access to the data stores available in the\r
- * system.\r
- * \r
- * \r
- * @see DataProviderService\r
-\r
- */\r
-public interface DataBrokerService extends BindingAwareService {\r
-\r
-    /**\r
-     * Returns a data from specified Data Store.\r
-     * \r
-     * Returns all the data visible to the consumer from specified Data Store.\r
-     * \r
-     * @param <T>\r
-     *            Interface generated from YANG module representing root of data\r
-     * @param store\r
-     *            Identifier of the store, from which will be data retrieved\r
-     * @return data visible to the consumer\r
-     */\r
-    <T extends DataRoot> T getData(DataStoreIdentifier store, Class<T> rootType);\r
-\r
-    /**\r
-     * Returns a filtered subset of data from specified Data Store.\r
-     * \r
-     * <p>\r
-     * The filter is modeled as an hierarchy of Java TOs starting with\r
-     * implementation of {@link DataRoot} representing data root. The semantics\r
-     * of the filter tree is the same as filter semantics defined in the NETCONF\r
-     * protocol for rpc operations <code>get</code> and <code>get-config</code>\r
-     * in Section 6 of RFC6241.\r
-     * \r
-     * \r
-     * @see http://tools.ietf.org/html/rfc6241#section-6\r
-     * @param <T>\r
-     *            Interface generated from YANG module representing root of data\r
-     * @param store\r
-     *            Identifier of the store, from which will be data retrieved\r
-     * @param filter\r
-     *            Data tree filter similar to the NETCONF filter\r
-     * @return\r
-     */\r
-    <T extends DataRoot> T getData(DataStoreIdentifier store, T filter);\r
-\r
-    /**\r
-     * Returns a candidate data which are not yet commited.\r
-     * \r
-     * \r
-     * @param <T>\r
-     *            Interface generated from YANG module representing root of data\r
-     * @param store\r
-     *            Identifier of the store, from which will be data retrieved\r
-     * @return\r
-     */\r
-    <T extends DataRoot> T getCandidateData(DataStoreIdentifier store,\r
-            Class<T> rootType);\r
-\r
-    /**\r
-     * Returns a filtered subset of candidate data from specified Data Store.\r
-     * \r
-     * <p>\r
-     * The filter is modeled as an hierarchy of {@link Node} starting with\r
-     * {@link CompositeNode} representing data root. The semantics of the filter\r
-     * tree is the same as filter semantics defined in the NETCONF protocol for\r
-     * rpc operations <code>get</code> and <code>get-config</code> in Section 6\r
-     * of RFC6241.\r
-     * \r
-     * \r
-     * @see http://tools.ietf.org/html/rfc6241#section-6\r
-     * @param <T>\r
-     *            Interface generated from YANG module representing root of data\r
-     * @param store\r
-     *            Identifier of the store, from which will be data retrieved\r
-     * @param filter\r
-     *            A filter data root\r
-     * @return\r
-     */\r
-    <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, T filter);\r
-\r
-    /**\r
-     * \r
-     * @param <T>\r
-     *            Interface generated from YANG module representing root of data\r
-     * @param store\r
-     *            Identifier of the store, in which will be the candidate data\r
-     *            modified\r
-     * @param changeSet\r
-     *            Modification of data tree.\r
-     * @return Result object containing the modified data tree if the operation\r
-     *         was successful, otherwise list of the encountered errors.\r
-     */\r
-    RpcResult<DataRoot> editCandidateData(DataStoreIdentifier store,\r
-            DataRoot changeSet);\r
-\r
-    /**\r
-     * Initiates a two-phase commit of candidate data.\r
-     * \r
-     * <p>\r
-     * The {@link Consumer} could initiate a commit of candidate data\r
-     * \r
-     * <p>\r
-     * The successful commit changes the state of the system and may affect\r
-     * several components.\r
-     * \r
-     * <p>\r
-     * The effects of successful commit of data are described in the\r
-     * specifications and YANG models describing the {@link Provider} components\r
-     * of controller. It is assumed that {@link Consumer} has an understanding\r
-     * of this changes.\r
-     * \r
-     * \r
-     * @see DataCommitHandler for further information how two-phase commit is\r
-     *      processed.\r
-     * @param store\r
-     *            Identifier of the store, where commit should occur.\r
-     * @return Result of the commit, containing success information or list of\r
-     *         encountered errors, if commit was not successful.\r
-     */\r
-    Future<RpcResult<Void>> commit(DataStoreIdentifier store);\r
-}\r
+/*
+ * 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.api.data;
+
+import java.util.concurrent.Future;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareService;
+import org.opendaylight.controller.sal.common.DataStoreIdentifier;
+import org.opendaylight.yangtools.yang.binding.DataRoot;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+/**
+ * DataBrokerService provides unified access to the data stores available in the
+ * system.
+ * 
+ * 
+ * @see DataConsumerService
+ */
+public interface DataBrokerService extends BindingAwareService {
+
+    /**
+     * Returns a data from specified Data Store.
+     * 
+     * Returns all the data visible to the consumer from specified Data Store.
+     * 
+     * @param <T>
+     *            Interface generated from YANG module representing root of data
+     * @param store
+     *            Identifier of the store, from which will be data retrieved
+     * @return data visible to the consumer
+     */
+    <T extends DataRoot> T getData(DataStoreIdentifier store, Class<T> rootType);
+
+    /**
+     * Returns a filtered subset of data from specified Data Store.
+     * 
+     * <p>
+     * The filter is modeled as an hierarchy of Java TOs starting with
+     * implementation of {@link DataRoot} representing data root. The semantics
+     * of the filter tree is the same as filter semantics defined in the NETCONF
+     * protocol for rpc operations <code>get</code> and <code>get-config</code>
+     * in Section 6 of RFC6241.
+     * 
+     * 
+     * @see http://tools.ietf.org/html/rfc6241#section-6
+     * @param <T>
+     *            Interface generated from YANG module representing root of data
+     * @param store
+     *            Identifier of the store, from which will be data retrieved
+     * @param filter
+     *            Data tree filter similar to the NETCONF filter
+     * @return
+     */
+    <T extends DataRoot> T getData(DataStoreIdentifier store, T filter);
+
+    /**
+     * Returns a candidate data which are not yet commited.
+     * 
+     * 
+     * @param <T>
+     *            Interface generated from YANG module representing root of data
+     * @param store
+     *            Identifier of the store, from which will be data retrieved
+     * @return
+     */
+    <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, Class<T> rootType);
+
+    /**
+     * Returns a filtered subset of candidate data from specified Data Store.
+     * 
+     * <p>
+     * The filter is modeled as an hierarchy of {@link Node} starting with
+     * {@link CompositeNode} representing data root. The semantics of the filter
+     * tree is the same as filter semantics defined in the NETCONF protocol for
+     * rpc operations <code>get</code> and <code>get-config</code> in Section 6
+     * of RFC6241.
+     * 
+     * 
+     * @see http://tools.ietf.org/html/rfc6241#section-6
+     * @param <T>
+     *            Interface generated from YANG module representing root of data
+     * @param store
+     *            Identifier of the store, from which will be data retrieved
+     * @param filter
+     *            A filter data root
+     * @return
+     */
+    <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, T filter);
+
+    /**
+     * 
+     * @param <T>
+     *            Interface generated from YANG module representing root of data
+     * @param store
+     *            Identifier of the store, in which will be the candidate data
+     *            modified
+     * @param changeSet
+     *            Modification of data tree.
+     * @return Result object containing the modified data tree if the operation
+     *         was successful, otherwise list of the encountered errors.
+     */
+    RpcResult<DataRoot> editCandidateData(DataStoreIdentifier store, DataRoot changeSet);
+
+    /**
+     * Initiates a two-phase commit of candidate data.
+     * 
+     * <p>
+     * The {@link Consumer} could initiate a commit of candidate data
+     * 
+     * <p>
+     * The successful commit changes the state of the system and may affect
+     * several components.
+     * 
+     * <p>
+     * The effects of successful commit of data are described in the
+     * specifications and YANG models describing the {@link Provider} components
+     * of controller. It is assumed that {@link Consumer} has an understanding
+     * of this changes.
+     * 
+     * 
+     * @see DataCommitHandler for further information how two-phase commit is
+     *      processed.
+     * @param store
+     *            Identifier of the store, where commit should occur.
+     * @return Result of the commit, containing success information or list of
+     *         encountered errors, if commit was not successful.
+     */
+    Future<RpcResult<Void>> commit(DataStoreIdentifier store);
+}
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.api;\r
-\r
-import java.util.Set;\r
-\r
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality;\r
-import org.opendaylight.controller.sal.common.DataStoreIdentifier;\r
-import org.opendaylight.controller.yang.common.RpcResult;\r
-\r
-\r
-/**\r
- * Two phase commit handler (cohort) of the two-phase commit protocol of data.\r
- * \r
- * <p>\r
- * The provider should expose the implementation of DataCommitHandler if it's\r
- * functionality depends on any subset of data stored in data repositories, in\r
- * order to participate in {@link DataBrokerService#commit(DataStoreIdentifier)\r
- * operation.\r
- * \r
- * <p>\r
- * Operations of two-phase commit handlers should not change data in data store,\r
- * this is responsibility of the coordinator (broker or some component of the\r
- * broker).\r
- * \r
- * The commit handlers are responsible for changing the internal state of the\r
- * provider to reflect the commited changes in data.\r
- * \r
- * <h3>Two-phase commit</h3>\r
- * \r
- * <h4>Commit Request Phase</h4>\r
- * \r
- * <ol>\r
- * <li> <code>Consumer</code> edits data by invocation of\r
- * <code>DataBrokerService.editCandidateData(DataStoreIdentifier, DataRoot)</code>\r
- * <li> <code>Consumer</code> starts a commit by invoking\r
- * <code>DataBrokerService.commit(DataStoreIdentifier)</code>\r
- * <li> <code>Broker</code> retrieves a list of all registered\r
- * <code>DataCommitHandlers</code>\r
- * <li>For each <code>DataCommitHandler</code>\r
- * <ol>\r
- * <li><code>Broker</code> invokes a\r
- * <code>DataCommitHandler.requestCommit(DataStoreIdentifier)</code> operation.\r
- * <li><code>DataCommitHandler</code> returns a <code>RpcResult</code> with\r
- * <code>CommitTransaction</code>\r
- * <li>If the result was successful, broker adds <code>CommitTransaction</code>\r
- * to the list of opened transactions. If not, brokers stops a commit request\r
- * phase and starts a rollback phase.\r
- * </ol>\r
- * <li><code>Broker</code> starts a commit finish phase\r
- * </ol>\r
- * \r
- * <h4>Commit Finish Phase</h4>\r
- * \r
- * <ol>\r
- * <li>For each <code>CommitTransaction</code> from Commit Request phase\r
- * <ol>\r
- * <li><code>Broker</code> broker invokes a\r
- * <code>CommitTransaction.finish()</code>\r
- * <li>The provider finishes a commit (applies the change) and returns an\r
- * <code>RpcResult</code>.\r
- * </ol>\r
- * <li>\r
- * <ul>\r
- * <li>If all returned results means successful, the brokers end two-phase\r
- * commit by returning a success commit result to the Consumer.\r
- * <li>If error occured, the broker starts a commit rollback phase.\r
- * </ul>\r
- * </ol>\r
- * \r
- * <h4>Commit Rollback Phase</h4>\r
- * <li>For each <code>CommitTransaction</code> from Commit Request phase\r
- * <ol>\r
- * <li><code>Broker</code>\r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * \r
- * broker invokes a {@link CommitTransaction#finish()}\r
- * <li>The provider rollbacks a commit and returns an {@link RpcResult} of\r
- * rollback. </ol>\r
- * <li>Broker returns a error result to the consumer.\r
- * \r
- * \r
- * <h3>Registration of functionality</h3>\r
- * The registration could be done by :\r
- * <ul>\r
- * <li>returning an instance of implementation in the return value of\r
- * {@link Provider#getProviderFunctionality()}\r
- * <li>passing an instance of implementation and {@link DataStoreIdentifier} of\r
- * rpc as arguments to the\r
- * {@link DataProviderService#addCommitHandler(DataStoreIdentifier, DataCommitHandler)}\r
- * </ul>\r
- * \r
-\r
- * \r
- */\r
-public interface DataCommitHandler extends ProviderFunctionality {\r
-    /**\r
-     * A set of Data Stores supported by implementation.\r
-     * \r
-     * The set of {@link DataStoreIdentifier}s which identifies target data\r
-     * stores which are supported by this commit handler. This set is used, when\r
-     * {@link Provider} is registered to the SAL, to register and expose the\r
-     * commit handler functionality to affected data stores.\r
-     * \r
-     * @return Set of Data Store identifiers\r
-     */\r
-    Set<DataStoreIdentifier> getSupportedDataStores();\r
-\r
-    /**\r
-     * The provider (commit handler) starts a commit transaction.\r
-     * \r
-     * <p>\r
-     * The commit handler (provider) prepares an commit scenario, rollback\r
-     * scenario and validates data.\r
-     * \r
-     * <p>\r
-     * If the provider is aware that at this point the commit would not be\r
-     * successful, the transaction is not created, but list of errors which\r
-     * prevented the start of transaction are returned.\r
-     * \r
-     * @param store\r
-     * @return Transaction object representing this commit, errors otherwise.\r
-     */\r
-    RpcResult<CommitTransaction> requestCommit(DataStoreIdentifier store);\r
-\r
-    public interface CommitTransaction {\r
-        /**\r
-         * \r
-         * @return Data store affected by the transaction\r
-         */\r
-        DataStoreIdentifier getDataStore();\r
-\r
-        /**\r
-         * Returns the handler associated with this transaction.\r
-         * \r
-         * @return Handler\r
-         */\r
-        DataCommitHandler getHandler();\r
-\r
-        /**\r
-         * \r
-         * Finishes a commit.\r
-         * \r
-         * The provider (commit handler) should apply all changes to its state\r
-         * which are a result of data change-\r
-         * \r
-         * @return\r
-         */\r
-        RpcResult<Void> finish() throws IllegalStateException;\r
-\r
-        /**\r
-         * Rollbacks a commit.\r
-         * \r
-         * @return\r
-         * @throws IllegalStateException\r
-         *             If the method is invoked after {@link #finish()}\r
-         */\r
-        RpcResult<Void> rollback() throws IllegalStateException;\r
-    }\r
-\r
-}\r
+/*
+ * 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.api.data;
+
+import java.util.Set;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality;
+import org.opendaylight.controller.sal.common.DataStoreIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+/**
+ * Two phase commit handler (cohort) of the two-phase commit protocol of data.
+ * 
+ * <p>
+ * The provider should expose the implementation of DataCommitHandler if it's
+ * functionality depends on any subset of data stored in data repositories, in
+ * order to participate in {@link DataBrokerService#commit(DataStoreIdentifier)
+ * operation.
+ * 
+ * <p>
+ * Operations of two-phase commit handlers should not change data in data store,
+ * this is responsibility of the coordinator (broker or some component of the
+ * broker).
+ * 
+ * The commit handlers are responsible for changing the internal state of the
+ * provider to reflect the commited changes in data.
+ * 
+ * <h3>Two-phase commit</h3>
+ * 
+ * <h4>Commit Request Phase</h4>
+ * 
+ * <ol>
+ * <li> <code>Consumer</code> edits data by invocation of
+ * <code>DataBrokerService.editCandidateData(DataStoreIdentifier, DataRoot)</code>
+ * <li> <code>Consumer</code> starts a commit by invoking
+ * <code>DataBrokerService.commit(DataStoreIdentifier)</code>
+ * <li> <code>Broker</code> retrieves a list of all registered
+ * <code>DataCommitHandlers</code>
+ * <li>For each <code>DataCommitHandler</code>
+ * <ol>
+ * <li><code>Broker</code> invokes a
+ * <code>DataCommitHandler.requestCommit(DataStoreIdentifier)</code> operation.
+ * <li><code>DataCommitHandler</code> returns a <code>RpcResult</code> with
+ * <code>CommitTransaction</code>
+ * <li>If the result was successful, broker adds <code>CommitTransaction</code>
+ * to the list of opened transactions. If not, brokers stops a commit request
+ * phase and starts a rollback phase.
+ * </ol>
+ * <li><code>Broker</code> starts a commit finish phase
+ * </ol>
+ * 
+ * <h4>Commit Finish Phase</h4>
+ * 
+ * <ol>
+ * <li>For each <code>CommitTransaction</code> from Commit Request phase
+ * <ol>
+ * <li><code>Broker</code> broker invokes a
+ * <code>CommitTransaction.finish()</code>
+ * <li>The provider finishes a commit (applies the change) and returns an
+ * <code>RpcResult</code>.
+ * </ol>
+ * <li>
+ * <ul>
+ * <li>If all returned results means successful, the brokers end two-phase
+ * commit by returning a success commit result to the Consumer.
+ * <li>If error occured, the broker starts a commit rollback phase.
+ * </ul>
+ * </ol>
+ * 
+ * <h4>Commit Rollback Phase</h4>
+ * <li>For each <code>CommitTransaction</code> from Commit Request phase
+ * <ol>
+ * <li><code>Broker</code>
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * 
+ * broker invokes a {@link CommitTransaction#finish()}
+ * <li>The provider rollbacks a commit and returns an {@link RpcResult} of
+ * rollback. </ol>
+ * <li>Broker returns a error result to the consumer.
+ * 
+ * 
+ * <h3>Registration of functionality</h3>
+ * The registration could be done by :
+ * <ul>
+ * <li>returning an instance of implementation in the return value of
+ * {@link Provider#getProviderFunctionality()}
+ * <li>passing an instance of implementation and {@link DataStoreIdentifier} of
+ * rpc as arguments to the
+ * {@link DataConsumerService#addCommitHandler(DataStoreIdentifier, DataCommitHandler)}
+ * </ul>
+ * 
+ * 
+ * 
+ */
+public interface DataCommitHandler extends ProviderFunctionality {
+    /**
+     * A set of Data Stores supported by implementation.
+     * 
+     * The set of {@link DataStoreIdentifier}s which identifies target data
+     * stores which are supported by this commit handler. This set is used, when
+     * {@link Provider} is registered to the SAL, to register and expose the
+     * commit handler functionality to affected data stores.
+     * 
+     * @return Set of Data Store identifiers
+     */
+    Set<DataStoreIdentifier> getSupportedDataStores();
+
+    /**
+     * The provider (commit handler) starts a commit transaction.
+     * 
+     * <p>
+     * The commit handler (provider) prepares an commit scenario, rollback
+     * scenario and validates data.
+     * 
+     * <p>
+     * If the provider is aware that at this point the commit would not be
+     * successful, the transaction is not created, but list of errors which
+     * prevented the start of transaction are returned.
+     * 
+     * @param store
+     * @return Transaction object representing this commit, errors otherwise.
+     */
+    RpcResult<CommitTransaction> requestCommit(DataStoreIdentifier store);
+
+    public interface CommitTransaction {
+        /**
+         * 
+         * @return Data store affected by the transaction
+         */
+        DataStoreIdentifier getDataStore();
+
+        /**
+         * Returns the handler associated with this transaction.
+         * 
+         * @return Handler
+         */
+        DataCommitHandler getHandler();
+
+        /**
+         * 
+         * Finishes a commit.
+         * 
+         * The provider (commit handler) should apply all changes to its state
+         * which are a result of data change-
+         * 
+         * @return
+         */
+        RpcResult<Void> finish() throws IllegalStateException;
+
+        /**
+         * Rollbacks a commit.
+         * 
+         * @return
+         * @throws IllegalStateException
+         *             If the method is invoked after {@link #finish()}
+         */
+        RpcResult<Void> rollback() throws IllegalStateException;
+    }
+
+}
@@ -1,67 +1,65 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.api;\r
-\r
-import org.opendaylight.controller.sal.common.DataStoreIdentifier;\r
-\r
-public interface DataProviderService extends DataBrokerService {\r
-\r
-    /**\r
-     * Adds {@link DataValidator} for specified Data Store\r
-     * \r
-     * @param store\r
-     *            Data Store\r
-     * @param validator\r
-     *            Validator\r
-     */\r
-    public void addValidator(DataStoreIdentifier store, DataValidator validator);\r
-\r
-    /**\r
-     * Removes {@link DataValidator} from specified Data Store\r
-     * \r
-     * @param store\r
-     * @param validator\r
-     *            Validator\r
-     */\r
-    public void removeValidator(DataStoreIdentifier store,\r
-            DataValidator validator);\r
-\r
-    /**\r
-     * Adds {@link DataCommitHandler} for specified data store\r
-     * \r
-     * @param store\r
-     * @param provider\r
-     */\r
-    void addCommitHandler(DataStoreIdentifier store, DataCommitHandler provider);\r
-\r
-    /**\r
-     * Removes {@link DataCommitHandler} from specified data store\r
-     * \r
-     * @param store\r
-     * @param provider\r
-     */\r
-    void removeCommitHandler(DataStoreIdentifier store,\r
-            DataCommitHandler provider);\r
-\r
-    /**\r
-     * Adds {@link DataRefresher} for specified data store\r
-     * \r
-     * @param store\r
-     * @param refresher\r
-     */\r
-    void addRefresher(DataStoreIdentifier store, DataRefresher refresher);\r
-\r
-    /**\r
-     * Removes {@link DataRefresher} from specified data store\r
-     * \r
-     * @param store\r
-     * @param refresher\r
-     */\r
-   void removeRefresher(DataStoreIdentifier store, DataRefresher refresher);\r
-\r
-}\r
+/*
+ * 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.api.data;
+
+import org.opendaylight.controller.sal.common.DataStoreIdentifier;
+
+public interface DataConsumerService extends DataBrokerService {
+
+    /**
+     * Adds {@link DataValidator} for specified Data Store
+     * 
+     * @param store
+     *            Data Store
+     * @param validator
+     *            Validator
+     */
+    public void addValidator(DataStoreIdentifier store, DataValidator validator);
+
+    /**
+     * Removes {@link DataValidator} from specified Data Store
+     * 
+     * @param store
+     * @param validator
+     *            Validator
+     */
+    public void removeValidator(DataStoreIdentifier store, DataValidator validator);
+
+    /**
+     * Adds {@link DataCommitHandler} for specified data store
+     * 
+     * @param store
+     * @param provider
+     */
+    void addCommitHandler(DataStoreIdentifier store, DataCommitHandler provider);
+
+    /**
+     * Removes {@link DataCommitHandler} from specified data store
+     * 
+     * @param store
+     * @param provider
+     */
+    void removeCommitHandler(DataStoreIdentifier store, DataCommitHandler provider);
+
+    /**
+     * Adds {@link DataRefresher} for specified data store
+     * 
+     * @param store
+     * @param refresher
+     */
+    void addRefresher(DataStoreIdentifier store, DataRefresher refresher);
+
+    /**
+     * Removes {@link DataRefresher} from specified data store
+     * 
+     * @param store
+     * @param refresher
+     */
+    void removeRefresher(DataStoreIdentifier store, DataRefresher refresher);
+
+}
@@ -1,26 +1,28 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.api;\r
-\r
-/**\r
- * Trigger for refreshing of the data exposed by the {@link Provider}\r
- * \r
- * \r
- * \r
- */\r
-public interface DataRefresher extends\r
-        BindingAwareProvider.ProviderFunctionality {\r
-\r
-    /**\r
-     * Fired when some component explicitly requested the data refresh.\r
-     * \r
-     * The provider which exposed the {@link DataRefresher} should republish its\r
-     * provided data by editing the data in all affected data stores.\r
-     */\r
-    void refreshData();\r
+/*
+ * 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.api.data;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality;
+
+/**
+ * Trigger for refreshing of the data exposed by the {@link Provider}
+ * 
+ * 
+ * 
+ */
+public interface DataRefresher extends BindingAwareProvider.ProviderFunctionality {
+
+    /**
+     * Fired when some component explicitly requested the data refresh.
+     * 
+     * The provider which exposed the {@link DataRefresher} should republish its
+     * provided data by editing the data in all affected data stores.
+     */
+    void refreshData();
 }
\ No newline at end of file
@@ -1,18 +1,18 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.api;\r
-\r
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality;\r
-import org.opendaylight.controller.yang.binding.DataRoot;\r
-import org.opendaylight.controller.yang.common.RpcResult;\r
-\r
-\r
-public interface DataValidator extends ProviderFunctionality {\r
-\r
-    RpcResult<Void> validate(DataRoot data);\r
-}\r
+/*
+ * 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.api.data;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality;
+import org.opendaylight.yangtools.yang.binding.DataRoot;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+public interface DataValidator extends ProviderFunctionality {
+
+    RpcResult<Void> validate(DataRoot data);
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/RuntimeDataProvider.java b/opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/RuntimeDataProvider.java
new file mode 100644 (file)
index 0000000..b9f5d5a
--- /dev/null
@@ -0,0 +1,10 @@
+package org.opendaylight.controller.sal.binding.api.data;
+
+import java.util.Set;
+
+import org.opendaylight.yangtools.yang.binding.DataRoot;
+
+public interface RuntimeDataProvider {
+
+    Set<Class<? extends DataRoot>> getProvidedDataRoots();
+}
index 552ac6a..31eec6b 100644 (file)
@@ -1,9 +1,9 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.api;\r
-\r
+/*
+ * 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.api;
+
index 3073bec..70f2e6c 100644 (file)
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
-    <modelVersion>4.0.0</modelVersion>\r
-    <parent>\r
-        <groupId>org.opendaylight.controller</groupId>\r
-        <artifactId>sal</artifactId>\r
-        <version>1.0-SNAPSHOT</version>\r
-    </parent>\r
-    <artifactId>sal-binding-broker-impl</artifactId>\r
-\r
-\r
-\r
-    <dependencies>\r
-        <dependency>\r
-            <groupId>org.opendaylight.controller</groupId>\r
-            <artifactId>sal-common-util</artifactId>\r
-            <version>1.0-SNAPSHOT</version>\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>org.opendaylight.controller</groupId>\r
-            <artifactId>sal-binding-api</artifactId>\r
-            <version>1.0-SNAPSHOT</version>\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>org.opendaylight.controller</groupId>\r
-            <artifactId>sal-binding-spi</artifactId>\r
-            <version>1.0-SNAPSHOT</version>\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>org.opendaylight.controller</groupId>\r
-            <artifactId>sal-core-api</artifactId>\r
-            <version>1.0-SNAPSHOT</version>\r
-        </dependency>\r
-\r
-        <dependency>\r
-            <groupId>org.slf4j</groupId>\r
-            <artifactId>slf4j-api</artifactId>\r
-        </dependency>\r
-\r
-        <dependency>\r
-            <groupId>com.google.guava</groupId>\r
-            <artifactId>guava</artifactId>\r
-            <type>jar</type>\r
-        </dependency>\r
-    </dependencies>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.opendaylight.controller</groupId>
+               <artifactId>sal-parent</artifactId>
+               <version>1.0-SNAPSHOT</version>
+       </parent>
+       <artifactId>sal-binding-broker-impl</artifactId>
+       <packaging>bundle</packaging>
+
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+                               <version>${maven.bundle.version}</version>
+                               <extensions>true</extensions>
+                               <configuration>
+                                       <instructions>
+                                               <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+                                               <Bundle-Activator>org.opendaylight.controller.sal.binding.impl.BrokerActivator</Bundle-Activator>
+                                               <Private-Package>
+                                                       org.opendaylight.controller.sal.binding.impl,
+                                                       org.opendaylight.controller.sal.binding.impl.utils,
+                                                       org.eclipse.xtend2.lib,
+                                                       org.eclipse.xtext.xbase.*
+                                               </Private-Package>
+                                       </instructions>
+                               </configuration>
+                       </plugin>
+
+                       <plugin>
+                               <groupId>org.eclipse.xtend</groupId>
+                               <artifactId>xtend-maven-plugin</artifactId>
+                               <version>2.4.2</version>
+                               <executions>
+                                       <execution>
+                                               <goals>
+                                                       <goal>compile</goal>
+                                               </goals>
+                                               <configuration>
+                                                       <outputDirectory>${basedir}/src/main/xtend-gen</outputDirectory>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
+                       <plugin>
+                               <artifactId>maven-clean-plugin</artifactId>
+                               <version>2.4.1</version>
+                               <configuration>
+                                       <filesets>
+                                               <fileset>
+                                                       <directory>${basedir}/src/main/xtend-gen</directory>
+                                                       <includes>
+                                                               <include>**</include>
+                                                       </includes>
+                                               </fileset>
+                                       </filesets>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+
+       <dependencies>
+               <dependency>
+                       <groupId>org.opendaylight.controller</groupId>
+                       <artifactId>sal-common-util</artifactId>
+                       <version>1.0-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.opendaylight.controller</groupId>
+                       <artifactId>sal-binding-api</artifactId>
+                       <version>1.0-SNAPSHOT</version>
+               </dependency>
+               <!-- >dependency> <groupId>org.opendaylight.controller</groupId> <artifactId>sal-core-api</artifactId> 
+                       <version>1.0-SNAPSHOT</version> </dependency -->
+
+               <dependency>
+                       <groupId>org.slf4j</groupId>
+                       <artifactId>slf4j-api</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.osgi</groupId>
+                       <artifactId>org.osgi.core</artifactId>
+                       <version>5.0.0</version>
+               </dependency>
+               <dependency>
+                       <groupId>com.google.guava</groupId>
+                       <artifactId>guava</artifactId>
+                       <type>jar</type>
+               </dependency>
+               <dependency>
+                       <groupId>org.reflections</groupId>
+                       <artifactId>reflections</artifactId>
+                       <version>0.9.9-RC1</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.javassist</groupId>
+                       <artifactId>javassist</artifactId>
+                       <version>3.17.1-GA</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.eclipse.xtend</groupId>
+                       <artifactId>org.eclipse.xtend.lib</artifactId>
+                       <version>2.4.2</version>
+               </dependency>
+       </dependencies>
 </project>
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend
new file mode 100644 (file)
index 0000000..74ef87a
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * 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.opendaylight.yangtools.yang.binding.RpcService
+import javassist.ClassPool
+import javassist.CtMethod
+import javassist.CtField
+import org.osgi.framework.BundleContext
+import java.util.Map
+import java.util.HashMap
+import javassist.LoaderClassPath
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker
+import java.util.Hashtable
+
+import static extension org.opendaylight.controller.sal.binding.impl.utils.PropertiesUtils.*
+import static extension org.opendaylight.controller.sal.binding.impl.utils.GeneratorUtils.*
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService
+import org.osgi.framework.ServiceRegistration
+import org.opendaylight.controller.sal.binding.impl.utils.PropertiesUtils
+import org.opendaylight.controller.sal.binding.api.NotificationService
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext
+import javassist.Modifier
+import org.slf4j.LoggerFactory
+
+class BindingAwareBrokerImpl implements BindingAwareBroker {
+    private static val DELEGATE_FIELD = "_delegate"
+    private static val log = LoggerFactory.getLogger(BindingAwareBrokerImpl)
+    
+    private val clsPool = ClassPool.getDefault()
+    private Map<Class<? extends RpcService>, RpcProxyContext> managedProxies = new HashMap();
+    private var NotificationBrokerImpl notifyBroker
+    private var ServiceRegistration<NotificationProviderService> notifyBrokerRegistration
+
+    @Property
+    var BundleContext brokerBundleContext
+
+    def start() {
+        initGenerator();
+
+        // Initialization of notificationBroker
+        notifyBroker = new NotificationBrokerImpl(null);
+        val brokerProperties = PropertiesUtils.newProperties();
+        notifyBrokerRegistration = brokerBundleContext.registerService(NotificationProviderService, notifyBroker,
+            brokerProperties)
+        brokerBundleContext.registerService(NotificationService, notifyBroker, brokerProperties)
+    }
+
+    def initGenerator() {
+
+        // YANG Binding Class Loader
+        clsPool.appendClassPath(new LoaderClassPath(RpcService.classLoader))
+    }
+
+    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)
+    }
+
+    def <T extends RpcService> getManagedDirectProxy(Class<T> service) {
+        
+        var RpcProxyContext existing = null
+        if ((existing = managedProxies.get(service)) != null) {
+            return existing.proxy
+        }
+        val proxyClass = service.generateDirectProxy()
+        val rpcProxyCtx = new RpcProxyContext(proxyClass)
+        val properties = new Hashtable<String, String>()
+        rpcProxyCtx.proxy = proxyClass.newInstance as RpcService
+
+        properties.salServiceType = Constants.SAL_SERVICE_TYPE_CONSUMER_PROXY
+        rpcProxyCtx.registration = brokerBundleContext.registerService(service, rpcProxyCtx.proxy as T, properties)
+        managedProxies.put(service, rpcProxyCtx)
+        return rpcProxyCtx.proxy
+    }
+
+    protected def generateDirectProxy(Class<? extends RpcService> delegate) {
+        val targetFqn = delegate.generatedName(Constants.PROXY_DIRECT_SUFFIX)
+        log.debug("Generating DirectProxy for {} Proxy name: {}",delegate,targetFqn);
+        val objCls = clsPool.get(Object)
+        val delegateCls = clsPool.get(delegate)
+        val proxyCls = clsPool.makeClass(targetFqn)
+        proxyCls.addInterface(delegateCls)
+        val delField = new CtField(delegateCls, DELEGATE_FIELD, proxyCls);
+        delField.modifiers = Modifier.PUBLIC
+        proxyCls.addField(delField)
+        delegateCls.methods.filter[it.declaringClass != objCls].forEach [
+            val proxyMethod = new CtMethod(it, proxyCls, null);
+            proxyMethod.body = '''return ($r) «DELEGATE_FIELD».«it.name»($$);'''
+            proxyCls.addMethod(proxyMethod)
+        ]
+        return proxyCls.toClass(delegate.classLoader)
+    }
+
+    def <T extends RpcService> registerRpcImplementation(Class<T> type, T service, OsgiProviderContext context,
+        Hashtable<String, String> properties) {
+        val proxy = getManagedDirectProxy(type)
+        if(proxy.delegate != null) {
+            throw new IllegalStateException("Service " + type + "is already registered");
+        }
+        val osgiReg = context.bundleContext.registerService(type, service, properties);
+        proxy.delegate = service;
+        return new RpcServiceRegistrationImpl<T>(type, service, osgiReg);
+    }
+    
+    def <T extends RpcService> getDelegate(RpcService proxy) {
+        val field = proxy.class.getField(DELEGATE_FIELD)
+        if(field == null) throw new UnsupportedOperationException("Unable to get delegate from proxy");
+        return field.get(proxy) as T
+    }
+    
+    def void setDelegate(RpcService proxy, RpcService delegate) {
+        val field = proxy.class.getField(DELEGATE_FIELD)
+        if(field == null) throw new UnsupportedOperationException("Unable to set delegate to proxy");
+        if (field.type.isAssignableFrom(delegate.class)) {
+            field.set(proxy,delegate)
+        } else throw new IllegalArgumentException("delegate class is not assignable to proxy");
+    }
+    
+    
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingBrokerImpl.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingBrokerImpl.java
deleted file mode 100644 (file)
index 32eff18..0000000
+++ /dev/null
@@ -1,436 +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.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-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.spi.Mapper;
-import org.opendaylight.controller.sal.binding.spi.MappingProvider;
-import org.opendaylight.controller.sal.binding.spi.RpcMapper;
-import org.opendaylight.controller.sal.binding.spi.RpcMapper.RpcProxyInvocationHandler;
-import org.opendaylight.controller.sal.binding.spi.SALBindingModule;
-import org.opendaylight.controller.sal.common.util.Rpcs;
-import org.opendaylight.controller.sal.core.api.Provider;
-import org.opendaylight.controller.sal.core.api.RpcImplementation;
-import org.opendaylight.controller.yang.binding.DataObject;
-import org.opendaylight.controller.yang.binding.RpcService;
-import org.opendaylight.controller.yang.common.QName;
-import org.opendaylight.controller.yang.common.RpcResult;
-import org.opendaylight.controller.yang.data.api.CompositeNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class BindingBrokerImpl implements BindingAwareBroker {
-
-    private static Logger log = LoggerFactory
-            .getLogger(BindingBrokerImpl.class);
-
-    private Set<ConsumerSessionImpl> sessions = new HashSet<ConsumerSessionImpl>();
-    private Set<ProviderSessionImpl> providerSessions = new HashSet<ProviderSessionImpl>();
-
-    private Set<SALBindingModule> modules = new HashSet<SALBindingModule>();
-    private Map<Class<? extends BindingAwareService>, SALBindingModule> salServiceProviders = new HashMap<Class<? extends BindingAwareService>, SALBindingModule>();
-    private MappingProvider mapping;
-    private BIFacade biFacade = new BIFacade();
-    private org.opendaylight.controller.sal.core.api.Broker.ProviderSession biSession;
-    private ExecutorService executor;
-
-    Map<Class<? extends RpcService>, RpcService> rpcImpls = Collections
-            .synchronizedMap(new HashMap<Class<? extends RpcService>, RpcService>());
-
-    private RpcProxyInvocationHandler rpcProxyHandler = new RpcProxyInvocationHandler() {
-
-        @Override
-        public Future<RpcResult<? extends DataObject>> invokeRpc(
-                RpcService proxy, QName rpc, DataObject input) {
-            return rpcProxyInvoked(proxy, rpc, input);
-        }
-    };
-
-    @Override
-    public ConsumerSession registerConsumer(BindingAwareConsumer consumer) {
-        checkPredicates(consumer);
-        log.info("Registering consumer " + consumer);
-
-        ConsumerSessionImpl session = newSessionFor(consumer);
-        consumer.onSessionInitialized(session);
-
-        sessions.add(session);
-        return session;
-    }
-
-    @Override
-    public ProviderSession registerProvider(BindingAwareProvider provider) {
-        checkPredicates(provider);
-
-        ProviderSessionImpl session = newSessionFor(provider);
-        provider.onSessionInitiated(session);
-
-        providerSessions.add(session);
-        return session;
-    }
-
-    public void addModule(SALBindingModule module) {
-        log.info("Registering broker module " + module);
-        if (modules.contains(module)) {
-            log.error("Module already registered");
-            throw new IllegalArgumentException("Module already exists.");
-        }
-
-        Set<Class<? extends BindingAwareService>> provServices = module
-                .getProvidedServices();
-        for (Class<? extends BindingAwareService> serviceType : provServices) {
-            log.info("  Registering session service implementation: "
-                    + serviceType.getCanonicalName());
-            salServiceProviders.put(serviceType, module);
-        }
-    }
-
-    public void consumerSessionClosed(ConsumerSessionImpl consumerSessionImpl) {
-        sessions.remove(consumerSessionImpl);
-        providerSessions.remove(consumerSessionImpl);
-    }
-
-    private void checkPredicates(BindingAwareProvider prov) {
-        if (prov == null)
-            throw new IllegalArgumentException("Provider should not be null.");
-        for (ProviderSessionImpl session : providerSessions) {
-            if (prov.equals(session.getProvider()))
-                throw new IllegalStateException("Provider already registered");
-        }
-
-    }
-
-    private void checkPredicates(BindingAwareConsumer cons) {
-        if (cons == null)
-            throw new IllegalArgumentException("Consumer should not be null.");
-        for (ConsumerSessionImpl session : sessions) {
-            if (cons.equals(session.getConsumer()))
-                throw new IllegalStateException("Consumer already registered");
-        }
-    }
-
-    private ConsumerSessionImpl newSessionFor(BindingAwareConsumer cons) {
-        return new ConsumerSessionImpl(cons);
-    }
-
-    private ProviderSessionImpl newSessionFor(BindingAwareProvider provider) {
-        return new ProviderSessionImpl(provider);
-    }
-
-    private <T extends BindingAwareService> T newSALServiceForSession(
-            Class<T> service, ConsumerSession session) {
-
-        SALBindingModule serviceProvider = salServiceProviders.get(service);
-        if (serviceProvider == null) {
-            return null;
-        }
-        return serviceProvider.getServiceForSession(service, session);
-
-    }
-
-    private <T extends RpcService> T newRpcProxyForSession(Class<T> service) {
-
-        RpcMapper<T> mapper = mapping.rpcMapperForClass(service);
-        if (mapper == null) {
-            log.error("Mapper for " + service + "is unavailable.");
-            return null;
-        }
-        T proxy = mapper.getConsumerProxy(rpcProxyHandler);
-
-        return proxy;
-    }
-
-    private Future<RpcResult<? extends DataObject>> rpcProxyInvoked(
-            RpcService rpcProxy, QName rpcType, DataObject inputData) {
-        if (rpcProxy == null) {
-            throw new IllegalArgumentException("Proxy must not be null");
-        }
-        if (rpcType == null) {
-            throw new IllegalArgumentException(
-                    "rpcType (QName) should not be null");
-        }
-        Future<RpcResult<? extends DataObject>> ret = null;
-
-        // Real invocation starts here
-        RpcMapper<? extends RpcService> mapper = mapping
-                .rpcMapperForProxy(rpcProxy);
-        RpcService impl = rpcImpls.get(mapper.getServiceClass());
-
-        if (impl == null) {
-            // RPC is probably remote
-            CompositeNode inputNode = null;
-            Mapper<? extends DataObject> inputMapper = mapper.getInputMapper();
-            if (inputMapper != null) {
-                inputNode = inputMapper.domFromObject(inputData);
-            }
-            Future<RpcResult<CompositeNode>> biResult = biSession.rpc(rpcType,
-                    inputNode);
-            ret = new TranslatedFuture(biResult, mapper);
-
-        } else {
-            // RPC is local
-            Callable<RpcResult<? extends DataObject>> invocation = localRpcCallableFor(
-                    impl, mapper, rpcType, inputData);
-            ret = executor.submit(invocation);
-        }
-        return ret;
-    }
-
-    private Callable<RpcResult<? extends DataObject>> localRpcCallableFor(
-            final RpcService impl,
-            final RpcMapper<? extends RpcService> mapper, final QName rpcType,
-            final DataObject inputData) {
-
-        return new Callable<RpcResult<? extends DataObject>>() {
-
-            @Override
-            public RpcResult<? extends DataObject> call() throws Exception {
-                return mapper.invokeRpcImplementation(rpcType, impl, inputData);
-            }
-        };
-    }
-
-    // Binding Independent invocation of Binding Aware RPC
-    private RpcResult<CompositeNode> invokeLocalRpc(QName rpc,
-            CompositeNode inputNode) {
-        RpcMapper<? extends RpcService> mapper = mapping.rpcMapperForData(rpc,
-                inputNode);
-
-        DataObject inputTO = mapper.getInputMapper().objectFromDom(inputNode);
-
-        RpcService impl = rpcImpls.get(mapper.getServiceClass());
-        if (impl == null) {
-            log.warn("Implementation for rpc: " + rpc + "not available.");
-        }
-        RpcResult<? extends DataObject> result = mapper
-                .invokeRpcImplementation(rpc, impl, inputTO);
-        DataObject outputTO = result.getResult();
-
-        CompositeNode outputNode = null;
-        if (outputTO != null) {
-            outputNode = mapper.getOutputMapper().domFromObject(outputTO);
-        }
-        return Rpcs.getRpcResult(result.isSuccessful(), outputNode,
-                result.getErrors());
-    }
-
-    private class ConsumerSessionImpl implements
-            BindingAwareBroker.ConsumerSession {
-
-        private final BindingAwareConsumer consumer;
-        private Map<Class<? extends BindingAwareService>, BindingAwareService> sessionSalServices = Collections
-                .synchronizedMap(new HashMap<Class<? extends BindingAwareService>, BindingAwareService>());
-
-        private Map<Class<? extends RpcService>, RpcService> sessionRpcProxies = Collections
-                .synchronizedMap(new HashMap<Class<? extends RpcService>, RpcService>());
-
-        public ConsumerSessionImpl(BindingAwareConsumer cons) {
-            this.consumer = cons;
-        }
-
-        @Override
-        public <T extends BindingAwareService> T getSALService(Class<T> service) {
-
-            BindingAwareService serv = sessionSalServices.get(service);
-            if (serv != null) {
-                if (service.isInstance(serv)) {
-                    @SuppressWarnings("unchecked")
-                    T ret = (T) serv;
-                    return ret;
-                } else {
-                    log.error("Implementation for service " + service.getName()
-                            + " does not implement the service interface");
-                    throw new IllegalStateException("Service implementation "
-                            + serv.getClass().getName() + "does not implement "
-                            + service.getName());
-                }
-            } else {
-                T ret = BindingBrokerImpl.this.newSALServiceForSession(service,
-                        this);
-                if (ret != null) {
-                    sessionSalServices.put(service, ret);
-                }
-                return ret;
-            }
-        }
-
-        @Override
-        public <T extends RpcService> T getRpcService(Class<T> service) {
-            RpcService current = sessionRpcProxies.get(service);
-            if (current != null) {
-                if (service.isInstance(current)) {
-                    @SuppressWarnings("unchecked")
-                    T ret = (T) current;
-                    return ret;
-                } else {
-                    log.error("Proxy  for rpc service " + service.getName()
-                            + " does not implement the service interface");
-                    throw new IllegalStateException("Service implementation "
-                            + current.getClass().getName()
-                            + "does not implement " + service.getName());
-                }
-            } else {
-                T ret = BindingBrokerImpl.this.newRpcProxyForSession(service);
-                if (ret != null) {
-                    sessionRpcProxies.put(service, ret);
-                }
-                return ret;
-            }
-        }
-
-        public BindingAwareConsumer getConsumer() {
-            return this.consumer;
-        }
-
-    }
-
-    private class ProviderSessionImpl extends ConsumerSessionImpl implements
-            BindingAwareBroker.ProviderSession {
-
-        private final BindingAwareProvider provider;
-
-        public ProviderSessionImpl(BindingAwareProvider provider2) {
-            super(null);
-            this.provider = provider2;
-        }
-
-        @Override
-        public void addRpcImplementation(RpcService implementation) {
-            if (implementation == null) {
-                throw new IllegalArgumentException(
-                        "Implementation should not be null");
-            }
-            // TODO Implement this method
-            throw new UnsupportedOperationException("Not implemented");
-        }
-
-        @Override
-        public void removeRpcImplementation(RpcService implementation) {
-            if (implementation == null) {
-                throw new IllegalArgumentException(
-                        "Implementation should not be null");
-            }
-            // TODO Implement this method
-            throw new UnsupportedOperationException("Not implemented");
-        }
-
-        public BindingAwareProvider getProvider() {
-            return this.provider;
-        }
-
-    }
-
-    private class BIFacade implements Provider,RpcImplementation {
-
-        @Override
-        public Set<QName> getSupportedRpcs() {
-            return Collections.emptySet();
-        }
-
-        @Override
-        public RpcResult<CompositeNode> invokeRpc(QName rpc, CompositeNode input) {
-            if (rpc == null) {
-                throw new IllegalArgumentException(
-                        "Rpc type should not be null");
-            }
-
-            return BindingBrokerImpl.this.invokeLocalRpc(rpc, input);
-        }
-
-        @Override
-        public void onSessionInitiated(
-                org.opendaylight.controller.sal.core.api.Broker.ProviderSession session) {
-            
-            BindingBrokerImpl.this.biSession = session;
-            for (SALBindingModule module : modules) {
-                try {
-                    module.onBISessionAvailable(biSession);
-                } catch(Exception e) {
-                    log.error("Module " +module +" throwed unexpected exception",e);
-                }
-            }
-        }
-
-        @Override
-        public Collection<ProviderFunctionality> getProviderFunctionality() {
-            return Collections.emptySet();
-        }
-
-    }
-
-    private static class TranslatedFuture implements
-            Future<RpcResult<? extends DataObject>> {
-        private final Future<RpcResult<CompositeNode>> realFuture;
-        private final RpcMapper<?> mapper;
-
-        public TranslatedFuture(Future<RpcResult<CompositeNode>> future,
-                RpcMapper<?> mapper) {
-            realFuture = future;
-            this.mapper = mapper;
-        }
-
-        @Override
-        public boolean cancel(boolean mayInterruptIfRunning) {
-            return realFuture.cancel(mayInterruptIfRunning);
-        }
-
-        @Override
-        public boolean isCancelled() {
-            return realFuture.isCancelled();
-        }
-
-        @Override
-        public boolean isDone() {
-            return realFuture.isDone();
-        }
-
-        @Override
-        public RpcResult<? extends DataObject> get()
-                throws InterruptedException, ExecutionException {
-            RpcResult<CompositeNode> val = realFuture.get();
-            return tranlate(val);
-        }
-
-        @Override
-        public RpcResult<? extends DataObject> get(long timeout, TimeUnit unit)
-                throws InterruptedException, ExecutionException,
-                TimeoutException {
-            RpcResult<CompositeNode> val = realFuture.get(timeout, unit);
-            return tranlate(val);
-        }
-
-        private RpcResult<? extends DataObject> tranlate(
-                RpcResult<CompositeNode> result) {
-            CompositeNode outputNode = result.getResult();
-            DataObject outputTO = null;
-            if (outputNode != null) {
-                Mapper<?> outputMapper = mapper.getOutputMapper();
-                outputTO = outputMapper.objectFromDom(outputNode);
-            }
-            return Rpcs.getRpcResult(result.isSuccessful(), outputTO,
-                    result.getErrors());
-        }
-
-    }
-}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/BrokerActivator.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/BrokerActivator.java
new file mode 100644 (file)
index 0000000..c5d54ec
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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.Hashtable;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BrokerActivator implements BundleActivator {
+
+       private static final Logger log = LoggerFactory.getLogger(BrokerActivator.class);
+       private BindingAwareBrokerImpl baSal;
+       private ServiceRegistration<BindingAwareBroker> baSalRegistration;
+       
+       
+       @Override
+       public void start(BundleContext context) throws Exception {
+               log.info("Binding Aware Broker initialized");
+               baSal = new BindingAwareBrokerImpl();
+               baSal.setBrokerBundleContext(context);
+               baSal.start();
+               
+               BindingAwareBroker baSalService = baSal;
+               Hashtable<String, String> properties = new Hashtable<>();
+               this.baSalRegistration = context.registerService(BindingAwareBroker.class,baSalService, properties);
+               
+       }
+
+       @Override
+       public void stop(BundleContext context) throws Exception {
+               log.info("Binding Aware Broker stopped");
+               baSalRegistration.unregister();
+       }
+
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/Constants.xtend b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/Constants.xtend
new file mode 100644 (file)
index 0000000..668635a
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * 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
+
+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"
+
+    public static val PROXY_DIRECT_SUFFIX = "DirectProxy";
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/DataModule.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/DataModule.java
deleted file mode 100644 (file)
index cbd6b00..0000000
+++ /dev/null
@@ -1,198 +0,0 @@
-package org.opendaylight.controller.sal.binding.impl;
-
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.Future;
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerSession;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality;
-import org.opendaylight.controller.sal.binding.api.BindingAwareService;
-import org.opendaylight.controller.sal.binding.api.DataBrokerService;
-import org.opendaylight.controller.sal.binding.api.DataCommitHandler;
-import org.opendaylight.controller.sal.binding.api.DataProviderService;
-import org.opendaylight.controller.sal.binding.api.DataValidator;
-import org.opendaylight.controller.sal.binding.spi.MappingProvider;
-import org.opendaylight.controller.sal.binding.spi.SALBindingModule;
-import org.opendaylight.controller.sal.common.DataStoreIdentifier;
-import org.opendaylight.controller.sal.binding.api.DataRefresher;
-import org.opendaylight.controller.yang.binding.DataRoot;
-import org.opendaylight.controller.yang.common.RpcResult;
-import org.opendaylight.controller.yang.data.api.CompositeNode;
-
-public class DataModule implements SALBindingModule {
-
-    private BindingAwareBroker broker;
-    private org.opendaylight.controller.sal.core.api.Broker.ProviderSession biSession;
-    private MappingProvider mappingProvider;
-    private final BIFacade biFacade = new BIFacade();
-    private org.opendaylight.controller.sal.core.api.data.DataProviderService biDataService;
-
-    @Override
-    public void setBroker(BindingAwareBroker broker) {
-        this.broker = broker;
-    }
-
-    @Override
-    public void onBISessionAvailable(
-            org.opendaylight.controller.sal.core.api.Broker.ProviderSession session) {
-        this.biSession = session;
-        this.biDataService = session
-                .getService(org.opendaylight.controller.sal.core.api.data.DataProviderService.class);
-        // biDataService.addRefresher(store, refresher)
-
-    }
-
-    @Override
-    public void setMappingProvider(MappingProvider provider) {
-        this.mappingProvider = provider;
-
-    }
-
-    @Override
-    public Set<Class<? extends BindingAwareService>> getProvidedServices() {
-        Set<Class<? extends BindingAwareService>> ret = new HashSet<Class<? extends BindingAwareService>>();
-        ret.add(DataBrokerService.class);
-        ret.add(DataProviderService.class);
-        return ret;
-    }
-
-    @Override
-    public <T extends BindingAwareService> T getServiceForSession(
-            Class<T> service, ConsumerSession session) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    public Set<Class<? extends ProviderFunctionality>> getSupportedProviderFunctionality() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    private class DataBrokerSession implements DataBrokerService {
-
-        @Override
-        public <T extends DataRoot> T getData(DataStoreIdentifier store,
-                Class<T> rootType) {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        @Override
-        public <T extends DataRoot> T getData(DataStoreIdentifier store,
-                T filter) {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        @Override
-        public <T extends DataRoot> T getCandidateData(
-                DataStoreIdentifier store, Class<T> rootType) {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        @Override
-        public <T extends DataRoot> T getCandidateData(
-                DataStoreIdentifier store, T filter) {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        @Override
-        public RpcResult<DataRoot> editCandidateData(DataStoreIdentifier store,
-                DataRoot changeSet) {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        @Override
-        public Future<RpcResult<Void>> commit(DataStoreIdentifier store) {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-    }
-
-    private class DataProviderSession extends DataBrokerSession implements
-            DataProviderService {
-
-        @Override
-        public void addValidator(DataStoreIdentifier store,
-                DataValidator validator) {
-            // TODO Auto-generated method stub
-
-        }
-
-        @Override
-        public void removeValidator(DataStoreIdentifier store,
-                DataValidator validator) {
-            // TODO Auto-generated method stub
-
-        }
-
-        @Override
-        public void addCommitHandler(DataStoreIdentifier store,
-                DataCommitHandler provider) {
-            // TODO Auto-generated method stub
-
-        }
-
-        @Override
-        public void removeCommitHandler(DataStoreIdentifier store,
-                DataCommitHandler provider) {
-            // TODO Auto-generated method stub
-
-        }
-
-        @Override
-        public void addRefresher(DataStoreIdentifier store,
-                DataRefresher refresher) {
-            // TODO Auto-generated method stub
-
-        }
-
-        @Override
-        public void removeRefresher(DataStoreIdentifier store,
-                DataRefresher refresher) {
-            // TODO Auto-generated method stub
-
-        }
-
-    }
-
-    private class BIFacade
-            implements
-            org.opendaylight.controller.sal.core.api.data.DataCommitHandler,
-            org.opendaylight.controller.sal.core.api.data.DataValidator,
-            org.opendaylight.controller.sal.core.api.data.DataProviderService.DataRefresher {
-
-        @Override
-        public RpcResult<Void> validate(CompositeNode toValidate) {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        @Override
-        public Set<DataStoreIdentifier> getSupportedDataStores() {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        @Override
-        public RpcResult<CommitTransaction> requestCommit(
-                DataStoreIdentifier store) {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        @Override
-        public void refreshData() {
-            // TODO Auto-generated method stub
-            
-        }
-
-    }
-
-}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.xtend b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.xtend
new file mode 100644 (file)
index 0000000..da1ba79
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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.NotificationProviderService
+import org.opendaylight.yangtools.yang.binding.Notification
+import com.google.common.collect.Multimap
+import org.opendaylight.controller.sal.binding.api.NotificationListener
+import com.google.common.collect.HashMultimap
+import java.util.concurrent.ExecutorService
+import java.util.Collection
+
+class NotificationBrokerImpl implements NotificationProviderService {
+
+    val Multimap<Class<? extends Notification>, NotificationListener<?>> listeners;
+    val ExecutorService executor;
+
+    new(ExecutorService executor) {
+        listeners = HashMultimap.create()
+        this.executor = executor;
+    }
+
+    override <T extends Notification> addNotificationListener(Class<T> notificationType,
+        NotificationListener<T> listener) {
+        listeners.put(notificationType, listener)
+    }
+
+    override <T extends Notification> removeNotificationListener(Class<T> notificationType,
+        NotificationListener<T> listener) {
+        listeners.remove(notificationType, listener)
+    }
+
+    override notify(Notification notification) {
+        notification.notificationTypes.forEach [
+            listeners.get(it as Class<? extends Notification>)?.notifyAll(notification)
+        ]
+    }
+
+    def getNotificationTypes(Notification notification) {
+        notification.class.interfaces.filter[it != Notification && Notification.isAssignableFrom(it)]
+    }
+
+    def notifyAll(Collection<NotificationListener<?>> listeners, Notification notification) {
+        listeners.forEach[(it as NotificationListener).onNotification(notification)]
+    }
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationInvoker.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationInvoker.java
deleted file mode 100644 (file)
index 640089a..0000000
+++ /dev/null
@@ -1,16 +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.spi.MappingProvider.MappingExtension;
-import org.opendaylight.controller.yang.binding.Notification;
-import org.opendaylight.controller.yang.binding.NotificationListener;
-
-public interface NotificationInvoker extends MappingExtension {
-    void notify(Notification notification, NotificationListener listener);
-}
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationModule.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationModule.java
deleted file mode 100644 (file)
index 89c4464..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.impl;\r
-\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-import java.util.HashSet;\r
-import java.util.Set;\r
-\r
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;\r
-import org.opendaylight.controller.sal.binding.api.BindingAwareService;\r
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;\r
-import org.opendaylight.controller.sal.binding.api.NotificationService;\r
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerSession;\r
-import org.opendaylight.controller.sal.binding.spi.SALBindingModule;\r
-import org.opendaylight.controller.sal.binding.spi.Mapper;\r
-import org.opendaylight.controller.sal.binding.spi.MappingProvider;\r
-import org.opendaylight.controller.sal.binding.spi.MappingProvider.MappingExtensionFactory;\r
-\r
-import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;\r
-import org.opendaylight.controller.yang.binding.DataObject;\r
-import org.opendaylight.controller.yang.binding.Notification;\r
-import org.opendaylight.controller.yang.binding.NotificationListener;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.data.api.CompositeNode;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import com.google.common.collect.HashMultimap;\r
-import com.google.common.collect.Multimap;\r
-\r
-public class NotificationModule implements SALBindingModule {\r
-\r
-    private ProviderSession biSession;\r
-    private org.opendaylight.controller.sal.core.api.notify.NotificationProviderService biNotifyService;\r
-    private MappingProvider mappingProvider;\r
-\r
-    private Multimap<Class<? extends Notification>, NotificationListener> listeners = HashMultimap\r
-            .create();\r
-    private Set<QName> biNotifications = new HashSet<QName>();\r
-    private static final Logger log = LoggerFactory\r
-            .getLogger(NotificationModule.class);\r
-    private final BindingIndependentListener biListener = new BindingIndependentListener();\r
-    private BindingAwareBroker broker;\r
-\r
-    @Override\r
-    public Set<Class<? extends BindingAwareService>> getProvidedServices() {\r
-\r
-        Set<Class<? extends BindingAwareService>> ret = new HashSet<Class<? extends BindingAwareService>>();\r
-        ret.add(NotificationService.class);\r
-        ret.add(NotificationProviderService.class);\r
-        return ret;\r
-    }\r
-\r
-    @Override\r
-    public <T extends BindingAwareService> T getServiceForSession(\r
-            Class<T> service, ConsumerSession session) {\r
-        if (service == null)\r
-            throw new IllegalArgumentException("Service should not be null");\r
-        if (session == null)\r
-            throw new IllegalArgumentException("Session should not be null");\r
-\r
-        if (NotificationProviderSession.class.equals(service)) {\r
-            if (session instanceof org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderSession) {\r
-                @SuppressWarnings("unchecked")\r
-                T ret = (T) new NotificationProviderSession(session);\r
-                return ret;\r
-            } else {\r
-                throw new IllegalArgumentException(\r
-                        "NotificationProviderService is available only to ProviderSession");\r
-            }\r
-        }\r
-\r
-        if (NotificationService.class.equals(service)) {\r
-            @SuppressWarnings("unchecked")\r
-            T ret = (T) new NotificationSession(session);\r
-            return ret;\r
-        }\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-    public Set<Class<? extends org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality>> getSupportedProviderFunctionality() {\r
-        return Collections.emptySet();\r
-    }\r
-\r
-    @Override\r
-    public void setBroker(BindingAwareBroker broker) {\r
-        this.broker = broker;\r
-    }\r
-\r
-    @Override\r
-    public void setMappingProvider(MappingProvider provider) {\r
-        this.mappingProvider = provider;\r
-    }\r
-\r
-    @Override\r
-    public void onBISessionAvailable(ProviderSession session) {\r
-        biSession = session;\r
-        if (biSession != null) {\r
-            biNotifyService = session\r
-                    .getService(org.opendaylight.controller.sal.core.api.notify.NotificationProviderService.class);\r
-        }\r
-    }\r
-\r
-    private void notify(Notification notification) {\r
-        notifyBindingIndependent(notification);\r
-        notifyBindingAware(notification);\r
-    }\r
-\r
-    private void notifyBindingAware(Notification notification) {\r
-        Class<? extends Notification> type = notification.getClass();\r
-        Collection<NotificationListener> toNotify = listeners.get(type);\r
-\r
-        // Invocation of notification on registered listeners\r
-        if (toNotify != null) {\r
-\r
-            // We get factory for Notification Invoker\r
-            MappingExtensionFactory<NotificationInvoker> invokerFactory = mappingProvider\r
-                    .getExtensionFactory(NotificationInvoker.class);\r
-\r
-            // We get generated invoker for NoficiationListener interface\r
-            // associated to Notification Type\r
-            NotificationInvoker invoker = invokerFactory.forClass(type);\r
-            for (NotificationListener listener : toNotify) {\r
-                try {\r
-                    // Invoker invokes the right method on subtype of\r
-                    // NotificationListener\r
-                    // associated to the type of notification\r
-                    invoker.notify(notification, listener);\r
-                } catch (Exception e) {\r
-\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    private void notifyBindingIndependent(Notification notification) {\r
-        Class<? extends Notification> type = notification.getClass();\r
-\r
-        if (biSession == null) {\r
-            return;\r
-        }\r
-        if (biSession.isClosed()) {\r
-            return;\r
-        }\r
-        if (biNotifyService == null) {\r
-            return;\r
-        }\r
-\r
-        // FIXME: Somehow we need to resolve this for class hierarchy.\r
-        // probably use type.getInterfaces()\r
-        Mapper<? extends Notification> mapper = mappingProvider\r
-                .mapperForClass(type);\r
-        CompositeNode domNotification = mapper.domFromObject(notification);\r
-\r
-        biNotifyService.sendNotification(domNotification);\r
-    }\r
-\r
-    private void addBAListener(Class<? extends Notification> notificationType,\r
-            NotificationListener listener) {\r
-\r
-        listeners.put(notificationType, listener);\r
-        Mapper<? extends Notification> mapper = mappingProvider\r
-                .mapperForClass(notificationType);\r
-        QName biType = mapper.getQName();\r
-        if (false == biNotifications.contains(biType)) {\r
-            // The listener is not registered for binding independent\r
-            // notification\r
-            biNotifications.add(biType);\r
-\r
-            if (biNotifyService != null) {\r
-                biNotifyService.addNotificationListener(biType, biListener);\r
-            }\r
-        }\r
-\r
-    }\r
-\r
-    private void removeBAListener(\r
-            Class<? extends Notification> notificationType,\r
-            NotificationListener listener) {\r
-        listeners.remove(notificationType, listener);\r
-    }\r
-\r
-    private class NotificationSession implements NotificationService {\r
-        private final ConsumerSession session;\r
-        private Multimap<Class<? extends Notification>, NotificationListener> sessionListeners = HashMultimap\r
-                .create();\r
-\r
-        public NotificationSession(ConsumerSession session) {\r
-            this.session = session;\r
-        }\r
-\r
-        @Override\r
-        public void addNotificationListener(\r
-                Class<? extends Notification> notificationType,\r
-                NotificationListener listener) {\r
-\r
-            NotificationModule.this.addBAListener(notificationType, listener);\r
-            sessionListeners.put(notificationType, listener);\r
-\r
-        }\r
-\r
-        @Override\r
-        public void removeNotificationListener(\r
-                Class<? extends Notification> notificationType,\r
-                NotificationListener listener) {\r
-            sessionListeners.remove(notificationType, listener);\r
-            NotificationModule.this\r
-                    .removeBAListener(notificationType, listener);\r
-        }\r
-\r
-    }\r
-\r
-    private class NotificationProviderSession extends NotificationSession\r
-            implements NotificationProviderService {\r
-\r
-        public NotificationProviderSession(ConsumerSession session) {\r
-            super(session);\r
-        }\r
-\r
-        @Override\r
-        public void notify(Notification notification) {\r
-            NotificationModule.this.notify(notification);\r
-        }\r
-\r
-    }\r
-\r
-    private class BindingIndependentListener\r
-            implements\r
-            org.opendaylight.controller.sal.core.api.notify.NotificationListener {\r
-\r
-        @Override\r
-        public Set<QName> getSupportedNotifications() {\r
-            return biNotifications;\r
-        }\r
-\r
-        @Override\r
-        public void onNotification(CompositeNode notification) {\r
-            NotificationModule.this\r
-                    .onBindingIndependentNotification(notification);\r
-        }\r
-\r
-    }\r
-\r
-    private void onBindingIndependentNotification(CompositeNode biNotification) {\r
-        QName biType = biNotification.getNodeType();\r
-\r
-        Mapper<DataObject> mapper = mappingProvider.mapperForQName(biType);\r
-        if (mapper == null) {\r
-            log.info("Received notification does not have a binding defined.");\r
-            return;\r
-        }\r
-        Class<DataObject> type = mapper.getDataObjectClass();\r
-\r
-        // We check if the received QName / type is really Notification\r
-        if (Notification.class.isAssignableFrom(type)) {\r
-            Notification notification = (Notification) mapper\r
-                    .objectFromDom(biNotification);\r
-            notifyBindingAware(notification);\r
-        } else {\r
-            // The generated type for this QName does not inherits from\r
-            // notification something went wrong - generated APIs and/or\r
-            // provider sending notification\r
-            // which was incorectly described in the YANG schema.\r
-            log.error("Received notification " + biType\r
-                    + " is not binded as notification");\r
-        }\r
-\r
-    }\r
-}\r
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationServiceImpl.xtend b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationServiceImpl.xtend
new file mode 100644 (file)
index 0000000..fb35ee3
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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.NotificationService
+import org.opendaylight.controller.sal.binding.api.NotificationListener
+import org.opendaylight.yangtools.yang.binding.Notification
+import com.google.common.collect.Multimap
+import com.google.common.collect.HashMultimap
+
+class NotificationServiceImpl implements NotificationService {
+    val Multimap<Class<? extends Notification>, NotificationListener<?>> listeners;
+
+    new() {
+        listeners = HashMultimap.create()
+    }
+
+    override <T extends Notification> addNotificationListener(Class<T> notificationType,
+        NotificationListener<T> listener) {
+        listeners.put(notificationType, listener)
+    }
+
+    override <T extends Notification> removeNotificationListener(Class<T> notificationType,
+        NotificationListener<T> listener) {
+        listeners.remove(notificationType, listener)
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiConsumerContext.xtend b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiConsumerContext.xtend
new file mode 100644 (file)
index 0000000..a87fa06
--- /dev/null
@@ -0,0 +1,53 @@
+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
+
+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;
+                       } 
+               } catch (InvalidSyntaxException e) {
+                       log.error("Created filter was invalid:", e.message,e)
+               }
+               return null;
+               
+
+       }
+
+       private def getProxyFilter() {
+               return '''(«Constants.SAL_SERVICE_TYPE»=«Constants.SAL_SERVICE_TYPE_CONSUMER_PROXY»)'''
+       }
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend
new file mode 100644 (file)
index 0000000..195fa8b
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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.controller.sal.binding.api.BindingAwareBroker.RpcServiceRegistration;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.osgi.framework.BundleContext;
+
+import static extension org.opendaylight.controller.sal.binding.impl.utils.PropertiesUtils.*;
+
+class OsgiProviderContext extends OsgiConsumerContext implements ProviderContext {
+
+    @Property
+    val Map<Class<? extends RpcService>, RpcServiceRegistrationImpl<? extends RpcService>> registeredServices
+
+    new(BundleContext ctx, BindingAwareBrokerImpl broker) {
+        super(ctx, broker);
+        _registeredServices = new HashMap();
+    }
+
+    override def <T extends RpcService> RpcServiceRegistration<T> addRpcImplementation(Class<T> type, T implementation) {
+
+        // TODO Auto-generated method stub
+        val properties = new Hashtable<String, String>();
+        properties.salServiceType = Constants.SAL_SERVICE_TYPE_PROVIDER
+
+        // Fill requirements
+        val salReg = broker.registerRpcImplementation(type, implementation, this, properties)
+        registeredServices.put(type, salReg)
+        return salReg;
+    }
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProxyContext.xtend b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProxyContext.xtend
new file mode 100644 (file)
index 0000000..0749459
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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.yangtools.yang.binding.RpcService
+import org.osgi.framework.ServiceRegistration
+
+class RpcProxyContext {
+       
+       new(Class<? extends RpcService> proxyClass) {
+               this.proxyClass = proxyClass
+       }
+       
+       protected val Class<? extends RpcService> proxyClass;
+       
+       @Property
+       protected var RpcService proxy;
+       
+       @Property
+       protected var ServiceRegistration<? extends RpcService> registration;
+}
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcServiceRegistrationImpl.xtend b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcServiceRegistrationImpl.xtend
new file mode 100644 (file)
index 0000000..afb27b4
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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.RpcServiceRegistration
+import org.osgi.framework.ServiceRegistration
+import org.opendaylight.yangtools.yang.binding.RpcService
+
+class RpcServiceRegistrationImpl<T extends RpcService> implements RpcServiceRegistration<T> {
+
+    val ServiceRegistration<T> osgiRegistration;
+    private val T service;
+    val Class<T> cls;
+
+    public new(Class<T> type, T service, ServiceRegistration<T> osgiReg) {
+        this.cls = type;
+        this.osgiRegistration = osgiReg;
+        this.service = service;
+    }
+
+    override getService() {
+        this.service
+    }
+
+    override unregister() {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/utils/GeneratorUtils.xtend b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/utils/GeneratorUtils.xtend
new file mode 100644 (file)
index 0000000..e94c375
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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.utils
+
+import javassist.ClassPool
+
+class GeneratorUtils {
+
+    static val PREFIX = "_gen.";
+
+    public static def generatedName(Class<?> cls, String suffix) {
+        '''«PREFIX»«cls.package.name».«cls.simpleName»$«suffix»'''.toString()
+    }
+    
+    public static def get(ClassPool pool,Class<?> cls) {
+        pool.get(cls.name);
+    }
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/utils/PropertiesUtils.xtend b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/utils/PropertiesUtils.xtend
new file mode 100644 (file)
index 0000000..7ba62f5
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * 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.utils
+
+import java.util.Hashtable
+import org.opendaylight.controller.sal.binding.impl.Constants
+
+class PropertiesUtils {
+       
+       private new() {}
+       
+       static def setSalServiceType(Hashtable<String,String> properties, String value) {
+               properties.put(Constants.SAL_SERVICE_TYPE,value)
+               return properties
+       }
+       
+       static def getSalServiceType(Hashtable<String,String> properties) {
+               return properties.get(Constants.SAL_SERVICE_TYPE)
+       }
+       
+       static def newProperties() {
+               new Hashtable<String,String>()
+       }
+       
+}
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/utils/package-info.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/utils/package-info.java
new file mode 100644 (file)
index 0000000..5110238
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+  * 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.utils;
\ No newline at end of file
index fd7fad6..8d0ddad 100644 (file)
@@ -3,7 +3,7 @@
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.opendaylight.controller</groupId>
-        <artifactId>sal</artifactId>
+        <artifactId>sal-parent</artifactId>
         <version>1.0-SNAPSHOT</version>
     </parent>
     <artifactId>sal-binding-spi</artifactId>
index db35de1..bdcb2c2 100644 (file)
@@ -8,9 +8,9 @@
 package org.opendaylight.controller.sal.binding.spi;
 
 import org.opendaylight.controller.concepts.lang.Transformer;
-import org.opendaylight.controller.yang.binding.DataObject;
-import org.opendaylight.controller.yang.common.QName;
-import org.opendaylight.controller.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 
 public interface DataDomToJavaTransformer<P extends DataObject> extends Transformer<CompositeNode, P> {
 
index 3c4d486..21154b4 100644 (file)
@@ -8,8 +8,8 @@
 package org.opendaylight.controller.sal.binding.spi;
 
 import org.opendaylight.controller.concepts.lang.InputClassBasedTransformer;
-import org.opendaylight.controller.yang.binding.DataObject;
-import org.opendaylight.controller.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 
 public interface JavaToDataDomTransformer<I extends DataObject> extends
         InputClassBasedTransformer<DataObject, I, CompositeNode> {
index 701e72c..44ca27e 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.controller.sal.binding.spi;
 
-import org.opendaylight.controller.yang.binding.DataObject;
-import org.opendaylight.controller.yang.common.QName;
-import org.opendaylight.controller.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 /**
  * Translator between Binding-Independent format and generated Binding Data Objects
  * 
index b29eac2..b3eded9 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.controller.sal.binding.spi;
 
-import org.opendaylight.controller.yang.binding.DataObject;
-import org.opendaylight.controller.yang.binding.RpcService;
-import org.opendaylight.controller.yang.common.QName;
-import org.opendaylight.controller.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 
 public interface MappingProvider {
 
index 0db1bc2..3e32ebc 100644 (file)
@@ -11,10 +11,10 @@ import java.util.Set;
 import java.util.concurrent.Future;
 
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.yang.binding.DataObject;
-import org.opendaylight.controller.yang.binding.RpcService;
-import org.opendaylight.controller.yang.common.QName;
-import org.opendaylight.controller.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.RpcResult;
 
 public interface RpcMapper<T extends RpcService> {
     
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-spi/src/main/java/org/opendaylight/controller/sal/binding/spi/SALBindingModule.java b/opendaylight/sal/yang-prototype/sal/sal-binding-spi/src/main/java/org/opendaylight/controller/sal/binding/spi/SALBindingModule.java
deleted file mode 100644 (file)
index f3ecf80..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.spi;
-
-import java.util.Set;
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareService;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerSession;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality;
-import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
-
-public interface SALBindingModule {
-
-    void setBroker(BindingAwareBroker broker);
-    void onBISessionAvailable(ProviderSession session);
-    
-    void setMappingProvider(MappingProvider provider);
-
-    Set<Class<? extends BindingAwareService>> getProvidedServices();
-
-    <T extends BindingAwareService> T getServiceForSession(Class<T> service,
-            ConsumerSession session);
-
-    Set<Class<? extends ProviderFunctionality>> getSupportedProviderFunctionality();
-}
index 779a6dc..0bb4041 100644 (file)
@@ -3,7 +3,7 @@
     <modelVersion>4.0.0</modelVersion>\r
     <parent>\r
         <groupId>org.opendaylight.controller</groupId>\r
-        <artifactId>sal</artifactId>\r
+        <artifactId>sal-parent</artifactId>\r
         <version>1.0-SNAPSHOT</version>\r
     </parent>\r
     <artifactId>sal-broker-impl</artifactId>\r
@@ -32,5 +32,5 @@
             <artifactId>guava</artifactId>\r
             <type>jar</type>\r
         </dependency>\r
-    </dependencies>
+    </dependencies>\r
 </project>
\ No newline at end of file
index b8a0b97..f0d1cc6 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.core.impl;\r
-\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-import java.util.HashMap;\r
-import java.util.HashSet;\r
-import java.util.Map;\r
-import java.util.Set;\r
-import java.util.concurrent.Callable;\r
-import java.util.concurrent.ExecutorService;\r
-import java.util.concurrent.Future;\r
-import org.opendaylight.controller.sal.core.api.Broker;\r
-import org.opendaylight.controller.sal.core.api.BrokerService;\r
-import org.opendaylight.controller.sal.core.api.Consumer;\r
-import org.opendaylight.controller.sal.core.api.Provider;\r
-import org.opendaylight.controller.sal.core.api.RpcImplementation;\r
-import org.opendaylight.controller.sal.core.spi.BrokerModule;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.common.RpcResult;\r
-import org.opendaylight.controller.yang.data.api.CompositeNode;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-public class BrokerImpl implements Broker {\r
-    private static Logger log = LoggerFactory.getLogger(BrokerImpl.class);\r
-\r
-    // Broker Generic Context\r
-    private Set<ConsumerSessionImpl> sessions = Collections\r
-            .synchronizedSet(new HashSet<ConsumerSessionImpl>());\r
-    private Set<ProviderSessionImpl> providerSessions = Collections\r
-            .synchronizedSet(new HashSet<ProviderSessionImpl>());\r
-    private Set<BrokerModule> modules = Collections\r
-            .synchronizedSet(new HashSet<BrokerModule>());\r
-    private Map<Class<? extends BrokerService>, BrokerModule> serviceProviders = Collections\r
-            .synchronizedMap(new HashMap<Class<? extends BrokerService>, BrokerModule>());\r
-\r
-    // RPC Context\r
-    private Map<QName, RpcImplementation> rpcImpls = Collections\r
-            .synchronizedMap(new HashMap<QName, RpcImplementation>());\r
-\r
-    // Implementation specific\r
-    private ExecutorService executor;\r
-\r
-    @Override\r
-    public ConsumerSession registerConsumer(Consumer consumer) {\r
-        checkPredicates(consumer);\r
-        log.info("Registering consumer " + consumer);\r
-        ConsumerSessionImpl session = newSessionFor(consumer);\r
-        consumer.onSessionInitiated(session);\r
-        sessions.add(session);\r
-        return session;\r
-    }\r
-\r
-    @Override\r
-    public ProviderSession registerProvider(Provider provider) {\r
-        checkPredicates(provider);\r
-\r
-        ProviderSessionImpl session = newSessionFor(provider);\r
-        provider.onSessionInitiated(session);\r
-        providerSessions.add(session);\r
-        return session;\r
-    }\r
-\r
-    public void addModule(BrokerModule module) {\r
-        log.info("Registering broker module " + module);\r
-        if (modules.contains(module)) {\r
-            log.error("Module already registered");\r
-            throw new IllegalArgumentException("Module already exists.");\r
-        }\r
-    \r
-        Set<Class<? extends BrokerService>> provServices = module\r
-                .getProvidedServices();\r
-        for (Class<? extends BrokerService> serviceType : provServices) {\r
-            log.info("  Registering session service implementation: "\r
-                    + serviceType.getCanonicalName());\r
-            serviceProviders.put(serviceType, module);\r
-        }\r
-    }\r
-\r
-    public <T extends BrokerService> T serviceFor(Class<T> service,\r
-            ConsumerSessionImpl session) {\r
-        BrokerModule prov = serviceProviders.get(service);\r
-        if (prov == null) {\r
-            log.warn("Service " + service.toString() + " is not supported");\r
-            return null;\r
-        }\r
-        return prov.getServiceForSession(service, session);\r
-    }\r
-\r
-    // RPC Functionality\r
-    \r
-    private void addRpcImplementation(QName rpcType,\r
-            RpcImplementation implementation) {\r
-        synchronized (rpcImpls) {\r
-            if (rpcImpls.get(rpcType) != null) {\r
-                throw new IllegalStateException("Implementation for rpc "\r
-                        + rpcType + " is already registered.");\r
-            }\r
-            rpcImpls.put(rpcType, implementation);\r
-        }\r
-        // TODO Add notification for availability of Rpc Implementation\r
-    }\r
-\r
-    private void removeRpcImplementation(QName rpcType,\r
-            RpcImplementation implToRemove) {\r
-        synchronized (rpcImpls) {\r
-            if (implToRemove == rpcImpls.get(rpcType)) {\r
-                rpcImpls.remove(rpcType);\r
-            }\r
-        }\r
-        // TODO Add notification for removal of Rpc Implementation\r
-    }\r
-\r
-    private Future<RpcResult<CompositeNode>> invokeRpc(QName rpc,\r
-            CompositeNode input) {\r
-        RpcImplementation impl = rpcImpls.get(rpc);\r
-        // if()\r
-\r
-        Callable<RpcResult<CompositeNode>> call = callableFor(impl,\r
-                rpc, input);\r
-        Future<RpcResult<CompositeNode>> result = executor.submit(call);\r
-\r
-        return result;\r
-    }\r
-    \r
-    // Validation\r
-\r
-    private void checkPredicates(Provider prov) {\r
-        if (prov == null)\r
-            throw new IllegalArgumentException("Provider should not be null.");\r
-        for (ProviderSessionImpl session : providerSessions) {\r
-            if (prov.equals(session.getProvider()))\r
-                throw new IllegalStateException("Provider already registered");\r
-        }\r
-\r
-    }\r
-\r
-    private void checkPredicates(Consumer cons) {\r
-        if (cons == null)\r
-            throw new IllegalArgumentException("Consumer should not be null.");\r
-        for (ConsumerSessionImpl session : sessions) {\r
-            if (cons.equals(session.getConsumer()))\r
-                throw new IllegalStateException("Consumer already registered");\r
-        }\r
-    }\r
-\r
-    // Private Factory methods\r
-    \r
-    private ConsumerSessionImpl newSessionFor(Consumer cons) {\r
-        return new ConsumerSessionImpl(cons);\r
-    }\r
-\r
-    private ProviderSessionImpl newSessionFor(Provider provider) {\r
-        return new ProviderSessionImpl(provider);\r
-    }\r
-\r
-    private void consumerSessionClosed(ConsumerSessionImpl consumerSessionImpl) {\r
-        sessions.remove(consumerSessionImpl);\r
-        providerSessions.remove(consumerSessionImpl);\r
-    }\r
-\r
-    private static Callable<RpcResult<CompositeNode>> callableFor(\r
-            final RpcImplementation implemenation, final QName rpc,\r
-            final CompositeNode input) {\r
-\r
-        return new Callable<RpcResult<CompositeNode>>() {\r
-\r
-            @Override\r
-            public RpcResult<CompositeNode> call() throws Exception {\r
-                return implemenation.invokeRpc(rpc, input);\r
-            }\r
-        };\r
-    }\r
-    \r
-    private class ConsumerSessionImpl implements ConsumerSession {\r
-\r
-        private final Consumer consumer;\r
-\r
-        private Map<Class<? extends BrokerService>, BrokerService> instantiatedServices = Collections\r
-                .synchronizedMap(new HashMap<Class<? extends BrokerService>, BrokerService>());\r
-        private boolean closed = false;\r
-\r
-        public Consumer getConsumer() {\r
-            return consumer;\r
-        }\r
-\r
-        public ConsumerSessionImpl(Consumer consumer) {\r
-            this.consumer = consumer;\r
-        }\r
-\r
-        @Override\r
-        public Future<RpcResult<CompositeNode>> rpc(QName rpc,\r
-                CompositeNode input) {\r
-            return BrokerImpl.this.invokeRpc(rpc, input);\r
-        }\r
-\r
-        @Override\r
-        public <T extends BrokerService> T getService(Class<T> service) {\r
-            BrokerService potential = instantiatedServices.get(service);\r
-            if (potential != null) {\r
-                @SuppressWarnings("unchecked")\r
-                T ret = (T) potential;\r
-                return ret;\r
-            }\r
-            T ret = BrokerImpl.this.serviceFor(service, this);\r
-            if (ret != null) {\r
-                instantiatedServices.put(service, ret);\r
-            }\r
-            return ret;\r
-        }\r
-\r
-        @Override\r
-        public void close() {\r
-            Collection<BrokerService> toStop = instantiatedServices.values();\r
-            this.closed = true;\r
-            for (BrokerService brokerService : toStop) {\r
-                brokerService.closeSession();\r
-            }\r
-            BrokerImpl.this.consumerSessionClosed(this);\r
-        }\r
-\r
-        @Override\r
-        public boolean isClosed() {\r
-            return closed;\r
-        }\r
-\r
-    }\r
-\r
-    private class ProviderSessionImpl extends ConsumerSessionImpl implements\r
-            ProviderSession {\r
-\r
-        private Provider provider;\r
-        private Map<QName, RpcImplementation> sessionRpcImpls = Collections.synchronizedMap(new HashMap<QName, RpcImplementation>());\r
-\r
-        public ProviderSessionImpl(Provider provider) {\r
-            super(null);\r
-            this.provider = provider;\r
-        }\r
-\r
-        @Override\r
-        public void addRpcImplementation(QName rpcType,\r
-                RpcImplementation implementation)\r
-                throws IllegalArgumentException {\r
-            if (rpcType == null) {\r
-                throw new IllegalArgumentException("rpcType must not be null");\r
-            }\r
-            if (implementation == null) {\r
-                throw new IllegalArgumentException(\r
-                        "Implementation must not be null");\r
-            }\r
-            BrokerImpl.this.addRpcImplementation(rpcType, implementation);\r
-            sessionRpcImpls.put(rpcType, implementation);\r
-        }\r
-\r
-        @Override\r
-        public void removeRpcImplementation(QName rpcType,\r
-                RpcImplementation implToRemove) throws IllegalArgumentException {\r
-            RpcImplementation localImpl = rpcImpls.get(rpcType);\r
-            if (localImpl != implToRemove) {\r
-                throw new IllegalStateException(\r
-                        "Implementation was not registered in this session");\r
-            }\r
-\r
-            BrokerImpl.this.removeRpcImplementation(rpcType, implToRemove);\r
-            sessionRpcImpls.remove(rpcType);\r
-        }\r
-\r
-        public Provider getProvider() {\r
-            return this.provider;\r
-        }\r
-\r
-    }\r
-}\r
+/*
+ * 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.core.impl;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import org.opendaylight.controller.sal.core.api.Broker;
+import org.opendaylight.controller.sal.core.api.BrokerService;
+import org.opendaylight.controller.sal.core.api.Consumer;
+import org.opendaylight.controller.sal.core.api.Provider;
+import org.opendaylight.controller.sal.core.api.RpcImplementation;
+import org.opendaylight.controller.sal.core.spi.BrokerModule;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BrokerImpl implements Broker {
+    private static Logger log = LoggerFactory.getLogger(BrokerImpl.class);
+
+    // Broker Generic Context
+    private Set<ConsumerSessionImpl> sessions = Collections
+            .synchronizedSet(new HashSet<ConsumerSessionImpl>());
+    private Set<ProviderSessionImpl> providerSessions = Collections
+            .synchronizedSet(new HashSet<ProviderSessionImpl>());
+    private Set<BrokerModule> modules = Collections
+            .synchronizedSet(new HashSet<BrokerModule>());
+    private Map<Class<? extends BrokerService>, BrokerModule> serviceProviders = Collections
+            .synchronizedMap(new HashMap<Class<? extends BrokerService>, BrokerModule>());
+
+    // RPC Context
+    private Map<QName, RpcImplementation> rpcImpls = Collections
+            .synchronizedMap(new HashMap<QName, RpcImplementation>());
+
+    // Implementation specific
+    private ExecutorService executor;
+
+    @Override
+    public ConsumerSession registerConsumer(Consumer consumer) {
+        checkPredicates(consumer);
+        log.info("Registering consumer " + consumer);
+        ConsumerSessionImpl session = newSessionFor(consumer);
+        consumer.onSessionInitiated(session);
+        sessions.add(session);
+        return session;
+    }
+
+    @Override
+    public ProviderSession registerProvider(Provider provider) {
+        checkPredicates(provider);
+
+        ProviderSessionImpl session = newSessionFor(provider);
+        provider.onSessionInitiated(session);
+        providerSessions.add(session);
+        return session;
+    }
+
+    public void addModule(BrokerModule module) {
+        log.info("Registering broker module " + module);
+        if (modules.contains(module)) {
+            log.error("Module already registered");
+            throw new IllegalArgumentException("Module already exists.");
+        }
+    
+        Set<Class<? extends BrokerService>> provServices = module
+                .getProvidedServices();
+        for (Class<? extends BrokerService> serviceType : provServices) {
+            log.info("  Registering session service implementation: "
+                    + serviceType.getCanonicalName());
+            serviceProviders.put(serviceType, module);
+        }
+    }
+
+    public <T extends BrokerService> T serviceFor(Class<T> service,
+            ConsumerSessionImpl session) {
+        BrokerModule prov = serviceProviders.get(service);
+        if (prov == null) {
+            log.warn("Service " + service.toString() + " is not supported");
+            return null;
+        }
+        return prov.getServiceForSession(service, session);
+    }
+
+    // RPC Functionality
+    
+    private void addRpcImplementation(QName rpcType,
+            RpcImplementation implementation) {
+        synchronized (rpcImpls) {
+            if (rpcImpls.get(rpcType) != null) {
+                throw new IllegalStateException("Implementation for rpc "
+                        + rpcType + " is already registered.");
+            }
+            rpcImpls.put(rpcType, implementation);
+        }
+        // TODO Add notification for availability of Rpc Implementation
+    }
+
+    private void removeRpcImplementation(QName rpcType,
+            RpcImplementation implToRemove) {
+        synchronized (rpcImpls) {
+            if (implToRemove == rpcImpls.get(rpcType)) {
+                rpcImpls.remove(rpcType);
+            }
+        }
+        // TODO Add notification for removal of Rpc Implementation
+    }
+
+    private Future<RpcResult<CompositeNode>> invokeRpc(QName rpc,
+            CompositeNode input) {
+        RpcImplementation impl = rpcImpls.get(rpc);
+        // if()
+
+        Callable<RpcResult<CompositeNode>> call = callableFor(impl,
+                rpc, input);
+        Future<RpcResult<CompositeNode>> result = executor.submit(call);
+
+        return result;
+    }
+    
+    // Validation
+
+    private void checkPredicates(Provider prov) {
+        if (prov == null)
+            throw new IllegalArgumentException("Provider should not be null.");
+        for (ProviderSessionImpl session : providerSessions) {
+            if (prov.equals(session.getProvider()))
+                throw new IllegalStateException("Provider already registered");
+        }
+
+    }
+
+    private void checkPredicates(Consumer cons) {
+        if (cons == null)
+            throw new IllegalArgumentException("Consumer should not be null.");
+        for (ConsumerSessionImpl session : sessions) {
+            if (cons.equals(session.getConsumer()))
+                throw new IllegalStateException("Consumer already registered");
+        }
+    }
+
+    // Private Factory methods
+    
+    private ConsumerSessionImpl newSessionFor(Consumer cons) {
+        return new ConsumerSessionImpl(cons);
+    }
+
+    private ProviderSessionImpl newSessionFor(Provider provider) {
+        return new ProviderSessionImpl(provider);
+    }
+
+    private void consumerSessionClosed(ConsumerSessionImpl consumerSessionImpl) {
+        sessions.remove(consumerSessionImpl);
+        providerSessions.remove(consumerSessionImpl);
+    }
+
+    private static Callable<RpcResult<CompositeNode>> callableFor(
+            final RpcImplementation implemenation, final QName rpc,
+            final CompositeNode input) {
+
+        return new Callable<RpcResult<CompositeNode>>() {
+
+            @Override
+            public RpcResult<CompositeNode> call() throws Exception {
+                return implemenation.invokeRpc(rpc, input);
+            }
+        };
+    }
+    
+    private class ConsumerSessionImpl implements ConsumerSession {
+
+        private final Consumer consumer;
+
+        private Map<Class<? extends BrokerService>, BrokerService> instantiatedServices = Collections
+                .synchronizedMap(new HashMap<Class<? extends BrokerService>, BrokerService>());
+        private boolean closed = false;
+
+        public Consumer getConsumer() {
+            return consumer;
+        }
+
+        public ConsumerSessionImpl(Consumer consumer) {
+            this.consumer = consumer;
+        }
+
+        @Override
+        public Future<RpcResult<CompositeNode>> rpc(QName rpc,
+                CompositeNode input) {
+            return BrokerImpl.this.invokeRpc(rpc, input);
+        }
+
+        @Override
+        public <T extends BrokerService> T getService(Class<T> service) {
+            BrokerService potential = instantiatedServices.get(service);
+            if (potential != null) {
+                @SuppressWarnings("unchecked")
+                T ret = (T) potential;
+                return ret;
+            }
+            T ret = BrokerImpl.this.serviceFor(service, this);
+            if (ret != null) {
+                instantiatedServices.put(service, ret);
+            }
+            return ret;
+        }
+
+        @Override
+        public void close() {
+            Collection<BrokerService> toStop = instantiatedServices.values();
+            this.closed = true;
+            for (BrokerService brokerService : toStop) {
+                brokerService.closeSession();
+            }
+            BrokerImpl.this.consumerSessionClosed(this);
+        }
+
+        @Override
+        public boolean isClosed() {
+            return closed;
+        }
+
+    }
+
+    private class ProviderSessionImpl extends ConsumerSessionImpl implements
+            ProviderSession {
+
+        private Provider provider;
+        private Map<QName, RpcImplementation> sessionRpcImpls = Collections.synchronizedMap(new HashMap<QName, RpcImplementation>());
+
+        public ProviderSessionImpl(Provider provider) {
+            super(null);
+            this.provider = provider;
+        }
+
+        @Override
+        public void addRpcImplementation(QName rpcType,
+                RpcImplementation implementation)
+                throws IllegalArgumentException {
+            if (rpcType == null) {
+                throw new IllegalArgumentException("rpcType must not be null");
+            }
+            if (implementation == null) {
+                throw new IllegalArgumentException(
+                        "Implementation must not be null");
+            }
+            BrokerImpl.this.addRpcImplementation(rpcType, implementation);
+            sessionRpcImpls.put(rpcType, implementation);
+        }
+
+        @Override
+        public void removeRpcImplementation(QName rpcType,
+                RpcImplementation implToRemove) throws IllegalArgumentException {
+            RpcImplementation localImpl = rpcImpls.get(rpcType);
+            if (localImpl != implToRemove) {
+                throw new IllegalStateException(
+                        "Implementation was not registered in this session");
+            }
+
+            BrokerImpl.this.removeRpcImplementation(rpcType, implToRemove);
+            sessionRpcImpls.remove(rpcType);
+        }
+
+        public Provider getProvider() {
+            return this.provider;
+        }
+
+    }
+}
index 852f6b6..34eba18 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.core.impl;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Set;\r
-import java.util.concurrent.ExecutorService;\r
-import java.util.concurrent.Future;\r
-\r
-import org.opendaylight.controller.sal.common.DataStoreIdentifier;\r
-import org.opendaylight.controller.sal.common.util.Rpcs;\r
-import org.opendaylight.controller.sal.core.api.BrokerService;\r
-import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession;\r
-import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;\r
-import org.opendaylight.controller.sal.core.api.Consumer.ConsumerFunctionality;\r
-import org.opendaylight.controller.sal.core.api.Provider.ProviderFunctionality;\r
-import org.opendaylight.controller.sal.core.api.data.DataBrokerService;\r
-import org.opendaylight.controller.sal.core.api.data.DataCommitHandler;\r
-import org.opendaylight.controller.sal.core.api.data.DataProviderService;\r
-import org.opendaylight.controller.sal.core.api.data.DataValidator;\r
-import org.opendaylight.controller.sal.core.api.data.DataCommitHandler.CommitTransaction;\r
-import org.opendaylight.controller.sal.core.api.data.DataProviderService.DataRefresher;\r
-import org.opendaylight.controller.sal.core.spi.BrokerModule;\r
-import org.opendaylight.controller.yang.common.RpcError;\r
-import org.opendaylight.controller.yang.common.RpcResult;\r
-import org.opendaylight.controller.yang.data.api.CompositeNode;\r
-import org.opendaylight.controller.yang.data.api.CompositeNodeModification;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import com.google.common.collect.ImmutableSet;\r
-\r
-public class DataBrokerModule implements BrokerModule {\r
-\r
-    private static final Logger log = LoggerFactory\r
-            .getLogger(DataBrokerModule.class);\r
-\r
-    private static final Set<Class<? extends ProviderFunctionality>> SUPPORTED_PROVIDER_FUNCTIONALITY = ImmutableSet\r
-            .of((Class<? extends ProviderFunctionality>) DataValidator.class,\r
-                    DataRefresher.class, DataCommitHandler.class);\r
-\r
-    private static final Set<Class<? extends BrokerService>> PROVIDED_SESSION_SERVICES = ImmutableSet\r
-            .of((Class<? extends BrokerService>) DataBrokerService.class,\r
-                    DataProviderService.class);\r
-\r
-    private Map<DataStoreIdentifier, StoreContext> storeContext;\r
-\r
-    private ExecutorService executor;\r
-    \r
-    private SequentialCommitHandlerCoordinator coordinator = new SequentialCommitHandlerCoordinator();\r
-\r
-    @Override\r
-    public Set<Class<? extends BrokerService>> getProvidedServices() {\r
-        return PROVIDED_SESSION_SERVICES;\r
-    }\r
-\r
-    @Override\r
-    public Set<Class<? extends ProviderFunctionality>> getSupportedProviderFunctionality() {\r
-        return SUPPORTED_PROVIDER_FUNCTIONALITY;\r
-    }\r
-\r
-    @Override\r
-    public Set<Class<? extends ConsumerFunctionality>> getSupportedConsumerFunctionality() {\r
-        return Collections.emptySet();\r
-    }\r
-\r
-    @Override\r
-    public <T extends BrokerService> T getServiceForSession(Class<T> service,\r
-            ConsumerSession session) {\r
-        if (DataProviderService.class.equals(service)\r
-                && session instanceof ProviderSession) {\r
-            @SuppressWarnings("unchecked")\r
-            T ret = (T) newDataProviderService(session);\r
-            return ret;\r
-        } else if (DataBrokerService.class.equals(service)) {\r
-\r
-            @SuppressWarnings("unchecked")\r
-            T ret = (T) newDataConsumerService(session);\r
-            return ret;\r
-        }\r
-\r
-        throw new IllegalArgumentException(\r
-                "The requested session-specific service is not provided by this module.");\r
-    }\r
-\r
-    private DataProviderService newDataProviderService(ConsumerSession session) {\r
-        return new DataProviderSession();\r
-    }\r
-\r
-    private DataBrokerService newDataConsumerService(ConsumerSession session) {\r
-        return new DataConsumerSession();\r
-    }\r
-\r
-    private StoreContext context(DataStoreIdentifier store) {\r
-        return storeContext.get(store);\r
-    }\r
-\r
-    private static class StoreContext {\r
-        private Set<DataCommitHandler> commitHandlers = Collections\r
-                .synchronizedSet(new HashSet<DataCommitHandler>());\r
-        private Set<DataValidator> validators = Collections\r
-                .synchronizedSet(new HashSet<DataValidator>());\r
-        private Set<DataRefresher> refreshers = Collections\r
-                .synchronizedSet(new HashSet<DataRefresher>());\r
-    }\r
-\r
-    private class DataConsumerSession implements DataBrokerService {\r
-\r
-        @Override\r
-        public CompositeNode getData(DataStoreIdentifier store) {\r
-            // TODO Implement this method\r
-            throw new UnsupportedOperationException("Not implemented");\r
-        }\r
-\r
-        @Override\r
-        public CompositeNode getData(DataStoreIdentifier store,\r
-                CompositeNode filter) {\r
-            // TODO Implement this method\r
-            throw new UnsupportedOperationException("Not implemented");\r
-        }\r
-\r
-        @Override\r
-        public CompositeNode getCandidateData(DataStoreIdentifier store) {\r
-            // TODO Implement this method\r
-            throw new UnsupportedOperationException("Not implemented");\r
-        }\r
-\r
-        @Override\r
-        public CompositeNode getCandidateData(DataStoreIdentifier store,\r
-                CompositeNode filter) {\r
-            // TODO Implement this method\r
-            throw new UnsupportedOperationException("Not implemented");\r
-        }\r
-\r
-        @Override\r
-        public RpcResult<CompositeNode> editCandidateData(\r
-                DataStoreIdentifier store, CompositeNodeModification changeSet) {\r
-            // TODO Implement this method\r
-            throw new UnsupportedOperationException("Not implemented");\r
-        }\r
-\r
-        @Override\r
-        public Future<RpcResult<Void>> commit(DataStoreIdentifier store) {\r
-            // TODO Implement this method\r
-            throw new UnsupportedOperationException("Not implemented");\r
-        }\r
-\r
-        @Override\r
-        public void closeSession() {\r
-            // TODO Implement this method\r
-            throw new UnsupportedOperationException("Not implemented");\r
-        }\r
-\r
-        @Override\r
-        public Set<DataStoreIdentifier> getDataStores() {\r
-            // TODO Auto-generated method stub\r
-            return null;\r
-        }\r
-\r
-    }\r
-\r
-    private class DataProviderSession extends DataConsumerSession implements\r
-            DataProviderService {\r
-\r
-        private Set<DataCommitHandler> providerCommitHandlers = new HashSet<DataCommitHandler>();\r
-        private Set<DataValidator> providerValidators = new HashSet<DataValidator>();\r
-        private Set<DataRefresher> providerRefreshers = new HashSet<DataRefresher>();\r
-\r
-        @Override\r
-        public void addValidator(DataStoreIdentifier store,\r
-                DataValidator validator) {\r
-            if (validator == null)\r
-                throw new IllegalArgumentException(\r
-                        "Validator should not be null");\r
-\r
-            providerValidators.add(validator);\r
-            context(store).validators.add(validator);\r
-        }\r
-\r
-        @Override\r
-        public void removeValidator(DataStoreIdentifier store,\r
-                DataValidator validator) {\r
-            if (validator == null)\r
-                throw new IllegalArgumentException(\r
-                        "Validator should not be null");\r
-\r
-            providerValidators.remove(validator);\r
-            context(store).validators.remove(validator);\r
-        }\r
-\r
-        @Override\r
-        public void addCommitHandler(DataStoreIdentifier store,\r
-                DataCommitHandler provider) {\r
-            if (provider == null)\r
-                throw new IllegalArgumentException(\r
-                        "CommitHandler should not be null");\r
-\r
-            providerCommitHandlers.add(provider);\r
-            context(store).commitHandlers.add(provider);\r
-        }\r
-\r
-        @Override\r
-        public void removeCommitHandler(DataStoreIdentifier store,\r
-                DataCommitHandler provider) {\r
-            if (provider == null)\r
-                throw new IllegalArgumentException(\r
-                        "CommitHandler should not be null");\r
-\r
-            providerCommitHandlers.remove(provider);\r
-            context(store).commitHandlers.remove(provider);\r
-        }\r
-\r
-        @Override\r
-        public void addRefresher(DataStoreIdentifier store,\r
-                DataRefresher provider) {\r
-            if (provider == null)\r
-                throw new IllegalArgumentException(\r
-                        "Refresher should not be null");\r
-\r
-            providerRefreshers.add(provider);\r
-            context(store).refreshers.add(provider);\r
-        }\r
-\r
-        @Override\r
-        public void removeRefresher(DataStoreIdentifier store,\r
-                DataRefresher provider) {\r
-            if (provider == null)\r
-                throw new IllegalArgumentException(\r
-                        "Refresher should not be null");\r
-\r
-            providerRefreshers.remove(provider);\r
-            context(store).refreshers.remove(provider);\r
-        }\r
-\r
-    }\r
-\r
-    private class SequentialCommitHandlerCoordinator implements\r
-            DataCommitHandler {\r
-\r
-        @Override\r
-        public RpcResult<CommitTransaction> requestCommit(\r
-                DataStoreIdentifier store) {\r
-            List<RpcError> errors = new ArrayList<RpcError>();\r
-            Set<CommitTransaction> transactions = new HashSet<DataCommitHandler.CommitTransaction>();\r
-            boolean successful = true;\r
-\r
-            for (DataCommitHandler commitHandler : context(store).commitHandlers) {\r
-                try {\r
-                    RpcResult<CommitTransaction> partialResult = commitHandler\r
-                            .requestCommit(store);\r
-                    successful = partialResult.isSuccessful() & successful;\r
-                    if (partialResult.isSuccessful()) {\r
-                        transactions.add(partialResult.getResult());\r
-                    }\r
-\r
-                    errors.addAll(partialResult.getErrors());\r
-                } catch (Exception e) {\r
-                    log.error("Uncaught exception prevented commit request."\r
-                            + e.getMessage(), e);\r
-                    successful = false;\r
-                    // FIXME: Add RPC Error with exception.\r
-                }\r
-                if (successful == false)\r
-                    break;\r
-            }\r
-            CommitTransaction transaction = new SequentialCommitTransaction(\r
-                    store, transactions);\r
-            return Rpcs.getRpcResult(successful, transaction, errors);\r
-        }\r
-\r
-        @Override\r
-        public Set<DataStoreIdentifier> getSupportedDataStores() {\r
-            return Collections.emptySet();\r
-        }\r
-    }\r
-\r
-    private class SequentialCommitTransaction implements CommitTransaction {\r
-\r
-        final Set<CommitTransaction> transactions;\r
-        final DataStoreIdentifier store;\r
-\r
-        public SequentialCommitTransaction(DataStoreIdentifier s,\r
-                Set<CommitTransaction> t) {\r
-            transactions = t;\r
-            store = s;\r
-        }\r
-\r
-        @Override\r
-        public RpcResult<Void> finish() {\r
-            List<RpcError> errors = new ArrayList<RpcError>();\r
-            boolean successful = true;\r
-\r
-            for (CommitTransaction commitHandler : transactions) {\r
-                try {\r
-                    RpcResult<Void> partialResult = commitHandler.finish();\r
-                    successful = partialResult.isSuccessful() & successful;\r
-                    errors.addAll(partialResult.getErrors());\r
-                } catch (Exception e) {\r
-                    log.error(\r
-                            "Uncaught exception prevented finishing of commit."\r
-                                    + e.getMessage(), e);\r
-                    successful = false;\r
-                    // FIXME: Add RPC Error with exception.\r
-                }\r
-                if (successful == false)\r
-                    break;\r
-            }\r
-\r
-            return Rpcs.getRpcResult(successful, null, errors);\r
-        }\r
-\r
-        @Override\r
-        public RpcResult<Void> rollback() {\r
-            List<RpcError> errors = new ArrayList<RpcError>();\r
-            boolean successful = true;\r
-\r
-            for (CommitTransaction commitHandler : transactions) {\r
-                try {\r
-                    RpcResult<Void> partialResult = commitHandler.rollback();\r
-                    successful = partialResult.isSuccessful() & successful;\r
-                    errors.addAll(partialResult.getErrors());\r
-                } catch (Exception e) {\r
-                    log.error(\r
-                            "Uncaught exception prevented rollback of commit."\r
-                                    + e.getMessage(), e);\r
-                    successful = false;\r
-                    // FIXME: Add RPC Error with exception.\r
-                }\r
-                if (successful == false)\r
-                    break;\r
-            }\r
-\r
-            return Rpcs.getRpcResult(successful, null, errors);\r
-        }\r
-\r
-        @Override\r
-        public DataStoreIdentifier getDataStore() {\r
-            return this.store;\r
-        }\r
-\r
-        @Override\r
-        public DataCommitHandler getHandler() {\r
-            return coordinator;\r
-        }\r
-    }\r
-\r
-    private class ValidationCoordinator implements DataValidator {\r
-\r
-        private final DataStoreIdentifier store;\r
-\r
-        ValidationCoordinator(DataStoreIdentifier store) {\r
-            this.store = store;\r
-        }\r
-\r
-        @Override\r
-        public RpcResult<Void> validate(CompositeNode toValidate) {\r
-            List<RpcError> errors = new ArrayList<RpcError>();\r
-            boolean successful = true;\r
-\r
-            for (DataValidator validator : context(store).validators) {\r
-                try {\r
-                    RpcResult<Void> partialResult = validator\r
-                            .validate(toValidate);\r
-                    successful = partialResult.isSuccessful() & successful;\r
-                    errors.addAll(partialResult.getErrors());\r
-                } catch (Exception e) {\r
-                    log.error(\r
-                            "Uncaught exception prevented validation."\r
-                                    + e.getMessage(), e);\r
-                    successful = false;\r
-                    // FIXME: Add RPC Error with exception.\r
-                }\r
-                if (successful == false)\r
-                    break;\r
-            }\r
-\r
-            return Rpcs.getRpcResult(successful, null, errors);\r
-        }\r
-\r
-        @Override\r
-        public Set<DataStoreIdentifier> getSupportedDataStores() {\r
-            return Collections.emptySet();\r
-        }\r
-\r
-    }\r
-\r
-    private class DataRefreshCoordinator implements DataRefresher {\r
-\r
-        private final DataStoreIdentifier store;\r
-\r
-        DataRefreshCoordinator(DataStoreIdentifier store) {\r
-            this.store = store;\r
-        }\r
-\r
-        @Override\r
-        public void refreshData() {\r
-\r
-            for (DataRefresher refresher : context(store).refreshers) {\r
-                try {\r
-                    refresher.refreshData();\r
-                } catch (Exception e) {\r
-                    log.error(\r
-                            "Uncaught exception during refresh of data: "\r
-                                    + e.getMessage(), e);\r
-                }\r
-\r
-            }\r
-        }\r
-    }\r
-}\r
+/*
+ * 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.core.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+
+import org.opendaylight.controller.sal.common.DataStoreIdentifier;
+import org.opendaylight.controller.sal.common.util.Rpcs;
+import org.opendaylight.controller.sal.core.api.BrokerService;
+import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession;
+import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
+import org.opendaylight.controller.sal.core.api.Consumer.ConsumerFunctionality;
+import org.opendaylight.controller.sal.core.api.Provider.ProviderFunctionality;
+import org.opendaylight.controller.sal.core.api.data.DataBrokerService;
+import org.opendaylight.controller.sal.core.api.data.DataCommitHandler;
+import org.opendaylight.controller.sal.core.api.data.DataProviderService;
+import org.opendaylight.controller.sal.core.api.data.DataValidator;
+import org.opendaylight.controller.sal.core.api.data.DataCommitHandler.CommitTransaction;
+import org.opendaylight.controller.sal.core.api.data.DataProviderService.DataRefresher;
+import org.opendaylight.controller.sal.core.spi.BrokerModule;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.MutableCompositeNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableSet;
+
+public class DataBrokerModule implements BrokerModule {
+
+    private static final Logger log = LoggerFactory
+            .getLogger(DataBrokerModule.class);
+
+    private static final Set<Class<? extends ProviderFunctionality>> SUPPORTED_PROVIDER_FUNCTIONALITY = ImmutableSet
+            .of((Class<? extends ProviderFunctionality>) DataValidator.class,
+                    DataRefresher.class, DataCommitHandler.class);
+
+    private static final Set<Class<? extends BrokerService>> PROVIDED_SESSION_SERVICES = ImmutableSet
+            .of((Class<? extends BrokerService>) DataBrokerService.class,
+                    DataProviderService.class);
+
+    private Map<DataStoreIdentifier, StoreContext> storeContext;
+
+    private ExecutorService executor;
+    
+    private SequentialCommitHandlerCoordinator coordinator = new SequentialCommitHandlerCoordinator();
+
+    @Override
+    public Set<Class<? extends BrokerService>> getProvidedServices() {
+        return PROVIDED_SESSION_SERVICES;
+    }
+
+    @Override
+    public Set<Class<? extends ProviderFunctionality>> getSupportedProviderFunctionality() {
+        return SUPPORTED_PROVIDER_FUNCTIONALITY;
+    }
+
+    @Override
+    public Set<Class<? extends ConsumerFunctionality>> getSupportedConsumerFunctionality() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public <T extends BrokerService> T getServiceForSession(Class<T> service,
+            ConsumerSession session) {
+        if (DataProviderService.class.equals(service)
+                && session instanceof ProviderSession) {
+            @SuppressWarnings("unchecked")
+            T ret = (T) newDataProviderService(session);
+            return ret;
+        } else if (DataBrokerService.class.equals(service)) {
+
+            @SuppressWarnings("unchecked")
+            T ret = (T) newDataConsumerService(session);
+            return ret;
+        }
+
+        throw new IllegalArgumentException(
+                "The requested session-specific service is not provided by this module.");
+    }
+
+    private DataProviderService newDataProviderService(ConsumerSession session) {
+        return new DataProviderSession();
+    }
+
+    private DataBrokerService newDataConsumerService(ConsumerSession session) {
+        return new DataConsumerSession();
+    }
+
+    private StoreContext context(DataStoreIdentifier store) {
+        return storeContext.get(store);
+    }
+
+    private static class StoreContext {
+        private Set<DataCommitHandler> commitHandlers = Collections
+                .synchronizedSet(new HashSet<DataCommitHandler>());
+        private Set<DataValidator> validators = Collections
+                .synchronizedSet(new HashSet<DataValidator>());
+        private Set<DataRefresher> refreshers = Collections
+                .synchronizedSet(new HashSet<DataRefresher>());
+    }
+
+    private class DataConsumerSession implements DataBrokerService {
+
+        @Override
+        public CompositeNode getData(DataStoreIdentifier store) {
+            // TODO Implement this method
+            throw new UnsupportedOperationException("Not implemented");
+        }
+
+        @Override
+        public CompositeNode getData(DataStoreIdentifier store,
+                CompositeNode filter) {
+            // TODO Implement this method
+            throw new UnsupportedOperationException("Not implemented");
+        }
+
+        @Override
+        public CompositeNode getCandidateData(DataStoreIdentifier store) {
+            // TODO Implement this method
+            throw new UnsupportedOperationException("Not implemented");
+        }
+
+        @Override
+        public CompositeNode getCandidateData(DataStoreIdentifier store,
+                CompositeNode filter) {
+            // TODO Implement this method
+            throw new UnsupportedOperationException("Not implemented");
+        }
+
+        @Override
+        public RpcResult<CompositeNode> editCandidateData(
+                DataStoreIdentifier store, MutableCompositeNode changeSet) {
+            // TODO Implement this method
+            throw new UnsupportedOperationException("Not implemented");
+        }
+
+        @Override
+        public Future<RpcResult<Void>> commit(DataStoreIdentifier store) {
+            // TODO Implement this method
+            throw new UnsupportedOperationException("Not implemented");
+        }
+
+        @Override
+        public void closeSession() {
+            // TODO Implement this method
+            throw new UnsupportedOperationException("Not implemented");
+        }
+
+        @Override
+        public Set<DataStoreIdentifier> getDataStores() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+    }
+
+    private class DataProviderSession extends DataConsumerSession implements
+            DataProviderService {
+
+        private Set<DataCommitHandler> providerCommitHandlers = new HashSet<DataCommitHandler>();
+        private Set<DataValidator> providerValidators = new HashSet<DataValidator>();
+        private Set<DataRefresher> providerRefreshers = new HashSet<DataRefresher>();
+
+        @Override
+        public void addValidator(DataStoreIdentifier store,
+                DataValidator validator) {
+            if (validator == null)
+                throw new IllegalArgumentException(
+                        "Validator should not be null");
+
+            providerValidators.add(validator);
+            context(store).validators.add(validator);
+        }
+
+        @Override
+        public void removeValidator(DataStoreIdentifier store,
+                DataValidator validator) {
+            if (validator == null)
+                throw new IllegalArgumentException(
+                        "Validator should not be null");
+
+            providerValidators.remove(validator);
+            context(store).validators.remove(validator);
+        }
+
+        @Override
+        public void addCommitHandler(DataStoreIdentifier store,
+                DataCommitHandler provider) {
+            if (provider == null)
+                throw new IllegalArgumentException(
+                        "CommitHandler should not be null");
+
+            providerCommitHandlers.add(provider);
+            context(store).commitHandlers.add(provider);
+        }
+
+        @Override
+        public void removeCommitHandler(DataStoreIdentifier store,
+                DataCommitHandler provider) {
+            if (provider == null)
+                throw new IllegalArgumentException(
+                        "CommitHandler should not be null");
+
+            providerCommitHandlers.remove(provider);
+            context(store).commitHandlers.remove(provider);
+        }
+
+        @Override
+        public void addRefresher(DataStoreIdentifier store,
+                DataRefresher provider) {
+            if (provider == null)
+                throw new IllegalArgumentException(
+                        "Refresher should not be null");
+
+            providerRefreshers.add(provider);
+            context(store).refreshers.add(provider);
+        }
+
+        @Override
+        public void removeRefresher(DataStoreIdentifier store,
+                DataRefresher provider) {
+            if (provider == null)
+                throw new IllegalArgumentException(
+                        "Refresher should not be null");
+
+            providerRefreshers.remove(provider);
+            context(store).refreshers.remove(provider);
+        }
+
+    }
+
+    private class SequentialCommitHandlerCoordinator implements
+            DataCommitHandler {
+
+        @Override
+        public RpcResult<CommitTransaction> requestCommit(
+                DataStoreIdentifier store) {
+            List<RpcError> errors = new ArrayList<RpcError>();
+            Set<CommitTransaction> transactions = new HashSet<DataCommitHandler.CommitTransaction>();
+            boolean successful = true;
+
+            for (DataCommitHandler commitHandler : context(store).commitHandlers) {
+                try {
+                    RpcResult<CommitTransaction> partialResult = commitHandler
+                            .requestCommit(store);
+                    successful = partialResult.isSuccessful() & successful;
+                    if (partialResult.isSuccessful()) {
+                        transactions.add(partialResult.getResult());
+                    }
+
+                    errors.addAll(partialResult.getErrors());
+                } catch (Exception e) {
+                    log.error("Uncaught exception prevented commit request."
+                            + e.getMessage(), e);
+                    successful = false;
+                    // FIXME: Add RPC Error with exception.
+                }
+                if (successful == false)
+                    break;
+            }
+            CommitTransaction transaction = new SequentialCommitTransaction(
+                    store, transactions);
+            return Rpcs.getRpcResult(successful, transaction, errors);
+        }
+
+        @Override
+        public Set<DataStoreIdentifier> getSupportedDataStores() {
+            return Collections.emptySet();
+        }
+    }
+
+    private class SequentialCommitTransaction implements CommitTransaction {
+
+        final Set<CommitTransaction> transactions;
+        final DataStoreIdentifier store;
+
+        public SequentialCommitTransaction(DataStoreIdentifier s,
+                Set<CommitTransaction> t) {
+            transactions = t;
+            store = s;
+        }
+
+        @Override
+        public RpcResult<Void> finish() {
+            List<RpcError> errors = new ArrayList<RpcError>();
+            boolean successful = true;
+
+            for (CommitTransaction commitHandler : transactions) {
+                try {
+                    RpcResult<Void> partialResult = commitHandler.finish();
+                    successful = partialResult.isSuccessful() & successful;
+                    errors.addAll(partialResult.getErrors());
+                } catch (Exception e) {
+                    log.error(
+                            "Uncaught exception prevented finishing of commit."
+                                    + e.getMessage(), e);
+                    successful = false;
+                    // FIXME: Add RPC Error with exception.
+                }
+                if (successful == false)
+                    break;
+            }
+
+            return Rpcs.getRpcResult(successful, null, errors);
+        }
+
+        @Override
+        public RpcResult<Void> rollback() {
+            List<RpcError> errors = new ArrayList<RpcError>();
+            boolean successful = true;
+
+            for (CommitTransaction commitHandler : transactions) {
+                try {
+                    RpcResult<Void> partialResult = commitHandler.rollback();
+                    successful = partialResult.isSuccessful() & successful;
+                    errors.addAll(partialResult.getErrors());
+                } catch (Exception e) {
+                    log.error(
+                            "Uncaught exception prevented rollback of commit."
+                                    + e.getMessage(), e);
+                    successful = false;
+                    // FIXME: Add RPC Error with exception.
+                }
+                if (successful == false)
+                    break;
+            }
+
+            return Rpcs.getRpcResult(successful, null, errors);
+        }
+
+        @Override
+        public DataStoreIdentifier getDataStore() {
+            return this.store;
+        }
+
+        @Override
+        public DataCommitHandler getHandler() {
+            return coordinator;
+        }
+    }
+
+    private class ValidationCoordinator implements DataValidator {
+
+        private final DataStoreIdentifier store;
+
+        ValidationCoordinator(DataStoreIdentifier store) {
+            this.store = store;
+        }
+
+        @Override
+        public RpcResult<Void> validate(CompositeNode toValidate) {
+            List<RpcError> errors = new ArrayList<RpcError>();
+            boolean successful = true;
+
+            for (DataValidator validator : context(store).validators) {
+                try {
+                    RpcResult<Void> partialResult = validator
+                            .validate(toValidate);
+                    successful = partialResult.isSuccessful() & successful;
+                    errors.addAll(partialResult.getErrors());
+                } catch (Exception e) {
+                    log.error(
+                            "Uncaught exception prevented validation."
+                                    + e.getMessage(), e);
+                    successful = false;
+                    // FIXME: Add RPC Error with exception.
+                }
+                if (successful == false)
+                    break;
+            }
+
+            return Rpcs.getRpcResult(successful, null, errors);
+        }
+
+        @Override
+        public Set<DataStoreIdentifier> getSupportedDataStores() {
+            return Collections.emptySet();
+        }
+
+    }
+
+    private class DataRefreshCoordinator implements DataRefresher {
+
+        private final DataStoreIdentifier store;
+
+        DataRefreshCoordinator(DataStoreIdentifier store) {
+            this.store = store;
+        }
+
+        @Override
+        public void refreshData() {
+
+            for (DataRefresher refresher : context(store).refreshers) {
+                try {
+                    refresher.refreshData();
+                } catch (Exception e) {
+                    log.error(
+                            "Uncaught exception during refresh of data: "
+                                    + e.getMessage(), e);
+                }
+
+            }
+        }
+    }
+}
index bd70ee1..2bbbde6 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.core.impl;\r
-\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-import java.util.HashSet;\r
-import java.util.Map;\r
-import java.util.Map.Entry;\r
-import java.util.Set;\r
-\r
-import org.opendaylight.controller.sal.core.api.BrokerService;\r
-import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession;\r
-import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;\r
-import org.opendaylight.controller.sal.core.api.Consumer.ConsumerFunctionality;\r
-import org.opendaylight.controller.sal.core.api.Provider.ProviderFunctionality;\r
-import org.opendaylight.controller.sal.core.api.notify.NotificationListener;\r
-import org.opendaylight.controller.sal.core.api.notify.NotificationProviderService;\r
-import org.opendaylight.controller.sal.core.api.notify.NotificationService;\r
-import org.opendaylight.controller.sal.core.spi.BrokerModule;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.data.api.CompositeNode;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import com.google.common.collect.HashMultimap;\r
-import com.google.common.collect.ImmutableSet;\r
-import com.google.common.collect.Multimap;\r
-\r
-public class NotificationModule implements BrokerModule {\r
-    private static Logger log = LoggerFactory\r
-            .getLogger(NotificationModule.class);\r
-\r
-    private Multimap<QName, NotificationListener> listeners = HashMultimap\r
-            .create();\r
-\r
-    private static final Set<Class<? extends BrokerService>> PROVIDED_SERVICE_TYPE = ImmutableSet\r
-            .of((Class<? extends BrokerService>) NotificationService.class,\r
-                    NotificationProviderService.class);\r
-\r
-    private static final Set<Class<? extends ConsumerFunctionality>> SUPPORTED_CONSUMER_FUNCTIONALITY = ImmutableSet\r
-            .of((Class<? extends ConsumerFunctionality>) NotificationListener.class,\r
-                    NotificationListener.class); // Workaround: if we use the\r
-                                                 // version of method with only\r
-                                                 // one argument, the generics\r
-                                                 // inference will not work\r
-\r
-    @Override\r
-    public Set<Class<? extends BrokerService>> getProvidedServices() {\r
-        return PROVIDED_SERVICE_TYPE;\r
-    }\r
-\r
-    @Override\r
-    public Set<Class<? extends ConsumerFunctionality>> getSupportedConsumerFunctionality() {\r
-        return SUPPORTED_CONSUMER_FUNCTIONALITY;\r
-    }\r
-\r
-    @Override\r
-    public <T extends BrokerService> T getServiceForSession(Class<T> service,\r
-            ConsumerSession session) {\r
-        if (NotificationProviderService.class.equals(service)\r
-                && session instanceof ProviderSession) {\r
-            @SuppressWarnings("unchecked")\r
-            T ret = (T) newNotificationProviderService(session);\r
-            return ret;\r
-        } else if (NotificationService.class.equals(service)) {\r
-\r
-            @SuppressWarnings("unchecked")\r
-            T ret = (T) newNotificationConsumerService(session);\r
-            return ret;\r
-        }\r
-\r
-        throw new IllegalArgumentException(\r
-                "The requested session-specific service is not provided by this module.");\r
-    }\r
-\r
-    private void sendNotification(CompositeNode notification) {\r
-        QName type = notification.getNodeType();\r
-        Collection<NotificationListener> toNotify = listeners.get(type);\r
-        log.info("Publishing notification " + type);\r
-\r
-        if (toNotify == null) {\r
-            // No listeners were registered - returns.\r
-            return;\r
-        }\r
-\r
-        for (NotificationListener listener : toNotify) {\r
-            try {\r
-                // FIXME: ensure that notification is immutable\r
-                listener.onNotification(notification);\r
-            } catch (Exception e) {\r
-                log.error("Uncaught exception in NotificationListener", e);\r
-            }\r
-        }\r
-\r
-    }\r
-\r
-    private NotificationService newNotificationConsumerService(\r
-            ConsumerSession session) {\r
-        return new NotificationConsumerSessionImpl();\r
-    }\r
-\r
-    private NotificationProviderService newNotificationProviderService(\r
-            ConsumerSession session) {\r
-        return new NotificationProviderSessionImpl();\r
-    }\r
-\r
-    private class NotificationConsumerSessionImpl implements\r
-            NotificationService {\r
-\r
-        private Multimap<QName, NotificationListener> consumerListeners = HashMultimap\r
-                .create();\r
-        private boolean closed = false;\r
-\r
-        @Override\r
-        public void addNotificationListener(QName notification,\r
-                NotificationListener listener) {\r
-            checkSessionState();\r
-            if (notification == null) {\r
-                throw new IllegalArgumentException(\r
-                        "Notification type must not be null.");\r
-            }\r
-            if (listener == null) {\r
-                throw new IllegalArgumentException("Listener must not be null.");\r
-            }\r
-\r
-            consumerListeners.put(notification, listener);\r
-            listeners.put(notification, listener);\r
-            log.info("Registered listener for notification: " + notification);\r
-        }\r
-\r
-        @Override\r
-        public void removeNotificationListener(QName notification,\r
-                NotificationListener listener) {\r
-            checkSessionState();\r
-            if (notification == null) {\r
-                throw new IllegalArgumentException(\r
-                        "Notification type must not be null.");\r
-            }\r
-            if (listener == null) {\r
-                throw new IllegalArgumentException("Listener must not be null.");\r
-            }\r
-            consumerListeners.remove(notification, listener);\r
-            listeners.remove(notification, listener);\r
-        }\r
-\r
-        @Override\r
-        public void closeSession() {\r
-            closed = true;\r
-            Map<QName, Collection<NotificationListener>> toRemove = consumerListeners\r
-                    .asMap();\r
-            for (Entry<QName, Collection<NotificationListener>> entry : toRemove\r
-                    .entrySet()) {\r
-                listeners.remove(entry.getKey(), entry.getValue());\r
-            }\r
-        }\r
-\r
-        protected void checkSessionState() {\r
-            if (closed)\r
-                throw new IllegalStateException("Session is closed");\r
-        }\r
-    }\r
-\r
-    private class NotificationProviderSessionImpl extends\r
-            NotificationConsumerSessionImpl implements\r
-            NotificationProviderService {\r
-\r
-        @Override\r
-        public void sendNotification(CompositeNode notification) {\r
-            checkSessionState();\r
-            if (notification == null)\r
-                throw new IllegalArgumentException(\r
-                        "Notification must not be null.");\r
-            NotificationModule.this.sendNotification(notification);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public Set<Class<? extends ProviderFunctionality>> getSupportedProviderFunctionality() {\r
-        return Collections.emptySet();\r
-    }\r
-}\r
+/*
+ * 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.core.impl;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.opendaylight.controller.sal.core.api.BrokerService;
+import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession;
+import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
+import org.opendaylight.controller.sal.core.api.Consumer.ConsumerFunctionality;
+import org.opendaylight.controller.sal.core.api.Provider.ProviderFunctionality;
+import org.opendaylight.controller.sal.core.api.notify.NotificationListener;
+import org.opendaylight.controller.sal.core.api.notify.NotificationProviderService;
+import org.opendaylight.controller.sal.core.api.notify.NotificationService;
+import org.opendaylight.controller.sal.core.spi.BrokerModule;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Multimap;
+
+public class NotificationModule implements BrokerModule {
+    private static Logger log = LoggerFactory
+            .getLogger(NotificationModule.class);
+
+    private Multimap<QName, NotificationListener> listeners = HashMultimap
+            .create();
+
+    private static final Set<Class<? extends BrokerService>> PROVIDED_SERVICE_TYPE = ImmutableSet
+            .of((Class<? extends BrokerService>) NotificationService.class,
+                    NotificationProviderService.class);
+
+    private static final Set<Class<? extends ConsumerFunctionality>> SUPPORTED_CONSUMER_FUNCTIONALITY = ImmutableSet
+            .of((Class<? extends ConsumerFunctionality>) NotificationListener.class,
+                    NotificationListener.class); // Workaround: if we use the
+                                                 // version of method with only
+                                                 // one argument, the generics
+                                                 // inference will not work
+
+    @Override
+    public Set<Class<? extends BrokerService>> getProvidedServices() {
+        return PROVIDED_SERVICE_TYPE;
+    }
+
+    @Override
+    public Set<Class<? extends ConsumerFunctionality>> getSupportedConsumerFunctionality() {
+        return SUPPORTED_CONSUMER_FUNCTIONALITY;
+    }
+
+    @Override
+    public <T extends BrokerService> T getServiceForSession(Class<T> service,
+            ConsumerSession session) {
+        if (NotificationProviderService.class.equals(service)
+                && session instanceof ProviderSession) {
+            @SuppressWarnings("unchecked")
+            T ret = (T) newNotificationProviderService(session);
+            return ret;
+        } else if (NotificationService.class.equals(service)) {
+
+            @SuppressWarnings("unchecked")
+            T ret = (T) newNotificationConsumerService(session);
+            return ret;
+        }
+
+        throw new IllegalArgumentException(
+                "The requested session-specific service is not provided by this module.");
+    }
+
+    private void sendNotification(CompositeNode notification) {
+        QName type = notification.getNodeType();
+        Collection<NotificationListener> toNotify = listeners.get(type);
+        log.info("Publishing notification " + type);
+
+        if (toNotify == null) {
+            // No listeners were registered - returns.
+            return;
+        }
+
+        for (NotificationListener listener : toNotify) {
+            try {
+                // FIXME: ensure that notification is immutable
+                listener.onNotification(notification);
+            } catch (Exception e) {
+                log.error("Uncaught exception in NotificationListener", e);
+            }
+        }
+
+    }
+
+    private NotificationService newNotificationConsumerService(
+            ConsumerSession session) {
+        return new NotificationConsumerSessionImpl();
+    }
+
+    private NotificationProviderService newNotificationProviderService(
+            ConsumerSession session) {
+        return new NotificationProviderSessionImpl();
+    }
+
+    private class NotificationConsumerSessionImpl implements
+            NotificationService {
+
+        private Multimap<QName, NotificationListener> consumerListeners = HashMultimap
+                .create();
+        private boolean closed = false;
+
+        @Override
+        public void addNotificationListener(QName notification,
+                NotificationListener listener) {
+            checkSessionState();
+            if (notification == null) {
+                throw new IllegalArgumentException(
+                        "Notification type must not be null.");
+            }
+            if (listener == null) {
+                throw new IllegalArgumentException("Listener must not be null.");
+            }
+
+            consumerListeners.put(notification, listener);
+            listeners.put(notification, listener);
+            log.info("Registered listener for notification: " + notification);
+        }
+
+        @Override
+        public void removeNotificationListener(QName notification,
+                NotificationListener listener) {
+            checkSessionState();
+            if (notification == null) {
+                throw new IllegalArgumentException(
+                        "Notification type must not be null.");
+            }
+            if (listener == null) {
+                throw new IllegalArgumentException("Listener must not be null.");
+            }
+            consumerListeners.remove(notification, listener);
+            listeners.remove(notification, listener);
+        }
+
+        @Override
+        public void closeSession() {
+            closed = true;
+            Map<QName, Collection<NotificationListener>> toRemove = consumerListeners
+                    .asMap();
+            for (Entry<QName, Collection<NotificationListener>> entry : toRemove
+                    .entrySet()) {
+                listeners.remove(entry.getKey(), entry.getValue());
+            }
+        }
+
+        protected void checkSessionState() {
+            if (closed)
+                throw new IllegalStateException("Session is closed");
+        }
+    }
+
+    private class NotificationProviderSessionImpl extends
+            NotificationConsumerSessionImpl implements
+            NotificationProviderService {
+
+        @Override
+        public void sendNotification(CompositeNode notification) {
+            checkSessionState();
+            if (notification == null)
+                throw new IllegalArgumentException(
+                        "Notification must not be null.");
+            NotificationModule.this.sendNotification(notification);
+        }
+    }
+
+    @Override
+    public Set<Class<? extends ProviderFunctionality>> getSupportedProviderFunctionality() {
+        return Collections.emptySet();
+    }
+}
index fedd6d1..f1bed65 100644 (file)
@@ -1,23 +1,24 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
-    <modelVersion>4.0.0</modelVersion>\r
-    <parent>\r
-        <groupId>org.opendaylight.controller</groupId>\r
-        <artifactId>sal</artifactId>\r
-        <version>1.0-SNAPSHOT</version>\r
-    </parent>\r
-    <artifactId>sal-common-util</artifactId>\r
-\r
-    <dependencies>\r
-        <dependency>\r
-            <groupId>org.opendaylight.controller</groupId>\r
-            <artifactId>yang-common</artifactId>\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>org.opendaylight.controller</groupId>\r
-            <artifactId>sal-common</artifactId>\r
-            <version>1.0-SNAPSHOT</version>\r
-        </dependency>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>sal-parent</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>sal-common-util</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-common</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-common</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
     </dependencies>
 
+    <packaging>bundle</packaging>
 </project>
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/sal/sal-common-util/src/main/java/org/opendaylight/controller/sal/common/util/Futures.java b/opendaylight/sal/yang-prototype/sal/sal-common-util/src/main/java/org/opendaylight/controller/sal/common/util/Futures.java
new file mode 100644 (file)
index 0000000..c942159
--- /dev/null
@@ -0,0 +1,51 @@
+package org.opendaylight.controller.sal.common.util;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+public class Futures {
+
+       private Futures(){}
+       
+       public static <T> Future<T> immediateFuture(T result) {
+               return new ImmediateFuture<T>(result);
+       }
+       
+       private static class ImmediateFuture<T> implements Future<T> {
+
+               private final T result;
+               
+               public ImmediateFuture(T result) {
+                       this.result = result;
+               }
+               
+               @Override
+               public boolean cancel(boolean mayInterruptIfRunning) {
+                       return false;
+               }
+
+               @Override
+               public boolean isCancelled() {
+                       return false;
+               }
+
+               @Override
+               public boolean isDone() {
+                       return true;
+               }
+
+               @Override
+               public T get() throws InterruptedException, ExecutionException {
+                       return result;
+               }
+
+               @Override
+               public T get(long timeout, TimeUnit unit) throws InterruptedException,
+                               ExecutionException, TimeoutException {
+                       return result;
+               }
+               
+       }
+}
index d397bff..e46b566 100644 (file)
@@ -1,53 +1,53 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.common.util;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-import org.opendaylight.controller.yang.common.RpcError;\r
-import org.opendaylight.controller.yang.common.RpcResult;\r
-\r
-public class Rpcs {\r
-    public static <T> RpcResult<T> getRpcResult(boolean successful, T result,\r
-            Collection<RpcError> errors) {\r
-        RpcResult<T> ret = new RpcResultTO<T>(successful, result, errors);\r
-        return ret;\r
-    }\r
-\r
-    private static class RpcResultTO<T> implements RpcResult<T> {\r
-\r
-        private final Collection<RpcError> errors;\r
-        private final T result;\r
-        private final boolean successful;\r
-\r
-        public RpcResultTO(boolean successful, T result,\r
-                Collection<RpcError> errors) {\r
-            this.successful = successful;\r
-            this.result = result;\r
-            this.errors = Collections.unmodifiableList(new ArrayList<RpcError>(\r
-                    errors));\r
-        }\r
-\r
-        @Override\r
-        public boolean isSuccessful() {\r
-            return successful;\r
-        }\r
-\r
-        @Override\r
-        public T getResult() {\r
-            return result;\r
-        }\r
-\r
-        @Override\r
-        public Collection<RpcError> getErrors() {\r
-            return errors;\r
-        }\r
-\r
-    }\r
-}\r
+/*
+ * 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.common.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+public class Rpcs {
+    public static <T> RpcResult<T> getRpcResult(boolean successful, T result,
+            Collection<RpcError> errors) {
+        RpcResult<T> ret = new RpcResultTO<T>(successful, result, errors);
+        return ret;
+    }
+
+    private static class RpcResultTO<T> implements RpcResult<T> {
+
+        private final Collection<RpcError> errors;
+        private final T result;
+        private final boolean successful;
+
+        public RpcResultTO(boolean successful, T result,
+                Collection<RpcError> errors) {
+            this.successful = successful;
+            this.result = result;
+            this.errors = Collections.unmodifiableList(new ArrayList<RpcError>(
+                    errors));
+        }
+
+        @Override
+        public boolean isSuccessful() {
+            return successful;
+        }
+
+        @Override
+        public T getResult() {
+            return result;
+        }
+
+        @Override
+        public Collection<RpcError> getErrors() {
+            return errors;
+        }
+
+    }
+}
index 89cf520..a4b2c7d 100644 (file)
@@ -1,14 +1,15 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
-    <modelVersion>4.0.0</modelVersion>\r
-    <parent>\r
-        <groupId>org.opendaylight.controller</groupId>\r
-        <artifactId>sal</artifactId>\r
-        <version>1.0-SNAPSHOT</version>\r
-    </parent>\r
-    <artifactId>sal-common</artifactId>\r
-\r
-    <dependencies>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>sal-parent</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>sal-common</artifactId>
+
+    <dependencies>
     </dependencies>
 
+    <packaging>bundle</packaging>
 </project>
\ No newline at end of file
index e82392d..e3ded1a 100644 (file)
@@ -3,7 +3,7 @@
     <modelVersion>4.0.0</modelVersion>\r
     <parent>\r
         <groupId>org.opendaylight.controller</groupId>\r
-        <artifactId>sal</artifactId>\r
+        <artifactId>sal-parent</artifactId>\r
         <version>1.0-SNAPSHOT</version>\r
     </parent>\r
     <artifactId>sal-core-api</artifactId>\r
@@ -23,5 +23,5 @@
             <groupId>org.opendaylight.controller</groupId>\r
             <artifactId>yang-model-api</artifactId>\r
         </dependency>\r
-    </dependencies>
+    </dependencies>\r
 </project>
\ No newline at end of file
index 9b3b47f..f26ed90 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.core.api;\r
-\r
-import java.util.concurrent.Future;\r
-\r
-import org.opendaylight.controller.sal.core.api.data.DataBrokerService;\r
-import org.opendaylight.controller.sal.core.api.data.DataProviderService;\r
-import org.opendaylight.controller.sal.core.api.notify.NotificationProviderService;\r
-import org.opendaylight.controller.sal.core.api.notify.NotificationService;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.common.RpcResult;\r
-import org.opendaylight.controller.yang.data.api.CompositeNode;\r
-\r
-\r
-/**\r
- * Core component of the SAL layer responsible for wiring the SAL consumers.\r
- * \r
- * The responsibility of the broker is to maintain registration of SAL\r
- * functionality {@link Consumer}s and {@link Provider}s, store provider and\r
- * consumer specific context and functionality registration via\r
- * {@link ConsumerSession} and provide access to infrastructure services, which\r
- * removes direct dependencies between providers and consumers.\r
- * \r
- * \r
- * <h3>Infrastructure services</h3> Some examples of infrastructure services:\r
- * \r
- * <ul>\r
- * <li>RPC Invocation - see {@link ConsumerSession#rpc(QName, CompositeNode)},\r
- * {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)} and\r
- * {@link RpcImplementation}\r
- * <li>Notification Service - see {@link NotificationService} and\r
- * {@link NotificationProviderService}\r
- * <li>Functionality and Data model\r
- * <li>Data Store access and modification - see {@link DataBrokerService} and\r
- * {@link DataProviderService}\r
- * </ul>\r
- * \r
- * The services are exposed via session.\r
- * \r
- * <h3>Session-based access</h3>\r
- * \r
- * The providers and consumers needs to register in order to use the\r
- * binding-independent SAL layer and to expose functionality via SAL layer.\r
- * \r
- * For more information about session-based access see {@link ConsumerSession}\r
- * and {@link ProviderSession}\r
- * \r
- * \r
- * \r
- */\r
-public interface Broker {\r
-\r
-    /**\r
-     * Registers the {@link Consumer}, which will use the SAL layer.\r
-     * \r
-     * <p>\r
-     * During the registration, the broker obtains the initial functionality\r
-     * from consumer, using the {@link Consumer#getConsumerFunctionality()}, and\r
-     * register that functionality into system and concrete infrastructure\r
-     * services.\r
-     * \r
-     * <p>\r
-     * Note that consumer could register additional functionality at later point\r
-     * by using service and functionality specific APIs.\r
-     * \r
-     * <p>\r
-     * The consumer is required to use returned session for all communication\r
-     * with broker or one of the broker services. The session is announced to\r
-     * the consumer by invoking\r
-     * {@link Consumer#onSessionInitiated(ConsumerSession)}.\r
-     * \r
-     * @param cons\r
-     *            Consumer to be registered.\r
-     * @return a session specific to consumer registration\r
-     * @throws IllegalArgumentException\r
-     *             If the consumer is <code>null</code>.\r
-     * @throws IllegalStateException\r
-     *             If the consumer is already registered.\r
-     */\r
-    ConsumerSession registerConsumer(Consumer cons);\r
-\r
-    /**\r
-     * Registers the {@link Provider}, which will use the SAL layer.\r
-     * \r
-     * <p>\r
-     * During the registration, the broker obtains the initial functionality\r
-     * from consumer, using the {@link Provider#getProviderFunctionality()}, and\r
-     * register that functionality into system and concrete infrastructure\r
-     * services.\r
-     * \r
-     * <p>\r
-     * Note that consumer could register additional functionality at later point\r
-     * by using service and functionality specific APIs (e.g.\r
-     * {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)}\r
-     * \r
-     * <p>\r
-     * The consumer is <b>required to use</b> returned session for all\r
-     * communication with broker or one of the broker services. The session is\r
-     * announced to the consumer by invoking\r
-     * {@link Provider#onSessionInitiated(ProviderSession)}.\r
-     * \r
-     * \r
-     * @param prov\r
-     *            Provider to be registered.\r
-     * @return a session unique to the provider registration.\r
-     * @throws IllegalArgumentException\r
-     *             If the provider is <code>null</code>.\r
-     * @throws IllegalStateException\r
-     *             If the consumer is already registered.\r
-     */\r
-    ProviderSession registerProvider(Provider prov);\r
-\r
-    /**\r
-     * {@link Consumer} specific access to the SAL functionality.\r
-     * \r
-     * <p>\r
-     * ConsumerSession is {@link Consumer}-specific access to the SAL\r
-     * functionality and infrastructure services.\r
-     * \r
-     * <p>\r
-     * The session serves to store SAL context (e.g. registration of\r
-     * functionality) for the consumer and provides access to the SAL\r
-     * infrastructure services and other functionality provided by\r
-     * {@link Provider}s.\r
-     * \r
-\r
-     * \r
-     */\r
-    public interface ConsumerSession {\r
-\r
-        /**\r
-         * Sends an RPC to other components registered to the broker.\r
-         * \r
-         * @see RpcImplementation\r
-         * @param rpc\r
-         *            Name of RPC\r
-         * @param input\r
-         *            Input data to the RPC\r
-         * @return Result of the RPC call\r
-         */\r
-        Future<RpcResult<CompositeNode>> rpc(QName rpc, CompositeNode input);\r
-\r
-        boolean isClosed();\r
-\r
-        /**\r
-         * Returns a session specific instance (implementation) of requested\r
-         * service\r
-         * \r
-         * @param service\r
-         *            Broker service\r
-         * @return Session specific implementation of service\r
-         */\r
-        <T extends BrokerService> T getService(Class<T> service);\r
-\r
-        /**\r
-         * Closes a session between consumer and broker.\r
-         * \r
-         * <p>\r
-         * The close operation unregisters a consumer and remove all registered\r
-         * functionality of the consumer from the system.\r
-         * \r
-         */\r
-        void close();\r
-    }\r
-\r
-    /**\r
-     * {@link Provider} specific access to the SAL functionality.\r
-     * \r
-     * <p>\r
-     * ProviderSession is {@link Provider}-specific access to the SAL\r
-     * functionality and infrastructure services, which also allows for exposing\r
-     * the provider's functionality to the other {@link Consumer}s.\r
-     * \r
-     * <p>\r
-     * The session serves to store SAL context (e.g. registration of\r
-     * functionality) for the providers and exposes access to the SAL\r
-     * infrastructure services, dynamic functionality registration and any other\r
-     * functionality provided by other {@link Provider}s.\r
-     * \r
-     */\r
-    public interface ProviderSession extends ConsumerSession {\r
-        /**\r
-         * Registers an implementation of the rpc.\r
-         * \r
-         * <p>\r
-         * The registered rpc functionality will be available to all other\r
-         * consumers and providers registered to the broker, which are aware of\r
-         * the {@link QName} assigned to the rpc.\r
-         * \r
-         * <p>\r
-         * There is no assumption that rpc type is in the set returned by\r
-         * invoking {@link RpcImplementation#getSupportedRpcs()}. This allows\r
-         * for dynamic rpc implementations.\r
-         * \r
-         * @param rpcType\r
-         *            Name of Rpc\r
-         * @param implementation\r
-         *            Provider's Implementation of the RPC functionality\r
-         * @throws IllegalArgumentException\r
-         *             If the name of RPC is invalid\r
-         */\r
-        void addRpcImplementation(QName rpcType,\r
-                RpcImplementation implementation)\r
-                throws IllegalArgumentException;\r
-\r
-        /**\r
-         * Unregisters an Rpc implementation\r
-         * \r
-         * @param rpcType\r
-         *            Name of Rpc\r
-         * @param implementation\r
-         *            Registered Implementation of the Rpc functionality\r
-         * @throws IllegalArgumentException\r
-         */\r
-        void removeRpcImplementation(QName rpcType,\r
-                RpcImplementation implementation)\r
-                throws IllegalArgumentException;\r
-\r
-        /**\r
-         * Closes a session between provider and SAL.\r
-         * \r
-         * <p>\r
-         * The close operation unregisters a provider and remove all registered\r
-         * functionality of the provider from the system.\r
-         */\r
-        @Override\r
-        public void close();\r
-\r
-        @Override\r
-        boolean isClosed();\r
-    }\r
-}\r
+/*
+ * 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.core.api;
+
+import java.util.concurrent.Future;
+
+import org.opendaylight.controller.sal.core.api.data.DataBrokerService;
+import org.opendaylight.controller.sal.core.api.data.DataProviderService;
+import org.opendaylight.controller.sal.core.api.notify.NotificationProviderService;
+import org.opendaylight.controller.sal.core.api.notify.NotificationService;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+
+
+/**
+ * Core component of the SAL layer responsible for wiring the SAL consumers.
+ * 
+ * The responsibility of the broker is to maintain registration of SAL
+ * functionality {@link Consumer}s and {@link Provider}s, store provider and
+ * consumer specific context and functionality registration via
+ * {@link ConsumerSession} and provide access to infrastructure services, which
+ * removes direct dependencies between providers and consumers.
+ * 
+ * 
+ * <h3>Infrastructure services</h3> Some examples of infrastructure services:
+ * 
+ * <ul>
+ * <li>RPC Invocation - see {@link ConsumerSession#rpc(QName, CompositeNode)},
+ * {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)} and
+ * {@link RpcImplementation}
+ * <li>Notification Service - see {@link NotificationService} and
+ * {@link NotificationProviderService}
+ * <li>Functionality and Data model
+ * <li>Data Store access and modification - see {@link DataBrokerService} and
+ * {@link DataProviderService}
+ * </ul>
+ * 
+ * The services are exposed via session.
+ * 
+ * <h3>Session-based access</h3>
+ * 
+ * The providers and consumers needs to register in order to use the
+ * binding-independent SAL layer and to expose functionality via SAL layer.
+ * 
+ * For more information about session-based access see {@link ConsumerSession}
+ * and {@link ProviderSession}
+ * 
+ * 
+ * 
+ */
+public interface Broker {
+
+    /**
+     * Registers the {@link Consumer}, which will use the SAL layer.
+     * 
+     * <p>
+     * During the registration, the broker obtains the initial functionality
+     * from consumer, using the {@link Consumer#getConsumerFunctionality()}, and
+     * register that functionality into system and concrete infrastructure
+     * services.
+     * 
+     * <p>
+     * Note that consumer could register additional functionality at later point
+     * by using service and functionality specific APIs.
+     * 
+     * <p>
+     * The consumer is required to use returned session for all communication
+     * with broker or one of the broker services. The session is announced to
+     * the consumer by invoking
+     * {@link Consumer#onSessionInitiated(ConsumerSession)}.
+     * 
+     * @param cons
+     *            Consumer to be registered.
+     * @return a session specific to consumer registration
+     * @throws IllegalArgumentException
+     *             If the consumer is <code>null</code>.
+     * @throws IllegalStateException
+     *             If the consumer is already registered.
+     */
+    ConsumerSession registerConsumer(Consumer cons);
+
+    /**
+     * Registers the {@link Provider}, which will use the SAL layer.
+     * 
+     * <p>
+     * During the registration, the broker obtains the initial functionality
+     * from consumer, using the {@link Provider#getProviderFunctionality()}, and
+     * register that functionality into system and concrete infrastructure
+     * services.
+     * 
+     * <p>
+     * Note that consumer could register additional functionality at later point
+     * by using service and functionality specific APIs (e.g.
+     * {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)}
+     * 
+     * <p>
+     * The consumer is <b>required to use</b> returned session for all
+     * communication with broker or one of the broker services. The session is
+     * announced to the consumer by invoking
+     * {@link Provider#onSessionInitiated(ProviderSession)}.
+     * 
+     * 
+     * @param prov
+     *            Provider to be registered.
+     * @return a session unique to the provider registration.
+     * @throws IllegalArgumentException
+     *             If the provider is <code>null</code>.
+     * @throws IllegalStateException
+     *             If the consumer is already registered.
+     */
+    ProviderSession registerProvider(Provider prov);
+
+    /**
+     * {@link Consumer} specific access to the SAL functionality.
+     * 
+     * <p>
+     * ConsumerSession is {@link Consumer}-specific access to the SAL
+     * functionality and infrastructure services.
+     * 
+     * <p>
+     * The session serves to store SAL context (e.g. registration of
+     * functionality) for the consumer and provides access to the SAL
+     * infrastructure services and other functionality provided by
+     * {@link Provider}s.
+     * 
+
+     * 
+     */
+    public interface ConsumerSession {
+
+        /**
+         * Sends an RPC to other components registered to the broker.
+         * 
+         * @see RpcImplementation
+         * @param rpc
+         *            Name of RPC
+         * @param input
+         *            Input data to the RPC
+         * @return Result of the RPC call
+         */
+        Future<RpcResult<CompositeNode>> rpc(QName rpc, CompositeNode input);
+
+        boolean isClosed();
+
+        /**
+         * Returns a session specific instance (implementation) of requested
+         * service
+         * 
+         * @param service
+         *            Broker service
+         * @return Session specific implementation of service
+         */
+        <T extends BrokerService> T getService(Class<T> service);
+
+        /**
+         * Closes a session between consumer and broker.
+         * 
+         * <p>
+         * The close operation unregisters a consumer and remove all registered
+         * functionality of the consumer from the system.
+         * 
+         */
+        void close();
+    }
+
+    /**
+     * {@link Provider} specific access to the SAL functionality.
+     * 
+     * <p>
+     * ProviderSession is {@link Provider}-specific access to the SAL
+     * functionality and infrastructure services, which also allows for exposing
+     * the provider's functionality to the other {@link Consumer}s.
+     * 
+     * <p>
+     * The session serves to store SAL context (e.g. registration of
+     * functionality) for the providers and exposes access to the SAL
+     * infrastructure services, dynamic functionality registration and any other
+     * functionality provided by other {@link Provider}s.
+     * 
+     */
+    public interface ProviderSession extends ConsumerSession {
+        /**
+         * Registers an implementation of the rpc.
+         * 
+         * <p>
+         * The registered rpc functionality will be available to all other
+         * consumers and providers registered to the broker, which are aware of
+         * the {@link QName} assigned to the rpc.
+         * 
+         * <p>
+         * There is no assumption that rpc type is in the set returned by
+         * invoking {@link RpcImplementation#getSupportedRpcs()}. This allows
+         * for dynamic rpc implementations.
+         * 
+         * @param rpcType
+         *            Name of Rpc
+         * @param implementation
+         *            Provider's Implementation of the RPC functionality
+         * @throws IllegalArgumentException
+         *             If the name of RPC is invalid
+         */
+        void addRpcImplementation(QName rpcType,
+                RpcImplementation implementation)
+                throws IllegalArgumentException;
+
+        /**
+         * Unregisters an Rpc implementation
+         * 
+         * @param rpcType
+         *            Name of Rpc
+         * @param implementation
+         *            Registered Implementation of the Rpc functionality
+         * @throws IllegalArgumentException
+         */
+        void removeRpcImplementation(QName rpcType,
+                RpcImplementation implementation)
+                throws IllegalArgumentException;
+
+        /**
+         * Closes a session between provider and SAL.
+         * 
+         * <p>
+         * The close operation unregisters a provider and remove all registered
+         * functionality of the provider from the system.
+         */
+        @Override
+        public void close();
+
+        @Override
+        boolean isClosed();
+    }
+}