ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1467913 - in /ace/trunk/org.apache.ace.client.repository: src/org/apache/ace/client/repository/impl/ test/org/apache/ace/client/repository/impl/
Date Mon, 15 Apr 2013 09:27:20 GMT
Author: marrs
Date: Mon Apr 15 09:27:20 2013
New Revision: 1467913

URL: http://svn.apache.org/r1467913
Log:
ACE-332 Added gzip compression to the from/toXML methods, which compresses the data before
it is sent over the network. Slightly modified the tests to handle IOExceptions.

Modified:
    ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositorySerializer.java
    ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositorySet.java
    ace/trunk/org.apache.ace.client.repository/test/org/apache/ace/client/repository/impl/ModelTest.java

Modified: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositorySerializer.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositorySerializer.java?rev=1467913&r1=1467912&r2=1467913&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositorySerializer.java
(original)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositorySerializer.java
Mon Apr 15 09:27:20 2013
@@ -23,6 +23,8 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
 
 import com.thoughtworks.xstream.XStream;
 import com.thoughtworks.xstream.converters.Converter;
@@ -82,12 +84,14 @@ class RepositorySerializer implements Co
     }
 
     @SuppressWarnings("unchecked")
-    public void toXML(OutputStream out) {
+    public void toXML(OutputStream out) throws IOException {
         for (ObjectRepositoryImpl repo : m_set.getRepos()) {
             repo.setBusy(true);
         }
         try {
-            m_stream.toXML(this, out);
+        	GZIPOutputStream zout = new GZIPOutputStream(out);
+            m_stream.toXML(this, zout);
+            zout.finish();
         }
         finally {
             // Ensure all busy flags are reset at all times...
@@ -114,6 +118,7 @@ class RepositorySerializer implements Co
         try {
             Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
             if (in.available() > 0) {
+            	in = new GZIPInputStream(in);
                 m_stream.fromXML(in, this);
             }
         }

Modified: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositorySet.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositorySet.java?rev=1467913&r1=1467912&r2=1467913&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositorySet.java
(original)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositorySet.java
Mon Apr 15 09:27:20 2013
@@ -206,8 +206,8 @@ class RepositorySet {
         final PipedOutputStream output = new PipedOutputStream(input);
         new Thread(new Runnable() {
             public void run() {
-                new RepositorySerializer(RepositorySet.this).toXML(output);
                 try {
+                	new RepositorySerializer(RepositorySet.this).toXML(output);
                     output.flush();
                     output.close();
                 }

Modified: ace/trunk/org.apache.ace.client.repository/test/org/apache/ace/client/repository/impl/ModelTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/test/org/apache/ace/client/repository/impl/ModelTest.java?rev=1467913&r1=1467912&r2=1467913&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/test/org/apache/ace/client/repository/impl/ModelTest.java
(original)
+++ ace/trunk/org.apache.ace.client.repository/test/org/apache/ace/client/repository/impl/ModelTest.java
Mon Apr 15 09:27:20 2013
@@ -20,6 +20,7 @@ package org.apache.ace.client.repository
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Dictionary;
 import java.util.HashMap;
@@ -228,7 +229,7 @@ public class ModelTest {
     }
 
     @Test( groups = { TestUtils.UNIT } )
-    public void testRepositorySerialization() {
+    public void testRepositorySerialization() throws IOException {
         createBasicArtifactObject("myartifact", "1");
         createBasicArtifactObject("myartifact", "2");
 
@@ -244,7 +245,7 @@ public class ModelTest {
     }
 
     @Test( groups = { TestUtils.UNIT } )
-    public void testSerialization() {
+    public void testSerialization() throws IOException {
         ArtifactObject b1 = createBasicArtifactObject("artifact1");
         ArtifactObject b2 = createBasicArtifactObject("artifact2");
         ArtifactObject b3 = createBasicArtifactObject("artifact3");
@@ -483,7 +484,7 @@ public class ModelTest {
     }
 
     @Test( groups = { TestUtils.UNIT } )
-    public void testDeploymentVersion() {
+    public void testDeploymentVersion() throws IOException {
         DeploymentVersionObject version = createBasicDeploymentVersionObject("target1", "1",
new String[] {"artifact1", "artifact2"});
 
         assert version.getDeploymentArtifacts().length == 2 : "We expect to find two artifacts,
but we find " + version.getDeploymentArtifacts().length;



Mime
View raw message