Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.infinispan.commons.marshall;
 
 
 import java.io.*;

Standard Java serialization marshaller.

Author(s):
Galder Zamarreño
Since:
5.3
   @Override
   protected ByteBuffer objectToBuffer(Object oint estimatedSizethrows IOException {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ObjectOutput out = new ObjectOutputStream(baos);
      out.writeObject(o);
      out.close();
      baos.close();
      byte[] bytes = baos.toByteArray();
      return new ByteBufferImpl(bytes, 0, bytes.length);
   }
   @Override
   public Object objectFromByteBuffer(byte[] bufint offsetint lengththrows IOExceptionClassNotFoundException {
      InputStream bais = new ByteArrayInputStream(buf);
      ObjectInput in = new ObjectInputStream(bais);
      Object o = in.readObject();
      in.close();
      bais.close();
      return o;
   }
   @Override
   public boolean isMarshallable(Object othrows Exception {
      return o instanceof Serializable;
   }
New to GrepCode? Check out our FAQ X