use of org.jboss.marshalling.SimpleDataOutput in project wildfly by wildfly.
the class SimpleMarshalledValue method getBytes.
byte[] getBytes() throws IOException {
byte[] bytes = this.bytes;
if (bytes != null)
return bytes;
if (this.object == null)
return null;
int version = this.context.getCurrentVersion();
ByteArrayOutputStream output = new ByteArrayOutputStream();
ClassLoader loader = setThreadContextClassLoader(this.context.getClassLoader());
try (SimpleDataOutput data = new SimpleDataOutput(Marshalling.createByteOutput(output))) {
IndexExternalizer.VARIABLE.writeData(data, version);
try (Marshaller marshaller = this.context.createMarshaller(version)) {
marshaller.start(data);
marshaller.writeObject(this.object);
marshaller.finish();
return output.toByteArray();
}
} finally {
setThreadContextClassLoader(loader);
}
}
use of org.jboss.marshalling.SimpleDataOutput in project wildfly by wildfly.
the class JBossByteBufferMarshaller method writeTo.
@Override
public void writeTo(OutputStream output, Object value) throws IOException {
int version = this.repository.getCurrentMarshallingVersion();
try (SimpleDataOutput data = new SimpleDataOutput(Marshalling.createByteOutput(output))) {
IndexSerializer.UNSIGNED_BYTE.writeInt(data, version);
ClassLoader loader = setThreadContextClassLoader(this.loader.get());
try (Marshaller marshaller = this.factory.createMarshaller(this.getMarshallingConfiguration(version))) {
marshaller.start(data);
marshaller.writeObject(value);
marshaller.finish();
} finally {
setThreadContextClassLoader(loader);
}
}
}
Aggregations