You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2013/06/15 00:23:24 UTC

svn commit: r1493266 - in /uima/uimaj/trunk/uimaj-core/src: main/java/org/apache/uima/cas/ main/java/org/apache/uima/cas/impl/ main/java/org/apache/uima/internal/util/ main/resources/org/apache/uima/ test/java/org/apache/uima/cas/impl/

Author: schor
Date: Fri Jun 14 22:23:23 2013
New Revision: 1493266

URL: http://svn.apache.org/r1493266
Log:
[UIMA-2874] remove the special APIs on the CASfor compressed serialization, per the discussion on this Jira.  Add them to all the others in Serialization class, with some cleanup, name matching, etc.  Along the way, document in javadocs the various other APIs involved with serialization stuff.  Update other parts of the code to use the new APIs.

Modified:
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/SerialFormat.java
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASCompleteSerializer.java
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASSerializer.java
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/Serialization.java
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/SerializationUtils.java
    uima/uimaj/trunk/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties
    uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest6.java

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java?rev=1493266&r1=1493265&r2=1493266&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java Fri Jun 14 22:23:23 2013
@@ -1063,40 +1063,5 @@ public interface CAS extends AbstractCas
   */
   List<Marker> getMarkers();
   
-  /**
-   * Serialize in compressed binary form 4
-   * @param out - an OutputStream, a DataOutputStream, or a File
-   * @throws IOException
-   */
-  public void serializeWithCompression(Object out) throws IOException ;
-  
-  /**
-   * Serialize in compress binary form 4, only the delta part of a CAS
-   * @param out - an OutputStream, a DataOutputStream, or a File
-   * @param marker identifying where the delta starts
-   * @throws IOException
-   */
-  public void serializeWithCompression(Object out, Marker marker) throws IOException;
-  
-  /**
-   * Serialize in compressed binary form 6
-   * @param out an OutputStream, a DataOutputStream, or a File
-   * @param tgtTypeSystem null or a target TypeSystem, which must be mergable with this CAS's type system
-   * @return information to be used on subsequent serializations (to save time) or deserializations (for receiving delta CASs) 
-   * @throws IOException
-   * @throws ResourceInitializationException if target type system is incompatible with this CAS's type system
-   */
-  public ReuseInfo serializeWithCompression(Object out, TypeSystem tgtTypeSystem) throws IOException, ResourceInitializationException;
-  
-  /**
-   * @param out an OutputStream, a DataOutputStream, or a File
-   * @param tgtTypeSystem null or a target TypeSystem, which must be mergable with this CAS's type system
-   * @param mark if not null, indicates doing a delta CAS serialization
-   * @param reuseInfo if mark is not null, this parameter is required 
-   * - and must have been computed when the service did the original deserialization of the CAS now being serialized as a delta CAS
-   * @throws IOException
-   * @throws ResourceInitializationException if target type system is incompatible with this CAS's type system
-   */
-  public void serializeWithCompression(Object out, TypeSystem tgtTypeSystem, Marker mark, ReuseInfo reuseInfo) throws IOException, ResourceInitializationException;
-  
+
 }

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java?rev=1493266&r1=1493265&r2=1493266&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java Fri Jun 14 22:23:23 2013
@@ -193,6 +193,9 @@ public class CASRuntimeException extends
 
   /** Deserializing Binary Header invalid */
   public static final String DESERIALIZING_BINARY_INVALID_HEADER = "DESERIALIZING_BINARY_INVALID_HEADER";
