jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r683244 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state: ItemState.java NodeState.java PropertyState.java
Date Wed, 06 Aug 2008 12:18:10 GMT
Author: mreutegg
Date: Wed Aug  6 05:18:08 2008
New Revision: 683244

URL: http://svn.apache.org/viewvc?rev=683244&view=rev
Log:
JCR-1709: Remove Serializable on ItemState classes

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ItemState.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ItemState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ItemState.java?rev=683244&r1=683243&r2=683244&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ItemState.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ItemState.java
Wed Aug  6 05:18:08 2008
@@ -21,18 +21,10 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-
 /**
  * <code>ItemState</code> represents the state of an <code>Item</code>.
  */
-public abstract class ItemState implements Serializable {
-
-    /** Serialization UID of this class. */
-    static final long serialVersionUID = -1473610775880779769L;
+public abstract class ItemState {
 
     /**
      * Logger instance
@@ -87,12 +79,12 @@
     /**
      * Parent container.
      */
-    private transient ItemStateListener container;
+    private ItemStateListener container;
 
     /**
      * the backing persistent item state (may be null)
      */
-    protected transient ItemState overlayedState;
+    protected ItemState overlayedState;
 
     /**
      * Constructs a new unconnected item state
@@ -429,15 +421,4 @@
      * @return the approximate memory consumption of this state.
      */
     public abstract long calculateMemoryFootprint();
-
-    //-------------------------------------------------< Serializable support >
-    private void writeObject(ObjectOutputStream out) throws IOException {
-        // delegate to default implementation
-        out.defaultWriteObject();
-    }
-
-    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
-        // delegate to default implementation
-        in.defaultReadObject();
-    }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java?rev=683244&r1=683243&r2=683244&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeState.java
Wed Aug  6 05:18:08 2008
@@ -23,12 +23,7 @@
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.nodetype.NodeDefId;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -46,11 +41,6 @@
 public class NodeState extends ItemState {
 
     /**
-     * Serialization UID of this class.
-     */
-    static final long serialVersionUID = 4392375681805781770L;
-
-    /**
      * the name of this node's primary type
      */
     private Name nodeTypeName;
@@ -959,18 +949,6 @@
         }
     }
 
-    //-------------------------------------------------< Serializable support >
-    private void writeObject(ObjectOutputStream out) throws IOException {
-        // delegate to default implementation
-        out.defaultWriteObject();
-    }
-
-    private void readObject(ObjectInputStream in)
-            throws IOException, ClassNotFoundException {
-        // delegate to default implementation
-        in.defaultReadObject();
-    }
-
     //--------------------------------------------------------< inner classes >
     /**
      * <code>ChildNodeEntries</code> represents an insertion-ordered
@@ -980,7 +958,7 @@
      * <code>ChildNodeEntries</code> also provides an unmodifiable
      * <code>List</code> view.
      */
