Merge "fix bug 431"
authorTony Tkacik <ttkacik@cisco.com>
Tue, 25 Feb 2014 12:02:03 +0000 (12:02 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 25 Feb 2014 12:02:03 +0000 (12:02 +0000)
43 files changed:
opendaylight/commons/opendaylight/pom.xml
opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/IdentityAttributeRef.java
opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/JmxAttribute.java
opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ModuleIdentifier.java
opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ValidationException.java
opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/CommitStatus.java
opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/ObjectNameUtil.java
opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/constants/ConfigRegistryConstants.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigRegistryImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionControllerImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ModuleInternalTransactionalInfo.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ServiceReferenceRegistryImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/TransactionIdentifier.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/TransactionStatus.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AbstractDynamicWrapper.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AnnotationsHelper.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AttributeHolder.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/factoriesresolver/HierarchicalConfigMBeanFactoriesHolder.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/InternalJMXRegistrator.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/ServiceReference.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/TransactionJMXRegistrator.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BundleContextBackedModuleFactoriesResolver.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/FtlFilePersister.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/ModuleMXBeanEntryBuilder.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/TOAttribute.java
opendaylight/config/yang-test/src/main/java/org/opendaylight/controller/config/yang/test/impl/IdentityTestModule.java
opendaylight/config/yang-test/src/main/java/org/opendaylight/controller/config/yang/test/impl/IdentityTestModuleStub.txt
opendaylight/distribution/opendaylight/src/main/resources/run.sh
opendaylight/md-sal/pom.xml
opendaylight/md-sal/sal-binding-it/pom.xml
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Broker.java
opendaylight/md-sal/sal-restconf-broker/src/main/java/org/opendaylight/controller/sal/restconf/broker/client/SalRemoteClient.java [new file with mode: 0644]
opendaylight/md-sal/sal-restconf-broker/src/main/java/org/opendaylight/controller/sal/restconf/broker/client/SalRemoteClientDeployer.java [new file with mode: 0644]
opendaylight/md-sal/sal-restconf-broker/src/main/java/org/opendaylight/controller/sal/restconf/broker/client/SalRemoteClientImpl.java [new file with mode: 0644]
opendaylight/md-sal/sal-restconf-broker/src/main/java/org/opendaylight/controller/sal/restconf/broker/impl/DataBrokerServiceImpl.java
opendaylight/netconf/netconf-it/pom.xml
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/pax/IdentityRefNetconfTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-it/src/test/resources/controller.xml [new file with mode: 0644]
opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/commit.xml [new file with mode: 0644]
opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/editConfig_identities.xml [new file with mode: 0644]
opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/getConfig.xml [new file with mode: 0644]

index 43b69e4d87d4eb3838a2ff2945b3195d1f5aefab..43e254c88d2ad366b9a76c662a17c7fefef664fa 100644 (file)
     <java.version.target>1.7</java.version.target>
     <!-- enforcer version -->
     <enforcer.version>1.3.1</enforcer.version>
+    <xtend.version>2.4.3</xtend.version>
+    <xtend.dstdir>${project.build.directory}/generated-sources/xtend-gen</xtend.dstdir>
   </properties>
 
   <dependencyManagement>
       </dependency>
 
         <!-- md-sal -->
+        <dependency>
+            <groupId>org.eclipse.xtend</groupId>
+            <artifactId>org.eclipse.xtend.lib</artifactId>
+            <version>${xtend.version}</version>
+        </dependency>
         <dependency>
           <groupId>org.opendaylight.controller</groupId>
           <artifactId>sal-common</artifactId>
           <artifactId>config-persister-impl</artifactId>
           <version>${netconf.version}</version>
         </dependency>
-        <dependency>
-          <groupId>${project.groupId}</groupId>
-          <artifactId>ietf-netconf-monitoring</artifactId>
-          <version>${netconf.version}</version>
-        </dependency>
-        <dependency>
-          <groupId>${project.groupId}</groupId>
-          <artifactId>ietf-netconf-monitoring-extension</artifactId>
-          <version>${netconf.version}</version>
-        </dependency>
 
          <!-- threadpool -->
           <dependency>
             <testTarget>${java.version.target}</testTarget>
           </configuration>
        </plugin>
+          <plugin>
+              <groupId>org.eclipse.xtend</groupId>
+              <artifactId>xtend-maven-plugin</artifactId>
+              <version>${xtend.version}</version>
+              <executions>
+                  <execution>
+                      <goals>
+                          <goal>compile</goal>
+                      </goals>
+                      <configuration>
+                          <outputDirectory>${xtend.dstdir}</outputDirectory>
+                      </configuration>
+                  </execution>
+              </executions>
+          </plugin>
       </plugins>
     </pluginManagement>
   </build>
index 73737593cf6af9359660147a4fb44d145809f6b5..5ad6e0da8d2bf8a29d8d403783e378c5ab950346 100644 (file)
@@ -19,8 +19,9 @@ public final class IdentityAttributeRef {
 
     @ConstructorProperties(QNAME_ATTR_NAME)
     public IdentityAttributeRef(String qNameOfIdentity) {
-        if (qNameOfIdentity == null)
+        if (qNameOfIdentity == null) {
             throw new NullPointerException("Parameter " + QNAME_ATTR_NAME + " is null");
+        }
         this.qNameOfIdentity = qNameOfIdentity;
     }
 
@@ -46,12 +47,18 @@ public final class IdentityAttributeRef {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o) return true;
-        if (!(o instanceof IdentityAttributeRef)) return false;
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof IdentityAttributeRef)) {
+            return false;
+        }
 
         IdentityAttributeRef that = (IdentityAttributeRef) o;
 
-        if (!qNameOfIdentity.equals(that.qNameOfIdentity)) return false;
+        if (!qNameOfIdentity.equals(that.qNameOfIdentity)) {
+            return false;
+        }
 
         return true;
     }
index 96deb051ef91a1f1f4a3d629fc7984626ddf0dc9..244f22f58efdd5b1615806a2859fd50902b79172 100644 (file)
@@ -15,8 +15,9 @@ public class JmxAttribute {
     private final String attributeName;
 
     public JmxAttribute(String attributeName) {
-        if (attributeName == null)
+        if (attributeName == null) {
             throw new NullPointerException("Parameter 'attributeName' is null");
+        }
         this.attributeName = attributeName;
     }
 
@@ -26,16 +27,19 @@ public class JmxAttribute {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o)
+        if (this == o) {
             return true;
-        if (o == null || getClass() != o.getClass())
+        }
+        if (o == null || getClass() != o.getClass()) {
             return false;
+        }
 
         JmxAttribute that = (JmxAttribute) o;
 
         if (attributeName != null ? !attributeName.equals(that.attributeName)
-                : that.attributeName != null)
+                : that.attributeName != null) {
             return false;
+        }
 
         return true;
     }
index c654f5fe0a3c97bacb0885df0857ca804db7939f..7baaf9f6e45021bb87dced0ee189fa889767e52d 100644 (file)
@@ -14,12 +14,12 @@ public class ModuleIdentifier implements Identifier {
     private final String factoryName, instanceName;
 
     public ModuleIdentifier(String factoryName, String instanceName) {
-        if (factoryName == null)
-            throw new IllegalArgumentException(
-                    "Parameter 'factoryName' is null");
-        if (instanceName == null)
-            throw new IllegalArgumentException(
-                    "Parameter 'instanceName' is null");
+        if (factoryName == null) {
+            throw new IllegalArgumentException("Parameter 'factoryName' is null");
+        }
+        if (instanceName == null) {
+            throw new IllegalArgumentException("Parameter 'instanceName' is null");
+        }
         this.factoryName = factoryName;
         this.instanceName = instanceName;
     }
@@ -34,17 +34,21 @@ public class ModuleIdentifier implements Identifier {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o)
+        if (this == o) {
             return true;
-        if (o == null || getClass() != o.getClass())
+        }
+        if (o == null || getClass() != o.getClass()) {
             return false;
+        }
 
         ModuleIdentifier that = (ModuleIdentifier) o;
 
-        if (!factoryName.equals(that.factoryName))
+        if (!factoryName.equals(that.factoryName)) {
             return false;
-        if (!instanceName.equals(that.instanceName))
+        }
+        if (!instanceName.equals(that.instanceName)) {
             return false;
+        }
 
         return true;
     }
index 68cd58d3a2a0e3f55fa073c26a9672259f940f1a..82b73d419e402a31f85a4dfeba7266c26d86b802 100644 (file)
@@ -120,23 +120,30 @@ public class ValidationException extends Exception {
 
         @Override
         public boolean equals(Object obj) {
-            if (this == obj)
+            if (this == obj) {
                 return true;
-            if (obj == null)
+            }
+            if (obj == null) {
                 return false;
-            if (getClass() != obj.getClass())
+            }
+            if (getClass() != obj.getClass()) {
                 return false;
+            }
             ExceptionMessageWithStackTrace other = (ExceptionMessageWithStackTrace) obj;
             if (message == null) {
-                if (other.message != null)
+                if (other.message != null) {
                     return false;
-            } else if (!message.equals(other.message))
+                }
+            } else if (!message.equals(other.message)) {
                 return false;
+            }
             if (stackTrace == null) {
-                if (other.stackTrace != null)
+                if (other.stackTrace != null) {
                     return false;
-            } else if (!stackTrace.equals(other.stackTrace))
+                }
+            } else if (!stackTrace.equals(other.stackTrace)) {
                 return false;
+            }
             return true;
         }
 
index bd53bd4e581dc7285fcd8b874fbae177a8cc13c2..4f9ea7ac6b57521697f85ca7e4cde7930601ad1e 100644 (file)
@@ -7,32 +7,27 @@
  */
 package org.opendaylight.controller.config.api.jmx;
 
+import javax.annotation.concurrent.Immutable;
+import javax.management.ObjectName;
 import java.beans.ConstructorProperties;
 import java.util.Collections;
 import java.util.List;
 
