Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-3380

JAX-RS: Support writing to DataSources

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.4.5, 2.5.1, 2.6
    • JAX-RS
    • None

    Description

      CXF's JAX-RS implementation can presently read from but not write to data sources (javax.activation.DataSource). Provide an ability to write to data sources so we can code this way:

      @Produces("image/jpg")
      @GET
      public DataSource getImageRep() {
      URL jpgURL = this.getClass().getResource("myimage.jpg");
      return new FileDataSource(jpgURL.getFile());
      }

      instead of something like this:

      @Produces("image/jpg")
      @GET
      public InputStream getImageRep() {
      FileInputStream fis = null;
      try

      { URL jpgURL = this.getClass().getResource("myimage.jpg"); fis = new FileInputStream(new File(jpgURL.getPath())); }

      catch (IOException e)

      { System.out.println("Couldn't find file!"); }

      return fis;
      }

      Attachments

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            gmazza Glen Mazza
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: