Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-297

Add factory method to create a Binary instance from a (local) File

    XMLWordPrintable

Details

    • Low

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              rhauch Randall Hauch (Inactive)
              rhauch Randall Hauch (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: