!str #19129 New homes for file and java.io stream factories

This commit is contained in:
Johan Andrén 2015-12-08 18:47:58 +01:00
parent 5041d3825d
commit 09a79f45e4
31 changed files with 420 additions and 327 deletions

View file

@ -195,32 +195,32 @@ public class MigrationsJava {
//#file-source-sink
final Source<ByteString, Future<Long>> fileSrc =
Source.file(new File("."));
FileIO.fromFile(new File("."));
final Source<ByteString, Future<Long>> otherFileSrc =
Source.file(new File("."), 1024);
FileIO.fromFile(new File("."), 1024);
final Sink<ByteString, Future<Long>> fileSink =
Sink.file(new File("."));
FileIO.toFile(new File("."));
//#file-source-sink
//#input-output-stream-source-sink
final Source<ByteString, Future<java.lang.Long>> inputStreamSrc =
Source.inputStream(new Creator<InputStream>(){
StreamConverters.fromInputStream(new Creator<InputStream>(){
public InputStream create() {
return new SomeInputStream();
}
});
final Source<ByteString, Future<java.lang.Long>> otherInputStreamSrc =
Source.inputStream(new Creator<InputStream>(){
StreamConverters.fromInputStream(new Creator<InputStream>(){
public InputStream create() {
return new SomeInputStream();
}
}, 1024);
final Sink<ByteString, Future<java.lang.Long>> outputStreamSink =
Sink.outputStream(new Creator<OutputStream>(){
StreamConverters.fromOutputStream(new Creator<OutputStream>(){
public OutputStream create() {
return new SomeOutputStream();
}
@ -232,16 +232,16 @@ public class MigrationsJava {
final FiniteDuration timeout = FiniteDuration.Zero();
final Source<ByteString, OutputStream> outputStreamSrc =
Source.outputStream();
StreamConverters.asOutputStream();
final Source<ByteString, OutputStream> otherOutputStreamSrc =
Source.outputStream(timeout);
StreamConverters.asOutputStream(timeout);
final Sink<ByteString, InputStream> someInputStreamSink =
Sink.inputStream();
StreamConverters.asInputStream();
final Sink<ByteString, InputStream> someOtherInputStreamSink =
Sink.inputStream(timeout);
StreamConverters.asInputStream(timeout);
//#output-input-stream-source-sink
}

View file

@ -562,17 +562,17 @@ should be replaced by:
SynchronousFileSource and SynchronousFileSink
=============================================
Both have been replaced by ``Source.file(…)`` and ``Sink.file(…)`` due to discoverability issues
Both have been replaced by ``FileIO.toFile(…)`` and ``FileIO.fromFile(…)`` due to discoverability issues
paired with names which leaked internal implementation details.
Update procedure
----------------
Replace ``SynchronousFileSource.create(`` with ``Source.file(``
Replace ``SynchronousFileSource.create(`` with ``FileIO.fromFile(``
Replace ``SynchronousFileSink.create(`` with ``Sink.file(``
Replace ``SynchronousFileSink.create(`` with ``FileIO.toFile(``
Replace ``SynchronousFileSink.appendTo(f)`` with ``Sink.file(f, true)``
Replace ``SynchronousFileSink.appendTo(f)`` with ``FileIO.toFile(f, true)``
Example
^^^^^^^
@ -598,14 +598,14 @@ should be replaced by
InputStreamSource and OutputStreamSink
======================================
Both have been replaced by ``Source.inputStream(…)`` and ``Sink.outputStream(…)`` due to discoverability issues.
Both have been replaced by ``StreamConverters.fromInputStream(…)`` and ``StreamConverters.fromOutputStream(…)`` due to discoverability issues.
Update procedure
----------------
Replace ``InputStreamSource.create(`` with ``Source.inputStream(``
Replace ``InputStreamSource.create(`` with ``StreamConverters.fromInputStream(``
Replace ``OutputStreamSink.create(`` with ``Sink.outputStream(``
Replace ``OutputStreamSink.create(`` with ``StreamConverters.fromOutputStream(``
Example
^^^^^^^
@ -644,14 +644,14 @@ should be replaced by
OutputStreamSource and InputStreamSink
======================================
Both have been replaced by ``Source.outputStream(…)`` and ``Sink.inputStream(…)`` due to discoverability issues.
Both have been replaced by ``StreamConverters.asOutputStream(…)`` and ``StreamConverters.asInputStream(…)`` due to discoverability issues.
Update procedure
----------------
Replace ``OutputStreamSource.create(`` with ``Source.outputStream(``
Replace ``OutputStreamSource.create(`` with ``StreamConverters.asOutputStream(``
Replace ``InputStreamSink.create(`` with ``Sink.inputStream(``
Replace ``InputStreamSink.create(`` with ``StreamConverters.asInputStream(``
Example
^^^^^^^

View file

@ -110,7 +110,7 @@ on files.
Once Akka is free to require JDK8 (from ``2.4.x``) these implementations will be updated to make use of the
new NIO APIs (i.e. :class:`AsynchronousFileChannel`).
Streaming data from a file is as easy as creating a `Source.file` given a target file, and an optional
Streaming data from a file is as easy as creating a `FileIO.fromFile` given a target file, and an optional
``chunkSize`` which determines the buffer size determined as one "element" in such stream:
.. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/stream/io/StreamFileDocTest.java#file-source