Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make #getBuffer() protected so it is easier to create custom sized bu…

…ffer depending on the type of the object to serialize

Pass the object to serialize as context
  • Loading branch information...
commit f78b31fca7a0bd2580b0986f7d2a833bd0ddb2fd 1 parent d5c8980
@martin-g martin-g authored
View
12 jdk-1.5-parent/serializer-kryo/src/main/java/org/wicketstuff/pageserializer/kryo/KryoSerializer.java
@@ -77,7 +77,7 @@ public KryoSerializer(final Bytes bufferSize)
public byte[] serialize(final Object object)
{
LOG.debug("Going to serialize: ", object);
- ByteBuffer buffer = getBuffer();
+ ByteBuffer buffer = getBuffer(object);
kryo.writeClassAndObject(buffer, object);
byte[] data;
if (buffer.hasArray()) {
@@ -109,7 +109,15 @@ public Object deserialize(byte[] data)
return object;
}
- private ByteBuffer getBuffer()
+ /**
+ * Creates the buffer that will be used to serialize the {@code target}
+ *
+ * @param target
+ * the object that will be serialized. Can be used to decide dynamically what size to use
+ * @return
+ * the buffer that will be used to serialize the {@code target}
+ */
+ protected ByteBuffer getBuffer(Object target)
{
return ByteBuffer.allocate((int)bufferSize.bytes());
}
Please sign in to comment.
Something went wrong with that request. Please try again.