[jira] [Commented] (ARIES-1966) JAX-RS MediaType annotation is not correctly evaluated

2020-01-27 Thread Jira


[ 
https://issues.apache.org/jira/browse/ARIES-1966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17024926#comment-17024926
 ] 

Carlos Sierra Andrés commented on ARIES-1966:
-

hi [~maggu2810],

thx you for helping our community!

> JAX-RS MediaType annotation is not correctly evaluated
> --
>
> Key: ARIES-1966
> URL: https://issues.apache.org/jira/browse/ARIES-1966
> Project: Aries
>  Issue Type: Bug
>  Components: jax-rs-whiteboard
>Affects Versions: jax-rs-whiteboard-1.0.5, jax-rs-whiteboard-1.0.6
>Reporter: Markus Rathgeb
>Assignee: Carlos Sierra Andrés
>Priority: Major
>
> I realized that my _JaxrsExtension_ for _JaxrsMediaType_ _APPLICATION_JSON_ 
> is not only used for endpoints that produces JSON (marked by annotation) but 
> also for endpoints that produces plain text (marked by annotation)
>  
> For testing purposed I used a message body reader and writer implementation 
> for the JSON media type that is using GSON.
>  
> The annotations and class declaration looks like:
>  
> {code:java}
> @Component(scope = PROTOTYPE)
> @JaxrsApplicationSelect("(osgi.jaxrs.name=*)")
> @JaxrsExtension
> @JaxrsMediaType(APPLICATION_JSON)
> public class GsonMessageBodyReaderWriter implements MessageBodyReader, 
> MessageBodyWriter { ... }{code}
>  
> I see that this class is used for media type JSON and PLAIN_TEXT.
>  
> So I created another message body reader for media type plain text and a 
> higher service ranking (just for testing).
>  
> {code:java}
> @Component(scope = PROTOTYPE)
> @ServiceRanking(100)
> @JaxrsApplicationSelect("(" + JaxrsWhiteboardConstants.JAX_RS_NAME + "=*)")
> @JaxrsExtension
> @JaxrsMediaType(MediaType.TEXT_PLAIN)
> public class PlainTextMediaTypeExtension implements MessageBodyReader, 
> MessageBodyWriter { ... }{code}
>  
> If both components are available I would assume the 
> PlainTextMediaTypeExtension is used for the media type plain text and the 
> GsonMessageBodyReaderWriter is used for media type json (because of the 
> JaxrsMediaType annotation.
>  
> But now PlainTextMediaTypeExtension is used for plain text AND JSON.
>  
> I would expect that the message body writer provided by 
> {code:java}
> @JaxrsExtension
> @JaxrsMediaType(MediaType.TEXT_PLAIN){code}
> is used for
> {code:java}
> @Produces(MediaType.TEXT_PLAIN){code}
> and the message body writer provided by
> {code:java}
> @JaxrsExtension
> @JaxrsMediaType(APPLICATION_JSON){code}
> is used for
> {code:java}
> @Produces(MediaType.APPLICATION_JSON){code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (ARIES-1966) JAX-RS MediaType annotation is not correctly evaluated

2020-01-27 Thread Markus Rathgeb (Jira)


[ 
https://issues.apache.org/jira/browse/ARIES-1966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17024665#comment-17024665
 ] 

Markus Rathgeb commented on ARIES-1966:
---

Thanks for your patience and explanation!

It seems my understanding of the JAX-RS media type has been wrong.

Sorry for the noise!

> JAX-RS MediaType annotation is not correctly evaluated
> --
>
> Key: ARIES-1966
> URL: https://issues.apache.org/jira/browse/ARIES-1966
> Project: Aries
>  Issue Type: Bug
>  Components: jax-rs-whiteboard
>Affects Versions: jax-rs-whiteboard-1.0.5, jax-rs-whiteboard-1.0.6
>Reporter: Markus Rathgeb
>Assignee: Carlos Sierra Andrés
>Priority: Major
>
> I realized that my _JaxrsExtension_ for _JaxrsMediaType_ _APPLICATION_JSON_ 
> is not only used for endpoints that produces JSON (marked by annotation) but 
> also for endpoints that produces plain text (marked by annotation)
>  
> For testing purposed I used a message body reader and writer implementation 
> for the JSON media type that is using GSON.
>  
> The annotations and class declaration looks like:
>  
> {code:java}
> @Component(scope = PROTOTYPE)
> @JaxrsApplicationSelect("(osgi.jaxrs.name=*)")
> @JaxrsExtension
> @JaxrsMediaType(APPLICATION_JSON)
> public class GsonMessageBodyReaderWriter implements MessageBodyReader, 
> MessageBodyWriter { ... }{code}
>  
> I see that this class is used for media type JSON and PLAIN_TEXT.
>  
> So I created another message body reader for media type plain text and a 
> higher service ranking (just for testing).
>  
> {code:java}
> @Component(scope = PROTOTYPE)
> @ServiceRanking(100)
> @JaxrsApplicationSelect("(" + JaxrsWhiteboardConstants.JAX_RS_NAME + "=*)")
> @JaxrsExtension
> @JaxrsMediaType(MediaType.TEXT_PLAIN)
> public class PlainTextMediaTypeExtension implements MessageBodyReader, 
> MessageBodyWriter { ... }{code}
>  
> If both components are available I would assume the 
> PlainTextMediaTypeExtension is used for the media type plain text and the 
> GsonMessageBodyReaderWriter is used for media type json (because of the 
> JaxrsMediaType annotation.
>  
> But now PlainTextMediaTypeExtension is used for plain text AND JSON.
>  
> I would expect that the message body writer provided by 
> {code:java}
> @JaxrsExtension
> @JaxrsMediaType(MediaType.TEXT_PLAIN){code}
> is used for
> {code:java}
> @Produces(MediaType.TEXT_PLAIN){code}
> and the message body writer provided by
> {code:java}
> @JaxrsExtension
> @JaxrsMediaType(APPLICATION_JSON){code}
> is used for
> {code:java}
> @Produces(MediaType.APPLICATION_JSON){code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (ARIES-1966) JAX-RS MediaType annotation is not correctly evaluated

2020-01-27 Thread Jira


[ 
https://issues.apache.org/jira/browse/ARIES-1966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17024527#comment-17024527
 ] 

Carlos Sierra Andrés commented on ARIES-1966:
-

hey [~maggu2810] ,

I believe the expected usage of those OSGi properties on the extension service 
is for application services to be able to require those extensions using 
{{osgi.jaxrs.extension.select}} so the application would not be started without 
having these extensions ready.

I am afraid those properties will not affect the registration of the extension 
into the JAX-RS application. In order to instruct the JAX-RS runtime that your 
reader or writer should only be registered for a specific media type you can 
use {{@Provides}} / {{@Consumes}} annotation on the extension implementations 
or via the {{isWritable/isReadable}} methods.

I hope this matches your expectations.

Carlos.

> JAX-RS MediaType annotation is not correctly evaluated
> --
>
> Key: ARIES-1966
> URL: https://issues.apache.org/jira/browse/ARIES-1966
> Project: Aries
>  Issue Type: Bug
>  Components: jax-rs-whiteboard
>Affects Versions: jax-rs-whiteboard-1.0.5, jax-rs-whiteboard-1.0.6
>Reporter: Markus Rathgeb
>Assignee: Carlos Sierra Andrés
>Priority: Major
>
> I realized that my _JaxrsExtension_ for _JaxrsMediaType_ _APPLICATION_JSON_ 
> is not only used for endpoints that produces JSON (marked by annotation) but 
> also for endpoints that produces plain text (marked by annotation)
>  
> For testing purposed I used a message body reader and writer implementation 
> for the JSON media type that is using GSON.
>  
> The annotations and class declaration looks like:
>  
> {code:java}
> @Component(scope = PROTOTYPE)
> @JaxrsApplicationSelect("(osgi.jaxrs.name=*)")
> @JaxrsExtension
> @JaxrsMediaType(APPLICATION_JSON)
> public class GsonMessageBodyReaderWriter implements MessageBodyReader, 
> MessageBodyWriter { ... }{code}
>  
> I see that this class is used for media type JSON and PLAIN_TEXT.
>  
> So I created another message body reader for media type plain text and a 
> higher service ranking (just for testing).
>  
> {code:java}
> @Component(scope = PROTOTYPE)
> @ServiceRanking(100)
> @JaxrsApplicationSelect("(" + JaxrsWhiteboardConstants.JAX_RS_NAME + "=*)")
> @JaxrsExtension
> @JaxrsMediaType(MediaType.TEXT_PLAIN)
> public class PlainTextMediaTypeExtension implements MessageBodyReader, 
> MessageBodyWriter { ... }{code}
>  
> If both components are available I would assume the 
> PlainTextMediaTypeExtension is used for the media type plain text and the 
> GsonMessageBodyReaderWriter is used for media type json (because of the 
> JaxrsMediaType annotation.
>  
> But now PlainTextMediaTypeExtension is used for plain text AND JSON.
>  
> I would expect that the message body writer provided by 
> {code:java}
> @JaxrsExtension
> @JaxrsMediaType(MediaType.TEXT_PLAIN){code}
> is used for
> {code:java}
> @Produces(MediaType.TEXT_PLAIN){code}
> and the message body writer provided by
> {code:java}
> @JaxrsExtension
> @JaxrsMediaType(APPLICATION_JSON){code}
> is used for
> {code:java}
> @Produces(MediaType.APPLICATION_JSON){code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (ARIES-1966) JAX-RS MediaType annotation is not correctly evaluated

2020-01-27 Thread Markus Rathgeb (Jira)


[ 
https://issues.apache.org/jira/browse/ARIES-1966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17024499#comment-17024499
 ] 

Markus Rathgeb commented on ARIES-1966:
---

I worked around the problem already by using only one component that handles 
all the different message types.

I don't fully understand your comment: Is my understanding of the specification 
wrong?

Assume there are two services for message body reader + writer, the one is 
marked as an JAX-RS extension for the media type plain text, the other is 
marked as an JAX-RS extension for the media type JSON. The services are marked 
by annotation in the code base that are reflected by OSGi service properties at 
runtime (at build time the XML files for the services are generated by taken 
the annotations into account). My understanding of the JAX-RS Whiteboard 
specification has been that the service / extension for media type plain text 
will be used to handle read / write of media type plain text and the service / 
extension for media type JSON will be used to handle read / write of media type 
JSON.

Is this wrong?

What is the use case for this annotations / service properties if not this one?

> JAX-RS MediaType annotation is not correctly evaluated
> --
>
> Key: ARIES-1966
> URL: https://issues.apache.org/jira/browse/ARIES-1966
> Project: Aries
>  Issue Type: Bug
>  Components: jax-rs-whiteboard
>Affects Versions: jax-rs-whiteboard-1.0.5, jax-rs-whiteboard-1.0.6
>Reporter: Markus Rathgeb
>Assignee: Carlos Sierra Andrés
>Priority: Major
>
> I realized that my _JaxrsExtension_ for _JaxrsMediaType_ _APPLICATION_JSON_ 
> is not only used for endpoints that produces JSON (marked by annotation) but 
> also for endpoints that produces plain text (marked by annotation)
>  
> For testing purposed I used a message body reader and writer implementation 
> for the JSON media type that is using GSON.
>  
> The annotations and class declaration looks like:
>  
> {code:java}
> @Component(scope = PROTOTYPE)
> @JaxrsApplicationSelect("(osgi.jaxrs.name=*)")
> @JaxrsExtension
> @JaxrsMediaType(APPLICATION_JSON)
> public class GsonMessageBodyReaderWriter implements MessageBodyReader, 
> MessageBodyWriter { ... }{code}
>  
> I see that this class is used for media type JSON and PLAIN_TEXT.
>  
> So I created another message body reader for media type plain text and a 
> higher service ranking (just for testing).
>  
> {code:java}
> @Component(scope = PROTOTYPE)
> @ServiceRanking(100)
> @JaxrsApplicationSelect("(" + JaxrsWhiteboardConstants.JAX_RS_NAME + "=*)")
> @JaxrsExtension
> @JaxrsMediaType(MediaType.TEXT_PLAIN)
> public class PlainTextMediaTypeExtension implements MessageBodyReader, 
> MessageBodyWriter { ... }{code}
>  
> If both components are available I would assume the 
> PlainTextMediaTypeExtension is used for the media type plain text and the 
> GsonMessageBodyReaderWriter is used for media type json (because of the 
> JaxrsMediaType annotation.
>  
> But now PlainTextMediaTypeExtension is used for plain text AND JSON.
>  
> I would expect that the message body writer provided by 
> {code:java}
> @JaxrsExtension
> @JaxrsMediaType(MediaType.TEXT_PLAIN){code}
> is used for
> {code:java}
> @Produces(MediaType.TEXT_PLAIN){code}
> and the message body writer provided by
> {code:java}
> @JaxrsExtension
> @JaxrsMediaType(APPLICATION_JSON){code}
> is used for
> {code:java}
> @Produces(MediaType.APPLICATION_JSON){code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (ARIES-1966) JAX-RS MediaType annotation is not correctly evaluated

2020-01-27 Thread Jira


[ 
https://issues.apache.org/jira/browse/ARIES-1966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17024443#comment-17024443
 ] 

Carlos Sierra Andrés commented on ARIES-1966:
-

hey [~maggu2810] ,

thx for reporting this.

If I remember correctly {{@JaxrsMediaType}} is a OSGi service property and is 
only understood by the OSGi layer. You can also annotate the 
{{MessageBodyReader}} and {{MessageBodyWriter}} with the 
{{@Produces(MediaType.TEXT_PLAIN)}} and/or 
{{@Produces(MediaType.APPLICATION_JSON)}} in order to instruct the JAX-RS layer 
on when apply each of the readers/writers.

You should also be able to govern this behavior by implementing {{isReadable}} 
or {{isWriteable}} on the reader/writer classes.

Would this match your expectation?

Carlos.

> JAX-RS MediaType annotation is not correctly evaluated
> --
>
> Key: ARIES-1966
> URL: https://issues.apache.org/jira/browse/ARIES-1966
> Project: Aries
>  Issue Type: Bug
>  Components: jax-rs-whiteboard
>Affects Versions: jax-rs-whiteboard-1.0.5, jax-rs-whiteboard-1.0.6
>Reporter: Markus Rathgeb
>Priority: Major
>
> I realized that my _JaxrsExtension_ for _JaxrsMediaType_ _APPLICATION_JSON_ 
> is not only used for endpoints that produces JSON (marked by annotation) but 
> also for endpoints that produces plain text (marked by annotation)
>  
> For testing purposed I used a message body reader and writer implementation 
> for the JSON media type that is using GSON.
>  
> The annotations and class declaration looks like:
>  
> {code:java}
> @Component(scope = PROTOTYPE)
> @JaxrsApplicationSelect("(osgi.jaxrs.name=*)")
> @JaxrsExtension
> @JaxrsMediaType(APPLICATION_JSON)
> public class GsonMessageBodyReaderWriter implements MessageBodyReader, 
> MessageBodyWriter { ... }{code}
>  
> I see that this class is used for media type JSON and PLAIN_TEXT.
>  
> So I created another message body reader for media type plain text and a 
> higher service ranking (just for testing).
>  
> {code:java}
> @Component(scope = PROTOTYPE)
> @ServiceRanking(100)
> @JaxrsApplicationSelect("(" + JaxrsWhiteboardConstants.JAX_RS_NAME + "=*)")
> @JaxrsExtension
> @JaxrsMediaType(MediaType.TEXT_PLAIN)
> public class PlainTextMediaTypeExtension implements MessageBodyReader, 
> MessageBodyWriter { ... }{code}
>  
> If both components are available I would assume the 
> PlainTextMediaTypeExtension is used for the media type plain text and the 
> GsonMessageBodyReaderWriter is used for media type json (because of the 
> JaxrsMediaType annotation.
>  
> But now PlainTextMediaTypeExtension is used for plain text AND JSON.
>  
> I would expect that the message body writer provided by 
> {code:java}
> @JaxrsExtension
> @JaxrsMediaType(MediaType.TEXT_PLAIN){code}
> is used for
> {code:java}
> @Produces(MediaType.TEXT_PLAIN){code}
> and the message body writer provided by
> {code:java}
> @JaxrsExtension
> @JaxrsMediaType(APPLICATION_JSON){code}
> is used for
> {code:java}
> @Produces(MediaType.APPLICATION_JSON){code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)