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 (JIRA)" <ji...@apache.org> on 2011/03/06 22:52:59 UTC
[jira] Created: (CXF-3380) Support writing to DataSources
Support writing to DataSources
------------------------------
Key: CXF-3380
URL: https://issues.apache.org/jira/browse/CXF-3380
Project: CXF
Issue Type: Improvement
Components: JAX-RS
Affects Versions: 2.4
Reporter: Glen Mazza
Priority: Minor
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.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (CXF-3380) JAX-RS: Support writing to
DataSources
Posted by "Dan Retzlaff (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-3380?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13139065#comment-13139065 ]
Dan Retzlaff commented on CXF-3380:
-----------------------------------
This functionality is required by JAX-RS 1.1 section 4.2.4.
> 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
> Affects Versions: 2.4
> Reporter: Glen Mazza
> Priority: Minor
>
> 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
[jira] [Reopened] (CXF-3380) JAX-RS: Support writing to DataSources
Posted by "Glen Mazza (Reopened) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-3380?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Glen Mazza reopened CXF-3380:
-----------------------------
Hi, this sample is still indicating a problem (perhaps one further down after the latest change made):
https://github.com/gmazza/jersey-samples-on-cxf/tree/master/simple-servlet
For this class within it:
https://github.com/gmazza/jersey-samples-on-cxf/blob/master/simple-servlet/src/main/java/com/sun/jersey/samples/servlet/resources/ResourceBean3.java
The traditional way as described in this JIRA (lines 153-164) works but the DataSoure way (143-151) doesn't.
Steps to replicate:
1. Check out simple-servlet:
git clone https://github.com/gmazza/jersey-samples-on-cxf.git
(move to simple-servlet folder).
2. Run "mvn clean install" on it.
3. Run "mvn jetty:run" and go to this page in a browser:
http://localhost:8080/SimpleServlet/resources/start
4. From the top, select "Resource 3", press the "Test Resource" button, leave Fred & Barney as-is, choose "Selection Method" of "Query Parameter" and MIME type of image/jpg.
5. Select the lower "Test Resource" button. You'll see the Oracle Duke logo/picture. Everything good.
6. In class ResourceBean3 listed above, comment out the "public InputStream getImageRep()" method and uncomment the "public DataSource getImageRep()" method; repeat steps 2-5 above. This time, though, no picture is returned and server reports back "WARNING: No message body writer has been found for response class FileDataSource."
> 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.3.8, 2.4.5, 2.5.1
>
>
> 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
[jira] [Commented] (CXF-3380) JAX-RS: Support writing to
DataSources
Posted by "Sergey Beryozkin (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-3380?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13227942#comment-13227942 ]
Sergey Beryozkin commented on CXF-3380:
---------------------------------------
DataSourceProvider is being picked up for me.
Can you try with 2.5.3-SNAPSHOT please ?
> 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
[jira] Updated: (CXF-3380) JAX-RS: Support writing to DataSources
Posted by "Glen Mazza (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-3380?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Glen Mazza updated CXF-3380:
----------------------------
Summary: JAX-RS: Support writing to DataSources (was: Support writing to DataSources)
> 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
> Affects Versions: 2.4
> Reporter: Glen Mazza
> Priority: Minor
>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Resolved] (CXF-3380) JAX-RS: Support writing to DataSources
Posted by "Sergey Beryozkin (Resolved) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-3380?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sergey Beryozkin resolved CXF-3380.
-----------------------------------
Resolution: Fixed
Fix Version/s: (was: 2.3.8)
2.6
I added the DataSourceProvider to the list of default providers. In meantime the explicit registration of org.apache.cxf.jaxrs.provider.DataSourceProvider will do, thanks
> 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.6, 2.5.1, 2.4.5
>
>
> 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
[jira] [Commented] (CXF-3380) JAX-RS: Support writing to
DataSources
Posted by "Glen Mazza (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-3380?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13208483#comment-13208483 ]
Glen Mazza commented on CXF-3380:
---------------------------------
Confirmed it works now, thanks!
> 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
[jira] [Resolved] (CXF-3380) JAX-RS: Support writing to DataSources
Posted by "Glen Mazza (Resolved) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-3380?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Glen Mazza resolved CXF-3380.
-----------------------------
Resolution: Fixed
Confirmed it works with 2.5.3-SNAPSHOT. Thanks Sergey!
> 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.6, 2.5.1, 2.4.5
>
>
> 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
[jira] [Reopened] (CXF-3380) JAX-RS: Support writing to DataSources
Posted by "Glen Mazza (Reopened) (JIRA)" <ji...@apache.org>.
[ 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
[jira] [Updated] (CXF-3380) JAX-RS: Support writing to DataSources
Posted by "Sergey Beryozkin (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-3380?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sergey Beryozkin updated CXF-3380:
----------------------------------
Priority: Major (was: Minor)
Affects Version/s: (was: 2.4)
Assignee: Sergey Beryozkin
> 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
>
> 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
[jira] [Resolved] (CXF-3380) JAX-RS: Support writing to DataSources
Posted by "Sergey Beryozkin (Resolved) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-3380?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sergey Beryozkin resolved CXF-3380.
-----------------------------------
Resolution: Fixed
Fix Version/s: 2.5.1
2.4.5
2.3.8
> 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.3.8, 2.4.5, 2.5.1
>
>
> 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