use of org.wildfly.clustering.marshalling.spi.ByteBufferOutputStream in project wildfly by wildfly.
the class DefaultProtoStreamWriter method writeObjectNoTag.
@Override
public void writeObjectNoTag(Object value) throws IOException {
ImmutableSerializationContext context = this.getSerializationContext();
ProtoStreamMarshaller<Object> marshaller = this.findMarshaller(value.getClass());
OptionalInt size = this.size(marshaller, value);
try (ByteBufferOutputStream output = new ByteBufferOutputStream(size)) {
TagWriterImpl writer = size.isPresent() ? TagWriterImpl.newInstance(context, output, size.getAsInt()) : TagWriterImpl.newInstance(context, output);
marshaller.writeTo(new DefaultProtoStreamWriter(writer), value);
writer.flush();
ByteBuffer buffer = output.getBuffer();
int offset = buffer.arrayOffset();
int length = buffer.limit() - offset;
this.writeVarint32(length);
this.writeRawBytes(buffer.array(), offset, length);
}
}
Aggregations