-import javax.annotation.concurrent.Immutable;
-import javax.management.ObjectName;
-
 @Immutable
 public class CommitStatus {
     private final List<ObjectName> newInstances, reusedInstances,
             recreatedInstances;
 
     /**
-     *
-     * @param newInstances
-     *            newly created instances
-     * @param reusedInstances
-     *            reused instances
-     * @param recreatedInstances
-     *            recreated instances
+     * @param newInstances       newly created instances
+     * @param reusedInstances    reused instances
+     * @param recreatedInstances recreated instances
      */
-    @ConstructorProperties({ "newInstances", "reusedInstances",
-            "recreatedInstances" })
+    @ConstructorProperties({"newInstances", "reusedInstances",
+            "recreatedInstances"})
     public CommitStatus(List<ObjectName> newInstances,
-            List<ObjectName> reusedInstances,
-            List<ObjectName> recreatedInstances) {
+                        List<ObjectName> reusedInstances,
+                        List<ObjectName> recreatedInstances) {
         this.newInstances = Collections.unmodifiableList(newInstances);
         this.reusedInstances = Collections.unmodifiableList(reusedInstances);
         this.recreatedInstances = Collections
@@ -40,7 +35,6 @@ public class CommitStatus {
     }
 
     /**
-     *
      * @return list of objectNames representing newly created instances
      */
     public List<ObjectName> getNewInstances() {
@@ -48,7 +42,6 @@ public class CommitStatus {
     }
 
     /**
-     *
      * @return list of objectNames representing reused instances
      */
     public List<ObjectName> getReusedInstances() {
@@ -56,7 +49,6 @@ public class CommitStatus {
     }
 
     /**
-     *
      * @return list of objectNames representing recreated instances
      */
     public List<ObjectName> getRecreatedInstances() {
@@ -72,7 +64,7 @@ public class CommitStatus {
         result = prime
                 * result
                 + ((recreatedInstances == null) ? 0 : recreatedInstances
-                        .hashCode());
+                .hashCode());
         result = prime * result
                 + ((reusedInstances == null) ? 0 : reusedInstances.hashCode());
         return result;
@@ -80,28 +72,37 @@ public class CommitStatus {
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         CommitStatus other = (CommitStatus) obj;
         if (newInstances == null) {
-            if (other.newInstances != null)
+            if (other.newInstances != null) {
                 return false;
-        } else if (!newInstances.equals(other.newInstances))
+            }
+        } else if (!newInstances.equals(other.newInstances)) {
             return false;
+        }
         if (recreatedInstances == null) {
-            if (other.recreatedInstances != null)
+            if (other.recreatedInstances != null) {
                 return false;
-        } else if (!recreatedInstances.equals(other.recreatedInstances))
+            }
+        } else if (!recreatedInstances.equals(other.recreatedInstances)) {
             return false;
+        }
         if (reusedInstances == null) {
-            if (other.reusedInstances != null)
+            if (other.reusedInstances != null) {
                 return false;
-        } else if (!reusedInstances.equals(other.reusedInstances))
+            }
+        } else if (!reusedInstances.equals(other.reusedInstances)) {
             return false;
+        }
         return true;
     }
 
index 3baa1039e0bd1c868c28b6d8d5f7ea35c8da3dc7..d60e6086176daebd69f58a795ccadd4f24eca4de 100644 (file)
@@ -11,6 +11,7 @@ import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.opendaylight.controller.config.api.jmx.constants.ConfigRegistryConstants;
 
 import javax.annotation.concurrent.ThreadSafe;
+import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -46,8 +47,8 @@ public class ObjectNameUtil {
     public static ObjectName createON(String on) {
         try {
             return new ObjectName(on);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
+        } catch (MalformedObjectNameException e) {
+            throw new IllegalArgumentException(e);
         }
     }
 
@@ -63,8 +64,8 @@ public class ObjectNameUtil {
         Hashtable<String, String> table = new Hashtable<>(attribs);
         try {
             return new ObjectName(domain, table);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
+        } catch (MalformedObjectNameException e) {
+            throw new IllegalArgumentException(e);
         }
 
     }
@@ -116,8 +117,7 @@ public class ObjectNameUtil {
     public static String getServiceQName(ObjectName objectName) {
         checkType(objectName, TYPE_SERVICE_REFERENCE);
         String quoted = objectName.getKeyProperty(SERVICE_QNAME_KEY);
-        String result = unquoteAndUnescape(objectName, quoted);
-        return result;
+        return unquoteAndUnescape(objectName, quoted);
     }
 
     // ObjectName supports quotation and ignores tokens like =, but fails to ignore ? sign.
@@ -292,8 +292,8 @@ public class ObjectNameUtil {
         }
     }
 
-    public static void checkTypeOneOf(ObjectName objectName, String ... types) {
-        for(String type: types) {
+    public static void checkTypeOneOf(ObjectName objectName, String... types) {
+        for (String type : types) {
             if (type.equals(objectName.getKeyProperty(TYPE_KEY))) {
                 return;
             }
@@ -304,10 +304,12 @@ public class ObjectNameUtil {
 
     public static ObjectName createModulePattern(String moduleName,
                                                  String instanceName) {
-        if (moduleName == null)
+        if (moduleName == null) {
             moduleName = "*";
-        if (instanceName == null)
+        }
+        if (instanceName == null) {
             instanceName = "*";
+        }
         // do not return object names containing transaction name
         ObjectName namePattern = ObjectNameUtil
                 .createON(ObjectNameUtil.ON_DOMAIN + ":"
@@ -343,13 +345,15 @@ public class ObjectNameUtil {
                                           String expectedType) {
         checkType(objectName, expectedType);
         String factoryName = getFactoryName(objectName);
-        if (factoryName == null)
+        if (factoryName == null) {
             throw new IllegalArgumentException(
                     "ObjectName does not contain module name");
+        }
         String instanceName = getInstanceName(objectName);
-        if (instanceName == null)
+        if (instanceName == null) {
             throw new IllegalArgumentException(
                     "ObjectName does not contain instance name");
+        }
         return new ModuleIdentifier(factoryName, instanceName);
     }
 
index 81a29bf7b3198215bcba9eb5a92732df3238f77d..1d9563bf4e1d7733b170cdd6c092f473a8baae20 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.config.api.jmx.constants;
 
+import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 
 public class ConfigRegistryConstants {
@@ -19,7 +20,7 @@ public class ConfigRegistryConstants {
 
     public static final ObjectName OBJECT_NAME = createONWithDomainAndType(TYPE_CONFIG_REGISTRY);
 
-    public static String GET_AVAILABLE_MODULE_NAMES_ATTRIBUT_NAME = "AvailableModuleNames";
+    public static final String GET_AVAILABLE_MODULE_NAMES_ATTRIBUT_NAME = "AvailableModuleNames";
 
     public static ObjectName createONWithDomainAndType(String type) {
         return createON(ON_DOMAIN, TYPE_KEY, type);
@@ -28,8 +29,8 @@ public class ConfigRegistryConstants {
     public static ObjectName createON(String name, String key, String value) {
         try {
             return new ObjectName(name, key, value);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
+        } catch (MalformedObjectNameException e) {
+            throw new IllegalArgumentException(e);
         }
 
     }
index 39682fa6b470226400b47a6aa0fdbec24a4bf522..8f6a4654b26d2d9f2548c38e91ea9b82445b326f 100644 (file)
@@ -105,27 +105,27 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
     private List<ModuleFactory> lastListOfFactories = Collections.emptyList();
 
     @GuardedBy("this") // switched in every 2ndPC
-    private CloseableServiceReferenceReadableRegistry  readableSRRegistry = ServiceReferenceRegistryImpl.createInitialSRLookupRegistry();
+    private CloseableServiceReferenceReadableRegistry readableSRRegistry = ServiceReferenceRegistryImpl.createInitialSRLookupRegistry();
 
     // constructor
     public ConfigRegistryImpl(ModuleFactoriesResolver resolver,
-            MBeanServer configMBeanServer, CodecRegistry codecRegistry) {
+                              MBeanServer configMBeanServer, CodecRegistry codecRegistry) {
         this(resolver, configMBeanServer,
                 new BaseJMXRegistrator(configMBeanServer), codecRegistry);
     }
 
     // constructor
     public ConfigRegistryImpl(ModuleFactoriesResolver resolver,
-            MBeanServer configMBeanServer,
-            BaseJMXRegistrator baseJMXRegistrator, CodecRegistry codecRegistry) {
+                              MBeanServer configMBeanServer,
+                              BaseJMXRegistrator baseJMXRegistrator, CodecRegistry codecRegistry) {
         this.resolver = resolver;
-        this.beanToOsgiServiceManager = new BeanToOsgiServiceManager();
+        beanToOsgiServiceManager = new BeanToOsgiServiceManager();
         this.configMBeanServer = configMBeanServer;
         this.baseJMXRegistrator = baseJMXRegistrator;
         this.codecRegistry = codecRegistry;
-        this.registryMBeanServer = MBeanServerFactory
+        registryMBeanServer = MBeanServerFactory
                 .createMBeanServer("ConfigRegistry" + configMBeanServer.getDefaultDomain());
-        this.transactionsMBeanServer = MBeanServerFactory
+        transactionsMBeanServer = MBeanServerFactory
                 .createMBeanServer("ConfigTransactions" + configMBeanServer.getDefaultDomain());
     }
 
@@ -181,6 +181,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
      * {@inheritDoc}
      */
     @Override
+    @SuppressWarnings("PMD.AvoidCatchingThrowable")
     public synchronized CommitStatus commitConfig(ObjectName transactionControllerON)
             throws ConflictingVersionException, ValidationException {
         final String transactionName = ObjectNameUtil
@@ -211,7 +212,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
             return secondPhaseCommit(
                     configTransactionController, commitInfo);
         } catch (Throwable t) { // some libs throw Errors: e.g.
-                                // javax.xml.ws.spi.FactoryFinder$ConfigurationError
+            // javax.xml.ws.spi.FactoryFinder$ConfigurationError
             isHealthy = false;
             logger.error("Configuration Transaction failed on 2PC, server is unhealthy", t);
             if (t instanceof RuntimeException) {
@@ -219,7 +220,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
             } else if (t instanceof Error) {
                 throw (Error) t;
             } else {
-                throw new RuntimeException(t);
+                throw new IllegalStateException(t);
             }
         }
     }
@@ -232,7 +233,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
         for (DestroyedModule toBeDestroyed : commitInfo
                 .getDestroyedFromPreviousTransactions()) {
             toBeDestroyed.close(); // closes instance (which should close
-                                   // runtime jmx registrator),
+            // runtime jmx registrator),
             // also closes osgi registration and ModuleJMXRegistrator
             // registration
             currentConfig.remove(toBeDestroyed.getIdentifier());
@@ -278,9 +279,10 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
         for (ModuleIdentifier moduleIdentifier : orderedModuleIdentifiers) {
             ModuleInternalTransactionalInfo entry = commitInfo.getCommitted()
                     .get(moduleIdentifier);
-            if (entry == null)
+            if (entry == null) {
                 throw new NullPointerException("Module not found "
                         + moduleIdentifier);
+            }
             Module module = entry.getModule();
             ObjectName primaryReadOnlyON = ObjectNameUtil
                     .createReadOnlyModuleON(moduleIdentifier);
@@ -342,7 +344,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
             // register to OSGi
             if (osgiRegistration == null) {
                 ModuleFactory moduleFactory = entry.getModuleFactory();
-                if(moduleFactory != null) {
+                if (moduleFactory != null) {
                     BundleContext bc = configTransactionController.
                             getModuleFactoryBundleContext(moduleFactory.getImplementationName());
                     osgiRegistration = beanToOsgiServiceManager.registerToOsgi(module.getClass(),
@@ -369,8 +371,8 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
         version = configTransactionController.getVersion();
 
         // switch readable Service Reference Registry
-        this.readableSRRegistry.close();
-        this.readableSRRegistry = ServiceReferenceRegistryImpl.createSRReadableRegistry(
+        readableSRRegistry.close();
+        readableSRRegistry = ServiceReferenceRegistryImpl.createSRReadableRegistry(
                 configTransactionController.getWritableRegistry(), this, baseJMXRegistrator);
 
         return new CommitStatus(newInstances, reusedInstances,
@@ -485,7 +487,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
      */
     @Override
     public Set<ObjectName> lookupConfigBeans(String moduleName,
-            String instanceName) {
+                                             String instanceName) {
         ObjectName namePattern = ObjectNameUtil.createModulePattern(moduleName,
                 instanceName);
         return baseJMXRegistrator.queryNames(namePattern, null);
@@ -504,11 +506,13 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
      */
     @Override
     public Set<ObjectName> lookupRuntimeBeans(String moduleName,
-            String instanceName) {
-        if (moduleName == null)
+                                              String instanceName) {
+        if (moduleName == null) {
             moduleName = "*";
-        if (instanceName == null)
+        }
+        if (instanceName == null) {
             instanceName = "*";
+        }
         ObjectName namePattern = ObjectNameUtil.createRuntimeBeanPattern(
                 moduleName, instanceName);
         return baseJMXRegistrator.queryNames(namePattern, null);
@@ -646,7 +650,6 @@ class TransactionsHolder {
      * {@link ConfigTransactionControllerInternal} instances, because platform
      * MBeanServer transforms mbeans into another representation. Map is cleaned
      * every time current transactions are requested.
-     *
      */
     @GuardedBy("ConfigRegistryImpl.this")
     private final Map<String /* transactionName */, ConfigTransactionControllerInternal> transactions = new HashMap<>();
@@ -655,7 +658,7 @@ class TransactionsHolder {
      * Can only be called from within synchronized method.
      */
     public void add(String transactionName,
-            ConfigTransactionControllerInternal transactionController) {
+                    ConfigTransactionControllerInternal transactionController) {
         Object oldValue = transactions.put(transactionName,
                 transactionController);
         if (oldValue != null) {
@@ -674,7 +677,7 @@ class TransactionsHolder {
     public Map<String, ConfigTransactionControllerInternal> getCurrentTransactions() {
         // first, remove closed transaction
         for (Iterator<Entry<String, ConfigTransactionControllerInternal>> it = transactions
-                .entrySet().iterator(); it.hasNext();) {
+                .entrySet().iterator(); it.hasNext(); ) {
             Entry<String, ConfigTransactionControllerInternal> entry = it
                     .next();
             if (entry.getValue().isClosed()) {
index 0ec6969802438b2c8e71856bf64cdeeb7fbcfb74..f7afded51ff0c81468b0678c0b964485cd1b0b8c 100644 (file)
@@ -53,7 +53,7 @@ import static java.lang.String.format;
 class ConfigTransactionControllerImpl implements
         ConfigTransactionControllerInternal,
         ConfigTransactionControllerImplMXBean,
-        Identifiable<TransactionIdentifier>{
+        Identifiable<TransactionIdentifier> {
     private static final Logger logger = LoggerFactory.getLogger(ConfigTransactionControllerImpl.class);
 
     private final ConfigTransactionLookupRegistry txLookupRegistry;
@@ -124,12 +124,12 @@ class ConfigTransactionControllerImpl implements
 
         List<ModuleFactory> toBeAdded = new ArrayList<>();
         List<ModuleFactory> toBeRemoved = new ArrayList<>();
-        for(ModuleFactory moduleFactory: factoriesHolder.getModuleFactories()) {
-            if (oldSet.contains(moduleFactory) == false){
+        for (ModuleFactory moduleFactory : factoriesHolder.getModuleFactories()) {
+            if (oldSet.contains(moduleFactory) == false) {
                 toBeAdded.add(moduleFactory);
             }
         }
-        for(ModuleFactory moduleFactory: lastListOfFactories){
+        for (ModuleFactory moduleFactory : lastListOfFactories) {
             if (newSet.contains(moduleFactory) == false) {
                 toBeRemoved.add(moduleFactory);
             }
@@ -151,7 +151,7 @@ class ConfigTransactionControllerImpl implements
         }
 
         // remove modules belonging to removed factories
-        for(ModuleFactory removedFactory: toBeRemoved){
+        for (ModuleFactory removedFactory : toBeRemoved) {
             List<ModuleIdentifier> modulesOfRemovedFactory = dependencyResolverManager.findAllByFactory(removedFactory);
             for (ModuleIdentifier name : modulesOfRemovedFactory) {
                 destroyModule(name);
@@ -189,7 +189,7 @@ class ConfigTransactionControllerImpl implements
 
     @Override
     public synchronized ObjectName createModule(String factoryName,
-            String instanceName) throws InstanceAlreadyExistsException {
+                                                String instanceName) throws InstanceAlreadyExistsException {
 
         transactionStatus.checkNotCommitStarted();
         transactionStatus.checkNotAborted();
@@ -213,11 +213,11 @@ class ConfigTransactionControllerImpl implements
             throws InstanceAlreadyExistsException {
 
         logger.debug("Adding module {} to transaction {}", moduleIdentifier, this);
-        if (moduleIdentifier.equals(module.getIdentifier())==false) {
+        if (moduleIdentifier.equals(module.getIdentifier()) == false) {
             throw new IllegalStateException("Incorrect name reported by module. Expected "
-             + moduleIdentifier + ", got " + module.getIdentifier());
+                    + moduleIdentifier + ", got " + module.getIdentifier());
         }
-        if (dependencyResolver.getIdentifier().equals(moduleIdentifier) == false ) {
+        if (dependencyResolver.getIdentifier().equals(moduleIdentifier) == false) {
             throw new IllegalStateException("Incorrect name reported by dependency resolver. Expected "
                     + moduleIdentifier + ", got " + dependencyResolver.getIdentifier());
         }
@@ -271,7 +271,7 @@ class ConfigTransactionControllerImpl implements
         // first remove refNames, it checks for objectname existence
         try {
             writableSRRegistry.removeServiceReferences(
-                    ObjectNameUtil.createTransactionModuleON(getTransactionName(),moduleIdentifier));
+                    ObjectNameUtil.createTransactionModuleON(getTransactionName(), moduleIdentifier));
         } catch (InstanceNotFoundException e) {
             logger.error("Possible code error: cannot find {} in {}", moduleIdentifier, writableSRRegistry);
             throw new IllegalStateException("Possible code error: cannot find " + moduleIdentifier, e);
@@ -294,8 +294,9 @@ class ConfigTransactionControllerImpl implements
 
     @Override
     public synchronized void validateConfig() throws ValidationException {
-        if (configBeanModificationDisabled.get())
+        if (configBeanModificationDisabled.get()) {
             throw new IllegalStateException("Cannot start validation");
+        }
         configBeanModificationDisabled.set(true);
         try {
             validate_noLocks();
@@ -383,7 +384,7 @@ class ConfigTransactionControllerImpl implements
                 logger.error("Commit failed on {} in transaction {}", name,
                         getTransactionIdentifier(), e);
                 internalAbort();
-                throw new RuntimeException(
+                throw new IllegalStateException(
                         format("Error - getInstance() failed for %s in transaction %s",
                                 name, getTransactionIdentifier()), e);
             }
index 0a4ceacb439c363a5884b0e2296089d6f10ab6ef..f5984334331ec2d7eb9d8c0d6bb07cfd1bc5f030 100644 (file)
@@ -7,16 +7,15 @@
  */
 package org.opendaylight.controller.config.manager.impl;
 
-import javax.annotation.Nullable;
-
 import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.opendaylight.controller.config.manager.impl.dynamicmbean.DynamicReadableWrapper;
-import org.opendaylight.controller.config.manager.impl.jmx.TransactionModuleJMXRegistrator
-        .TransactionModuleJMXRegistration;
+import org.opendaylight.controller.config.manager.impl.jmx.TransactionModuleJMXRegistrator.TransactionModuleJMXRegistration;
 import org.opendaylight.controller.config.spi.Module;
 import org.opendaylight.controller.config.spi.ModuleFactory;
 import org.opendaylight.yangtools.concepts.Identifiable;
 
+import javax.annotation.Nullable;
+
 public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdentifier> {
     private final ModuleIdentifier name;
     private final Module module;
@@ -27,10 +26,10 @@ public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdent
     private final boolean isDefaultBean;
 
     ModuleInternalTransactionalInfo(ModuleIdentifier name, Module module,
-            ModuleFactory moduleFactory,
-            ModuleInternalInfo maybeOldInternalInfo,
-            TransactionModuleJMXRegistration transactionModuleJMXRegistration,
-            boolean isDefaultBean) {
+                                    ModuleFactory moduleFactory,
+                                    ModuleInternalInfo maybeOldInternalInfo,
+                                    TransactionModuleJMXRegistration transactionModuleJMXRegistration,
+                                    boolean isDefaultBean) {
         this.name = name;
         this.module = module;
         this.moduleFactory = moduleFactory;
@@ -67,8 +66,9 @@ public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdent
 
     @Nullable
     public ModuleInternalInfo getOldInternalInfo() {
-        if (maybeOldInternalInfo == null)
+        if (maybeOldInternalInfo == null) {
             throw new NullPointerException();
+        }
         return maybeOldInternalInfo;
     }
 
index 0faa32b7dc4e181962802d8d5e1345472d8378d9..bf35fd1ed86f6b8249dcb4a7ca386d85ad2a53d1 100644 (file)
@@ -195,7 +195,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
 
         this.serviceReferenceRegistrator = serviceReferenceRegistratorFactory.create();
 
-        Map<String, Set<String /* QName */>> factoryNamesToQNames = new HashMap<>();
+        Map<String, Set<String /* QName */>> modifiableFactoryNamesToQNames = new HashMap<>();
         Set<ServiceInterfaceAnnotation> allAnnotations = new HashSet<>();
         Set<String /* qName */> allQNames = new HashSet<>();
         for (Entry<String, ModuleFactory> entry : factories.entrySet()) {
@@ -210,27 +210,27 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
             }
             allAnnotations.addAll(siAnnotations);
             allQNames.addAll(qNames);
-            factoryNamesToQNames.put(entry.getKey(), Collections.unmodifiableSet(qNames));
+            modifiableFactoryNamesToQNames.put(entry.getKey(), Collections.unmodifiableSet(qNames));
         }
-        this.factoryNamesToQNames = Collections.unmodifiableMap(factoryNamesToQNames);
+        this.factoryNamesToQNames = Collections.unmodifiableMap(modifiableFactoryNamesToQNames);
         this.allQNames = Collections.unmodifiableSet(allQNames);
         // fill namespacesToAnnotations
-        Map<String /* namespace */, Map<String /* localName */, ServiceInterfaceAnnotation>> namespacesToAnnotations =
+        Map<String /* namespace */, Map<String /* localName */, ServiceInterfaceAnnotation>> modifiableNamespacesToAnnotations =
                 new HashMap<>();
         for (ServiceInterfaceAnnotation sia : allAnnotations) {
-            Map<String, ServiceInterfaceAnnotation> ofNamespace = namespacesToAnnotations.get(sia.namespace());
+            Map<String, ServiceInterfaceAnnotation> ofNamespace = modifiableNamespacesToAnnotations.get(sia.namespace());
             if (ofNamespace == null) {
                 ofNamespace = new HashMap<>();
-                namespacesToAnnotations.put(sia.namespace(), ofNamespace);
+                modifiableNamespacesToAnnotations.put(sia.namespace(), ofNamespace);
             }
             if (ofNamespace.containsKey(sia.localName())) {
                 logger.error("Cannot construct namespacesToAnnotations map, conflict between local names in {}, offending local name: {}, map so far {}",
-                        sia.namespace(), sia.localName(), namespacesToAnnotations);
+                        sia.namespace(), sia.localName(), modifiableNamespacesToAnnotations);
                 throw new IllegalArgumentException("Conflict between local names in " + sia.namespace() + " : " + sia.localName());
             }
             ofNamespace.put(sia.localName(), sia);
         }
-        this.namespacesToAnnotations = Collections.unmodifiableMap(namespacesToAnnotations);
+        this.namespacesToAnnotations = Collections.unmodifiableMap(modifiableNamespacesToAnnotations);
         // copy refNames
         logger.trace("factoryNamesToQNames:{}", this.factoryNamesToQNames);
     }
index 28bd613648d31bfcb6072737b065ceaa07bf7390..15c69bf25fe4db456ae9a7890ad389f8f953251a 100644 (file)
@@ -28,15 +28,18 @@ public class TransactionIdentifier implements Identifier {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o)
+        if (this == o) {
             return true;
-        if (o == null || getClass() != o.getClass())
+        }
+        if (o == null || getClass() != o.getClass()) {
             return false;
+        }
 
         TransactionIdentifier that = (TransactionIdentifier) o;
 
-        if (name != null ? !name.equals(that.name) : that.name != null)
+        if (name != null ? !name.equals(that.name) : that.name != null) {
             return false;
+        }
 
         return true;
     }
index a25062074b8384837a46924d77dc0badc4a03eac..f86d6b1d818715481f601a4e366240aae2e5d4a5 100644 (file)
@@ -48,18 +48,21 @@ public class TransactionStatus {
     }
 
     public synchronized void checkNotCommitStarted() {
-        if (secondPhaseCommitStarted == true)
+        if (secondPhaseCommitStarted == true) {
             throw new IllegalStateException("Commit was triggered");
+        }
     }
 
     public synchronized void checkCommitStarted() {
-        if (secondPhaseCommitStarted == false)
+        if (secondPhaseCommitStarted == false) {
             throw new IllegalStateException("Commit was not triggered");
+        }
     }
 
     public synchronized void checkNotAborted() {
-        if (aborted == true)
+        if (aborted == true) {
             throw new IllegalStateException("Configuration was aborted");
+        }
     }
 
     public synchronized void checkNotCommitted() {
index ec9678fd2d7df3545f15bc5a8fa0e7b8129b5760..e3057a1179419bf6c42daafee1f48bbbd131e786 100644 (file)
@@ -39,7 +39,7 @@ import static java.lang.String.format;
  * during validation. Tracks dependencies for ordering purposes.
  */
 final class DependencyResolverImpl implements DependencyResolver,
-       Comparable<DependencyResolverImpl> {
+        Comparable<DependencyResolverImpl> {
     private static final Logger logger = LoggerFactory.getLogger(DependencyResolverImpl.class);
 
     private final ModulesHolder modulesHolder;
@@ -74,15 +74,15 @@ final class DependencyResolverImpl implements DependencyResolver,
             throw new NullPointerException(
                     "Parameter 'expectedServiceInterface' is null");
         }
-        if (jmxAttribute == null)
+        if (jmxAttribute == null) {
             throw new NullPointerException("Parameter 'jmxAttribute' is null");
+        }
 
         JmxAttributeValidationException.checkNotNull(dependentReadOnlyON,
                 "is null, expected dependency implementing "
                         + expectedServiceInterface, jmxAttribute);
 
 
-
         // check that objectName belongs to this transaction - this should be
         // stripped
         // in DynamicWritableWrapper
@@ -135,7 +135,7 @@ final class DependencyResolverImpl implements DependencyResolver,
     //TODO: check for cycles
     @Override
     public <T> T resolveInstance(Class<T> expectedType, ObjectName dependentReadOnlyON,
-            JmxAttribute jmxAttribute) {
+                                 JmxAttribute jmxAttribute) {
         if (expectedType == null || dependentReadOnlyON == null || jmxAttribute == null) {
             throw new IllegalArgumentException(format(
                     "Null parameters not allowed, got %s %s %s", expectedType,
@@ -161,8 +161,7 @@ final class DependencyResolverImpl implements DependencyResolver,
             throw new JmxAttributeValidationException(message, jmxAttribute);
         }
         try {
-            T result = expectedType.cast(instance);
-            return result;
+            return expectedType.cast(instance);
         } catch (ClassCastException e) {
             String message = format(
                     "Instance cannot be cast to expected type. Instance class is %s , "
@@ -178,7 +177,7 @@ final class DependencyResolverImpl implements DependencyResolver,
         IdentityCodec<?> identityCodec = codecRegistry.getIdentityCodec();
         Class<? extends BaseIdentity> deserialized = identityCodec.deserialize(qName);
         if (deserialized == null) {
-            throw new RuntimeException("Unable to retrieve identity class for " + qName + ", null response from "
+            throw new IllegalStateException("Unable to retrieve identity class for " + qName + ", null response from "
                     + codecRegistry);
         }
         if (expectedBaseClass.isAssignableFrom(deserialized)) {
@@ -194,7 +193,7 @@ final class DependencyResolverImpl implements DependencyResolver,
     public <T extends BaseIdentity> void validateIdentity(IdentityAttributeRef identityRef, Class<T> expectedBaseClass, JmxAttribute jmxAttribute) {
         try {
             resolveIdentity(identityRef, expectedBaseClass);
-        } catch(Exception e) {
+        } catch (Exception e) {
             throw JmxAttributeValidationException.wrap(e, jmxAttribute);
         }
     }
@@ -224,8 +223,8 @@ final class DependencyResolverImpl implements DependencyResolver,
     }
 
     private static int getMaxDepth(DependencyResolverImpl impl,
-            DependencyResolverManager manager,
-            LinkedHashSet<ModuleIdentifier> chainForDetectingCycles) {
+                                   DependencyResolverManager manager,
+                                   LinkedHashSet<ModuleIdentifier> chainForDetectingCycles) {
         int maxDepth = 0;
         LinkedHashSet<ModuleIdentifier> chainForDetectingCycles2 = new LinkedHashSet<>(
                 chainForDetectingCycles);
index 6f0d1b2682a00e17b8935cca72c86599cd2b2b63..7e48af1caae9adc31cb0c76b64a86d0fb7bca428 100644 (file)
@@ -55,7 +55,6 @@ import static java.lang.String.format;
  * requests (getAttribute, setAttribute, invoke) into the actual instance, but
  * provides additional functionality - namely it disallows setting attribute on
  * a read only wrapper.
- *
  */
 abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
     private static final Logger logger = LoggerFactory
@@ -71,9 +70,9 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
     protected final MBeanServer internalServer;
 
     public AbstractDynamicWrapper(Module module, boolean writable,
-            ModuleIdentifier moduleIdentifier,
-            ObjectName thisWrapperObjectName, MBeanOperationInfo[] dOperations,
-            MBeanServer internalServer, MBeanServer configMBeanServer) {
+                                  ModuleIdentifier moduleIdentifier,
+                                  ObjectName thisWrapperObjectName, MBeanOperationInfo[] dOperations,
+                                  MBeanServer internalServer, MBeanServer configMBeanServer) {
 
         this.writable = writable;
         this.module = module;
@@ -98,10 +97,10 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
      * case unregister the module and remove listener.
      */
     private final NotificationListener registerActualModule(Module module,
-            final ObjectName thisWrapperObjectName,
-            final ObjectName objectNameInternal,
-            final MBeanServer internalServer,
-            final MBeanServer configMBeanServer) {
+                                                            final ObjectName thisWrapperObjectName,
+                                                            final ObjectName objectNameInternal,
+                                                            final MBeanServer internalServer,
+                                                            final MBeanServer configMBeanServer) {
 
         try {
             internalServer.registerMBean(module, objectNameInternal);
@@ -116,7 +115,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
             public void handleNotification(Notification n, Object handback) {
                 if (n instanceof MBeanServerNotification
                         && n.getType()
-                                .equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
+                        .equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
                     if (((MBeanServerNotification) n).getMBeanName().equals(
                             thisWrapperObjectName)) {
                         try {
@@ -142,8 +141,8 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
     }
 
     private static MBeanInfo generateMBeanInfo(String className, Module module,
-            Map<String, AttributeHolder> attributeHolderMap,
-            MBeanOperationInfo[] dOperations, Set<Class<?>> jmxInterfaces) {
+                                               Map<String, AttributeHolder> attributeHolderMap,
+                                               MBeanOperationInfo[] dOperations, Set<Class<?>> jmxInterfaces) {
 
         String dDescription = findDescription(module.getClass(), jmxInterfaces);
         MBeanConstructorInfo[] dConstructors = new MBeanConstructorInfo[0];
@@ -170,9 +169,9 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
     // inspect all exported interfaces ending with MXBean, extract getters &
     // setters into attribute holder
     private static Map<String, AttributeHolder> buildMBeanInfo(Module module,
-            boolean writable, ModuleIdentifier moduleIdentifier,
-            Set<Class<?>> jmxInterfaces, MBeanServer internalServer,
-            ObjectName internalObjectName) {
+                                                               boolean writable, ModuleIdentifier moduleIdentifier,
+                                                               Set<Class<?>> jmxInterfaces, MBeanServer internalServer,
+                                                               ObjectName internalObjectName) {
 
         // internal variables for describing MBean elements
         Set<Method> methods = new HashSet<>();
@@ -217,7 +216,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
                 }
                 AttributeHolder attributeHolder = new AttributeHolder(
                         attribName, module, attributeMap.get(attribName)
-                                .getType(), writable, ifc, description);
+                        .getType(), writable, ifc, description);
                 attributeHolderMap.put(attribName, attributeHolder);
             }
         }
@@ -257,7 +256,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
         }
 
 
-        if(isDependencyListAttr(attributeName, obj)) {
+        if (isDependencyListAttr(attributeName, obj)) {
             obj = fixDependencyListAttribute(obj);
         }
 
@@ -265,14 +264,16 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
     }
 
     private Object fixDependencyListAttribute(Object attribute) {
-        if(attribute.getClass().isArray() == false)
+        if (attribute.getClass().isArray() == false) {
             throw new IllegalArgumentException("Unexpected attribute type, should be an array, but was " + attribute.getClass());
+        }
 
         for (int i = 0; i < Array.getLength(attribute); i++) {
 
             Object on = Array.get(attribute, i);
-            if(on instanceof ObjectName == false)
+            if (on instanceof ObjectName == false) {
                 throw new IllegalArgumentException("Unexpected attribute type, should be an ObjectName, but was " + on.getClass());
+            }
             on = fixObjectName((ObjectName) on);
 
             Array.set(attribute, i, on);
@@ -282,8 +283,9 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
     }
 
     private boolean isDependencyListAttr(String attributeName, Object attribute) {
-        if (attributeHolderMap.containsKey(attributeName) == false)
+        if (attributeHolderMap.containsKey(attributeName) == false) {
             return false;
+        }
 
         AttributeHolder attributeHolder = attributeHolderMap.get(attributeName);
 
@@ -294,15 +296,17 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
     }
 
     protected ObjectName fixObjectName(ObjectName on) {
-        if (!ObjectNameUtil.ON_DOMAIN.equals(on.getDomain()))
+        if (!ObjectNameUtil.ON_DOMAIN.equals(on.getDomain())) {
             throw new IllegalArgumentException("Wrong domain, expected "
                     + ObjectNameUtil.ON_DOMAIN + " setter on " + on);
+        }
         // if on contains transaction name, remove it
         String transactionName = ObjectNameUtil.getTransactionName(on);
-        if (transactionName != null)
+        if (transactionName != null) {
             return ObjectNameUtil.withoutTransactionName(on);
-        else
+        } else {
             return on;
+        }
     }
 
     @Override
index 64664f79802bc62b10f7e895df7efe36418effe0..f3e1b4e705c3b943230d13ee52eca44bd798b930 100644 (file)
@@ -7,15 +7,15 @@
  */
 package org.opendaylight.controller.config.manager.impl.dynamicmbean;
 
+import org.opendaylight.controller.config.api.annotations.Description;
+
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
 
-import org.opendaylight.controller.config.api.annotations.Description;
-
-class AnnotationsHelper {
+public class AnnotationsHelper {
 
     /**
      * Look for annotation specified by annotationType on method. First observe
index 9dd6a2269e259cf4ca5ee4e6b1331d85ef015d81..044f7a9ada06af871fad5bc1cad531e550bab8c8 100644 (file)
@@ -40,9 +40,9 @@ class AttributeHolder {
     }
 
     public AttributeHolder(String name, Object object, String returnType,
-            boolean writable,
-            @Nullable RequireInterface requireInterfaceAnnotation,
-            String description) {
+                           boolean writable,
+                           @Nullable RequireInterface requireInterfaceAnnotation,
+                           String description) {
         if (name == null) {
             throw new NullPointerException();
         }
@@ -65,7 +65,7 @@ class AttributeHolder {
 
     /**
      * @return annotation if setter sets ObjectName or ObjectName[], and is
-     *         annotated. Return null otherwise.
+     * annotated. Return null otherwise.
      */
     RequireInterface getRequireInterfaceOrNull() {
         return requireInterfaceAnnotation;
@@ -98,7 +98,7 @@ class AttributeHolder {
      * @param setter
      * @param jmxInterfaces
      * @return empty string if no annotation is found, or list of descriptions
-     *         separated by newline
+     * separated by newline
      */
     static String findDescription(Method setter, Set<Class<?>> jmxInterfaces) {
         List<Description> descriptions = AnnotationsHelper
@@ -112,21 +112,21 @@ class AttributeHolder {
      *
      * @param setter
      * @param inspectedInterfaces
-     * @throws IllegalStateException
-     *             if more than one value is specified by found annotations
-     * @throws IllegalArgumentException
-     *             if set of exported interfaces contains non interface type
      * @return null if no annotation is found, otherwise return the annotation
+     * @throws IllegalStateException    if more than one value is specified by found annotations
+     * @throws IllegalArgumentException if set of exported interfaces contains non interface type
      */
     static RequireInterface findRequireInterfaceAnnotation(final Method setter,
-            Set<Class<?>> inspectedInterfaces) {
+                                                           Set<Class<?>> inspectedInterfaces) {
 
         // only allow setX(ObjectName y) or setX(ObjectName[] y) or setX(List<ObjectName> y) to continue
 
-        if (setter.getParameterTypes().length > 1)
+        if (setter.getParameterTypes().length > 1) {
             return null;
-        if(PERMITTED_PARAMETER_TYPES_FOR_DEPENDENCY_SETTER.contains(setter.getParameterTypes()[0]) == false)
+        }
+        if (PERMITTED_PARAMETER_TYPES_FOR_DEPENDENCY_SETTER.contains(setter.getParameterTypes()[0]) == false) {
             return null;
+        }
 
         List<RequireInterface> foundRequireInterfaces = AnnotationsHelper
                 .findMethodAnnotationInSuperClassesAndIfcs(setter, RequireInterface.class, inspectedInterfaces);
index 16f7cf024a40958118467641736eae6ebecfcd98..adc8168af5d85b0aee22e717cb59cda7b8939b8f 100644 (file)
@@ -10,25 +10,21 @@ package org.opendaylight.controller.config.manager.impl.factoriesresolver;
 
 import org.opendaylight.controller.config.spi.ModuleFactory;
 import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
-import java.util.Map.Entry;
-import java.util.Set;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
-import java.util.Collections;
+import java.util.Map.Entry;
+import java.util.Set;
 import java.util.TreeSet;
-import java.util.Collection;
-import java.util.ArrayList;
 
 /**
  * Hold sorted ConfigMBeanFactories by their module names. Check that module
  * names are globally unique.
  */
 public class HierarchicalConfigMBeanFactoriesHolder {
-    private static final Logger logger = LoggerFactory
-            .getLogger(HierarchicalConfigMBeanFactoriesHolder.class);
 
     private final Map<String, Map.Entry<ModuleFactory, BundleContext>> moduleNamesToConfigBeanFactories;
     private final Set<String> moduleNames;
index 5d771560a53b5dd25a3ec2140b5c2bf74f1791c0..98f0908dc710cf40fbb93b88004d411d03f594fd 100644 (file)
@@ -7,22 +7,24 @@
  */
 package org.opendaylight.controller.config.manager.impl.jmx;
 
-import java.io.Closeable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.annotation.concurrent.GuardedBy;
 import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
 import javax.management.JMX;
+import javax.management.MBeanRegistrationException;
 import javax.management.MBeanServer;
+import javax.management.NotCompliantMBeanException;
 import javax.management.ObjectName;
 import javax.management.QueryExp;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.io.Closeable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
 
 public class InternalJMXRegistrator implements Closeable {
     private static final Logger logger = LoggerFactory
@@ -38,7 +40,7 @@ public class InternalJMXRegistrator implements Closeable {
         private final ObjectName on;
 
         InternalJMXRegistration(InternalJMXRegistrator internalJMXRegistrator,
-                ObjectName on) {
+                                ObjectName on) {
             this.internalJMXRegistrator = internalJMXRegistrator;
             this.on = on;
         }
@@ -54,13 +56,11 @@ public class InternalJMXRegistrator implements Closeable {
     private final List<InternalJMXRegistrator> children = new ArrayList<>();
 
     public synchronized InternalJMXRegistration registerMBean(Object object,
-            ObjectName on) throws InstanceAlreadyExistsException {
+                                                              ObjectName on) throws InstanceAlreadyExistsException {
         try {
             configMBeanServer.registerMBean(object, on);
-        } catch (InstanceAlreadyExistsException e) {
-            throw e;
-        } catch (Exception e) {
-            throw new RuntimeException(e);
+        } catch (MBeanRegistrationException | NotCompliantMBeanException e) {
+            throw new IllegalStateException(e);
         }
         registeredObjectNames.add(on);
         return new InternalJMXRegistration(this, on);
@@ -69,14 +69,13 @@ public class InternalJMXRegistrator implements Closeable {
     private synchronized void unregisterMBean(ObjectName on) {
         // first check that on was registered using this instance
         boolean removed = registeredObjectNames.remove(on);
-        if (!removed)
-            throw new IllegalStateException(
-                    "Cannot unregister - ObjectName not found in 'registeredObjectNames': "
-                            + on);
+        if (!removed) {
+            throw new IllegalStateException("Cannot unregister - ObjectName not found in 'registeredObjectNames': " + on);
+        }
         try {
             configMBeanServer.unregisterMBean(on);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
+        } catch (InstanceNotFoundException | MBeanRegistrationException e) {
+            throw new IllegalStateException(e);
         }
     }
 
@@ -112,7 +111,7 @@ public class InternalJMXRegistrator implements Closeable {
     }
 
     public <T> T newMBeanProxy(ObjectName objectName, Class<T> interfaceClass,
-            boolean notificationBroadcaster) {
+                               boolean notificationBroadcaster) {
         return JMX.newMBeanProxy(configMBeanServer, objectName, interfaceClass,
                 notificationBroadcaster);
     }
@@ -123,7 +122,7 @@ public class InternalJMXRegistrator implements Closeable {
     }
 
     public <T> T newMXBeanProxy(ObjectName objectName, Class<T> interfaceClass,
-            boolean notificationBroadcaster) {
+                                boolean notificationBroadcaster) {
         return JMX.newMXBeanProxy(configMBeanServer, objectName,
                 interfaceClass, notificationBroadcaster);
     }
index 849f75234f05ccec20361066de8140ef37a5659e..cd74ddf7565a32fd74e650cde1d50e720966d506 100644 (file)
@@ -25,13 +25,21 @@ public class ServiceReference {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
 
         ServiceReference that = (ServiceReference) o;
 
-        if (!refName.equals(that.refName)) return false;
-        if (!serviceInterfaceName.equals(that.serviceInterfaceName)) return false;
+        if (!refName.equals(that.refName)) {
+            return false;
+        }
+        if (!serviceInterfaceName.equals(that.serviceInterfaceName)) {
+            return false;
+        }
 
         return true;
     }
index b371c3f1709c3160bc2c2a372f0d7647dec24253..6fd2a2fc65201ea0d48c974875e2fe9477300ac0 100644 (file)
@@ -7,15 +7,14 @@
  */
 package org.opendaylight.controller.config.manager.impl.jmx;
 
-import java.io.Closeable;
-import java.util.Set;
+import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
+import org.opendaylight.controller.config.manager.impl.jmx.InternalJMXRegistrator.InternalJMXRegistration;
 
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.ObjectName;
 import javax.management.QueryExp;
-
-import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-import org.opendaylight.controller.config.manager.impl.jmx.InternalJMXRegistrator.InternalJMXRegistration;
+import java.io.Closeable;
+import java.util.Set;
 
 /**
  * Contains constraints on passed {@link ObjectName} parameters. Only allow (un)
@@ -26,7 +25,7 @@ public class TransactionJMXRegistrator implements Closeable {
     private final String transactionName;
 
     TransactionJMXRegistrator(InternalJMXRegistrator internalJMXRegistrator,
-            String transactionName) {
+                              String transactionName) {
         this.childJMXRegistrator = internalJMXRegistrator.createChild();
         this.transactionName = transactionName;
     }
@@ -46,10 +45,11 @@ public class TransactionJMXRegistrator implements Closeable {
 
     public TransactionJMXRegistration registerMBean(Object object, ObjectName on)
             throws InstanceAlreadyExistsException {
-        if (!transactionName.equals(ObjectNameUtil.getTransactionName(on)))
+        if (!transactionName.equals(ObjectNameUtil.getTransactionName(on))) {
             throw new IllegalArgumentException(
                     "Transaction name mismatch between expected "
                             + transactionName + " " + "and " + on);
+        }
         ObjectNameUtil.checkType(on, ObjectNameUtil.TYPE_CONFIG_TRANSACTION);
         return new TransactionJMXRegistration(
                 childJMXRegistrator.registerMBean(object, on));
index 2a533ab9a3a6813ad4fed4c4dcfe4a5dbcec2cf6..1e94e5e9c021b1660e02a6d8303333832716ad44 100644 (file)
@@ -53,7 +53,7 @@ public class BundleContextBackedModuleFactoriesResolver implements
             if(factory == null) {
                 throw new NullPointerException("ServiceReference of class" + serviceReference.getClass() + "not found.");
             }
-            StringBuffer errors = new StringBuffer();
+
             String moduleName = factory.getImplementationName();
             if (moduleName == null || moduleName.isEmpty()) {
                 throw new IllegalStateException(
@@ -63,23 +63,17 @@ public class BundleContextBackedModuleFactoriesResolver implements
                 throw new NullPointerException("Bundle context of " + factory + " ModuleFactory not found.");
             }
             logger.debug("Reading factory {} {}", moduleName, factory);
-            String error = null;
+
             Map.Entry<ModuleFactory, BundleContext> conflicting = result.get(moduleName);
             if (conflicting != null) {
-                error = String
-                        .format("Module name is not unique. Found two conflicting factories with same name '%s': " +
-                                "\n\t%s\n\t%s\n", moduleName, conflicting.getKey(), factory);
-
-            }
-
-            if (error == null) {
+                String error = String
+                        .format("Module name is not unique. Found two conflicting factories with same name '%s': '%s' '%s'",
+                                moduleName, conflicting.getKey(), factory);
+                logger.error(error);
+                throw new IllegalArgumentException(error);
+            } else {
                 result.put(moduleName, new AbstractMap.SimpleImmutableEntry<>(factory,
                         serviceReference.getBundle().getBundleContext()));
-            } else {
-                errors.append(error);
-            }
-            if (errors.length() > 0) {
-                throw new IllegalArgumentException(errors.toString());
             }
         }
         return result;
index d464cb9006af15b24de4e1e517f57883a893fd47..02cc5ea1e4a01681e9c6b2fe73b435c1a7699db4 100644 (file)
@@ -41,7 +41,7 @@ public class ConfigManagerActivator implements BundleActivator {
     private RuntimeGeneratedMappingServiceActivator mappingServiceActivator;
 
     @Override
-    public void start(BundleContext context) throws Exception {
+    public void start(BundleContext context) {
 
         // track bundles containing YangModuleInfo
         ModuleInfoBundleTracker moduleInfoBundleTracker = new ModuleInfoBundleTracker();
@@ -72,7 +72,7 @@ public class ConfigManagerActivator implements BundleActivator {
         try {
             configRegistryJMXRegistrator.registerToJMX(configRegistry);
         } catch (InstanceAlreadyExistsException e) {
-            throw new RuntimeException("Config Registry was already registered to JMX", e);
+            throw new IllegalStateException("Config Registry was already registered to JMX", e);
         }
 
         ServiceTracker<ModuleFactory, Object> serviceTracker = new ServiceTracker<>(context, ModuleFactory.class,
@@ -81,7 +81,7 @@ public class ConfigManagerActivator implements BundleActivator {
     }
 
     @Override
-    public void stop(BundleContext context) throws Exception {
+    public void stop(BundleContext context) {
         try {
             configRegistry.close();
         } catch (Exception e) {
index d6d3893bebdd54113a549bf9692e3851f7545af8..37d5e6bd3fcae0259ae06079d1c909e016b8525f 100644 (file)
@@ -53,7 +53,7 @@ public class FtlFilePersister {
                         ftlFile.getFtlTempleteLocation());
                 try {
                     template.process(ftlFile, writer);
-                } catch (Throwable e) {
+                } catch (Exception e) {
                     throw new IllegalStateException(
                             "Template error while generating " + ftlFile, e);
                 }
index 4a9d5512d3fc024892d641215572b566c51b8d6c..676c8eca6ec6f9a903c34aeebd69d9c8abbeae07 100644 (file)
@@ -195,16 +195,17 @@ final class ModuleMXBeanEntryBuilder {
                 boolean providedServiceWasSet = false;
                 for (UnknownSchemaNode unknownNode : id.getUnknownSchemaNodes()) {
                     // TODO: test this
-                    if (ConfigConstants.PROVIDED_SERVICE_EXTENSION_QNAME.equals(unknownNode.getNodeType())) {
-                        // no op: 0 or more provided identities are allowed
-                    } else if (ConfigConstants.JAVA_NAME_PREFIX_EXTENSION_QNAME.equals(unknownNode.getNodeType())) {
+                    boolean unknownNodeIsProvidedServiceExtension = ConfigConstants.PROVIDED_SERVICE_EXTENSION_QNAME.equals(unknownNode.getNodeType());
+                    // true => no op: 0 or more provided identities are allowed
+
+                    if (ConfigConstants.JAVA_NAME_PREFIX_EXTENSION_QNAME.equals(unknownNode.getNodeType())) {
                         // 0..1 allowed
                         checkState(
                                 providedServiceWasSet == false,
                                 format("More than one language extension %s is not allowed here: %s",
                                         ConfigConstants.JAVA_NAME_PREFIX_EXTENSION_QNAME, id));
                         providedServiceWasSet = true;
-                    } else {
+                    } else if (unknownNodeIsProvidedServiceExtension == false) {
                         throw new IllegalStateException("Unexpected language extension " + unknownNode.getNodeType());
                     }
                 }
index 84300cb81d1000571e5fb52070ebefa91c3c33e4..cbeb5c3b297415bacf1a74596abbbf8d4fb9d207 100644 (file)
@@ -25,7 +25,9 @@ import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import javax.management.openmbean.CompositeType;
 import javax.management.openmbean.OpenDataException;
 import javax.management.openmbean.OpenType;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
@@ -208,22 +210,20 @@ public class TOAttribute extends AbstractAttribute implements TypedAttribute {
 
     @Override
     public CompositeType getOpenType() {
-        String description = getNullableDescription() == null ? getAttributeYangName()
-                : getNullableDescription();
-        final String[] itemNames = new String[yangNameToAttributeMap.keySet()
-                .size()];
-        String[] itemDescriptions = itemNames;
-        FunctionImpl functionImpl = new FunctionImpl(itemNames);
+        String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
+
+        FunctionImpl functionImpl = new FunctionImpl();
         Map<String, AttributeIfc> jmxPropertiesToTypesMap = getJmxPropertiesToTypesMap();
         OpenType<?>[] itemTypes = Collections2.transform(
                 jmxPropertiesToTypesMap.entrySet(), functionImpl).toArray(
                 new OpenType<?>[] {});
+        String[] itemNames = functionImpl.getItemNames();
         try {
             // TODO add package name to create fully qualified name for this
             // type
             CompositeType compositeType = new CompositeType(
                     getUpperCaseCammelCase(), description, itemNames,
-                    itemDescriptions, itemTypes);
+                    itemNames, itemTypes);
             return compositeType;
         } catch (OpenDataException e) {
             throw new RuntimeException("Unable to create CompositeType for "
@@ -235,20 +235,20 @@ public class TOAttribute extends AbstractAttribute implements TypedAttribute {
         return packageName;
     }
 
-    private static final class FunctionImpl implements
-            Function<Entry<String, AttributeIfc>, OpenType<?>> {
-        private final String[] itemNames;
-        int i = 0;
+}
 
-        private FunctionImpl(String[] itemNames) {
-            this.itemNames = itemNames;
-        }
+class FunctionImpl implements
+        Function<Entry<String, AttributeIfc>, OpenType<?>> {
+    private final List<String> itemNames = new ArrayList<>();
 
-        @Override
-        public OpenType<?> apply(Entry<String, AttributeIfc> input) {
-            AttributeIfc innerType = input.getValue();
-            itemNames[i++] = input.getKey();
-            return innerType.getOpenType();
-        }
+    @Override
+    public OpenType<?> apply(Entry<String, AttributeIfc> input) {
+        AttributeIfc innerType = input.getValue();
+        itemNames.add(input.getKey());
+        return innerType.getOpenType();
+    }
+
+    public String[] getItemNames(){
+        return itemNames.toArray(new String[itemNames.size()]);
     }
 }
index b000f11e4e352f0d76f8d6cf7e55449863951071..398bba99bde6b3923028f9e20d88582a33c96454 100644 (file)
@@ -31,15 +31,16 @@ public final class IdentityTestModule extends org.opendaylight.controller.config
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-        System.err.println(getAfi());
-        System.err.println(getAfiIdentity());
+        org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(getClass());
+        logger.info("Afi: {}", getAfi());
+        logger.info("Afi class: {}", getAfiIdentity());
 
-        getAfiIdentity();
         for (Identities identities : getIdentities()) {
-            identities.resolveAfi();
-            identities.resolveSafi();
+            logger.info("Identities Afi class: {}", identities.resolveAfi());
+            logger.info("Identities Safi class: {}", identities.resolveSafi());
+
         }
-        getIdentitiesContainer().resolveAfi();
+        logger.info("IdentityContainer Afi class: {}", getIdentitiesContainer().resolveAfi());
 
         return new AutoCloseable() {
             @Override
index a81159ea24c6fc0f29b2e1a9e7684c069f2db4bc..7fa0c10eb2c570bd91c47f924ecc26087d4e360e 100644 (file)
@@ -1,12 +1,13 @@
-        System.err.println(getAfi());
-        System.err.println(getAfiIdentity());
+        org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(getClass());
+        logger.info("Afi: {}", getAfi());
+        logger.info("Afi class: {}", getAfiIdentity());
 
-        getAfiIdentity();
         for (Identities identities : getIdentities()) {
-            identities.resolveAfi();
-            identities.resolveSafi();
+            logger.info("Identities Afi class: {}", identities.resolveAfi());
+            logger.info("Identities Safi class: {}", identities.resolveSafi());
+
         }
-        getIdentitiesContainer().resolveAfi();
+        logger.info("IdentityContainer Afi class: {}", getIdentitiesContainer().resolveAfi());
 
         return new AutoCloseable() {
             @Override
index 90e3b03ae4b7168fcc51a70a32499caca2086515..64f2c877f7ea60f2e87f13bb9d4b173a11d7a16d 100755 (executable)
@@ -59,7 +59,7 @@ else
 fi
 
 function usage {
-    echo "Usage: $0 [-jmx] [-jmxport <num>] [-debug] [-debugsuspend] [-debugport <num>] [-start [<console port>]] [-stop] [-status] [-console] [-help] [<other args will automatically be used for the JVM>]"
+    echo "Usage: $0 [-jmx] [-jmxport <num>] [-debug] [-debugsuspend] [-debugport <num>] [-start [<console port>]] [-stop] [-status] [-console] [-help] [-agentpath:<path to lib>] [<other args will automatically be used for the JVM>]"
     exit 1
 }
 
@@ -83,6 +83,7 @@ statusdaemon=0
 consolestart=1
 dohelp=0
 extraJVMOpts=""
+agentPath=""
 unknown_option=0
 while true ; do
     case "$1" in
@@ -98,6 +99,7 @@ while true ; do
         -help) dohelp=1; shift;;
         -D*) extraJVMOpts="${extraJVMOpts} $1"; shift;;
         -X*) extraJVMOpts="${extraJVMOpts} $1"; shift;;
+        -agentpath:*) agentPath="$1"; shift;;
         "") break ;;
         *) echo "Unknown option $1"; unknown_option=1; shift ;;
     esac
@@ -209,6 +211,7 @@ if [ "${startdaemon}" -eq 1 ]; then
         exit -1
     fi
     $JAVA_HOME/bin/java ${extraJVMOpts} \
+        ${agentPath} \
         -Djava.io.tmpdir="${iotmpdir}/work/tmp" \
         -Dosgi.install.area="${bdir}" \
         -Dosgi.configuration.area="${confarea}/configuration" \
@@ -227,6 +230,7 @@ elif [ "${consolestart}" -eq 1 ]; then
         exit -1
     fi
     $JAVA_HOME/bin/java ${extraJVMOpts} \
+        ${agentPath} \
         -Djava.io.tmpdir="${iotmpdir}/work/tmp" \
         -Dosgi.install.area="${bdir}" \
         -Dosgi.configuration.area="${confarea}/configuration" \
index f900c0b18c6558e0808c7fca3452bf3608aaeddf..562db9830197176ae3cd301199ddf13790e3c07f 100644 (file)
 
         <!-- Dependency Versions -->
         <mockito.version>1.9.5</mockito.version>
-        <xtend.version>2.4.3</xtend.version>
+
 
         <!-- Sonar properties using jacoco to retrieve integration test results -->
         <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
                 <artifactId>slf4j-api</artifactId>
                 <version>${slf4j.version}</version>
             </dependency>
-            <dependency>
-                <groupId>org.eclipse.xtend</groupId>
-                <artifactId>org.eclipse.xtend.lib</artifactId>
-                <version>${xtend.version}</version>
-            </dependency>
+
             <dependency>
                 <groupId>org.osgi</groupId>
                 <artifactId>org.osgi.core</artifactId>
index 9bc8a482145e120d10857a136d35caf1ec693121..213e4f47f759026215fb7824dc214eb092c7416d 100644 (file)
 
 
     <dependencies>
+        <!--Compile scopes for all testing dependencies are intentional-->
+        <!--This way, all testing dependencies can be transitively used by other integration test modules-->
+        <!--If the dependencies are test scoped, they are not visible to other maven modules depending on sal-binding-it-->
 
+        <!--TODO Create generic utilities(extract from this module) for integration tests on the controller-->
         <dependency>
             <groupId>org.opendaylight.yangtools.thirdparty</groupId>
             <artifactId>xtend-lib-osgi</artifactId>
             <version>2.4.3</version>
-            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>sal-binding-broker-impl</artifactId>
-            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.ops4j.pax.exam</groupId>
             <artifactId>pax-exam-container-native</artifactId>
-            <scope>test</scope>
+            <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.ops4j.pax.exam</groupId>
             <artifactId>pax-exam-junit4</artifactId>
-            <scope>test</scope>
+            <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>config-netconf-connector</artifactId>
-            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
         <dependency>
             <groupId>org.ops4j.pax.exam</groupId>
             <artifactId>pax-exam-link-mvn</artifactId>
-            <scope>test</scope>
+            <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>equinoxSDK381</groupId>
             <artifactId>org.eclipse.osgi</artifactId>
-            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.slf4j</groupId>
         <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-all</artifactId>
-            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.controller.model</groupId>
index f7c46086e301ac9309bb435921388b97a39cd4a2..6af06255c7ef3adbbfd526404babf70b4b285a6b 100644 (file)
@@ -25,16 +25,16 @@ import org.osgi.framework.BundleContext;
 
 /**
  * Core component of the SAL layer responsible for wiring the SAL consumers.
- * 
+ *
  * The responsibility of the broker is to maintain registration of SAL
  * functionality {@link Consumer}s and {@link Provider}s, store provider and
  * consumer specific context and functionality registration via
  * {@link ConsumerSession} and provide access to infrastructure services, which
  * removes direct dependencies between providers and consumers.
- * 
- * 
+ *
+ *
  * <h3>Infrastructure services</h3> Some examples of infrastructure services:
- * 
+ *
  * <ul>
  * <li>RPC Invocation - see {@link ConsumerSession#rpc(QName, CompositeNode)},
  * {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)} and
@@ -45,41 +45,41 @@ import org.osgi.framework.BundleContext;
  * <li>Data Store access and modification - see {@link DataBrokerService} and
  * {@link DataProviderService}
  * </ul>
- * 
+ *
  * The services are exposed via session.
- * 
+ *
  * <h3>Session-based access</h3>
- * 
+ *
  * The providers and consumers needs to register in order to use the
  * binding-independent SAL layer and to expose functionality via SAL layer.
- * 
+ *
  * For more information about session-based access see {@link ConsumerSession}
  * and {@link ProviderSession}
- * 
- * 
- * 
+ *
+ *
+ *
  */
 public interface Broker {
 
     /**
      * Registers the {@link Consumer}, which will use the SAL layer.
-     * 
+     *
      * <p>
      * During the registration, the broker obtains the initial functionality
      * from consumer, using the {@link Consumer#getConsumerFunctionality()}, and
      * register that functionality into system and concrete infrastructure
      * services.
-     * 
+     *
      * <p>
      * Note that consumer could register additional functionality at later point
      * by using service and functionality specific APIs.
-     * 
+     *
      * <p>
      * The consumer is required to use returned session for all communication
      * with broker or one of the broker services. The session is announced to
      * the consumer by invoking
      * {@link Consumer#onSessionInitiated(ConsumerSession)}.
-     * 
+     *
      * @param cons
      *            Consumer to be registered.
      * @param context
@@ -93,25 +93,25 @@ public interface Broker {
 
     /**
      * Registers the {@link Provider}, which will use the SAL layer.
-     * 
+     *
      * <p>
      * During the registration, the broker obtains the initial functionality
      * from consumer, using the {@link Provider#getProviderFunctionality()}, and
      * register that functionality into system and concrete infrastructure
      * services.
-     * 
+     *
      * <p>
      * Note that consumer could register additional functionality at later point
      * by using service and functionality specific APIs (e.g.
      * {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)}
-     * 
+     *
      * <p>
      * The consumer is <b>required to use</b> returned session for all
      * communication with broker or one of the broker services. The session is
      * announced to the consumer by invoking
      * {@link Provider#onSessionInitiated(ProviderSession)}.
-     * 
-     * 
+     *
+     *
      * @param prov
      *            Provider to be registered.
      * @param context
@@ -125,25 +125,25 @@ public interface Broker {
 
     /**
      * {@link Consumer} specific access to the SAL functionality.
-     * 
+     *
      * <p>
      * ConsumerSession is {@link Consumer}-specific access to the SAL
      * functionality and infrastructure services.
-     * 
+     *
      * <p>
      * The session serves to store SAL context (e.g. registration of
      * functionality) for the consumer and provides access to the SAL
      * infrastructure services and other functionality provided by
      * {@link Provider}s.
-     * 
-     * 
-     * 
+     *
+     *
+     *
      */
     public interface ConsumerSession {
 
         /**
          * Sends an RPC to other components registered to the broker.
-         * 
+         *
          * @see RpcImplementation
          * @param rpc
          *            Name of RPC
@@ -158,7 +158,7 @@ public interface Broker {
         /**
          * Returns a session specific instance (implementation) of requested
          * service
-         * 
+         *
          * @param service
          *            Broker service
          * @return Session specific implementation of service
@@ -167,44 +167,44 @@ public interface Broker {
 
         /**
          * Closes a session between consumer and broker.
-         * 
+         *
          * <p>
          * The close operation unregisters a consumer and remove all registered
          * functionality of the consumer from the system.
-         * 
+         *
          */
         void close();
     }
 
     /**
      * {@link Provider} specific access to the SAL functionality.
-     * 
+     *
      * <p>
      * ProviderSession is {@link Provider}-specific access to the SAL
      * functionality and infrastructure services, which also allows for exposing
      * the provider's functionality to the other {@link Consumer}s.
-     * 
+     *
      * <p>
      * The session serves to store SAL context (e.g. registration of
      * functionality) for the providers and exposes access to the SAL
      * infrastructure services, dynamic functionality registration and any other
      * functionality provided by other {@link Provider}s.
-     * 
+     *
      */
     public interface ProviderSession extends ConsumerSession {
         /**
          * Registers an implementation of the rpc.
-         * 
+         *
          * <p>
          * The registered rpc functionality will be available to all other
          * consumers and providers registered to the broker, which are aware of
          * the {@link QName} assigned to the rpc.
-         * 
+         *
          * <p>
          * There is no assumption that rpc type is in the set returned by
          * invoking {@link RpcImplementation#getSupportedRpcs()}. This allows
          * for dynamic rpc implementations.
-         * 
+         *
          * @param rpcType
          *            Name of Rpc
          * @param implementation
@@ -221,7 +221,7 @@ public interface Broker {
 
         /**
          * Closes a session between provider and SAL.
-         * 
+         *
          * <p>
          * The close operation unregisters a provider and remove all registered
          * functionality of the provider from the system.
@@ -233,12 +233,15 @@ public interface Broker {
         boolean isClosed();
 
         Set<QName> getSupportedRpcs();
-        
+
         ListenerRegistration<RpcRegistrationListener> addRpcRegistrationListener(RpcRegistrationListener listener);
     }
 
     public interface RpcRegistration extends Registration<RpcImplementation> {
         QName getType();
+
+        @Override
+        void close();
     }
 
     public interface RoutedRpcRegistration extends RpcRegistration,
diff --git a/opendaylight/md-sal/sal-restconf-broker/src/main/java/org/opendaylight/controller/sal/restconf/broker/client/SalRemoteClient.java b/opendaylight/md-sal/sal-restconf-broker/src/main/java/org/opendaylight/controller/sal/restconf/broker/client/SalRemoteClient.java
new file mode 100644 (file)
index 0000000..0044d36
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2014 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.restconf.broker.client;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
+
+public interface SalRemoteClient extends AutoCloseable {
+
+    ConsumerContext registerConsumer();
+
+}
diff --git a/opendaylight/md-sal/sal-restconf-broker/src/main/java/org/opendaylight/controller/sal/restconf/broker/client/SalRemoteClientDeployer.java b/opendaylight/md-sal/sal-restconf-broker/src/main/java/org/opendaylight/controller/sal/restconf/broker/client/SalRemoteClientDeployer.java
new file mode 100644 (file)
index 0000000..a1bb81b
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2014 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.restconf.broker.client;
+
+import java.net.URL;
+
+public class SalRemoteClientDeployer {
+
+    public static SalRemoteClient createSalRemoteClient(final URL url) {
+        return new SalRemoteClientImpl(url);
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-restconf-broker/src/main/java/org/opendaylight/controller/sal/restconf/broker/client/SalRemoteClientImpl.java b/opendaylight/md-sal/sal-restconf-broker/src/main/java/org/opendaylight/controller/sal/restconf/broker/client/SalRemoteClientImpl.java
new file mode 100644 (file)
index 0000000..ec62568
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2014 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.restconf.broker.client;
+
+import java.net.URL;
+
+import javassist.ClassPool;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
+import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
+import org.opendaylight.controller.sal.restconf.broker.SalRemoteServiceBroker;
+import org.opendaylight.yangtools.restconf.client.RestconfClientFactory;
+import org.opendaylight.yangtools.restconf.client.api.RestconfClientContext;
+import org.opendaylight.yangtools.restconf.client.api.UnsupportedProtocolException;
+import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Preconditions;
+
+class SalRemoteClientImpl implements SalRemoteClient {
+
+    private static final Logger logger = LoggerFactory.getLogger(SalRemoteClientImpl.class);
+
+    private final RestconfClientContext restconfClientContext;
+    private final SalRemoteServiceBroker salRemoteBroker;
+    private final RuntimeGeneratedMappingServiceImpl mappingService;
+
+    public SalRemoteClientImpl(final URL url) {
+        Preconditions.checkNotNull(url);
+
+        this.mappingService = new RuntimeGeneratedMappingServiceImpl();
+        this.mappingService.setPool(ClassPool.getDefault());
+        this.mappingService.init();
+
+        final ModuleInfoBackedContext moduleInfo = ModuleInfoBackedContext.create();
+        moduleInfo.addModuleInfos(BindingReflections.loadModuleInfos());
+        this.mappingService.onGlobalContextUpdated(moduleInfo.tryToCreateSchemaContext().get());
+
+        try {
+            this.restconfClientContext = new RestconfClientFactory().getRestconfClientContext(url, this.mappingService,
+                    this.mappingService);
+
+            this.salRemoteBroker = new SalRemoteServiceBroker("remote-broker", restconfClientContext);
+            this.salRemoteBroker.start();
+        } catch (UnsupportedProtocolException e) {
+            logger.error("Unsupported protocol {}.", url.getProtocol(), e);
+            throw new IllegalArgumentException("Unsupported protocol.", e);
+        }
+    }
+
+    @Override
+    public ConsumerContext registerConsumer() {
+        return this.salRemoteBroker.registerConsumer(new BindingAwareConsumer() {
+
+            @Override
+            public void onSessionInitialized(ConsumerContext session) {
+            }
+        }, null);
+    }
+
+    @Override
+    public void close() throws Exception {
+        this.restconfClientContext.close();
+        this.salRemoteBroker.close();
+    }
+
+}
index 9410d17007dc1072f16074d27193505805f52e06..e31d576d01763a04d5e88e153f1a28997447843d 100644 (file)
@@ -22,6 +22,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.CreateDataChangeEventSubscriptionInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.CreateDataChangeEventSubscriptionOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.SalRemoteService;
+import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.restconf.client.api.RestconfClientContext;
 import org.opendaylight.yangtools.restconf.client.api.event.EventStreamInfo;
@@ -149,22 +150,12 @@ public class DataBrokerServiceImpl implements DataBrokerService  {
         final Map<String,EventStreamInfo> desiredEventStream = RemoteStreamTools.createEventStream(restconfClientContext,streamName);
         ListenableEventStreamContext restConfListenableEventStreamContext = restconfClientContext.getEventStreamContext(desiredEventStream.get(streamName));
         RemoteDataChangeNotificationListener remoteDataChangeNotificationListener = new RemoteDataChangeNotificationListener(listener);
-        restConfListenableEventStreamContext.registerNotificationListener(remoteDataChangeNotificationListener);
-        return new SalRemoteDataListenerRegistration(listener);
-    }
-
-    private class SalRemoteDataListenerRegistration implements ListenerRegistration<DataChangeListener> {
-        private final DataChangeListener dataChangeListener;
-        public SalRemoteDataListenerRegistration(DataChangeListener dataChangeListener){
-            this.dataChangeListener = dataChangeListener;
-        }
-        @Override
-        public DataChangeListener getInstance() {
-            return this.dataChangeListener;
-        }
-        @Override
-        public void close() {
-            //noop
-        }
+        final ListenerRegistration<?> reg = restConfListenableEventStreamContext.registerNotificationListener(remoteDataChangeNotificationListener);
+        return new AbstractListenerRegistration<DataChangeListener>(listener) {
+            @Override
+            protected void removeRegistration() {
+                reg.close();
+            }
+        };
     }
 }
index 549d4074eb48667136f81b29a57ac569000ce353..57067f47ecded6b0d9e6bd745b0b0de3df344d3d 100644 (file)
             <artifactId>yang-store-api</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>yang-test</artifactId>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>netconf-api</artifactId>
             <artifactId>netconf-monitoring</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>sal-binding-it</artifactId>
+            <version>${mdsal.version}</version>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>netconf-mapping-api</artifactId>
             <scope>test</scope>
             <type>test-jar</type>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>yang-test</artifactId>
+            <version>${config.version}</version>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>yang-store-impl</artifactId>
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.ops4j.pax.exam</groupId>
+                <artifactId>maven-paxexam-plugin</artifactId>
+                <version>1.2.4</version>
+                <executions>
+                    <execution>
+                        <id>generate-config</id>
+                        <goals>
+                            <goal>generate-depends-file</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 </project>
diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/pax/IdentityRefNetconfTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/pax/IdentityRefNetconfTest.java
new file mode 100644 (file)
index 0000000..4e536c4
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * 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.netconf.it.pax;
+
+import static org.opendaylight.controller.test.sal.binding.it.TestHelper.baseModelBundles;
+import static org.opendaylight.controller.test.sal.binding.it.TestHelper.bindingAwareSalBundles;
+import static org.opendaylight.controller.test.sal.binding.it.TestHelper.configMinumumBundles;
+import static org.opendaylight.controller.test.sal.binding.it.TestHelper.flowCapableModelBundles;
+import static org.opendaylight.controller.test.sal.binding.it.TestHelper.junitAndMockitoBundles;
+import static org.opendaylight.controller.test.sal.binding.it.TestHelper.mdSalCoreBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import javax.inject.Inject;
+import javax.xml.parsers.ParserConfigurationException;
+
+import com.google.common.base.Preconditions;
+import io.netty.channel.nio.NioEventLoopGroup;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.matchers.JUnitMatchers;
+import org.junit.runner.RunWith;
+import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.client.NetconfClient;
+import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.options.DefaultCompositeOption;
+import org.ops4j.pax.exam.util.Filter;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetSocketAddress;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+@RunWith(PaxExam.class)
+public class IdentityRefNetconfTest {
+
+    public static final int CLIENT_CONNECTION_TIMEOUT_MILLIS = 5000;
+
+    // Wait for controller to start
+    @Inject
+    @Filter(timeout = 60 * 1000)
+    BindingAwareBroker broker;
+
+    @Configuration
+    public Option[] config() {
+        return options(
+                systemProperty("osgi.console").value("2401"),
+                systemProperty("osgi.bundles.defaultStartLevel").value("4"),
+                systemProperty("pax.exam.osgi.unresolved.fail").value("true"),
+
+                testingModules(),
+                loggingModules(),
+                mdSalCoreBundles(),
+                bindingAwareSalBundles(), configMinumumBundles(), baseModelBundles(), flowCapableModelBundles(),
+                junitAndMockitoBundles());
+    }
+
+    private Option loggingModules() {
+        return new DefaultCompositeOption(
+                mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(),
+                mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(),
+                mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(),
+                mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject());
+    }
+
+    private Option testingModules() {
+        return new DefaultCompositeOption(
+                mavenBundle("org.opendaylight.controller", "yang-test").versionAsInProject());
+    }
+
+    private static final InetSocketAddress tcpAddress = new InetSocketAddress("127.0.0.1", 18383);
+
+    @Test
+    public void testIdRef() throws Exception {
+        Preconditions.checkNotNull(broker, "Controller not initialized");
+
+        NioEventLoopGroup nettyThreadgroup = new NioEventLoopGroup();
+        NetconfClientDispatcher clientDispatcher = new NetconfClientDispatcher(nettyThreadgroup, nettyThreadgroup,
+                CLIENT_CONNECTION_TIMEOUT_MILLIS);
+
+        NetconfMessage edit = xmlFileToNetconfMessage("netconfMessages/editConfig_identities.xml");
+        NetconfMessage commit = xmlFileToNetconfMessage("netconfMessages/commit.xml");
+        NetconfMessage getConfig = xmlFileToNetconfMessage("netconfMessages/getConfig.xml");
+
+        try (NetconfClient netconfClient = new NetconfClient("client", tcpAddress, CLIENT_CONNECTION_TIMEOUT_MILLIS, clientDispatcher)) {
+            sendMessage(edit, netconfClient);
+            sendMessage(commit, netconfClient);
+            sendMessage(getConfig, netconfClient, "id-test",
+                    "<afi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity1</afi>",
+                    "<afi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity2</afi>",
+                    "<safi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity2</safi>",
+                    "<safi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity1</safi>");
+        }
+
+        clientDispatcher.close();
+    }
+
+    private void sendMessage(NetconfMessage edit, NetconfClient netconfClient, String... containingResponse)
+            throws ExecutionException, InterruptedException, TimeoutException {
+        NetconfMessage response = netconfClient.sendRequest(edit).get();
+        if (containingResponse == null) {
+            Assert.assertThat(XmlUtil.toString(response.getDocument()), JUnitMatchers.containsString("<ok/>"));
+        } else {
+            for (String resp : containingResponse) {
+                Assert.assertThat(XmlUtil.toString(response.getDocument()), JUnitMatchers.containsString(resp));
+            }
+        }
+    }
+
+    public static NetconfMessage xmlFileToNetconfMessage(final String fileName) throws IOException, SAXException,
+            ParserConfigurationException {
+        return new NetconfMessage(xmlFileToDocument(fileName));
+    }
+
+    public static Document xmlFileToDocument(final String fileName) throws IOException, SAXException,
+            ParserConfigurationException {
+        // TODO xml messages from netconf-util test-jar cannot be loaded here(in OSGi), since test jar is not a bundle
+        try (InputStream resourceAsStream = IdentityRefNetconfTest.class.getClassLoader().getResourceAsStream(fileName)) {
+            Preconditions.checkNotNull(resourceAsStream);
+            final Document doc = XmlUtil.readXmlToDocument(resourceAsStream);
+            return doc;
+        }
+    }
+}
diff --git a/opendaylight/netconf/netconf-it/src/test/resources/controller.xml b/opendaylight/netconf/netconf-it/src/test/resources/controller.xml
new file mode 100644 (file)
index 0000000..664a30d
--- /dev/null
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persisted-snapshots>
+   <snapshots>
+      <snapshot>
+         <required-capabilities>
+            <capability>urn:opendaylight:params:xml:ns:yang:controller:config:test:types?module=test-types&amp;revision=2013-11-27</capability>
+            <capability>urn:opendaylight:params:xml:ns:yang:controller:config?module=config&amp;revision=2013-04-05</capability>
+            <capability>urn:opendaylight:params:xml:ns:yang:controller:logback:config?module=config-logging&amp;revision=2013-07-16</capability>
+            <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&amp;revision=2013-10-28</capability>
+            <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
+            <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&amp;revision=2013-10-28</capability>
+            <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&amp;revision=2013-10-28</capability>
+            <capability>urn:opendaylight:params:xml:ns:yang:controller:test:impl?module=config-test-impl&amp;revision=2013-04-03</capability>
+            <capability>urn:opendaylight:params:xml:ns:yang:controller:test?module=config-test&amp;revision=2013-06-13</capability>
+         </required-capabilities>
+         <configuration>
+            <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+               <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+                  <module>
+                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:test:impl">prefix:impl-identity-test</type>
+                     <name>id-test</name>
+                     <identities-container xmlns="urn:opendaylight:params:xml:ns:yang:controller:test:impl">
+                        <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity2</afi>
+                     </identities-container>
+                     <identities xmlns="urn:opendaylight:params:xml:ns:yang:controller:test:impl">
+                        <safi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity2</safi>
+                        <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity1</afi>
+                     </identities>
+                     <identities xmlns="urn:opendaylight:params:xml:ns:yang:controller:test:impl">
+                        <safi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity1</safi>
+                        <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity2</afi>
+                     </identities>
+                     <afi xmlns="urn:opendaylight:params:xml:ns:yang:controller:test:impl" xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity1</afi>
+                  </module>
+                  <module>
+                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-broker-impl</type>
+                     <name>binding-broker-impl</name>
+                     <notification-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+                        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-notification-service</type>
+                        <name>ref_binding-notification-broker</name>
+                     </notification-service>
+                     <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+                        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-data-broker</type>
+                        <name>ref_binding-data-broker</name>
+                     </data-broker>
+                  </module>
+                  <module>
+                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:runtime-generated-mapping</type>
+                     <name>runtime-mapping-singleton</name>
+                  </module>
+                  <module>
+                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-notification-broker</type>
+                     <name>binding-notification-broker</name>
+                  </module>
+                  <module>
+                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-data-broker</type>
+                     <name>binding-data-broker</name>
+                     <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+                        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type>
+                        <name>ref_dom-broker</name>
+                     </dom-broker>
+                     <mapping-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+                        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-dom-mapping-service</type>
+                        <name>ref_runtime-mapping-singleton</name>
+                     </mapping-service>
+                  </module>
+                  <module>
+                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:logback:config">prefix:logback</type>
+                     <name>singleton</name>
+                     <console-appenders xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+                        <threshold-filter>DEBUG</threshold-filter>
+                        <name>console</name>
+                        <encoder-pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</encoder-pattern>
+                     </console-appenders>
+                     <loggers xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+                        <level>DEBUG</level>
+                        <logger-name>ROOT</logger-name>
+                        <appenders>console</appenders>
+                     </loggers>
+                  </module>
+                  <module>
+                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:schema-service-singleton</type>
+                     <name>yang-schema-service</name>
+                  </module>
+                  <module>
+                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:hash-map-data-store</type>
+                     <name>hash-map-data-store</name>
+                  </module>
+                  <module>
+                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:dom-broker-impl</type>
+                     <name>dom-broker</name>
+                     <data-store xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
+                        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-data-store</type>
+                        <name>ref_hash-map-data-store</name>
+                     </data-store>
+                  </module>
+               </modules>
+               <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+                  <service>
+                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:schema-service</type>
+                     <instance>
+                        <name>ref_yang-schema-service</name>
+                        <provider>/modules/module[type='schema-service-singleton'][name='yang-schema-service']</provider>
+                     </instance>
+                  </service>
+                  <service>
+                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-data-store</type>
+                     <instance>
+                        <name>ref_hash-map-data-store</name>
+                        <provider>/modules/module[type='hash-map-data-store'][name='hash-map-data-store']</provider>
+                     </instance>
+                  </service>
+                  <service>
+                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type>
+                     <instance>
+                        <name>ref_dom-broker</name>
+                        <provider>/modules/module[type='dom-broker-impl'][name='dom-broker']</provider>
+                     </instance>
+                  </service>
+                  <service>
+                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:test">prefix:testing</type>
+                     <instance>
+                        <name>ref_id-test</name>
+                        <provider>/modules/module[type='impl-identity-test'][name='id-test']</provider>
+                     </instance>
+                  </service>
+                  <service>
+                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-dom-mapping-service</type>
+                     <instance>
+                        <name>ref_runtime-mapping-singleton</name>
+                        <provider>/modules/module[type='runtime-generated-mapping'][name='runtime-mapping-singleton']</provider>
+                     </instance>
+                  </service>
+                  <service>
+                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-data-consumer-broker</type>
+                     <instance>
+                        <name>ref_binding-data-broker</name>
+                        <provider>/modules/module[type='binding-data-broker'][name='binding-data-broker']</provider>
+                     </instance>
+                  </service>
+                  <service>
+                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-rpc-registry</type>
+                     <instance>
+                        <name>ref_binding-broker-impl</name>
+                        <provider>/modules/module[type='binding-broker-impl'][name='binding-broker-impl']</provider>
+                     </instance>
+                  </service>
+                  <service>
+                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-notification-service</type>
+                     <instance>
+                        <name>ref_binding-notification-broker</name>
+                        <provider>/modules/module[type='binding-notification-broker'][name='binding-notification-broker']</provider>
+                     </instance>
+                  </service>
+                  <service>
+                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
+                     <instance>
+                        <name>ref_binding-broker-impl</name>
+                        <provider>/modules/module[type='binding-broker-impl'][name='binding-broker-impl']</provider>
+                     </instance>
+                  </service>
+                  <service>
+                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-notification-subscription-service</type>
+                     <instance>
+                        <name>ref_binding-notification-broker</name>
+                        <provider>/modules/module[type='binding-notification-broker'][name='binding-notification-broker']</provider>
+                     </instance>
+                  </service>
+                  <service>
+                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-data-broker</type>
+                     <instance>
+                        <name>ref_binding-data-broker</name>
+                        <provider>/modules/module[type='binding-data-broker'][name='binding-data-broker']</provider>
+                     </instance>
+                  </service>
+               </services>
+            </data>
+         </configuration>
+      </snapshot>
+   </snapshots>
+</persisted-snapshots>
diff --git a/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/commit.xml b/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/commit.xml
new file mode 100644 (file)
index 0000000..ffdf132
--- /dev/null
@@ -0,0 +1,3 @@
+<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
+    <commit></commit>
+</rpc>
diff --git a/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/editConfig_identities.xml b/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/editConfig_identities.xml
new file mode 100644 (file)
index 0000000..cf9f3e5
--- /dev/null
@@ -0,0 +1,37 @@
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+<edit-config>
+    <target>
+        <candidate/>
+    </target>
+    <test-option>
+        set
+    </test-option>
+    <default-operation>merge</default-operation>
+    <config>
+        <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+            <module>
+                <type xmlns:test-impl="urn:opendaylight:params:xml:ns:yang:controller:test:impl">
+                    test-impl:impl-identity-test
+                </type>
+                <name>id-test</name>
+                <identities>
+                    <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity1</afi>
+                    <safi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity2</safi>
+                </identities>
+                <identities>
+                    <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity2</afi>
+                    <safi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity1</safi>
+                </identities>
+                <identities-container>
+                    <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity2</afi>
+                </identities-container>
+                <afi xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:test:types">prefix:test-identity1</afi>
+            </module>
+        </modules>
+
+        <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+
+        </services>
+    </config>
+</edit-config>
+</rpc>
diff --git a/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/getConfig.xml b/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/getConfig.xml
new file mode 100644 (file)
index 0000000..39efb49
--- /dev/null
@@ -0,0 +1,7 @@
+<rpc id="a" a="64" xmlnx="a:b:c:d" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
+    <get-config>
+        <source>
+            <running/>
+        </source>
+    </get-config>
+</rpc>