return new ByteBuffer(baos.getRawBuffer(), 0, baos.size());
}
public Object objectFromByteBuffer(byte[] bytes, int offset, int len) throws IOException, ClassNotFoundException {
int versionId;
ObjectInputStream in = new MarshalledValueInputStream(new ByteArrayInputStream(bytes, offset, len));
try {
versionId = in.readShort();
log.trace("Read version {0}", versionId);
}
catch (Exception e) {
log.error("Unable to read version id from first two bytes of stream, barfing.");
throw new IOException("Unable to read version id from first two bytes of stream.");