Interface StreamRepository
- All Known Implementing Classes:
FileStreamRepository
InputStream
and OutputStream
interfaces.
Conceptually, there is a single underlying byte array. Instances behave as if an atomic readable snapshot
is made at the moment getInputStream()
is invoked, and the results of that snapshot are then available
in the returned InputStream
.
Similarly, instances behave as if the underlying byte array is atomically updated at the moment the output
stream returned by getOutputStream()
is successfully closed. If the
close operation fails, or never takes place, the underlying byte array is not updated.
Instances are thread safe, and support multiple concurrent open input and output streams. In particular, two output streams may be closed at the same time by two different threads, and one will always win the race.
-
Method Summary
Modifier and TypeMethodDescriptionGet an input stream reading the current value of the underlying store.Get an output stream writing to the underlying store.
-
Method Details
-
getInputStream
Get an input stream reading the current value of the underlying store.- Returns:
- input containing current repository contents
- Throws:
IOException
- if an error occurs
-
getOutputStream
Get an output stream writing to the underlying store. The underlying store is not modified until if/when the returned output stream is successfully closed, at which time it is atomically updated with the newly written content.If the returned stream throws an
IOException
at any time, including duringclose()
, or ifclose()
is never invoked, then no update to the underlying storage occurs.- Returns:
- output for overwriting the current repository contents
- Throws:
IOException
- if an error occurs
-