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))) { IndexSerializer.VARIABLE.writeInt(data, version); try (Marshaller marshaller = this.context.createMarshaller(version)) { marshaller.start(data); marshaller.writeObject(this.object); marshaller.finish(); return output.toByteArray(); } } finally { setThreadContextClassLoader(loader); } }
public SimpleByteDataOutput(final OutputStream outputStream) { this.output = new SimpleDataOutput(Marshalling.createByteOutput(outputStream)); }
public SimpleByteDataOutput(final OutputStream outputStream) { this.output = new SimpleDataOutput(Marshalling.createByteOutput(outputStream)); }
public SimpleByteDataOutput(final OutputStream outputStream) { this.output = new SimpleDataOutput(Marshalling.createByteOutput(outputStream)); }
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))) { IndexSerializer.VARIABLE.writeInt(data, version); try (Marshaller marshaller = this.context.createMarshaller(version)) { marshaller.start(data); marshaller.writeObject(this.object); marshaller.finish(); return output.toByteArray(); } } finally { setThreadContextClassLoader(loader); } }
int version = this.context.getCurrentVersion(); ByteArrayOutputStream output = new ByteArrayOutputStream(); SimpleDataOutput data = new SimpleDataOutput(Marshalling.createByteOutput(output)); data.writeInt(version); Marshaller marshaller = this.context.createMarshaller(version);
@Override public void store(V obj) { File file = getFile(obj.getId()); log.tracef("Storing state to %s", file); try { FileOutputStream outputStream = null; try { outputStream = FOSAction.open(file); SimpleDataOutput output = new SimpleDataOutput(Marshalling.createByteOutput(outputStream)); int version = this.passivationManager.getCurrentMarshallingVersion(); output.writeInt(version); MarshallingConfiguration config = this.passivationManager.getMarshallingConfiguration(version); Marshaller marshaller = this.marshallerFactory.createMarshaller(config); marshaller.start(output); try { marshaller.writeObject(obj); marshaller.finish(); } finally { marshaller.close(); } } finally { safeClose(outputStream); } } catch (IOException e) { throw EjbMessages.MESSAGES.passivationFailed(e, obj.getId()); } }