+  
+  /** Deserializing compressed binary other than form 4 not supported by this method */
+  public static final String DESERIALIZING_COMPRESSED_BINARY_UNSUPPORTED = "DESERIALIZING_COMPRESSED_BINARY_UNSUPPORTED";
 
   
 	public CASRuntimeException() {

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/SerialFormat.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/SerialFormat.java?rev=1493266&r1=1493265&r2=1493266&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/SerialFormat.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/SerialFormat.java Fri Jun 14 22:23:23 2013
@@ -18,6 +18,10 @@
  */
 package org.apache.uima.cas;
 
+/**
+ * The various forms of serialization (typically of the CAS)  
+ *
+ */
 public enum SerialFormat {
   UNKNOWN,
   XCAS,         // with reachability filtering

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java?rev=1493266&r1=1493265&r2=1493266&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java Fri Jun 14 22:23:23 2013
@@ -123,13 +123,8 @@ import org.apache.uima.util.impl.Seriali
  * 
  * 1) get an appropriate CAS to deserialize into.  For delta CAS, it does not have to be empty, but it must
  *    be the originating CAS from which the delta was produced.
- * 2) call CASImpl: cas.reinit(inputStream)  This is the existing method
- *    for binary deserialization, and it now handles this compressed version, too.
- *    Delta cas is also supported.  This form requires both source and target type systems to be exactly the same.
- *    
- * An alternative interface for Deserialization with type system mapping:
- * 1) get an appropriate CAS to deserialize into (as above).
- * 2) create an instance of this class -> xxx
+ * 2) If the case is one where the target type system == the CAS's, and the serialized for is not Delta,
+ *    then, call aCAS.reinit(source).  Otherwise, create an instance of this class -> xxx
  *    a) Assuming the object being deserialized has a different type system, 
  *       set the "target" type system to the TypeSystemImpl instance of the 
  *       object being deserialized.    
