Merge "Add strong password check for users"
authorGiovanni Meo <gmeo@cisco.com>
Thu, 19 Sep 2013 08:24:02 +0000 (08:24 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 19 Sep 2013 08:24:02 +0000 (08:24 +0000)
72 files changed:
opendaylight/archetypes/odl-model-project/src/main/resources/archetype-resources/pom.xml
opendaylight/clustering/integrationtest/pom.xml
opendaylight/clustering/services_implementation/pom.xml
opendaylight/commons/opendaylight/pom.xml
opendaylight/connectionmanager/api/src/main/java/org/opendaylight/controller/connectionmanager/ConnectionLocality.java [new file with mode: 0644]
opendaylight/connectionmanager/api/src/main/java/org/opendaylight/controller/connectionmanager/IConnectionManager.java
opendaylight/connectionmanager/implementation/src/main/java/org/opendaylight/controller/connectionmanager/internal/ConnectionManager.java
opendaylight/connectionmanager/implementation/src/main/java/org/opendaylight/controller/connectionmanager/scheme/AbstractScheme.java
opendaylight/containermanager/api/src/main/java/org/opendaylight/controller/containermanager/ContainerConfig.java
opendaylight/distribution/opendaylight/pom.xml
opendaylight/forwardingrulesmanager/implementation/pom.xml
opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java
opendaylight/forwardingrulesmanager/integrationtest/pom.xml
opendaylight/hosttracker/implementation/pom.xml
opendaylight/hosttracker/integrationtest/pom.xml
opendaylight/hosttracker_new/implementation/pom.xml
opendaylight/md-sal/sal-compability/pom.xml [new file with mode: 0644]
opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ToSalConversionsUtils.java [new file with mode: 0644]
opendaylight/northbound/commons/pom.xml
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/JacksonJsonProcessingExceptionMapper.java [new file with mode: 0644]
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/NorthboundApplication.java
opendaylight/northbound/integrationtest/pom.xml
opendaylight/northbound/integrationtest/src/test/java/org/opendaylight/controller/northbound/integrationtest/NorthboundIT.java
opendaylight/sal/yang-prototype/pom.xml
opendaylight/sal/yang-prototype/sal/model/model-flow-base/src/main/yang/group-types.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/model/model-flow-base/src/main/yang/match-types.yang
opendaylight/sal/yang-prototype/sal/model/model-flow-service/src/main/yang/group-service.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/pom.xml
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/codegen/RuntimeCodeHelper.xtend [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeSpecification.xtend [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/codegen/YangtoolsMappingHelper.xtend [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/JavassistUtils.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RoutingPair.xtend [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeCodeGenerator.xtend [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/DataProviderContext.xtend [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.xtend
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiConsumerContext.xtend
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/_DataBrokerImpl.xtend [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/osgi/Constants.xtend [moved from opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/Constants.xtend with 84% similarity]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/osgi/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/osgi/package-info.java [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 [deleted file]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/utils/PropertiesUtils.xtend [deleted file]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/utils/package-info.java [deleted file]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/test/org/opendaylight/controller/sal/binding/test/GenerationTest.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/RuntimeCodeGeneratorTest.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/BarUpdate.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooListener.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooService.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooUpdate.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/Grouping.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/InheritedContextInput.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/ReferencableObject.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/ReferencableObjectKey.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/SimpleInput.java [new file with mode: 0644]
opendaylight/statisticsmanager/implementation/pom.xml
opendaylight/statisticsmanager/integrationtest/pom.xml
opendaylight/switchmanager/api/pom.xml
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java
opendaylight/switchmanager/implementation/pom.xml
opendaylight/switchmanager/integrationtest/pom.xml
opendaylight/topologymanager/implementation/pom.xml [moved from opendaylight/topologymanager/pom.xml with 97% similarity]
opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/ITopologyManager.java [moved from opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/ITopologyManager.java with 100% similarity]
opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/ITopologyManagerAware.java [moved from opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/ITopologyManagerAware.java with 100% similarity]
opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/ITopologyManagerClusterWideAware.java [moved from opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/ITopologyManagerClusterWideAware.java with 100% similarity]
opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/TopologyUserLinkConfig.java [moved from opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/TopologyUserLinkConfig.java with 100% similarity]
opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/Activator.java [moved from opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/internal/Activator.java with 100% similarity]
opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java [moved from opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java with 100% similarity]
opendaylight/topologymanager/implementation/src/test/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImplTest.java [moved from opendaylight/topologymanager/src/test/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImplTest.java with 100% similarity]

index b84346514f17c85a3b4d24c2f1f1878747bcd623..ecc08d011db9db0063711104dfb205d3ddca0e02 100644 (file)
@@ -9,7 +9,7 @@
   <properties>\r
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\r
     <nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>\r
-    <yang.version>0.5.7-SNAPSHOT</yang.version>\r
+    <yang.version>0.5.8-SNAPSHOT</yang.version>\r
     <maven.bundle.version>2.4.0</maven.bundle.version>\r
   </properties>\r
 \r
@@ -56,7 +56,7 @@
       <plugin>\r
         <groupId>org.opendaylight.yangtools</groupId>\r
         <artifactId>yang-maven-plugin</artifactId>\r
-        <version>0.5.7-SNAPSHOT</version>\r
+        <version>${yang.version}</version>\r
         <executions>\r
           <execution>\r
             <goals>\r
@@ -79,7 +79,7 @@
           <dependency>\r
             <groupId>org.opendaylight.yangtools</groupId>\r
             <artifactId>maven-sal-api-gen-plugin</artifactId>\r
-            <version>0.5.7-SNAPSHOT</version>\r
+            <version>${yang.version}</version>\r
             <type>jar</type>\r
           </dependency>\r
         </dependencies>\r
   </build>\r
   <pluginRepositories>\r
     <pluginRepository>\r
-      <id>central2</id>\r
-      <name>central2</name>\r
-      <url>http://repo2.maven.org/maven2</url>\r
+      <id>central</id>\r
+      <name>maven repo1</name>\r
+      <url>http://repo1.maven.org/maven2</url>\r
        <snapshots>\r
         <enabled>false</enabled>\r
       </snapshots>\r
       <name>ebr-bundles-external</name>\r
       <url>${nexusproxy}/repositories/ebr-bundles-external/</url>\r
     </repository>\r
-    <repository>\r
-      <id>central2</id>\r
-      <name>central2</name>\r
-      <url>http://repo2.maven.org/maven2</url>\r
-      <snapshots>\r
-        <enabled>false</enabled>\r
-      </snapshots>\r
-      <releases>\r
-        <enabled>true</enabled>\r
-      </releases>\r
-    </repository>\r
     <repository>\r
       <id>central</id>\r
       <name>central</name>\r
index 0fadb128901cd16749511f32c58e2ea71973fc75..63ef24d3b161bb98947540c3e1c64f00071672b8 100644 (file)
@@ -52,7 +52,7 @@
     <!-- Sonar jacoco plugin to get integration test coverage info -->
     <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
     <sonar.jacoco.reportPath>../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
-    <sonar.jacoco.itReportPath>../implementaiton/target/jacoco-it.exec</sonar.jacoco.itReportPath>
+    <sonar.jacoco.itReportPath>../implementation/target/jacoco-it.exec</sonar.jacoco.itReportPath>
     <sonar.language>java</sonar.language>
   </properties>
   <build>
@@ -69,7 +69,7 @@
       <plugin>
         <groupId>org.jacoco</groupId>
         <artifactId>jacoco-maven-plugin</artifactId>
-        <version>0.5.3.201107060350</version>
+        <version>${jacoco.version}</version>
         <configuration>
           <destFile>../implementation/target/jacoco-it.exec</destFile>
           <includes>org.opendaylight.controller.*</includes>
index c0a8064493d6d303ba24fb75466751f8f8c75aa0..d6bd287434a499c19b1aa1576b0aa11ee303344d 100644 (file)
@@ -30,7 +30,7 @@
         <plugin>
           <groupId>org.jacoco</groupId>
           <artifactId>jacoco-maven-plugin</artifactId>
-          <version>0.5.3.201107060350</version>
+          <version>${jacoco.version}</version>
         </plugin>
       </plugins>
     </pluginManagement>
index cb1892ae664513667693413eac0fef5824ef35e6..31dd741cfdb0d7cfa8328e26cc639c94769f208b 100644 (file)
     <sample-toaster.version>1.0-SNAPSHOT</sample-toaster.version>
     <releaseplugin.version>2.3.2</releaseplugin.version>
     <commons.lang.version>3.1</commons.lang.version>
+    <jacoco.version>0.5.3.201107060350</jacoco.version>
   </properties>
 
   <pluginRepositories>
     <pluginRepository>
-      <id>central2</id>
-      <name>central2</name>
-      <url>http://repo2.maven.org/maven2</url>
+      <id>central</id>
+      <name>maven repo1</name>
+      <url>http://repo1.maven.org/maven2</url>
     </pluginRepository>
   </pluginRepositories>
 
       <name>ebr-bundles-external</name>
       <url>${nexusproxy}/repositories/ebr-bundles-external/</url>
     </repository>
-    <repository>
-      <id>central2</id>
-      <name>central2</name>
-      <url>http://repo2.maven.org/maven2</url>
-      <snapshots>
-        <enabled>false</enabled>
-      </snapshots>
-      <releases>
-          <enabled>true</enabled>
-      </releases>
-    </repository>
     <repository>
       <id>central</id>
       <name>central</name>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
         <version>${surefire.version}</version>
-        <configuration>
-          <argLine>${testvm.argLine}</argLine>
-        </configuration>
       </plugin>
     </plugins>
     <pluginManagement>
diff --git a/opendaylight/connectionmanager/api/src/main/java/org/opendaylight/controller/connectionmanager/ConnectionLocality.java b/opendaylight/connectionmanager/api/src/main/java/org/opendaylight/controller/connectionmanager/ConnectionLocality.java
new file mode 100644 (file)
index 0000000..347ca07
--- /dev/null
@@ -0,0 +1,28 @@
+package org.opendaylight.controller.connectionmanager;
+
+public enum ConnectionLocality {
+    /**
+     * This controller is the (or one of the) master for a given node
+     */
+    LOCAL("This controller is the (or one of the) master for a given node"),
+
+    /**
+     * This controller is not the master for a given node
+     */
+    NOT_LOCAL("This controller is not the master for a given node"),
+
+    /**
+     * The given node is not connected to any of the controllers in the cluster
+     */
+    NOT_CONNECTED("The given node is not connected to any of the controllers in the cluster");
+
+    private ConnectionLocality(String description) {
+        this.description = description;
+    }
+
+    private String description;
+
+    public String toString() {
+        return description;
+    }
+}
index 12b196989e4a0c4fa1f608cd7a479d224064555c..788af16248ccd62c8cc0760dbcb20134983b3cac 100644 (file)
@@ -54,12 +54,27 @@ public interface IConnectionManager {
     public Set<Node> getLocalNodes();
 
     /**
+     * @deprecated Use getLocalityStatus(Node node) instead.
+     *
      * Method to test if a node is local to a controller.
      *
-     * @return true if node is local to this controller. false otherwise.
+     * @param node The node for which the locality is being tested
+     * @return true if node is local to this controller.<br>
+     *         false if either node is not connected to this controller or
+     *         not connected to any other controllers in the cluster.
      */
     public boolean isLocal(Node node);
 
+    /**
+     * getLocalityStatus provides the tri-state connectivity status as opposed to the
+     * binary status returned by isLocal.
+     * ConnectionLocality enum that is returned by this method also includes the case of
+     * a Node not connected to any of the controllers in the cluster.
+     * @param node The node for which the locality is being verified
+     * @return ConnectionLocality
+     */
+    public ConnectionLocality getLocalityStatus(Node node);
+
     /**
      * Disconnect a Node from the controller.
      *
index bd377190f2d2f2911f3ae9b43edda2b2b0c39bc2..df5175083b1870ef99b29443d42003eb2bb179c5 100644 (file)
@@ -37,6 +37,7 @@ import org.eclipse.osgi.framework.console.CommandProvider;
 import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
 import org.opendaylight.controller.clustering.services.ICoordinatorChangeAware;
+import org.opendaylight.controller.connectionmanager.ConnectionLocality;
 import org.opendaylight.controller.connectionmanager.ConnectionMgmtScheme;
 import org.opendaylight.controller.connectionmanager.IConnectionManager;
 import org.opendaylight.controller.connectionmanager.scheme.AbstractScheme;
@@ -185,6 +186,13 @@ public class ConnectionManager implements IConnectionManager, IConnectionListene
         return scheme.isLocal(node);
     }
 
+    @Override
+    public ConnectionLocality getLocalityStatus(Node node) {
+        AbstractScheme scheme = schemes.get(activeScheme);
+        if (scheme == null) return ConnectionLocality.NOT_CONNECTED;
+        return scheme.getLocalityStatus(node);
+    }
+
     @Override
     public void updateNode(Node node, UpdateType type, Set<Property> props) {
         logger.debug("updateNode: {} type {} props {}", node, type, props);
index 06b72219f7fbddc5b5b17357f421f003691a36f7..78f274c717585993d13a3deeb86812a32ad4ad5a 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.controller.clustering.services.CacheConfigException;
 import org.opendaylight.controller.clustering.services.CacheExistException;
 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
 import org.opendaylight.controller.clustering.services.IClusterServices;
+import org.opendaylight.controller.connectionmanager.ConnectionLocality;
 import org.opendaylight.controller.connectionmanager.ConnectionMgmtScheme;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.utils.Status;
@@ -146,6 +147,15 @@ public abstract class AbstractScheme {
         return (controllers != null && controllers.contains(myController));
     }
 
+    public ConnectionLocality getLocalityStatus(Node node) {
+        if (nodeConnections == null) return ConnectionLocality.NOT_CONNECTED;
+        Set<InetAddress> controllers = nodeConnections.get(node);
+        if (controllers == null || controllers.size() == 0) return ConnectionLocality.NOT_CONNECTED;
+        InetAddress myController = clusterServices.getMyAddress();
+        return controllers.contains(myController) ? ConnectionLocality.LOCAL:
+                                                    ConnectionLocality.NOT_LOCAL;
+    }
+
     public Status removeNode (Node node) {
         return removeNodeFromController(node, clusterServices.getMyAddress());
     }
index a34746949e8d9697251da00b32b442ea0c9147f4..89bf424e67a4465c885c82b2ec3206d559709064 100644 (file)
@@ -386,11 +386,38 @@ public class ContainerConfig implements Serializable {
                             config.getName()));
                 }
             }
+        } else {
+            // Check for conflicting names with existing cFlows
+            List<String> conflicting = new ArrayList<String>(existingNames);
+            conflicting.retainAll(proposedNames);
+            if (!conflicting.isEmpty()) {
+                return new Status(StatusCode.CONFLICT,
+                        "Invalid Flow Spec configuration: flow spec name(s) conflict with existing flow specs: "
+                                + conflicting.toString());
+            }
+
+            /*
+             * Check for conflicting flow spec match (we only check for strict
+             * equality). Remove this in case (*) is reintroduced
+             */
+            if (this.containerFlows != null && !this.containerFlows.isEmpty()) {
+                Set<Match> existingMatches = new HashSet<Match>();
+                for (ContainerFlowConfig existing : this.containerFlows) {
+                    existingMatches.addAll(existing.getMatches());
+                }
+                for (ContainerFlowConfig proposed : cFlowConfigs) {
+                    if (existingMatches.removeAll(proposed.getMatches())) {
+                        return new Status(StatusCode.CONFLICT, String.format(
+                                "Invalid Flow Spec configuration: %s conflicts with existing flow spec",
+                                proposed.getName()));
+                    }
+                }
+            }
         }
+
         /*
          * Revisit the following flow-spec confict validation later based on more testing.
-         */
-         /*
+         * (*)
         if (!delete) {
             // Check for overlapping container flows in the request
             int size = cFlowConfigs.size();
index 1fb131e4aff8fc6e5c505e6437bc8a5dc6c2e2b9..3efd97e2aa3857fa549e752ae16d1aa6990ab0f3 100644 (file)
@@ -74,7 +74,7 @@
     <module>../../statisticsmanager/api</module>
     <module>../../statisticsmanager/implementation</module>
     <module>../../statisticsmanager/integrationtest</module>
-    <module>../../topologymanager</module>
+    <module>../../topologymanager/implementation</module>
     <module>../../usermanager/api</module>
     <module>../../usermanager/implementation</module>
     <module>../../connectionmanager/api</module>
index ea55ac8b08951f14191cbcd900a6309c7154fcfc..d146eead6f0168e7e25cdd290459fb5ff20be7d2 100644 (file)
@@ -33,7 +33,7 @@
         <plugin>
           <groupId>org.jacoco</groupId>
           <artifactId>jacoco-maven-plugin</artifactId>
-          <version>0.5.3.201107060350</version>
+          <version>${jacoco.version}</version>
         </plugin>
       </plugins>
     </pluginManagement>
index 4e6818c3062511b01c9b8f73d3f5fa610c73134d..6e3e6b6633b0fc6098ee6795dac661df71a20fed 100644 (file)
@@ -39,6 +39,7 @@ import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
 import org.opendaylight.controller.clustering.services.IClusterServices;
 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
+import org.opendaylight.controller.connectionmanager.ConnectionLocality;
 import org.opendaylight.controller.connectionmanager.IConnectionManager;
 import org.opendaylight.controller.forwardingrulesmanager.FlowConfig;
 import org.opendaylight.controller.forwardingrulesmanager.FlowEntry;
@@ -273,7 +274,7 @@ public class ForwardingRulesManager implements
         }
 
         Node n = e.getNode();
-        if (!connectionManager.isLocal(n)) {
+        if (connectionManager.getLocalityStatus(n) == ConnectionLocality.NOT_LOCAL) {
             Callable<Future<Status>> worker = new DistributeOrderCallable(e, u, t);
             if (worker != null) {
                 Future<Future<Status>> workerRes = this.executor.submit(worker);
@@ -291,7 +292,7 @@ public class ForwardingRulesManager implements
             }
         }
 
-        logsync.trace("LOCAL Node {} so processing Entry:{} UpdateType:{}", n, e, t);
+        logsync.trace("Node {} could be local. so processing Entry:{} UpdateType:{}", n, e, t);
         return null;
     }
 
@@ -3109,7 +3110,7 @@ public class ForwardingRulesManager implements
                 return;
             }
             Node n = fei.getNode();
-            if (connectionManager.isLocal(n)) {
+            if (connectionManager.getLocalityStatus(n) == ConnectionLocality.LOCAL) {
                 logsync.trace("workOrder for fe {} processed locally", fe);
                 // I'm the controller in charge for the request, queue it for
                 // processing
index 77792435991ce414a6edf14590b7f9fe071a9b56..32cae25dba5aec22aa4b67a070f7b5848ce31014 100644 (file)
     <!-- Sonar jacoco plugin to get integration test coverage info -->
     <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
     <sonar.jacoco.reportPath>../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
-    <sonar.jacoco.itReportPath>../implementaiton/target/jacoco-it.exec</sonar.jacoco.itReportPath>
+    <sonar.jacoco.itReportPath>../implementation/target/jacoco-it.exec</sonar.jacoco.itReportPath>
     <sonar.language>java</sonar.language>
   </properties>
   <build>
       <plugin>
         <groupId>org.jacoco</groupId>
         <artifactId>jacoco-maven-plugin</artifactId>
-        <version>0.5.3.201107060350</version>
+        <version>${jacoco.version}</version>
         <configuration>
           <destFile>../implementation/target/jacoco-it.exec</destFile>
           <includes>org.opendaylight.controller.*</includes>
index 268dd4f67f6039f9bde419b8a726d4fe23063ac7..e93559b42ccae19ac461607d5680b4a3db1e0ec6 100644 (file)
@@ -33,7 +33,7 @@
         <plugin>
           <groupId>org.jacoco</groupId>
           <artifactId>jacoco-maven-plugin</artifactId>
-          <version>0.5.3.201107060350</version>
+          <version>${jacoco.version}</version>
         </plugin>
       </plugins>
     </pluginManagement>
index 81551650c34fe2a0eb49d0afeb2405ec75de4549..f2fefcdabcc05e7265ba811dbb9acd90fc14e4e1 100644 (file)
       <plugin>\r
         <groupId>org.jacoco</groupId>\r
         <artifactId>jacoco-maven-plugin</artifactId>\r
-        <version>0.5.3.201107060350</version>\r
+        <version>${jacoco.version}</version>\r
         <configuration>\r
           <destFile>../implementation/target/jacoco-it.exec</destFile>\r
           <includes>org.opendaylight.controller.*</includes>\r
index af2ea7b3475970cde2db15dfd660e13cdf177144..dfc2955cfd9679f8c7f3eca2ca4fb60fcf5ef2c5 100644 (file)
@@ -22,7 +22,7 @@
     <!-- Sonar properties using jacoco to retrieve integration test results -->
     <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
     <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
-    <sonar.jacoco.Reportpath>target/jacoco.exec</sonar.jacoco.Reportpath>
+    <sonar.jacoco.reportpath>target/jacoco.exec</sonar.jacoco.reportpath>
     <sonar.jacoco.itReportPath>target/jacoco-it.exec</sonar.jacoco.itReportPath>
     <sonar.language>java</sonar.language>
   </properties>
@@ -33,7 +33,7 @@
         <plugin>
           <groupId>org.jacoco</groupId>
           <artifactId>jacoco-maven-plugin</artifactId>
-          <version>0.5.3.201107060350</version>
+          <version>${jacoco.version}</version>
         </plugin>
       </plugins>
     </pluginManagement>
diff --git a/opendaylight/md-sal/sal-compability/pom.xml b/opendaylight/md-sal/sal-compability/pom.xml
new file mode 100644 (file)
index 0000000..e3d8c58
--- /dev/null
@@ -0,0 +1,45 @@
+<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>
+               <relativePath>../../sal/yang-prototype/sal/pom.xml</relativePath>
+       </parent>
+       <artifactId>sal-compability</artifactId>
+
+       <dependencies>
+               <dependency>
+                       <groupId>org.opendaylight.controller</groupId>
+                       <artifactId>sal</artifactId>
+                       <version>0.5.0-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.opendaylight.controller.model</groupId>
+                       <artifactId>model-flow-service</artifactId>
+                       <version>1.0-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.opendaylight.controller.model</groupId>
+                       <artifactId>model-flow-statistics</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-common-util</artifactId>
+                       <version>1.0-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>com.google.guava</groupId>
+                       <artifactId>guava</artifactId>
+                       <type>bundle</type>
+                       <version>14.0.1</version>
+               </dependency>
+       </dependencies>
+</project>
diff --git a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ToSalConversionsUtils.java b/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ToSalConversionsUtils.java
new file mode 100644 (file)
index 0000000..c113cd8
--- /dev/null
@@ -0,0 +1,349 @@
+package org.opendaylight.controller.sal.compability;
+
+import static org.opendaylight.controller.sal.match.MatchType.DL_DST;
+import static org.opendaylight.controller.sal.match.MatchType.DL_SRC;
+import static org.opendaylight.controller.sal.match.MatchType.DL_TYPE;
+import static org.opendaylight.controller.sal.match.MatchType.DL_VLAN;
+import static org.opendaylight.controller.sal.match.MatchType.DL_VLAN_PR;
+import static org.opendaylight.controller.sal.match.MatchType.NW_DST;
+import static org.opendaylight.controller.sal.match.MatchType.NW_PROTO;
+import static org.opendaylight.controller.sal.match.MatchType.NW_SRC;
+import static org.opendaylight.controller.sal.match.MatchType.NW_TOS;
+import static org.opendaylight.controller.sal.match.MatchType.TP_DST;
+import static org.opendaylight.controller.sal.match.MatchType.TP_SRC;
+
+import java.net.InetAddress;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.opendaylight.controller.sal.action.Controller;
+import org.opendaylight.controller.sal.action.Output;
+import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.flowprogrammer.Flow;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.ControllerAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.OutputAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.PopMplsAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.PushMplsAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.PushPbbAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.PushVlanAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.SetMplsTtlAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.SetNwTtlAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.SetQueueAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.MacAddressFilter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.ethernet.match.fields.EthernetType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.EthernetMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.IpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.Layer3Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.Layer4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.VlanMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.layer._3.match.ArpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.layer._3.match.Ipv4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.layer._3.match.Ipv6Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.layer._4.match.SctpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.layer._4.match.TcpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.layer._4.match.UdpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.vlan.match.fields.VlanId;
+
+import com.google.common.net.InetAddresses;
+
+public class ToSalConversionsUtils {
+
+    private ToSalConversionsUtils() {
+
+    }
+
+    public static Flow flowFrom(NodeFlow source) {
+        final Flow target = new Flow();
+
+        Integer hardTimeout = source.getHardTimeout();
+        if (hardTimeout != null) {
+            target.setHardTimeout(hardTimeout.shortValue());
+        }
+
+        Integer idleTimeout = source.getIdleTimeout();
+        if (idleTimeout != null) {
+            target.setIdleTimeout(idleTimeout.shortValue());
+        }
+
+        Integer priority = source.getPriority();
+        if (priority != null) {
+            target.setPriority(priority.shortValue());
+        }
+
+        target.setMatch(matchFrom(source.getMatch()));
+
+        List<Action> actions = source.getAction();
+        if (actions != null) {
+            for (Action sourceAction : actions) {
+                Set<org.opendaylight.controller.sal.action.Action> targetActions = actionFrom(sourceAction);
+                for (org.opendaylight.controller.sal.action.Action targetAction : targetActions) {
+                    target.addAction(targetAction);
+                }
+            }
+        }
+
+        target.setId(source.getCookie().longValue());
+        return target;
+    }
+
+    public static Set<org.opendaylight.controller.sal.action.Action> actionFrom(Action source) {
+        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.Action sourceAction = source
+                .getAction();
+        Set<org.opendaylight.controller.sal.action.Action> targetAction = new HashSet<>();
+        if (sourceAction instanceof ControllerAction) {
+            targetAction.add(new Controller());
+        } else if (sourceAction instanceof OutputAction) {
+
+            List<Uri> nodeConnectors = ((OutputAction) sourceAction).getOutputNodeConnector();
+            for (Uri uri : nodeConnectors) {
+                targetAction.add(new Output(fromNodeConnectorRef(uri)));
+            }
+        } else if (sourceAction instanceof PopMplsAction) {
+            // TODO: define maping
+        } else if (sourceAction instanceof PushMplsAction) {
+            // TODO: define maping
+        } else if (sourceAction instanceof PushPbbAction) {
+            // TODO: define maping
+        } else if (sourceAction instanceof PushVlanAction) {
+            // TODO: define maping
+            // PushVlanAction vlanAction = (PushVlanAction) sourceAction;
+            // targetAction.add(new PushVlan(vlanAction., pcp, cfi, vlanId);
+        } else if (sourceAction instanceof SetMplsTtlAction) {
+            // TODO: define maping
+            // targetAction = //no action to map
+        } else if (sourceAction instanceof SetNwTtlAction) {
+            // TODO: define maping
+        } else if (sourceAction instanceof SetQueueAction) {
+            // TODO: define maping
+            // targetAction = //no action to map
+        }
+
+        return targetAction;
+    }
+
+    private static NodeConnector fromNodeConnectorRef(Uri uri) {
+        // TODO: Define mapping
+        return null;
+    }
+
+    public static Match matchFrom(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.Match source) {
+        Match target = new Match();
+        if (source != null) {
+            fillFrom(target, source.getVlanMatch());
+            fillFrom(target, source.getEthernetMatch());
+            fillFrom(target, source.getLayer3Match());
+            fillFrom(target, source.getLayer4Match());
+            fillFrom(target, source.getIpMatch());
+        }
+
+        return target;
+    }
+
+    private static void fillFrom(Match target, VlanMatch vlanMatch) {
+        if (vlanMatch != null) {
+            VlanId vlanId = vlanMatch.getVlanId();
+            if (vlanId != null) {
+                org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId vlanIdInner = vlanId
+                        .getVlanId();
+                if (vlanIdInner != null) {
+                    Integer vlanValue = vlanIdInner.getValue();
+                    if (vlanValue != null) {
+                        target.setField(DL_VLAN, vlanValue.shortValue());
+                    }
+                }
+            }
+            VlanPcp vlanPcp = vlanMatch.getVlanPcp();
+            if (vlanPcp != null) {
+                Short vlanPcpValue = vlanPcp.getValue();
+                if (vlanPcpValue != null) {
+                    target.setField(DL_VLAN_PR, vlanPcpValue.byteValue());
+                }
+            }
+        }
+    }
+
+    private static void fillFrom(Match target, IpMatch ipMatch) {
+        if (ipMatch != null) {
+            Short ipProtocol = ipMatch.getIpProtocol();
+            if (ipProtocol != null) {
+                target.setField(NW_PROTO, ipProtocol.byteValue());
+            }
+            Dscp dscp = ipMatch.getIpDscp();
+            if (dscp != null) {
+                Short dscpValue = dscp.getValue();
+                if (dscpValue != null) {
+                    target.setField(NW_TOS, dscpValue.byteValue());
+                }
+            }
+        }
+    }
+
+    private static void fillFrom(Match target, Layer4Match layer4Match) {
+        if (layer4Match == null) {
+            return;
+        }
+        if (layer4Match instanceof SctpMatch) {
+            fillTransportLayer(target, (SctpMatch) layer4Match);
+        } else if (layer4Match instanceof TcpMatch) {
+            fillTransportLayer(target, (TcpMatch) layer4Match);
+        } else if (layer4Match instanceof UdpMatch) {
+            fillTransportLayer(target, (UdpMatch) layer4Match);
+        }
+    }
+
+    private static void fillTransportLayer(Match target, UdpMatch source) {
+        PortNumber udpSourcePort = source.getUdpSourcePort();
+        if (udpSourcePort != null) {
+            Integer udpSourcePortValue = udpSourcePort.getValue();
+            if (udpSourcePortValue != null) {
+                target.setField(TP_SRC, udpSourcePortValue.shortValue());
+            }
+        }
+
+        PortNumber udpDestPort = source.getUdpDestinationPort();
+        if (udpDestPort != null) {
+            Integer udpDestPortValue = udpDestPort.getValue();
+            if (udpDestPortValue != null) {
+                target.setField(TP_DST, udpDestPortValue.shortValue());
+            }
+        }
+    }
+
+    private static void fillTransportLayer(Match target, TcpMatch source) {
+        PortNumber tcpSourcePort = source.getTcpSourcePort();
+        if (tcpSourcePort != null) {
+            Integer tcpSourcePortValue = tcpSourcePort.getValue();
+            if (tcpSourcePortValue != null) {
+                target.setField(TP_SRC, tcpSourcePortValue.shortValue());
+            }
+        }
+
+        PortNumber tcpDestPort = source.getTcpDestinationPort();
+        if (tcpDestPort != null) {
+            Integer tcpDestPortValue = tcpDestPort.getValue();
+            if (tcpDestPortValue != null) {
+                target.setField(TP_DST, tcpDestPortValue.shortValue());
+            }
+        }
+    }
+
+    private static void fillTransportLayer(Match target, SctpMatch source) {
+        PortNumber sctpSourcePort = source.getSctpSourcePort();
+        if (sctpSourcePort != null) {
+            Integer sctpSourcePortValue = sctpSourcePort.getValue();
+            if (sctpSourcePortValue != null) {
+                target.setField(TP_SRC, sctpSourcePortValue.shortValue());
+            }
+        }
+        PortNumber sctpDestPort = source.getSctpDestinationPort();
+        if (sctpDestPort != null) {
+            Integer sctpDestPortValue = sctpDestPort.getValue();
+            if (sctpDestPortValue != null) {
+                target.setField(TP_DST, sctpDestPortValue.shortValue());
+            }
+        }
+    }
+
+    private static void fillFrom(Match target, Layer3Match source) {
+        if (source == null)
+            return;
+        if (source instanceof Ipv4Match) {
+            fillFromIpv4(target, (Ipv4Match) source);
+        } else if (source instanceof Ipv6Match) {
+            fillFromIpv6(target, (Ipv6Match) source);
+        } else if (source instanceof ArpMatch) {
+            fillFromArp(target, (ArpMatch) source);
+        }
+    }
+
+    private static void fillFromArp(Match target, ArpMatch source) {
+        Ipv4Prefix sourceAddress = source.getArpSourceTransportAddress();
+        if (sourceAddress != null) {
+            target.setField(NW_SRC, (InetAddress) inetAddressFrom(sourceAddress), null);
+        }
+        Ipv4Prefix destAddress = source.getArpSourceTransportAddress();
+        if (destAddress != null) {
+            target.setField(NW_DST, (InetAddress) inetAddressFrom(destAddress), null);
+        }
+    }
+
+    private static void fillFromIpv6(Match target, Ipv6Match source) {
+        Ipv6Prefix sourceAddress = source.getIpv6Source();
+        if (sourceAddress != null) {
+            target.setField(NW_SRC, (InetAddress) inetAddressFrom(sourceAddress), null);
+        }
+        Ipv6Prefix destAddress = source.getIpv6Source();
+        if (destAddress != null) {
+            target.setField(NW_DST, (InetAddress) inetAddressFrom(destAddress), null);
+        }
+    }
+
+    private static void fillFromIpv4(Match target, Ipv4Match source) {
+        Ipv4Prefix sourceAddress = source.getIpv4Source();
+        if (sourceAddress != null) {
+            target.setField(NW_SRC, (InetAddress) inetAddressFrom(sourceAddress), null);
+        }
+        Ipv4Prefix destAddress = source.getIpv4Source();
+        if (destAddress != null) {
+            target.setField(NW_DST, (InetAddress) inetAddressFrom(destAddress), null);
+        }
+    }
+
+    private static InetAddress inetAddressFrom(Ipv4Prefix source) {
+        if (source != null) {
+            String[] parts = source.getValue().split("/");
+            return InetAddresses.forString(parts[0]);
+        }
+        return null;
+    }
+
+    private static InetAddress inetAddressFrom(Ipv6Prefix source) {
+        if (source != null) {
+            String[] parts = source.getValue().split("/");
+            return InetAddresses.forString(parts[0]);
+        }
+        return null;
+    }
+
+    private static void fillFrom(Match target, EthernetMatch source) {
+        if (source == null)
+            return;
+        EthernetType ethType = source.getEthernetType();
+        if (ethType != null) {
+            EtherType ethInnerType = ethType.getType();
+            if (ethInnerType != null) {
+                Long value = ethInnerType.getValue();
+                target.setField(DL_TYPE, value.shortValue());
+            }
+        }
+
+        MacAddressFilter ethSource = source.getEthernetSource();
+        if (ethSource != null) {
+            target.setField(DL_SRC, bytesFrom(ethSource.getAddress()));
+        }
+
+        MacAddressFilter ethDest = source.getEthernetDestination();
+        if (ethDest != null) {
+            target.setField(DL_DST, bytesFrom(ethDest.getAddress()));
+        }
+    }
+
+    private static byte[] bytesFrom(MacAddress address) {
+        if (address != null) {
+            return address.getValue().getBytes();
+        }
+        return null;
+    }
+}
index 692b17a9a6c5409bdb38d1e729b504a5177a4f27..972bece91fd2ce9e0400bf2500397e76a2d19691 100644 (file)
@@ -48,7 +48,9 @@
               org.osgi.service.packageadmin,
               org.osgi.util.tracker,
               javax.servlet.http,
+              org.codehaus.jackson,
               org.codehaus.jackson.jaxrs,
+              org.codehaus.jackson.map,
               org.slf4j
             </Import-Package>
           </instructions>
diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/JacksonJsonProcessingExceptionMapper.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/JacksonJsonProcessingExceptionMapper.java
new file mode 100644 (file)
index 0000000..ca0d1b7
--- /dev/null
@@ -0,0 +1,37 @@
+/**
+ * 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.northbound.commons;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.GenericEntity;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+import org.codehaus.jackson.JsonProcessingException;
+
+/**
+ * A custom exception mapper for handling Jackson JsonProcessingException types
+ */
+@Provider
+@Consumes({MediaType.APPLICATION_JSON, "text/json"})
+public class JacksonJsonProcessingExceptionMapper
+    implements ExceptionMapper<JsonProcessingException>
+{
+
+    @Override
+    public Response toResponse(JsonProcessingException exception) {
+        GenericEntity<String> entity =
+                new GenericEntity<String>(exception.getMessage()) {};
+        return Response.status(Response.Status.BAD_REQUEST).entity(entity).build();
+    }
+}
+
index 1d3919f4ea396739af2dfb89a953a24cf59dd5de..5b8219126b8abbb7c82124b22f502505c2791e8c 100644 (file)
@@ -20,6 +20,7 @@ import javax.xml.bind.JAXBException;
 import javax.xml.bind.annotation.XmlRootElement;
 
 import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
+import org.codehaus.jackson.map.DeserializationConfig;
 import org.opendaylight.controller.northbound.bundlescanner.IBundleScanService;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -54,7 +55,8 @@ public class NorthboundApplication extends Application {
             }
 
         } );
-        singletons.add(new JacksonJaxbJsonProvider());
+        singletons.add(getJsonProvider());
+        singletons.add(new JacksonJsonProcessingExceptionMapper());
         return singletons;
     }
 
@@ -65,6 +67,13 @@ public class NorthboundApplication extends Application {
         return result;
     }
 
+    private static final JacksonJaxbJsonProvider getJsonProvider() {
+        JacksonJaxbJsonProvider jsonProvider = new JacksonJaxbJsonProvider();
+        jsonProvider.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,
+                false);
+        return jsonProvider;
+    }
+
     private BundleContext getBundleContext() {
         ClassLoader tlcl = Thread.currentThread().getContextClassLoader();
         Bundle bundle = null;
index 9f4e05dff0ba81df97abb2fde6159667608da026..3f2585e0c2f215e343f567c1ecb9331ca6555307 100644 (file)
@@ -20,9 +20,9 @@
   <version>0.4.0-SNAPSHOT</version>
   <pluginRepositories>
     <pluginRepository>
-      <id>central2</id>
-      <name>central2</name>
-      <url>http://repo2.maven.org/maven2</url>
+      <id>central</id>
+      <name>maven repo1</name>
+      <url>http://repo1.maven.org/maven2</url>
       <snapshots>
         <enabled>false</enabled>
       </snapshots>
index 4404951135391f632a968aae8345e472e8f413c0..e7ca7f57822a438e4243a29115fd38f854dce5ed 100644 (file)
@@ -428,6 +428,11 @@ public class NorthboundIT {
         // Test GET deleted subnet1
         result = getJsonResult(baseURL + "default/subnet/" + name1);
         Assert.assertEquals(404, httpResponseCode.intValue());
+
+        // TEST PUT bad subnet, expect 400, validate JSON exception mapper
+        JSONObject joBad = new JSONObject().put("foo", "bar");
+        result = getJsonResult(baseURL + "default/subnet/foo", "PUT", joBad.toString());
+        Assert.assertEquals(400, httpResponseCode.intValue());
   }
 
     @Test
index b1107594f50fb3d60390f71b081e2b495dc89f8c..3f84ff09a47b875a63bf18873a3d06e9b09cd80f 100644 (file)
@@ -43,9 +43,9 @@
 
     <pluginRepositories>
         <pluginRepository>
-          <id>central2</id>
-          <name>central2</name>
-          <url>http://repo2.maven.org/maven2</url>
+          <id>central</id>
+          <name>maven repo1</name>
+          <url>http://repo1.maven.org/maven2</url>
           <snapshots>
              <enabled>false</enabled>
           </snapshots>
             <name>ebr-bundles-external</name>
             <url>${nexusproxy}/repositories/ebr-bundles-external/</url>
         </repository>
-        <repository>
-          <id>central2</id>
-          <name>central2</name>
-          <url>http://repo2.maven.org/maven2</url>
-          <snapshots>
-            <enabled>false</enabled>
-          </snapshots>
-          <releases>
-            <enabled>true</enabled>
-          </releases>
-        </repository>
         <repository>
           <id>central</id>
           <name>central</name>
diff --git a/opendaylight/sal/yang-prototype/sal/model/model-flow-base/src/main/yang/group-types.yang b/opendaylight/sal/yang-prototype/sal/model/model-flow-base/src/main/yang/group-types.yang
new file mode 100644 (file)
index 0000000..626eabd
--- /dev/null
@@ -0,0 +1,175 @@
+module opendaylight-group-types {
+    namespace "urn:opendaylight:group:types";
+    prefix group;
+
+    import ietf-inet-types {prefix inet;}
+    import ietf-yang-types {prefix yang;}
+       import opendaylight-flow-types {prefix flow-types;}
+
+    revision "2013-09-17" {
+        description "Initial revision of group service";
+    }
+
+       typedef group-ref {
+               type instance-identifier;
+       }
+       
+       grouping group-types {
+               leaf group-type {
+                       type enumeration {
+                               enum group-all;
+                               enum group_select;
+                               enum group_indirect;
+                               enum group_ff;
+                       }
+               }
+       }
+       
+       grouping group {
+        
+        uses group-types;       
+               
+               leaf group-id {
+            type group-ref;
+        }
+               
+               container buckets {
+                       list bucket {
+                               key "order";
+                               leaf order {
+                                       type int32;
+                               }
+                               
+                               leaf weight {
+                                       type uint16;
+                               }
+                               
+                               leaf watch_port {
+                                       type uint32;
+                               }
+                               
+                               leaf watch_group {
+                                       type uint32;
+                               }
+                               
+                               container actions {
+                                       list action {
+                                               key "action-order";
+                                               leaf action-order {
+                                                       type int32;
+                                               }
+            
+                                               uses flow-types:action;
+                                       }
+                               }
+                       }
+               }
+    }
+       
+       grouping group-statistics-request {
+               list group-stats {
+                       key "group-id";                 
+                       
+                       leaf group-id {
+                               type int32;
+                       }                       
+               }
+       }
+       
+       grouping group-statistics {
+                       
+               leaf group-id {
+            type int32;
+               }
+               
+           leaf ref-count {
+            type yang:counter32;
+               }
+               
+               leaf packet-count {
+            type yang:counter64;
+        } 
+               
+        leaf byte-count {
+            type yang:counter64;
+        }
+
+        container duration {
+            leaf second {
+                type yang:counter32;
+            }
+            leaf nanosecond {
+                type yang:counter32;
+            }
+        }
+               
+               container buckets {
+                       list bucket-counter {
+                               key "order";
+                               leaf order {
+                                       type int32;
+                               }
+                               
+                               leaf packet-count {
+                                       type yang:counter64;
+                               } 
+               
+                               leaf byte-count {
+                                       type yang:counter64;
+                               }
+                       }
+               }               
+    }
+
+       grouping group-statistics-reply {
+               list group-stats {
+                       key "group-stats-order";
+                       leaf group-stats-order {
+                               type int32;
+                       }
+                       
+                       uses group-statistics;
+               }
+       }
+       
+       grouping group-desc-stats {
+               list group-desc-stats {
+                       key "order-id";                 
+                       
+                       leaf order-id {
+                               type int32;
+                       }
+                       
+                       uses group;
+               }
+       }
+       
+    grouping group-features {
+               list group-features {
+                       key "order";
+                       leaf order {
+                               type int32;
+                       }
+                       
+                       uses group-types;
+                       type capabilities {
+                               enum select-weight;
+                               enum select-liveness;
+                               enum chaining;
+                               enum chaining-checks;
+                       }       
+
+                       leaf-list max-groups {
+                               type uint32;
+                               description "Maximum number of groups for each type";
+                               max-elements 4;
+                       }
+                       
+                       leaf-list actions {
+                               type uint32;
+                               description "Bitmap number OFPAT_* that are supported";
+                               max-elements 4;
+                       }
+               }
+       }    
+}
\ No newline at end of file
index 54b46d5587af0e0c65841d03546d80aa7f58d5bb..757686c662ab747baced122af0d5218a170f061a 100644 (file)
@@ -68,16 +68,16 @@ module opendaylight-match-types {
     grouping "ip-match-fields" {
         leaf ip-protocol {
                 description "IP protocol.";
-                type uint8; // TODO define IP protocol number
+                type uint8; 
         }
 
         leaf ip-dscp {
             description "IP DSCP (6 bits in ToS field).";
-            type inet:dscp; // TODO: Define DSCP type
+            type inet:dscp; 
         }
         leaf ip-ecn {
             description "IP ECN (2 bits in ToS field).";
-            type uint8; // TODO define ECN
+            type uint8; 
         }
     }
 
@@ -130,7 +130,7 @@ module opendaylight-match-types {
             description "SCTP source port.";
             type inet:port-number;
         }
-        leaf sctp-destination-dst {
+        leaf sctp-destination-port {
             description "SCTP destination port.";
             type inet:port-number;
         }
diff --git a/opendaylight/sal/yang-prototype/sal/model/model-flow-service/src/main/yang/group-service.yang b/opendaylight/sal/yang-prototype/sal/model/model-flow-service/src/main/yang/group-service.yang
new file mode 100644 (file)
index 0000000..1ea2d34
--- /dev/null
@@ -0,0 +1,49 @@
+module sal-group {
+    namespace "urn:opendaylight:group:service";
+    prefix group;
+
+    import yang-ext {prefix ext;}
+    import opendaylight-inventory {prefix inv;}
+    import ietf-inet-types {prefix inet;}
+    import opendaylight-group-types {prefix group-type;}
+
+    revision "2013-09-17" {
+        description "Initial revision of group service";
+    }        
+       
+    grouping node-group {
+        leaf node {
+            type inv:node-ref;
+        }
+        
+        uses group-type:group;
+    }
+
+    /** Base configuration structure **/
+    grouping group-update {
+        container original-group {
+            uses group-type:group;
+        }
+        container updated-group {
+            uses group-type:group;
+        }
+    }
+
+    rpc add-group {
+        input {
+            uses node-group;
+        }
+    }
+
+    rpc remove-group {
+        input {
+            uses node-group;
+        }
+    }
+
+    rpc update-group {
+        input {
+            uses node-group;
+        }
+    }     
+}
\ No newline at end of file
index 0442e8f9b2646d8f9b4d159fdfff7ea1e47d0287..d70338e4e0d1623e385ba1d72b1e4976aa8e4c4e 100644 (file)
@@ -25,7 +25,7 @@
                <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>
+               <yang.version>0.5.8-SNAPSHOT</yang.version>
                <maven.bundle.version>2.4.0</maven.bundle.version>
         <releaseplugin.version>2.3.2</releaseplugin.version>
         <guava.version>14.0.1</guava.version>
@@ -33,9 +33,9 @@
 
     <pluginRepositories>
         <pluginRepository>
-          <id>central2</id>
-          <name>central2</name>
-          <url>http://repo2.maven.org/maven2</url>
+          <id>central</id>
+          <name>maven repo1</name>
+          <url>http://repo1.maven.org/maven2</url>
           <snapshots>
               <enabled>false</enabled>
           </snapshots>
 
 
        <repositories>
-      <repository>
-        <id>central2</id>
-        <name>central2</name>
-        <url>http://repo2.maven.org/maven2</url>
-        <snapshots>
-            <enabled>false</enabled>
-        </snapshots>
-        <releases>
-            <enabled>true</enabled>
-        </releases>
-      </repository>
       <repository>
         <id>central</id>
         <name>central</name>
index 549e427d82e816fb4374d3b80b3b44e2b9aeee1d..96a16dcd5772d6000421f680259b3373d4f978c3 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>
-       <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>
+    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>
     <scm>
-      <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
-      <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
-      <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
+        <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
+        <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
+        <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
     </scm>
 
-       <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>
+    <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.*,
+                            org.opendaylight.controller.sal.binding.codegen.*,
+                            org.eclipse.xtend2.lib,
+                            org.eclipse.xtend.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>
+            <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 -->
+    <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>
-               </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>
+        <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>
+        </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>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <version>1.9.5</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
 </project>
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeHelper.xtend b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeHelper.xtend
new file mode 100644 (file)
index 0000000..6bdb3c8
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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.codegen
+
+import java.util.Map
+
+import org.opendaylight.yangtools.yang.binding.BaseIdentity
+import org.opendaylight.yangtools.yang.binding.RpcService
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
+
+import static extension org.opendaylight.controller.sal.binding.codegen.RuntimeCodeSpecification.*
+
+class RuntimeCodeHelper {
+    /**
+     * Helper method to return delegate from ManagedDirectedProxy with use of reflection.
+     * 
+     * Note: This method uses reflection, but access to delegate field should be 
+     * avoided and called only if neccessary.
+     * 
+     */
+    public static 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
+    }
+
+    /**
+     * Helper method to set delegate to ManagedDirectedProxy with use of reflection.
+     * 
+     * Note: This method uses reflection, but setting delegate field should not occur too much
+     * to introduce any significant performance hits.
+     * 
+     */
+    public static 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");
+    }
+
+    public static def Map<InstanceIdentifier, ? extends RpcService> getRoutingTable(RpcService target,
+        Class<? extends BaseIdentity> tableClass) {
+        val field = target.class.getField(tableClass.routingTableField)
+        if (field == null) throw new UnsupportedOperationException(
+            "Unable to get routing table. Table field does not exists");
+        return field.get(target) as Map<InstanceIdentifier, ? extends RpcService>;
+    }
+
+    public static def void setRoutingTable(RpcService target, Class<? extends BaseIdentity> tableClass,
+        Map<InstanceIdentifier, ? extends RpcService> routingTable) {
+         val field = target.class.getField(tableClass.routingTableField)
+        if (field == null) throw new UnsupportedOperationException(
+            "Unable to set routing table. Table field does not exists");
+        field.set(target,routingTable);
+        
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeSpecification.xtend b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeSpecification.xtend
new file mode 100644 (file)
index 0000000..c6e76c2
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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.codegen
+
+import org.opendaylight.yangtools.yang.binding.RpcService
+import org.opendaylight.yangtools.yang.binding.BaseIdentity
+import org.opendaylight.yangtools.yang.binding.NotificationListener
+
+/**
+ * 
+ * 
+ */
+class RuntimeCodeSpecification {
+
+    public static val PACKAGE_PREFIX = "_gen.";
+
+    public static val DIRECT_PROXY_SUFFIX = "DirectProxy";
+    public static val ROUTER_SUFFIX = "Router";
+    public static val INVOKER_SUFFIX = "Invoker";
+
+    public static val DELEGATE_FIELD = "_delegate"
+    public static val ROUTING_TABLE_FIELD_PREFIX = "_routes_"
+
+    public static def getInvokerName(Class<? extends NotificationListener> listener) {
+        getGeneratedName(listener, INVOKER_SUFFIX);
+    }
+
+    /**
+     * Returns a name for DirectProxy implementation
+     * 
+     * 
+     */
+    public static def getDirectProxyName(Class<? extends RpcService> base) {
+        getGeneratedName(base, DIRECT_PROXY_SUFFIX);
+    }
+
+    /**
+     * Returns a name for Router implementation
+     * 
+     */
+    public static def getRouterName(Class<? extends RpcService> base) {
+        getGeneratedName(base, ROUTER_SUFFIX);
+    }
+
+    /**
+     * Returns a name for generated interface
+     * 
+     */
+    public static def getGeneratedName(Class<?> cls, String suffix) {
+        '''«PACKAGE_PREFIX»«cls.package.name».«cls.simpleName»$«suffix»'''.toString()
+    }
+
+    /**
+     * Returns a field name for specified routing context
+     * 
+     */
+    public static def getRoutingTableField(Class<? extends BaseIdentity> routingContext) {
+        return '''_routes_«routingContext.simpleName»'''.toString;
+    }
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/codegen/YangtoolsMappingHelper.xtend b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/codegen/YangtoolsMappingHelper.xtend
new file mode 100644 (file)
index 0000000..18d3e26
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * 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.codegen
+
+import java.lang.reflect.Method
+import org.opendaylight.yangtools.yang.binding.Notification
+
+public static class YangtoolsMappingHelper {
+
+    public static def boolean isNotificationCallback(Method it) {
+        return name.startsWith("on") && parameterTypes.size === 1 &&
+            Notification.isAssignableFrom(parameterTypes.get(0))
+    }
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/JavassistUtils.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/JavassistUtils.java
new file mode 100644 (file)
index 0000000..c6be284
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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.codegen.impl;
+
+import javassist.CtClass;
+import javassist.CtField;
+import javassist.CtMethod;
+
+public class JavassistUtils {
+
+    public static interface ClassGenerator {
+        void process(CtClass cls);
+    }
+
+    public static interface MethodGenerator {
+        void process(CtMethod method);
+    }
+
+    public static interface FieldGenerator {
+        void process(CtField field);
+    }
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RoutingPair.xtend b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RoutingPair.xtend
new file mode 100644 (file)
index 0000000..4324b4e
--- /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.codegen.impl
+
+import org.opendaylight.yangtools.yang.binding.BaseIdentity
+import javassist.CtMethod
+import java.lang.reflect.Method
+
+@Data
+class RoutingPair {
+
+    @Property
+    val Class<? extends BaseIdentity> context;
+    @Property
+    val CtMethod getter;
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeCodeGenerator.xtend b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeCodeGenerator.xtend
new file mode 100644 (file)
index 0000000..3b3f419
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+ * 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.codegen.impl
+
+import javassist.ClassPool
+import org.opendaylight.yangtools.yang.binding.RpcService
+
+import javassist.CtClass
+import static com.google.common.base.Preconditions.*
+
+import javassist.CtField
+import javassist.Modifier
+import javassist.CtMethod
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
+import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext
+import org.opendaylight.yangtools.yang.binding.BaseIdentity
+
+import java.util.Map
+import java.util.HashMap
+import javassist.NotFoundException
+import javassist.LoaderClassPath
+import org.opendaylight.controller.sal.binding.codegen.impl.JavassistUtils.MethodGenerator
+import org.opendaylight.controller.sal.binding.codegen.impl.JavassistUtils.ClassGenerator
+import org.opendaylight.yangtools.yang.binding.NotificationListener
+import org.opendaylight.yangtools.yang.binding.Notification
+import java.util.Arrays
+
+import static extension org.opendaylight.controller.sal.binding.codegen.YangtoolsMappingHelper.*
+import static extension org.opendaylight.controller.sal.binding.codegen.RuntimeCodeSpecification.*
+
+class RuntimeCodeGenerator {
+
+    val ClassPool classPool;
+
+    public new(ClassPool pool) {
+        classPool = pool;
+    }
+
+    def <T extends RpcService> Class<? extends T> generateDirectProxy(Class<T> iface) {
+        val supertype = iface.asCtClass
+        val targetCls = createClass(iface.directProxyName, supertype) [
+            field(DELEGATE_FIELD, iface);
+            implementMethodsFrom(supertype) [
+                body = '''return ($r) Â«DELEGATE_FIELD».«it.name»($$);'''
+            ]
+        ]
+        return targetCls.toClass(iface.classLoader)
+    }
+
+    def <T extends RpcService> Class<? extends T> generateRouter(Class<T> iface) {
+        val supertype = iface.asCtClass
+        val targetCls = createClass(iface.routerName, supertype) [
+            //field(ROUTING_TABLE_FIELD,Map)
+            field(DELEGATE_FIELD, iface)
+            val contexts = new HashMap<String, Class<? extends BaseIdentity>>();
+            // We search for routing pairs and add fields
+            supertype.methods.filter[declaringClass == supertype && parameterTypes.size === 1].forEach [ method |
+                val routingPair = method.routingContextInput;
+                if (routingPair !== null)
+                    contexts.put(routingPair.context.routingTableField, routingPair.context);
+            ]
+            for (ctx : contexts.entrySet) {
+                field(ctx.key, Map)
+            }
+            implementMethodsFrom(supertype) [
+                if (parameterTypes.size === 1) {
+                    val routingPair = routingContextInput;
+                    val bodyTmp = '''
+                    {
+                        final Â«InstanceIdentifier.name» identifier = $1.«routingPair.getter.name»();
+                        Â«supertype.name» instance = («supertype.name») Â«routingPair.context.routingTableField».get(identifier);
+                        if(instance == null) {
+                           instance = Â«DELEGATE_FIELD»;
+                        }
+                        return ($r) instance.«it.name»($$);
+                    }'''
+                    body = bodyTmp
+                } else if (parameterTypes.size === 0) {
+                    body = '''return ($r) Â«DELEGATE_FIELD».«it.name»($$);'''
+                }
+            ]
+        ]
+        return targetCls.toClass(iface.classLoader)
+    }
+
+    def Class<?> generateListenerInvoker(Class<? extends NotificationListener> iface) {
+        val targetCls = createClass(iface.invokerName) [
+            field(DELEGATE_FIELD, iface)
+            it.method(Void, "invoke", Notification) [
+                val callbacks = iface.methods.filter[notificationCallback]
+                body = '''
+                    {
+                        Â«FOR callback : callbacks SEPARATOR " else "»
+                            if($1 instanceof Â«val cls = callback.parameterTypes.get(0).name») {
+                                Â«DELEGATE_FIELD».«callback.name»((«cls») $1);
+                                return;
+                            }
+                        Â«ENDFOR»
+                    }
+                '''
+            ]
+        ]
+        return targetCls.toClass(iface.classLoader);
+    }
+
+    def void method(CtClass it, Class<?> returnType, String name, Class<?> parameter, MethodGenerator function1) {
+        val method = new CtMethod(returnType.asCtClass, name, Arrays.asList(parameter.asCtClass), it);
+        function1.process(method);
+        it.addMethod(method);
+    }
+
+    private def routingContextInput(CtMethod method) {
+        val inputClass = method.parameterTypes.get(0);
+        return inputClass.contextInstance;
+    }
+
+    private def RoutingPair getContextInstance(CtClass dataClass) {
+        for (method : dataClass.methods) {
+            if (method.parameterTypes.size === 0 && method.name.startsWith("get")) {
+                for (annotation : method.availableAnnotations) {
+                    if (annotation instanceof RoutingContext) {
+                        return new RoutingPair((annotation as RoutingContext).value, method)
+                    }
+                }
+            }
+        }
+        for (iface : dataClass.interfaces) {
+            val ret = getContextInstance(iface);
+            if (ret != null) return ret;
+        }
+        return null;
+    }
+
+    private def void implementMethodsFrom(CtClass target, CtClass source, MethodGenerator function1) {
+        for (method : source.methods) {
+            if (method.declaringClass == source) {
+                val redeclaredMethod = new CtMethod(method, target, null);
+                function1.process(redeclaredMethod);
+                target.addMethod(redeclaredMethod);
+            }
+        }
+    }
+
+    private def CtClass createClass(String fqn, ClassGenerator cls) {
+        val target = classPool.makeClass(fqn);
+        cls.process(target);
+        return target;
+    }
+
+    private def CtClass createClass(String fqn, CtClass superInterface, ClassGenerator cls) {
+        val target = classPool.makeClass(fqn);
+        target.implementsType(superInterface);
+        cls.process(target);
+        return target;
+    }
+
+    private def void implementsType(CtClass it, CtClass supertype) {
+        checkArgument(supertype.interface, "Supertype must be interface");
+        addInterface(supertype);
+    }
+
+    private def asCtClass(Class<?> class1) {
+        classPool.get(class1);
+    }
+
+    private def CtField field(CtClass it, String name, Class<?> returnValue) {
+        val field = new CtField(returnValue.asCtClass, name, it);
+        field.modifiers = Modifier.PUBLIC
+        addField(field);
+        return field;
+    }
+
+    def get(ClassPool pool, Class<?> cls) {
+        try {
+            return pool.get(cls.name)
+        } catch (NotFoundException e) {
+            pool.appendClassPath(new LoaderClassPath(cls.classLoader));
+            return pool.get(cls.name)
+        }
+    }
+}
index 2953466b2928a419eb0a2c3a09f4d74b771b7ab9..298a74ece5f71982ae7bcbb48f205e4039c44046 100644 (file)
@@ -11,30 +11,29 @@ 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.codegen.RuntimeCodeHelper.*
 
-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 static org.opendaylight.controller.sal.binding.impl.osgi.Constants.*
+import static extension org.opendaylight.controller.sal.binding.impl.osgi.PropertiesUtils.*
 import org.opendaylight.controller.sal.binding.api.NotificationService
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext
-import javassist.Modifier
+
 import org.slf4j.LoggerFactory
+import org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator
 
 class BindingAwareBrokerImpl implements BindingAwareBroker {
-    private static val DELEGATE_FIELD = "_delegate"
     private static val log = LoggerFactory.getLogger(BindingAwareBrokerImpl)
     
     private val clsPool = ClassPool.getDefault()
+    private var RuntimeCodeGenerator generator;
     private Map<Class<? extends RpcService>, RpcProxyContext> managedProxies = new HashMap();
     private var NotificationBrokerImpl notifyBroker
     private var ServiceRegistration<NotificationProviderService> notifyBrokerRegistration
@@ -47,7 +46,7 @@ class BindingAwareBrokerImpl implements BindingAwareBroker {
 
         // Initialization of notificationBroker
         notifyBroker = new NotificationBrokerImpl(null);
-        val brokerProperties = PropertiesUtils.newProperties();
+        val brokerProperties = newProperties();
         notifyBrokerRegistration = brokerBundleContext.registerService(NotificationProviderService, notifyBroker,
             brokerProperties)
         brokerBundleContext.registerService(NotificationService, notifyBroker, brokerProperties)
@@ -56,7 +55,8 @@ class BindingAwareBrokerImpl implements BindingAwareBroker {
     def initGenerator() {
 
         // YANG Binding Class Loader
-        clsPool.appendClassPath(new LoaderClassPath(RpcService.classLoader))
+        clsPool.appendClassPath(new LoaderClassPath(RpcService.classLoader));
+        generator = new RuntimeCodeGenerator(clsPool);
     }
 
     override registerConsumer(BindingAwareConsumer consumer, BundleContext bundleCtx) {
@@ -97,35 +97,16 @@ class BindingAwareBrokerImpl implements BindingAwareBroker {
         if ((existing = managedProxies.get(service)) != null) {
             return existing.proxy
         }
-        val proxyClass = service.generateDirectProxy()
+        val proxyClass = generator.generateDirectProxy(service)
         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
+        properties.salServiceType = 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)
-    }
-
     /**
      * Registers RPC Implementation
      * 
@@ -140,34 +121,4 @@ class BindingAwareBrokerImpl implements BindingAwareBroker {
         proxy.delegate = service;
         return new RpcServiceRegistrationImpl<T>(type, service, osgiReg);
     }
-    
-    /**
-     * Helper method to return delegate from ManagedDirectedProxy with use of reflection.
-     * 
-     * Note: This method uses reflection, but access to delegate field should be 
-     * avoided and called only if neccessary.
-     * 
-     */
-    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
-    }
-    
-        /**
-     * Helper method to set delegate to ManagedDirectedProxy with use of reflection.
-     * 
-     * Note: This method uses reflection, but setting delegate field should not occur too much
-     * to introduce any significant performance hits.
-     * 
-     */
-    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/DataProviderContext.xtend b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/DataProviderContext.xtend
new file mode 100644 (file)
index 0000000..398a219
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * 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.common.DataStoreIdentifier
+import org.opendaylight.controller.sal.binding.api.data.RuntimeDataProvider
+
+class DataProviderContext {
+
+    @Property
+    var DataStoreIdentifier identifier;
+    @Property
+    var RuntimeDataProvider provider;
+}
index da1ba79997d16a910ccafe023076e72db460ae7c..22db73526e2e2e386636cc8b45320b3c246f24ad 100644 (file)
@@ -45,6 +45,7 @@ class NotificationBrokerImpl implements NotificationProviderService {
         notification.class.interfaces.filter[it != Notification && Notification.isAssignableFrom(it)]
     }
 
+    @SuppressWarnings("unchecked")
     def notifyAll(Collection<NotificationListener<?>> listeners, Notification notification) {
         listeners.forEach[(it as NotificationListener).onNotification(notification)]
     }
index a87fa0642a4eec5b33eca03630e2122f9d01ba61..a9031240c777961e9fdb5ad5bcb642b70c311f0a 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
 package org.opendaylight.controller.sal.binding.impl;
 
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
@@ -7,47 +14,45 @@ import org.osgi.framework.BundleContext;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 import org.slf4j.LoggerFactory
+import static org.opendaylight.controller.sal.binding.impl.osgi.Constants.*
 
 class OsgiConsumerContext implements ConsumerContext {
 
-       static val log = LoggerFactory.getLogger(OsgiConsumerContext)
-       protected val BundleContext bundleContext;
-       protected val BindingAwareBrokerImpl broker;
-       
-       new(BundleContext ctx,BindingAwareBrokerImpl broker) {
-               this.bundleContext = ctx;
-               this.broker = broker;
-       }
-
-       
-       override def <T extends BindingAwareService> getSALService(Class<T> service) {
-               // SAL Services are global
-               var ref =  bundleContext.getServiceReference(service);
-               return bundleContext.getService(ref) as T;
-       }
-       
-       
-
-       override def <T extends RpcService> T getRpcService(Class<T> module) {
-               try {
-                       
-                       val services = bundleContext.getServiceReferences(module, getProxyFilter());
-                       
-                       // Proxy service found / using first implementation
-                       // FIXME: Add advanced logic to retrieve service with right set of models
-                       if(false == services.empty) {
-                               val ref = services.iterator().next() as ServiceReference<T>;
-                               return bundleContext.getService(ref) as T;
-                       } 
-               } 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»)'''
-       }
+    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 '''(«SAL_SERVICE_TYPE»=«SAL_SERVICE_TYPE_CONSUMER_PROXY»)'''
+    }
 }
index 195fa8b9597ba19b5784e68e15d8d2fc563eef42..c769ca1ee38509fa3dbebd52948f81735fddf59c 100644 (file)
@@ -16,7 +16,8 @@ import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcService
 import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.osgi.framework.BundleContext;
 
-import static extension org.opendaylight.controller.sal.binding.impl.utils.PropertiesUtils.*;
+import static org.opendaylight.controller.sal.binding.impl.osgi.Constants.*;
+import static extension org.opendaylight.controller.sal.binding.impl.osgi.PropertiesUtils.*;
 
 class OsgiProviderContext extends OsgiConsumerContext implements ProviderContext {
 
@@ -32,7 +33,7 @@ class OsgiProviderContext extends OsgiConsumerContext implements ProviderContext
 
         // TODO Auto-generated method stub
         val properties = new Hashtable<String, String>();
-        properties.salServiceType = Constants.SAL_SERVICE_TYPE_PROVIDER
+        properties.salServiceType = SAL_SERVICE_TYPE_PROVIDER
 
         // Fill requirements
         val salReg = broker.registerRpcImplementation(type, implementation, this, properties)
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/_DataBrokerImpl.xtend b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/_DataBrokerImpl.xtend
new file mode 100644 (file)
index 0000000..b278df5
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * 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.data.DataBrokerService
+import org.opendaylight.controller.sal.common.DataStoreIdentifier
+import org.opendaylight.yangtools.yang.binding.DataRoot
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService
+import org.opendaylight.controller.sal.binding.api.data.DataCommitHandler
+import org.opendaylight.controller.sal.binding.api.data.DataRefresher
+import org.opendaylight.controller.sal.binding.api.data.DataValidator
+import org.opendaylight.yangtools.yang.common.RpcResult
+import org.opendaylight.controller.sal.binding.api.data.RuntimeDataProvider
+import java.util.Map
+
+class _DataBrokerImpl implements DataProviderService {
+
+    Map<DataStoreIdentifier, DataProviderContext> dataProviders;
+    var DataProviderContext defaultDataProvider;
+
+    override <T extends DataRoot> getData(DataStoreIdentifier store, Class<T> rootType) {
+        val dataStore = resolveProvider(store, rootType);
+        return dataStore.provider.getData(store, rootType);
+    }
+
+    override <T extends DataRoot> getData(DataStoreIdentifier store, T filter) {
+    }
+
+    override <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, Class<T> rootType) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub");
+    }
+
+    override <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, T filter) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub");
+    }
+
+    override commit(DataStoreIdentifier store) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    override editCandidateData(DataStoreIdentifier store, DataRoot changeSet) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    override addCommitHandler(DataStoreIdentifier store, DataCommitHandler provider) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    override addRefresher(DataStoreIdentifier store, DataRefresher refresher) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    override addValidator(DataStoreIdentifier store, DataValidator validator) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    override removeRefresher(DataStoreIdentifier store, DataRefresher refresher) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    override removeCommitHandler(DataStoreIdentifier store, DataCommitHandler provider) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+
+    }
+
+    override removeValidator(DataStoreIdentifier store, DataValidator validator) {
+        throw new UnsupportedOperationException("TODO: auto-generated method stub")
+    }
+
+    def DataProviderContext resolveProvider(DataStoreIdentifier store, Class<? extends DataRoot> root) {
+    }
+
+}
@@ -5,7 +5,7 @@
  * 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
+package org.opendaylight.controller.sal.binding.impl.osgi
 
 class Constants {
 
@@ -16,6 +16,4 @@ class Constants {
     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/osgi/PropertiesUtils.xtend b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/osgi/PropertiesUtils.xtend
new file mode 100644 (file)
index 0000000..d04ca7f
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.sal.binding.impl.osgi
+
+import java.util.Hashtable
+import static org.opendaylight.controller.sal.binding.impl.osgi.Constants.*
+
+class PropertiesUtils {
+
+    private new() {
+    }
+
+    static def setSalServiceType(Hashtable<String, String> properties, String value) {
+        properties.put(SAL_SERVICE_TYPE, value)
+        return properties
+    }
+
+    static def getSalServiceType(Hashtable<String, String> properties) {
+        return properties.get(SAL_SERVICE_TYPE)
+    }
+
+    static def newProperties() {
+        new Hashtable<String, String>()
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/osgi/package-info.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/osgi/package-info.java
new file mode 100644 (file)
index 0000000..d788ccf
--- /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.osgi;
\ 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/GeneratorUtils.xtend b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/utils/GeneratorUtils.xtend
deleted file mode 100644 (file)
index c888121..0000000
+++ /dev/null
@@ -1,30 +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.utils
-
-import javassist.ClassPool
-import javassist.NotFoundException
-import javassist.LoaderClassPath
-
-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) {
-        try {
-            return pool.get(cls.name)
-        } catch (NotFoundException e) {
-            pool.appendClassPath(new LoaderClassPath(cls.classLoader));
-            return 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
deleted file mode 100644 (file)
index 7ba62f5..0000000
+++ /dev/null
@@ -1,30 +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.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
deleted file mode 100644 (file)
index 5110238..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
-  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
-  *
-  * This program and the accompanying materials are made available under the
-  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
-  * and is available at http://www.eclipse.org/legal/epl-v10.html
-  */
-package org.opendaylight.controller.sal.binding.impl.utils;
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/test/org/opendaylight/controller/sal/binding/test/GenerationTest.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/test/org/opendaylight/controller/sal/binding/test/GenerationTest.java
new file mode 100644 (file)
index 0000000..9bbb501
--- /dev/null
@@ -0,0 +1,31 @@
+package org.opendaylight.controller.sal.binding.test;
+import static org.junit.Assert.*;
+
+import java.util.concurrent.Future;
+
+import org.junit.Test;
+import org.opendaylight.controller.sal.binding.impl.ProxyFactoryGenerator;
+import org.opendaylight.controller.sal.binding.impl.RpcServiceProxy;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+
+public class GenerationTest {
+
+       public interface MockService extends RpcService {
+               
+           Future<RpcResult<java.lang.Void>> cancelToast();
+           
+           Future<RpcResult<java.lang.Void>> makeToast(String input);
+       }
+       
+       @Test
+       public void test() {
+               ProxyFactoryGenerator generator = new ProxyFactoryGenerator();
+               Class<? extends RpcServiceProxy<MockService>> ret = generator.generate(MockService.class);
+               
+               assertTrue(RpcServiceProxy.class.isAssignableFrom(ret));
+               assertTrue(MockService.class.isAssignableFrom(ret));
+       }
+
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/RuntimeCodeGeneratorTest.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/RuntimeCodeGeneratorTest.java
new file mode 100644 (file)
index 0000000..5dddd1a
--- /dev/null
@@ -0,0 +1,142 @@
+package org.opendaylight.controller.sal.binding.test;
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import javassist.ClassPool;
+
+import org.junit.Before;
+import org.junit.Test;
+import static org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper.*;
+import org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator;
+import org.opendaylight.controller.sal.binding.test.mock.FooService;
+import org.opendaylight.controller.sal.binding.test.mock.ReferencableObject;
+import org.opendaylight.controller.sal.binding.test.mock.ReferencableObjectKey;
+import org.opendaylight.controller.sal.binding.test.mock.SimpleInput;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
+
+import static org.mockito.Mockito.*;
+
+
+public class RuntimeCodeGeneratorTest {
+
+    private RuntimeCodeGenerator codeGenerator;
+
+    
+    @Before
+    public void initialize() {
+        this.codeGenerator = new RuntimeCodeGenerator(ClassPool.getDefault());
+    }
+    
+    @Test
+    public void testGenerateDirectProxy() {
+        Class<? extends FooService> product = codeGenerator.generateDirectProxy(FooService.class);
+        assertNotNull(product);
+    }
+
+    @Test
+    public void testGenerateRouter() throws Exception {
+        Class<? extends FooService> product = codeGenerator.generateRouter(FooService.class);
+        assertNotNull(product);
+        assertNotNull(product.getSimpleName());
+        assertEquals("2 fields should be generated.",2,product.getFields().length);
+        
+        verifyRouting(product.newInstance());
+    }
+
+    private void verifyRouting(FooService product) {
+        Map<InstanceIdentifier,FooService> routingTable = new HashMap<>();
+        setRoutingTable(product, BaseIdentity.class, routingTable);
+        
+        assertSame("Returned routing table should be same instance",routingTable,getRoutingTable(product, BaseIdentity.class));
+        
+        int servicesCount = 2;
+        int instancesPerService = 3;
+        
+        InstanceIdentifier[][] identifiers = identifiers(servicesCount,instancesPerService);
+        FooService service[] = new FooService[] {
+                mock(FooService.class, "Instance 0"),
+                mock(FooService.class,"Instance 1")
+        };
+        
+        for(int i = 0;i<service.length;i++) {
+            for (InstanceIdentifier instance : identifiers[i]) {
+                routingTable.put(instance, service[i]);
+            }
+        }
+        
+        assertEquals("All instances should be registered.", servicesCount*instancesPerService, routingTable.size());
+        
+        SimpleInput[] instance_0_input = new SimpleInputImpl[] {
+            new SimpleInputImpl(identifiers[0][0]),
+            new SimpleInputImpl(identifiers[0][1]),
+            new SimpleInputImpl(identifiers[0][2])
+        };
+        
+        SimpleInput[] instance_1_input = new SimpleInputImpl[] {
+                new SimpleInputImpl(identifiers[1][0]),
+                new SimpleInputImpl(identifiers[1][1]),
+                new SimpleInputImpl(identifiers[1][2])
+        };
+        
+        // We test sending mock messages
+        
+        product.simple(instance_0_input[0]);
+        verify(service[0]).simple(instance_0_input[0]);
+        
+        product.simple(instance_0_input[1]);
+        product.simple(instance_0_input[2]);
+        
+        verify(service[0]).simple(instance_0_input[1]);
+        verify(service[0]).simple(instance_0_input[2]);
+        
+        product.simple(instance_1_input[0]);
+        verify(service[1]).simple(instance_1_input[0]);
+    }
+
+    private InstanceIdentifier[][] identifiers(int serviceSize, int instancesPerService) {
+        InstanceIdentifier[][] ret = new InstanceIdentifier[serviceSize][];
+        int service = 0;
+        for (int i = 0;i<serviceSize;i++) {
+            
+            InstanceIdentifier[] instanceIdentifiers = new InstanceIdentifier[instancesPerService];
+            ret[i] = instanceIdentifiers;
+            for(int id = 0;id<instancesPerService;id++) {
+                instanceIdentifiers[id] = referencableIdentifier(service*instancesPerService+id);
+            }
+            service++;
+        }
+        
+        return ret;
+    }
+
+    private InstanceIdentifier referencableIdentifier(int i) {
+        ReferencableObjectKey key = new ReferencableObjectKey(i);
+        IdentifiableItem<ReferencableObject,ReferencableObjectKey> pathArg = new IdentifiableItem<>(ReferencableObject.class,key);
+        return new InstanceIdentifier(Arrays.<PathArgument>asList(pathArg), ReferencableObject.class);
+    }
+
+    private static class SimpleInputImpl implements SimpleInput {
+        private final InstanceIdentifier identifier;
+
+        public SimpleInputImpl(InstanceIdentifier _identifier) {
+            this.identifier = _identifier;
+        }
+
+        @Override
+        public <E extends Augmentation<SimpleInput>> E getAugmentation(Class<E> augmentationType) {
+            return null;
+        }
+
+        @Override
+        public InstanceIdentifier getIdentifier() {
+            return this.identifier;
+        }
+    }
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/BarUpdate.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/BarUpdate.java
new file mode 100644 (file)
index 0000000..b64ebdf
--- /dev/null
@@ -0,0 +1,7 @@
+package org.opendaylight.controller.sal.binding.test.mock;
+
+import org.opendaylight.yangtools.yang.binding.Notification;
+
+public interface BarUpdate extends Grouping,Notification {
+
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooListener.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooListener.java
new file mode 100644 (file)
index 0000000..3629689
--- /dev/null
@@ -0,0 +1,10 @@
+package org.opendaylight.controller.sal.binding.test.mock;
+
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+
+public interface FooListener extends NotificationListener {
+
+    void onFooUpdate(FooUpdate notification);
+    void onBarUpdate(BarUpdate notification);
+    
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooService.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooService.java
new file mode 100644 (file)
index 0000000..3161e93
--- /dev/null
@@ -0,0 +1,16 @@
+package org.opendaylight.controller.sal.binding.test.mock;
+
+import java.util.concurrent.Future;
+
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+public interface FooService extends RpcService {
+    
+    Future<RpcResult<Void>> foo();
+    
+    Future<RpcResult<Void>> simple(SimpleInput obj);
+    
+    Future<RpcResult<Void>> inheritedContextInput(InheritedContextInput obj);
+
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooUpdate.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/FooUpdate.java
new file mode 100644 (file)
index 0000000..a5a5eb8
--- /dev/null
@@ -0,0 +1,7 @@
+package org.opendaylight.controller.sal.binding.test.mock;
+
+import org.opendaylight.yangtools.yang.binding.Notification;
+
+public interface FooUpdate extends Notification {
+
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/Grouping.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/Grouping.java
new file mode 100644 (file)
index 0000000..86624e0
--- /dev/null
@@ -0,0 +1,11 @@
+package org.opendaylight.controller.sal.binding.test.mock;
+
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext;
+
+public interface Grouping {
+
+    @RoutingContext(BaseIdentity.class)
+    InstanceIdentifier getInheritedIdentifier();
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/InheritedContextInput.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/InheritedContextInput.java
new file mode 100644 (file)
index 0000000..39b20cc
--- /dev/null
@@ -0,0 +1,5 @@
+package org.opendaylight.controller.sal.binding.test.mock;
+
+public interface InheritedContextInput extends Grouping {
+
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/ReferencableObject.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/ReferencableObject.java
new file mode 100644 (file)
index 0000000..8e0d457
--- /dev/null
@@ -0,0 +1,8 @@
+package org.opendaylight.controller.sal.binding.test.mock;
+
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.Identifiable;
+
+public interface ReferencableObject extends DataObject,Identifiable<ReferencableObjectKey> {
+
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/ReferencableObjectKey.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/ReferencableObjectKey.java
new file mode 100644 (file)
index 0000000..d2e1817
--- /dev/null
@@ -0,0 +1,44 @@
+package org.opendaylight.controller.sal.binding.test.mock;
+
+import org.opendaylight.yangtools.yang.binding.Identifier;
+
+public class ReferencableObjectKey implements Identifier<ReferencableObject> {
+
+    final Integer value;
+    
+    public ReferencableObjectKey(Integer _value) {
+        this.value = _value;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        ReferencableObjectKey other = (ReferencableObjectKey) obj;
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        return "ReferencableObjectKey [value=" + value + "]";
+    }
+    
+    
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/SimpleInput.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/mock/SimpleInput.java
new file mode 100644 (file)
index 0000000..dedbd98
--- /dev/null
@@ -0,0 +1,13 @@
+package org.opendaylight.controller.sal.binding.test.mock;
+
+import org.opendaylight.yangtools.yang.binding.Augmentable;
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext;
+
+public interface SimpleInput extends DataObject,Augmentable<SimpleInput> {
+
+    @RoutingContext(BaseIdentity.class)
+    InstanceIdentifier getIdentifier();
+}
index 8be254e6b5eef24bae8eaf087289a81fbf3a851e..d7dea84686eca42ecf15a91e19dd1d58542a6845 100644 (file)
@@ -21,7 +21,7 @@
     <!-- Sonar properties using jacoco to retrieve integration test results -->
     <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
     <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
-    <sonar.jacoco.Reportpath>target/jacoco.exec</sonar.jacoco.Reportpath>
+    <sonar.jacoco.reportpath>target/jacoco.exec</sonar.jacoco.reportpath>
     <sonar.jacoco.itReportPath>target/jacoco-it.exec</sonar.jacoco.itReportPath>
     <sonar.language>java</sonar.language>
   </properties>
@@ -31,7 +31,7 @@
         <plugin>
           <groupId>org.jacoco</groupId>
           <artifactId>jacoco-maven-plugin</artifactId>
-          <version>0.5.3.201107060350</version>
+          <version>${jacoco.version}</version>
         </plugin>
       </plugins>
     </pluginManagement>
index 527dd0a02b3671451d6e612d3df25d69c7b0d1ba..d620d676f495bb286cca63dbb10ea0a6d19da81e 100644 (file)
     <!-- Sonar jacoco plugin to get integration test coverage info -->
     <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
     <sonar.jacoco.reportPath>../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
-    <sonar.jacoco.itReportPath>../implementaiton/target/jacoco-it.exec</sonar.jacoco.itReportPath>
+    <sonar.jacoco.itReportPath>../implementation/target/jacoco-it.exec</sonar.jacoco.itReportPath>
     <sonar.language>java</sonar.language>
   </properties>
   <build>
       <plugin>
         <groupId>org.jacoco</groupId>
         <artifactId>jacoco-maven-plugin</artifactId>
-        <version>0.5.3.201107060350</version>
+        <version>${jacoco.version}</version>
         <configuration>
           <destFile>../implementation/target/jacoco-it.exec</destFile>
           <includes>org.opendaylight.controller.*</includes>
index 607c42858e7b4ee52d8e9974c4d677ce1d61cc2f..14a056d5fee3b50ba27f2fe240d378495dc7ad85 100644 (file)
@@ -32,7 +32,7 @@
         <plugin>
           <groupId>org.jacoco</groupId>
           <artifactId>jacoco-maven-plugin</artifactId>
-          <version>0.5.3.201107060350</version>
+          <version>${jacoco.version}</version>
         </plugin>
       </plugins>
     </pluginManagement>
index 522f45946d98fbdc170db4ec9531d9128df53f97..4bb6438b32ce40a71b89796ecc81e91e7382c543 100644 (file)
@@ -14,10 +14,8 @@ import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
-import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType;
 import org.opendaylight.controller.sal.utils.GUIField;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -116,32 +114,12 @@ public class SpanConfig implements Serializable {
     }
 
     public ArrayList<NodeConnector> getPortArrayList() {
-        Node node = Node.fromString(nodeId);
         ArrayList<NodeConnector> portList = new ArrayList<NodeConnector>();
         String[] elemArray = spanPort.split(",");
         for (String elem : elemArray) {
-            if (elem.contains("-")) {
-                String[] limits = elem.split("-");
-                for (short j = Short.valueOf(limits[0]); j <= Short
-                        .valueOf(limits[1]); j++) {
-                    try {
-                        portList.add(new NodeConnector(
-                                NodeConnectorIDType.OPENFLOW, Short.valueOf(j),
-                                node));
-                    } catch (ConstructionException e) {
-                        logger.error("",e);
-                    }
-                }
-            } else {
-                try {
-                    portList.add(new NodeConnector(
-                            NodeConnectorIDType.OPENFLOW, Short.valueOf(elem),
-                            node));
-                } catch (NumberFormatException e) {
-                    logger.error("",e);
-                } catch (ConstructionException e) {
-                    logger.error("",e);
-                }
+            NodeConnector nodeConnector = NodeConnector.fromString(elem);
+            if (nodeConnector != null) {
+                portList.add(nodeConnector);
             }
         }
         return portList;
index 1b09f3c34d62a26a204288c9143fc8b1e54f3dd4..ee126f3408ce51d6b1036f351f4ffb7a1be218b8 100644 (file)
@@ -32,7 +32,7 @@
         <plugin>
           <groupId>org.jacoco</groupId>
           <artifactId>jacoco-maven-plugin</artifactId>
-          <version>0.5.3.201107060350</version>
+          <version>${jacoco.version}</version>
         </plugin>
       </plugins>
     </pluginManagement>
index d571d9df532d682650033bdf0ae94eca349d176a..3fc63001d4dcc63e5f665b051cf0e5f253ece9c9 100644 (file)
     <!-- Sonar jacoco plugin to get integration test coverage info -->
     <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
     <sonar.jacoco.reportPath>../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
-    <sonar.jacoco.itReportPath>../implementaiton/target/jacoco-it.exec</sonar.jacoco.itReportPath>
+    <sonar.jacoco.itReportPath>../implementation/target/jacoco-it.exec</sonar.jacoco.itReportPath>
     <sonar.language>java</sonar.language>
   </properties>
 
   <build>
-    <pluginManagement>
-      <plugins>
-        <plugin>
-          <groupId>org.jacoco</groupId>
-          <artifactId>jacoco-maven-plugin</artifactId>
-          <version>0.5.3.201107060350</version>
-        </plugin>
-      </plugins>
-    </pluginManagement>
     <plugins>
       <plugin>
         <groupId>org.jacoco</groupId>
         <artifactId>jacoco-maven-plugin</artifactId>
-        <version>0.5.3.201107060350</version>
+        <version>${jacoco.version}</version>
         <configuration>
           <destFile>../implementation/target/jacoco-it.exec</destFile>
           <includes>org.opendaylight.controller.*</includes>
similarity index 97%
rename from opendaylight/topologymanager/pom.xml
rename to opendaylight/topologymanager/implementation/pom.xml
index 98bc0e42c81cf0cb08b7bcd5225289726c67b84e..399f878223aa639e5acd421ecb55b7134ab83d12 100755 (executable)
@@ -6,7 +6,7 @@
     <groupId>org.opendaylight.controller</groupId>
     <artifactId>commons.opendaylight</artifactId>
     <version>1.4.0-SNAPSHOT</version>
-    <relativePath>../commons/opendaylight</relativePath>
+    <relativePath>../../commons/opendaylight</relativePath>
   </parent>
   <scm>
     <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>