public Object getObject(ClassLoader classLoader) throws ClassNotFoundException { return buf.getObject(classLoader); }
public Object getObject() throws ClassNotFoundException { return buf.getObject(); }
/** * Reads a Java object from the buffer using the context {@link ClassLoader} * of the current thread. */ public Object getObject() throws ClassNotFoundException { return getObject(Thread.currentThread().getContextClassLoader()); }
protected boolean doDecode(IoSession session, ByteBuffer in, ProtocolDecoderOutput out) throws Exception { if (!in.prefixedDataAvailable(4, maxObjectSize)) { return false; } out.write(in.getObject(classLoader)); return true; } }
public Object readObject() throws ClassNotFoundException, IOException { int objectSize = in.readInt(); if (objectSize <= 0) { throw new StreamCorruptedException("Invalid objectSize: " + objectSize); } if (objectSize > maxObjectSize) { throw new StreamCorruptedException("ObjectSize too big: " + objectSize + " (expected: <= " + maxObjectSize + ')'); } ByteBuffer buf = ByteBuffer.allocate(objectSize + 4, false); buf.putInt(objectSize); in.readFully(buf.array(), 4, objectSize); buf.position(0); buf.limit(objectSize + 4); Object answer = buf.getObject(classLoader); buf.release(); return answer; }