Class RecordingObjectInputStream

java.lang.Object
java.io.InputStream
java.io.ObjectInputStream
de.aristaflow.adept2.util.injection.RecordingObjectInputStream
All Implemented Interfaces:
Closeable, DataInput, ObjectInput, ObjectStreamConstants, AutoCloseable

public final class RecordingObjectInputStream extends ObjectInputStream
An ObjectInputStream recording the InjectionAware objects it reads instead of refusing them: it is the reading half of a driver, which claims the recorded objects at its completion point. The stream neither injects nor needs bindings, so decoding stays as cheap as it is without recording, at the price of one instanceof per decoded object.

Recording happens after the fields of an object have been read and after its readObject and readResolve have run, so a replacing class is recorded as the replacement the graph ends up with. A canonicalising class returns the same instance for distinct stream objects, so the same instance may be recorded several times; the holder deduplicates by identity.

An instance is state of one decode and must not be shared across threads.

  • Constructor Details

    • RecordingObjectInputStream

      public RecordingObjectInputStream(InputStream in) throws IOException
      Creates a recording stream reading from the designated input stream.
      Parameters:
      in - The input stream to read the objects from.
      Throws:
      IOException - If the header of the designated input stream cannot be read, an IOException will be thrown.
  • Method Details