@@ -252,8 +247,10 @@ public class BinaryCasSerDes6 {
    */
   public static class ReuseInfo {
     /**
-     * kept here only to avoid recomputation in the use case:
-     *   serialize to target 1, serialize same to target 2, etc.
+     * kept to avoid recomputation in the use case:
+     *   - serialize to target 1, serialize same to target 2, etc.
+     *   - Delta serialization (uses reuse info saved during initial deserialization)
+     *   - Delta deserialization 
      *   if Null, recomputed when needed
      * BitSet used to test if fsRef needs to be serialized   
      */
@@ -3537,7 +3534,7 @@ public class BinaryCasSerDes6 {
     
     version = deserIn.readInt();
     if (version == 0) {
-      throw new RuntimeException(String.format("Wrong version: %d in compressed file passed to BinaryCasSerDes6", version));
+      throw new RuntimeException(String.format("Wrong version: %d in input source passed to BinaryCasSerDes6 for deserialization", version));
     }
   }
   

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASCompleteSerializer.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASCompleteSerializer.java?rev=1493266&r1=1493265&r2=1493266&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASCompleteSerializer.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASCompleteSerializer.java Fri Jun 14 22:23:23 2013
@@ -22,9 +22,9 @@ package org.apache.uima.cas.impl;
 import java.io.Serializable;
 
 /**
- * Class comment for CASCompleteSerializer.java goes here.
- * 
- * 
+ * This is a small object which contains 
+ *   - CASMgrSerializer instance - a Java serializable form of the type system + index definitions
+ *   - CASSerializer instance - a Java serializable form of the CAS including lists of which FSs are indexed  
  */
 public class CASCompleteSerializer implements Serializable {
 

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java?rev=1493266&r1=1493265&r2=1493266&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java Fri Jun 14 22:23:23 2013
@@ -1162,20 +1162,10 @@ public class CASImpl extends AbstractCas
    * @param istream
    * @throws CASRuntimeException
    */
-  
+
   public SerialFormat reinit(InputStream istream) throws CASRuntimeException {
-    return reinit(istream, null);
-  }
-  
-  /**
-   * Called by services for delta deserialization with saved reuse info
-   * @param istream
-   * @param rfs - reuse info collected when serializaing out to service
-   * @throws CASRuntimeException
-   */
-  public SerialFormat reinit(InputStream istream, ReuseInfo rfs) throws CASRuntimeException {
     if (this != this.svd.baseCAS) {
-      return this.svd.baseCAS.reinit(istream, rfs);
+      return this.svd.baseCAS.reinit(istream);
     }
    
     final DataInputStream dis = (istream instanceof DataInputStream) ?  
@@ -1207,10 +1197,12 @@ public class CASImpl extends AbstractCas
           (new BinaryCasSerDes4(this.getTypeSystemImpl(), false)).deserialize(this, dis, delta);
           return SerialFormat.COMPRESSED;
         } else {
+//          throw new CASRuntimeException(CASRuntimeException.DESERIALIZING_COMPRESSED_BINARY_UNSUPPORTED);
+          // Only works for cases where the type systems match, and delta is false.
           try {
-            (new BinaryCasSerDes6(this, rfs)).deserializeAfterVersion(dis, delta, AllowPreexistingFS.allow);
+            (new BinaryCasSerDes6(this)).deserializeAfterVersion(dis, delta, AllowPreexistingFS.allow);
           } catch (ResourceInitializationException e) {
-            // never thrown
+            throw new CASRuntimeException(CASRuntimeException.DESERIALIZING_COMPRESSED_BINARY_UNSUPPORTED, null, e);
           }
           return SerialFormat.COMPRESSED_FILTERED;
         }
@@ -4310,37 +4302,4 @@ public class CASImpl extends AbstractCas
 		return this.svd.modifiedLongHeapCells;  
   }
   
-  /**
-   * @see org.apache.uima.cas.CAS#serializeWithCompression(Object out)
-   */
-  public void serializeWithCompression(Object out) throws IOException {
-    (new BinaryCasSerDes4(this.getTypeSystemImpl(), false)).serialize(this, out);
-  }
-  
-  /**
-   * @see org.apache.uima.cas.CAS#serializeWithCompression(Object out, Marker marker)
-   */
-  public void serializeWithCompression(Object out, Marker marker) throws IOException {
-    (new BinaryCasSerDes4(this.getTypeSystemImpl(), false)).serialize(this, out, marker);
-  }
-  
-  /**
-   * @throws ResourceInitializationException if target type system is incompatible with this CAS's type system
-   * @see org.apache.uima.cas.CAS#serializeWithCompression(Object out, TypeSystem tgtTypeSystem, Marker marker)
-   */
-  public ReuseInfo serializeWithCompression(Object out, TypeSystem tgtTypeSystem) throws IOException, ResourceInitializationException {
-    BinaryCasSerDes6 bcs = new BinaryCasSerDes6(this, (TypeSystemImpl) tgtTypeSystem);
-    bcs.serialize(out);
-    return bcs.getReuseInfo();
-  }
-  
-  /**
-   * @throws ResourceInitializationException if target type system is incompatible with this CAS's type system
-   * @see org.apache.uima.cas.CAS#serializeWithCompression(Object out, TypeSystem tgtTypeSystem, Marker mark, ReuseInfo reuseInfo)
-   */
-  public void serializeWithCompression(Object out, TypeSystem tgtTypeSystem, Marker mark, ReuseInfo reuseInfo) throws IOException, ResourceInitializationException {
-    BinaryCasSerDes6 bcs = new BinaryCasSerDes6(this, (MarkerImpl) mark, (TypeSystemImpl) tgtTypeSystem, reuseInfo);
-    bcs.serialize(out);
-  }
-   
 }

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASSerializer.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASSerializer.java?rev=1493266&r1=1493265&r2=1493266&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASSerializer.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASSerializer.java Fri Jun 14 22:23:23 2013
@@ -30,14 +30,19 @@ import org.apache.uima.cas.CASRuntimeExc
 import org.apache.uima.cas.Marker;
 
 /**
- * Binary Serialization for CAS. This serializes the state of the CAS, assuming that the type and index
- * information remains constant. <code>CASSerializer</code> objects can be serialized with
- * standard Java serialization; many uses of this class follow this form:
+ * This object has 2 purposes.
+ *   - it can hold a collection of individually Java-object-serializable objects representing a CAS +
+ *     the list of FS's indexed in the CAS
+ *     
+ *   - it has special methods to do a custom binary serialization (no compression) of a CAS + lists
+ *     of its indexed FSs.
+ * 
+ * One use of this class follows this form:
  * 
  * 1) create an instance of this class
  * 2) add a Cas to it (via addCAS methods)
  * 3) use the instance of this class as the argument to anObjectOutputStream.writeObject(anInstanceOfThisClass)
- *    In UIMA this is done in the SerializationUtils class.
+ *    In UIMA this is done in the SerializationUtils class; it appears to be used for SOAP and Vinci service adapters.
  * 
  * There are also custom serialization methods that serialize to outputStreams.
  * 
@@ -48,17 +53,14 @@ import org.apache.uima.cas.Marker;
  *     full / delta:
  *       full - the entire cas
  *       delta - only differences from a previous "mark" are serialized
- *     uncompressed / compressed / compressed (fast)
- *       uncompressed
- *       compressed - trades off time for space to give the most compression
- *       compressed (fast) - less compression, but faster 
+ *       
+ *   This class only does uncompressed forms of custom binary serialization.    
  *     
  * This class is for internal use.  Some of the serialized formats are readable by the C++
  * implementation, and used for efficiently transferring CASes between Java frameworks and other ones.
  * Others are used with Vinci or SOAP to communicate to remote annotators.
  * 
- * To serialize the shared common information among a group of CASes sharing the same
- * type definition and index specifications, 
+ * To serialize the type definition and index specifications for a CAS
  * @see org.apache.uima.cas.impl.CASMgrSerializer
  * 
  * 

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/Serialization.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/Serialization.java?rev=1493266&r1=1493265&r2=1493266&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/Serialization.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/Serialization.java Fri Jun 14 22:23:23 2013
@@ -19,6 +19,7 @@
 
 package org.apache.uima.cas.impl;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 
@@ -26,22 +27,64 @@ import org.apache.uima.cas.CAS;
 import org.apache.uima.cas.CASRuntimeException;
 import org.apache.uima.cas.Marker;
 import org.apache.uima.cas.SerialFormat;
+import org.apache.uima.cas.TypeSystem;
 import org.apache.uima.cas.admin.CASMgr;
+import org.apache.uima.cas.impl.BinaryCasSerDes6.ReuseInfo;
+import org.apache.uima.resource.ResourceInitializationException;
 
+/**
+ * This class has no fields or instance methods, but instead 
+ * has only static methods.
+ * 
+ * In spite of its name, it has static methods for both serializing and deserializing CASes.
+ * 
+ * It has 2 styles of Serialization / Deserialization 
+ *   - one which makes use of variouscustom binary serialization methods, and
+ *   - one which just converts CAS and related objects into other objects which
+ *     in turn are serializable by normal Java Object serialization.
+ *      
+ */
 public class Serialization {
 
+  /***************************************************************
+   * These methods convert a CAS to / from a serializable object * 
+   * and vice-versa.                                             *
+   * Some also handle type system and index definitions          *
+   ***************************************************************/
+
+  /**
+   * Convert a CAS to a CASSerializer object.
+   * This object used in testing , and also to pass things via the CPP JNI interface, and the Vinci protocol
+   * @param cas
+   * @return a corresponding CASSerializer object
+   */
   public static CASSerializer serializeCAS(CAS cas) {
     CASSerializer ser = new CASSerializer();
     ser.addCAS((CASImpl) cas);
     return ser;
   }
 
+  /**
+   * Convert a CAS to a CASSerializer object.
+   * This object used in testing
+   * Excludes metadata about the CAS
+   * @param cas
+   * @return a corresponding CASSerializer object
+   */
+
   public static CASSerializer serializeNoMetaData(CAS cas) {
     CASSerializer ser = new CASSerializer();
     ser.addNoMetaData((CASImpl) cas);
     return ser;
   }
 
+  /**
+   * Convert a Type System and Index Repository into a 
+   * CASMgrSerializer object which can be serialized
+   * 
+   * @param casMgr the type system and index repo definitions
+   * @return a seriailzable object version of these
+   */
   public static CASMgrSerializer serializeCASMgr(CASMgr casMgr) {
     CASMgrSerializer ser = new CASMgrSerializer();
     ser.addTypeSystem((TypeSystemImpl) casMgr.getCAS().getTypeSystem());
@@ -50,14 +93,32 @@ public class Serialization {
     return ser;
   }
 
+  /**
+   * Convert a CAS + the type system and index definitions into a
+   * CASCompleteSerializer object
+   * @param casMgr
+   * @return
+   */
   public static CASCompleteSerializer serializeCASComplete(CASMgr casMgr) {
     return new CASCompleteSerializer((CASImpl) casMgr);
   }
 
+  /**
+   * Deserialize the data in a CASCompleteSerializer into an 
+   * existing CAS
+   * @param casCompSer
+   * @param casMgr
+   */
   public static void deserializeCASComplete(CASCompleteSerializer casCompSer, CASMgr casMgr) {
     ((CASImpl) casMgr).reinit(casCompSer);
   }
 
+  /**
+   * Deserialize a type system and index repository definition and use to initialize
+   * a new instance of a CAS.
+   * @param ser
+   * @return
+   */
   public static CASMgr createCASMgr(CASMgrSerializer ser) {
     return new CASImpl(ser);
   }
@@ -66,16 +127,46 @@ public class Serialization {
   // return new CASImpl(ser);
   // }
 
+  /**
+   * Deserialize the data in a CASSerializer into an existing CAS,
+   * return the currentview in that Cas.
+   * @param casMgr
+   * @param casSer
+   * @return
+   */
   public static CAS createCAS(CASMgr casMgr, CASSerializer casSer) {
     ((CASImpl) casMgr).reinit(casSer);
     return ((CASImpl) casMgr).getCurrentView();
   }
 
+  
+  /*******************************************************************************
+   * Methods from here on do some form of custom serialization / deserialization *
+   * with data streams, byte arrays, etc.                                        *   
+   *******************************************************************************/
+  
+  /**
+   * Serialize a CAS including what's indexed, to an output stream
+   * Uses uncompressed binary serialization
+   * @param cas
+   * @param ostream
+   */
   public static void serializeCAS(CAS cas, OutputStream ostream) {
     CASSerializer ser = new CASSerializer();
     ser.addCAS((CASImpl) cas, ostream);
   }
 
+  /**
+   * Deserialize a CAS, in various binary formats, into an existing CAS
+   *   Note: this form supports deserializing the following binary representations:
+   *     - plain (uncompressed)
+   *     - compressed, no type filtering (form 4), Delta and not-delta
+   *     - compressed, no type filtering (form 6), not-delta only.
+   *     If this form encounters a non-conforming kind of input, it will throw a runtime exception.  
+   * @param cas the CAS to deserialize into.  If the incoming representation is a Delta Cas, then the receiving CAS is not reset, but is added to.
+   * @param istream 
+   * @return The form of the serialized CAS (from its header)
+   */
   public static SerialFormat deserializeCAS(CAS cas, InputStream istream) {
     return ((CASImpl) cas).reinit(istream);
   }
@@ -83,6 +174,7 @@ public class Serialization {
   /**
    * Serializes CAS data added or modified after the tracking Marker was created and writes it
    * to the output stream in Delta CAS format
+   * using uncompressed binary format
    * @param cas
    * @param ostream
    * @param mark
@@ -95,4 +187,116 @@ public class Serialization {
   	ser.addCAS((CASImpl) cas, ostream, mark);
   }
 
+  /*******************************************************************************
+   * Methods from here on use some form of compression                           *
+   *******************************************************************************/
+  
+  /**
+   * Serialize in compressed binary form 4
+   * @param out - an OutputStream, a DataOutputStream, or a File
+   * @throws IOException
+   */
+  public void serializeWithCompression(CAS cas, Object out) throws IOException {
+    (new BinaryCasSerDes4(((CASImpl)cas).getTypeSystemImpl(), false)).serialize(cas, out);
+  }
+  
+  /**
+   * Serialize in compress binary form 4, only the delta part of a CAS
+   * @param out - an OutputStream, a DataOutputStream, or a File
+   * @param marker identifying where the delta starts
+   * @throws IOException
+   */  
+  public void serializeWithCompression(CAS cas, Object out, Marker marker) throws IOException {
+    (new BinaryCasSerDes4(((CASImpl)cas).getTypeSystemImpl(), false)).serialize(cas, out, marker);
+  }
+  
+  /**
+   * Serialize in compressed binary with type filtering
+   * This method can use type filtering to omit sending those types and/or features not present in the target type system.
+   *   - To omit type filtering, use null for the target type system
+   * It also only sends those feature structures which are reachable either from an index or references from other reachable feature structures.
+   * 
+   * @param out an OutputStream, a DataOutputStream, or a File
+   * @param tgtTypeSystem null or a target TypeSystem, which must be mergable with this CAS's type system
+   * @return information to be used on subsequent serializations (to save time) or deserializations (for receiving delta CASs), or reserializations (if sending delta CASs)
+   * @throws IOException
+   * @throws ResourceInitializationException if target type system is incompatible with this CAS's type system
+   */  
+  public ReuseInfo serializeWithCompression(CAS cas, Object out, TypeSystem tgtTypeSystem) throws IOException, ResourceInitializationException {
+    BinaryCasSerDes6 bcs = new BinaryCasSerDes6(cas, (TypeSystemImpl) tgtTypeSystem);
+    bcs.serialize(out);
+    return bcs.getReuseInfo();
+  }
+  
+  /**
+   * Delta Serialize in compressed form, with type filtering
+   * This method can use type filtering to omit sending those types and/or features not present in the target type system.
+   *   - To omit type filtering, use null for the target type system
+   * It also only sends those feature structures which are reachable either from an index or references from other reachable feature structures.
+   *
+   * @param out an OutputStream, a DataOutputStream, or a File
+   * @param tgtTypeSystem null or a target TypeSystem, which must be mergable with this CAS's type system
+   * @param mark null or where the mark is in the CAS. If not null, indicates doing a delta CAS serialization
+   * @param reuseInfo if mark is not null, this parameter is required 
+   *                  and must have been computed when the original deserialization (of the CAS now being serialized as a delta CAS) was done
+   * @throws IOException
+   * @throws ResourceInitializationException if the target type system and the CAS's type system can't be merged
+   */
+  public void serializeWithCompression(CAS cas, Object out, TypeSystem tgtTypeSystem, Marker mark, ReuseInfo reuseInfo) throws IOException, ResourceInitializationException {
+    BinaryCasSerDes6 bcs = new BinaryCasSerDes6(cas, (MarkerImpl) mark, (TypeSystemImpl) tgtTypeSystem, reuseInfo);
+    bcs.serialize(out);
+  }  
+  
+  /**
+   * Deserialize a CAS, in various binary formats, into an existing CAS
+   *   Note: this form supports deserializing the following binary representations:
+   *     - compressed, type filtering (form 6), delta and not-delta.
+   *   
+   * @param cas the CAS to deserialize into.  If the incoming representation is a Delta Cas, then the receiving CAS is not reset, but is added to.
+   * @param istream 
+   * @param tgtTypeSystem The typeSystem of the serialized form of the CAS; must be compatible with the type system of the receiving cas.
+   * @param reuseInfo If delta CAS is being received and form 6 compression is being used, then this must be the reuseInfo captured when the
+   *                  original CAS (being updated by the delta coming in) was sent out.
+   * @return The instance of BinaryCasSerDes6 used for deserialization
+   * @throws IOException 
+   * @throws ResourceInitializationException if the target type system and the CAS's type system can't be merged
+   */
+  public static BinaryCasSerDes6 deserializeCAS(CAS cas, InputStream istream, TypeSystem tgtTypeSystem, ReuseInfo reuseInfo) throws IOException, ResourceInitializationException {
+    BinaryCasSerDes6 bcs = new BinaryCasSerDes6(cas, null, (TypeSystemImpl) tgtTypeSystem, reuseInfo);
+    bcs.deserialize(istream);
+    return bcs;
+  }
+  
+  /**
+   * Deserialize a CAS, in various binary formats, into an existing CAS
+   *   Note: this form supports deserializing the following binary representations:
+   *     - compressed, type filtering (form 6), delta and not-delta.
+   *   
+   * @param cas the CAS to deserialize into.  If the incoming representation is a Delta Cas, then the receiving CAS is not reset, but is added to.
+   * @param istream 
+   * @param tgtTypeSystem The typeSystem of the serialized form of the CAS; must be compatible with the type system of the receiving cas.
+   * @param reuseInfo If delta CAS is being received and form 6 compression is being used, then this must be the reuseInfo captured when the
+   *                  original CAS (being updated by the delta coming in) was sent out.
+   * @param allowPreexisting used to control what happens when a delta cas is modifying Feature Structures below the line
+   * @return The instance of BinaryCasSerDes6 used for deserialization
+   * @throws IOException 
+   * @throws ResourceInitializationException if the target type system and the CAS's type system can't be merged
+   */
+  /**
+   * 
+   * @param cas
+   * @param istream
+   * @param tgtTypeSystem
+   * @param reuseInfo
+
+   * @return
+   * @throws IOException
+   * @throws ResourceInitializationException
+   */
+  public static BinaryCasSerDes6 deserializeCAS(CAS cas, InputStream istream, TypeSystem tgtTypeSystem, ReuseInfo reuseInfo, AllowPreexistingFS allowPreexisting) throws IOException, ResourceInitializationException {
+    BinaryCasSerDes6 bcs = new BinaryCasSerDes6(cas, null, (TypeSystemImpl) tgtTypeSystem, reuseInfo);
+    bcs.deserialize(istream, allowPreexisting);
+    return bcs;
+  }
+
 }

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/SerializationUtils.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/SerializationUtils.java?rev=1493266&r1=1493265&r2=1493266&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/SerializationUtils.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/SerializationUtils.java Fri Jun 14 22:23:23 2013
@@ -27,9 +27,17 @@ import java.io.ObjectOutputStream;
 import java.io.Serializable;
 
 /**
- * Utilities for serializing and deserializing objects.
+ * Serialize and Deserialize arbitrary objects to/from byte arrays, 
+ * using standard Java object serialization/deserialization support.
  * 
+ * Used in the Vinci and Soap transports to serialize/deserialize 
+ * CASSerializer objects or
+ * CASCompleteSerializer objects (includes type system and index definitions) or
+ * (for SOAP) arbitrary objects
  * 
+ * 
+ * This class is abstract only to prevent instantiation.
+ * All the methods are static.
  */
 public abstract class SerializationUtils {
 

Modified: uima/uimaj/trunk/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties?rev=1493266&r1=1493265&r2=1493266&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties Fri Jun 14 22:23:23 2013
@@ -559,4 +559,5 @@ CANNOT_CLONE_SOFA = SofaFS may not be cl
 DELTA_CAS_PREEXISTING_FS_DISALLOWED = "Preexisting FS encountered but not allowed. "{0}"
 INVALID_MARKER = Marker is invalid.
 MULTIPLE_CREATE_MARKER = CreateMarker called multiple times for one CAS.  This implementation only supports one call.
-DESERIALIZING_BINARY_INVALID_HEADER = While deserializing binary CAS, found invalid header.
\ No newline at end of file
+DESERIALIZING_BINARY_INVALID_HEADER = While deserializing binary CAS, found invalid header.
+DESERIALIZING_COMPRESSED_BINARY_UNSUPPORTED = Using the reinit method to deserialize a binary CAS serialized with compressed serialization not supported for this case.
\ No newline at end of file

Modified: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest6.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest6.java?rev=1493266&r1=1493265&r2=1493266&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest6.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest6.java Fri Jun 14 22:23:23 2013
@@ -1154,9 +1154,8 @@ public class SerDesTest6 extends TestCas
         bcs.serialize(baos);
       }
       ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-      bcs = new BinaryCasSerDes6(casTgt, casSrc.getTypeSystemImpl());
-      bcs.deserialize(bais);
-      
+      Serialization.deserializeCAS(casTgt, bais, casSrc.getTypeSystemImpl(), null);
+
       bcs = new BinaryCasSerDes6(casSrc, casTgt.getTypeSystemImpl());
       assertTrue(bcs.compareCASes(casSrc, casTgt));
     } catch (IOException e) {
@@ -1193,9 +1192,7 @@ public class SerDesTest6 extends TestCas
       if (doPlain) {
         casTgt.reinit(bais);
       } else {
-        BinaryCasSerDes6 bcsDeserRmt = new BinaryCasSerDes6(casTgt);
-        bcsDeserRmt.deserialize(bais);
-        riToReturn[1] = bcsDeserRmt.getReuseInfo();
+        riToReturn[1] = Serialization.deserializeCAS(casTgt, bais, null, null).getReuseInfo();
       }
     } catch (IOException e) {
       throw new RuntimeException(e);
@@ -1221,8 +1218,7 @@ public class SerDesTest6 extends TestCas
         casSrc.reinit(bais);
         assertTrue(new BinaryCasSerDes6(casSrc).compareCASes(casSrc, remoteCas));
       } else {
-          BinaryCasSerDes6 bcsDeserialize = new BinaryCasSerDes6(casSrc, null, remoteCas.getTypeSystemImpl(), ri[0]);
-          bcsDeserialize.deserialize(bais);
+          BinaryCasSerDes6 bcsDeserialize = Serialization.deserializeCAS(casSrc, bais, remoteCas.getTypeSystemImpl(), ri[0]);
           assertTrue(bcsDeserialize.compareCASes(casSrc, remoteCas));
       }      
     } catch (IOException e) {