You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Glen Mazza (Reopened) (JIRA)" <ji...@apache.org> on 2012/03/09 16:42:57 UTC
[jira] [Reopened] (CXF-3380) JAX-RS: Support writing to DataSources
[ https://issues.apache.org/jira/browse/CXF-3380?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Glen Mazza reopened CXF-3380:
-----------------------------
Sorry, my earlier statement that I had verified this was working was apparently incorrect (I may have inadvertently just tested the traditional method--not the DataSource one.) I still can't get the image to appear, even after attaching the DataSource provider in my Application subclass: https://github.com/gmazza/jersey-samples-on-cxf/blob/master/simple-servlet/src/main/java/com/sun/jersey/samples/servlet/resources/MyApplication.java
> JAX-RS: Support writing to DataSources
> --------------------------------------
>
> Key: CXF-3380
> URL: https://issues.apache.org/jira/browse/CXF-3380
> Project: CXF
> Issue Type: Improvement
> Components: JAX-RS
> Reporter: Glen Mazza
> Assignee: Sergey Beryozkin
> Fix For: 2.4.5, 2.5.1, 2.6
>
>
> 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;
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira