Merge changes I07a18f32,I8a1a0129
authorTony Tkacik <ttkacik@cisco.com>
Fri, 5 Dec 2014 11:22:17 +0000 (11:22 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 5 Dec 2014 11:22:17 +0000 (11:22 +0000)
* changes:
  Implement NetconfMessage.toString()
  Cleanup message logging in netconf handlers

opendaylight/adsal/commons/integrationtest/pom.xml
opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorFactory.java
opendaylight/netconf/netconf-it/pom.xml
opendaylight/netconf/netconf-monitoring/src/main/java/org/opendaylight/controller/netconf/monitoring/xml/JaxBSerializer.java

index 1701964bf1855cbf967e9e113cacd157608012a7..e4d795d563b174960750f9fcb2b1b5c47d0e07c4 100644 (file)
       <plugin>
         <groupId>org.ops4j.pax.exam</groupId>
         <artifactId>maven-paxexam-plugin</artifactId>
-        <version>1.2.4</version>
         <executions>
           <execution>
             <id>generate-config</id>
index 7efb28b4674e4fd592b169a2c7191c8f999f6585..ac13729d885fbf5b83ff21d4e9a90e91ab2dfa64 100644 (file)
@@ -10,10 +10,11 @@ package org.opendaylight.controller.netconf.client;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
+import com.google.common.collect.ImmutableSet;
 import io.netty.channel.Channel;
 import io.netty.util.Timer;
 import io.netty.util.concurrent.Promise;
+import java.util.Set;
 import org.opendaylight.controller.netconf.api.NetconfClientSessionPreferences;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 import org.opendaylight.controller.netconf.api.NetconfMessage;
@@ -32,28 +33,43 @@ import org.slf4j.LoggerFactory;
 
 public class NetconfClientSessionNegotiatorFactory implements SessionNegotiatorFactory<NetconfMessage, NetconfClientSession, NetconfClientSessionListener> {
 
-    public static final java.util.Set<String> CLIENT_CAPABILITIES = Sets.newHashSet(
+    public static final Set<String> CLIENT_CAPABILITIES = ImmutableSet.of(
             XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_0,
             XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_1,
             XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_CAPABILITY_EXI_1_0);
 
+    private static final Logger LOG = LoggerFactory.getLogger(NetconfClientSessionNegotiatorFactory.class);
     private static final String START_EXI_MESSAGE_ID = "default-start-exi";
+    private static final EXIOptions DEFAULT_OPTIONS;
 
     private final Optional<NetconfHelloMessageAdditionalHeader> additionalHeader;
     private final long connectionTimeoutMillis;
     private final Timer timer;
     private final EXIOptions options;
-    private static final Logger LOG = LoggerFactory.getLogger(NetconfClientSessionNegotiatorFactory.class);
 
-    public NetconfClientSessionNegotiatorFactory(Timer timer,
-                                                 Optional<NetconfHelloMessageAdditionalHeader> additionalHeader,
-                                                 long connectionTimeoutMillis) {
+    static {
+        final EXIOptions opts = new EXIOptions();
+        try {
+            opts.setPreserveDTD(true);
+            opts.setPreserveNS(true);
+            opts.setPreserveLexicalValues(true);
+            opts.setAlignmentType(AlignmentType.byteAligned);
+        } catch (EXIOptionsException e) {
+            throw new ExceptionInInitializerError(e);
+        }
+
+        DEFAULT_OPTIONS = opts;
+    }
+
+    public NetconfClientSessionNegotiatorFactory(final Timer timer,
+                                                 final Optional<NetconfHelloMessageAdditionalHeader> additionalHeader,
+                                                 final long connectionTimeoutMillis) {
         this(timer, additionalHeader, connectionTimeoutMillis, DEFAULT_OPTIONS);
     }
 
-    public NetconfClientSessionNegotiatorFactory(Timer timer,
-                                                 Optional<NetconfHelloMessageAdditionalHeader> additionalHeader,
-                                                 long connectionTimeoutMillis, EXIOptions exiOptions) {
+    public NetconfClientSessionNegotiatorFactory(final Timer timer,
+                                                 final Optional<NetconfHelloMessageAdditionalHeader> additionalHeader,
+                                                 final long connectionTimeoutMillis, final EXIOptions exiOptions) {
         this.timer = Preconditions.checkNotNull(timer);
         this.additionalHeader = additionalHeader;
         this.connectionTimeoutMillis = connectionTimeoutMillis;
@@ -61,9 +77,9 @@ public class NetconfClientSessionNegotiatorFactory implements SessionNegotiatorF
     }
 
     @Override
-    public SessionNegotiator<NetconfClientSession> getSessionNegotiator(SessionListenerFactory<NetconfClientSessionListener> sessionListenerFactory,
-                                                                        Channel channel,
-            Promise<NetconfClientSession> promise) {
+    public SessionNegotiator<NetconfClientSession> getSessionNegotiator(final SessionListenerFactory<NetconfClientSessionListener> sessionListenerFactory,
+                                                                        final Channel channel,
+            final Promise<NetconfClientSession> promise) {
 
         NetconfMessage startExiMessage = NetconfStartExiMessage.create(options, START_EXI_MESSAGE_ID);
         NetconfHelloMessage helloMessage = null;
@@ -78,17 +94,4 @@ public class NetconfClientSessionNegotiatorFactory implements SessionNegotiatorF
         return new NetconfClientSessionNegotiator(proposal, promise, channel, timer,
                 sessionListenerFactory.getSessionListener(),connectionTimeoutMillis);
     }
-
-    private static final EXIOptions DEFAULT_OPTIONS = new EXIOptions();
-    static {
-        try {
-            DEFAULT_OPTIONS.setPreserveDTD(true);
-            DEFAULT_OPTIONS.setPreserveNS(true);
-            DEFAULT_OPTIONS.setPreserveLexicalValues(true);
-            DEFAULT_OPTIONS.setAlignmentType(AlignmentType.preCompress);
-        } catch (EXIOptionsException e) {
-            // Should not happen since DEFAULT_OPTIONS are still the same
-            throw new IllegalStateException("Unable to create EXI DEFAULT_OPTIONS");
-        }
-    }
 }
index b2c5c4c8f7a6fa4a6818ba5a740cae1b29ebb7c2..7218ac78726c7c7297e215d57211a8a749f70c8f 100644 (file)
       <scope>test</scope>
     </dependency>
   </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.ops4j.pax.exam</groupId>
-        <artifactId>maven-paxexam-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>generate-config</id>
-            <goals>
-              <goal>generate-depends-file</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
 </project>
index 45f02af78994d1e87b8dc1c86c7b81e7e57d9f1a..e80e3f82b1f6c0650bfc4619ab3e17ad5660186e 100644 (file)
@@ -16,12 +16,20 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 public class JaxBSerializer {
+    private static final JAXBContext JAXB_CONTEXT;
+
+    static {
+        try {
+            JAXB_CONTEXT = JAXBContext.newInstance(NetconfState.class);
+        } catch (JAXBException e) {
+            throw new ExceptionInInitializerError(e);
+        }
+    }
 
     public Element toXml(final NetconfState monitoringModel) {
         final DOMResult res;
         try {
-            final JAXBContext jaxbContext = JAXBContext.newInstance(NetconfState.class);
-            final Marshaller marshaller = jaxbContext.createMarshaller();
+            final Marshaller marshaller = JAXB_CONTEXT.createMarshaller();
 
             marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);