-    private static class ChildNodeEntries implements List, Cloneable, Serializable {
+    private static class ChildNodeEntries implements List, Cloneable {
 
         // insertion-ordered map of entries (key=NodeId, value=entry)
         private LinkedMap entries;
@@ -1375,32 +1353,6 @@
             throw new UnsupportedOperationException();
         }
 
-        //---------------------------------------------< Serializable support >
-        private void writeObject(ObjectOutputStream out) throws IOException {
-            // important: fields must be written in same order as they are
-            // read in readObject(ObjectInputStream)
-            out.writeShort(size()); // count
-            for (Iterator iter = iterator(); iter.hasNext();) {
-                NodeState.ChildNodeEntry entry =
-                        (NodeState.ChildNodeEntry) iter.next();
-                out.writeUTF(entry.getName().toString());   // name
-                out.writeUTF(entry.getId().toString());  // id
-            }
-        }
-
-        private void readObject(ObjectInputStream in) throws IOException {
-            entries = new LinkedMap();
-            nameMap = new HashMap();
-            // important: fields must be read in same order as they are
-            // written in writeObject(ObjectOutputStream)
-            short count = in.readShort();   // count
-            for (int i = 0; i < count; i++) {
-                Name name = NameFactoryImpl.getInstance().create(in.readUTF());    // name
-                String s = in.readUTF();   // id
-                add(name, NodeId.valueOf(s));
-            }
-        }
-
         //------------------------------------------------< Cloneable support >
         /**
          * Returns a shallow copy of this <code>ChildNodeEntries</code> instance;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java?rev=683244&r1=683243&r2=683244&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/PropertyState.java
Wed Aug  6 05:18:08 2008
@@ -16,37 +16,20 @@
  */
 package org.apache.jackrabbit.core.state;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.PropertyId;
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.ItemId;
 import org.apache.jackrabbit.core.nodetype.PropDefId;
-import org.apache.jackrabbit.core.value.BLOBFileValue;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Name;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
 
 /**
  * <code>PropertyState</code> represents the state of a <code>Property</code>.
  */
 public class PropertyState extends ItemState {
 
-    /** Logger instance */
-    private static Logger log = LoggerFactory.getLogger(PropertyState.class);
-
-    /**
-     * Serialization UID of this class.
-     */
-    static final long serialVersionUID = 90076676913237139L;
-
     /**
      * the id of this property state
      */
@@ -254,120 +237,4 @@
         */
         return 350 + values.length * 100;
     }
-
-    //-------------------------------------------------< Serializable support >
-    private void writeObject(ObjectOutputStream out) throws IOException {
-        // important: fields must be written in same order as they are
-        // read in readObject(ObjectInputStream)
-        out.writeUTF(id.toString());
-        out.writeUTF(defId.toString());
-        out.writeInt(type);
-        out.writeBoolean(multiValued);
-        if (values == null) {
-            out.writeShort(-1);
-        } else {
-            out.writeShort(values.length);
-            for (int i = 0; i < values.length; i++) {
-                InternalValue val = values[i];
-                try {
-                    if (type == PropertyType.BINARY) {
-                        // special handling required for binary value
-                        BLOBFileValue blob = val.getBLOBFileValue();
-                        out.writeLong(blob.getLength());
-                        InputStream in = blob.getStream();
-                        try {
-                            IOUtils.copy(in, out);
-                        } finally {
-                            in.close();
-                        }
-                    } else {
-                        out.writeUTF(val.toString());
-                    }
-                } catch (IllegalStateException ise) {
-                    throw new IOException(ise.getMessage());
-                } catch (RepositoryException re) {
-                    throw new IOException(re.getMessage());
-                }
-            }
-        }
-    }
-
-    private void readObject(ObjectInputStream in) throws IOException {
-        // important: fields must be read in same order as they are
-        // written in writeObject(ObjectOutputStream)
-        id = PropertyId.valueOf(in.readUTF());
-        defId = PropDefId.valueOf(in.readUTF());
-        type = in.readInt();
-        multiValued = in.readBoolean();
-        short count = in.readShort(); // # of values
-        if (count < 0) {
-            values = null;
-        } else {
-            values = new InternalValue[count];
-            for (int i = 0; i < values.length; i++) {
-                if (type == PropertyType.BINARY) {
-                    // special handling required for binary value
-                    final long length = in.readLong();
-                    final InputStream stream = in;
-                    // create InputStream wrapper of size 'length'
-                    try {
-                        values[i] = createInternalValueFromInputStream(stream, length);
-                    } catch (RepositoryException e) {
-                        String msg = "Failed to create internal value: " + e.getMessage();
-                        log.error(msg, e);
-                        throw new IOException(msg);
-                    }
-
-                } else {
-                    values[i] = InternalValue.valueOf(in.readUTF(), type);
-                }
-            }
-        }
-    }
-
-    private InternalValue createInternalValueFromInputStream(
-            final InputStream stream, final long length)
-            throws RepositoryException {
-        return InternalValue.create(new InputStream() {
-
-            private long consumed = 0;
-
-            public int read() throws IOException {
-                if (consumed >= length) {
-                    return -1;  // eof
-                }
-                int b = stream.read();
-                consumed++;
-                return b;
-            }
-
-            public int read(byte[] b, int off, int len) throws IOException {
-                if (consumed >= length) {
-                    return -1;  // eof
-                }
-                if ((consumed + len) > length) {
-                    len = (int) (length - consumed);
-                }
-                int read = stream.read(b, off, len);
-                consumed += read;
-                return read;
-            }
-
-            public long skip(long n) throws IOException {
-                if (consumed >= length && n > 0) {
-                    return -1;  // eof
-                }
-                if ((consumed + n) > length) {
-                    n = length - consumed;
-                }
-                long skipped = stream.skip(n);
-                consumed += skipped;
-                return skipped;
-            }
-
-            public void close() {
-                // nop
-            }
-        });
-    }
 }



Mime
View raw message