[infinispan-commits] Infinispan SVN: r2029 - trunk/core/src/main/java/org/infinispan/marshall.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Mon Jul 12 14:50:01 EDT 2010
Author: manik.surtani at jboss.com
Date: 2010-07-12 14:50:00 -0400 (Mon, 12 Jul 2010)
New Revision: 2029
Added:
trunk/core/src/main/java/org/infinispan/marshall/Marshaller.java
Log:
1. Make Util.getInstance() NOT throw an exception except ConfigurationException, and provide alternative, Strict methods
2. Update usages of this method accordingly.
3. Marshaller, AbstractMarshaller and StreamMarshaller refactoring
4. Removed VHelper and SerializationMarshaller from hotrod-client
5. Removed InputStreamAdapter and OutputStreamAdapter from hotrod-client
6. Removed InternalCacheEntryMarshaller from remotecachestore
Added: trunk/core/src/main/java/org/infinispan/marshall/Marshaller.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/Marshaller.java (rev 0)
+++ trunk/core/src/main/java/org/infinispan/marshall/Marshaller.java 2010-07-12 18:50:00 UTC (rev 2029)
@@ -0,0 +1,68 @@
+package org.infinispan.marshall;
+
+import net.jcip.annotations.ThreadSafe;
+
+import java.io.IOException;
+
+/**
+ * A marshaller is a class that is able to marshall and unmarshall objects efficiently.
+ * <p/>
+ * This interface is used to marshall {@link org.infinispan.commands.ReplicableCommand}s, their parameters and their
+ * response values, as well as any other arbitraty Object <--> byte[] conversions, such as those used in client/server
+ * communications.
+ * <p/>
+ * The interface is also used by the {@link org.infinispan.loaders.CacheStore} framework to efficiently serialize data
+ * to be persisted, as well as the {@link org.infinispan.statetransfer.StateTransferManager} when serializing the cache
+ * for transferring state en-masse.
+ * <p />
+ * A single instance of any implementation is shared by multiple threads, so implementations <i>need</i> to be threadsafe,
+ * and preferably immutable.
+ *
+ * @author Manik Surtani
+ * @version 4.1
+ */
+ at ThreadSafe
+public interface Marshaller {
+
+ /**
+ * Marshalls an object to a byte array. The estimatedSize parameter is a hint that can be passed in to allow for
+ * efficient sizing of the byte array before attempting to marshall the object. The more accurate this estimate is,
+ * the less likely byte[]s will need to be resized to hold the byte stream generated by marshalling the object.
+ *
+ * @param obj object to convert to a byte array. Must not be null.
+ * @param estimatedSize an estimate of how large the resulting byte array may be
+ * @return a byte array
+ * @throws IOException
+ */
+ byte[] objectToByteBuffer(Object obj, int estimatedSize) throws IOException;
+
+ /**
+ * Marshalls an object to a byte array.
+ *
+ * @param obj object to convert to a byte array. Must not be null.
+ * @return a byte array
+ * @throws IOException
+ */
+ byte[] objectToByteBuffer(Object obj) throws IOException;
+
+ /**
+ * Unmarshalls an object from a byte array.
+ * @param buf byte array containing the binary representation of an object. Must not be null.
+ * @return an object
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ Object objectFromByteBuffer(byte[] buf) throws IOException, ClassNotFoundException;
+
+ /**
+ * Unmarshalls an object from a specific portion of a byte array.
+ * @param buf byte array containing the binary representation of an object. Must not be null.
+ * @param offset point in buffer to start reading
+ * @param length number of bytes to consider
+ * @return an object
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ Object objectFromByteBuffer(byte[] buf, int offset, int length) throws IOException, ClassNotFoundException;
+}
+
Property changes on: trunk/core/src/main/java/org/infinispan/marshall/Marshaller.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
More information about the infinispan-commits
mailing list