Add factory method to create a Binary instance from a (local) File
------------------------------------------------------------------
Key: DNA-260
URL:
https://jira.jboss.org/jira/browse/DNA-260
Project: DNA
Issue Type: Feature Request
Components: API, Graph
Affects Versions: 0.3
Reporter: Randall Hauch
Priority: Minor
Fix For: 0.4
A client sometimes has a file and wants to represent the content of the file with a Binary
value object. Currently, the client would have to obtain an InputStream or a Reader to
the file, and create the Binary value object with that. Then, when somebody wants to read
the binary value, they have to create another stream/reader. Essentially, the content is
streamed 1+n times, where n is the number of times the value is read. This can be very
expensive when the size of the file is large (or very large, as in gigabytes).
By adding a factor method that takes a File object, the factory could optimize the
behavior. Rather than creating a stream/reader to put the content into the Binary value
object, the factory could just create a Binary implementation that delegates to a File.
Then, the only time a stream/reader is created is when the client wants to read the value.
In other words, the content is streamed only n times.
We don't yet have a BinaryFactory interface, and are currently using
ValueFactory<Binary>. Therefore, the first step is to create the BinaryFactory
interface and use this in the ValueFactories interface. (Most uses of the
'getBinaryFactory()' method would not need to change, since they're either
just immediately calling 'create(...)' on the returned reference, or are using
ValueFactory<Binary>, which would still work.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira