users@jsr311.java.net

Re: JSR 311 Improvement Proposal

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Mon, 16 Jun 2008 12:11:25 -0400

An implementation is free to optimize the lookup as you suggest.
isReadable and isWritable aren't supplied with the instance.

Marc.

On Jun 16, 2008, at 11:53 AM, Markus KARG wrote:

> I could imagine that it is pretty much kind of a performance
> drawback to ask all Providers for all references each time again, so
> maybe single-time registration ("JAXRS: Register me for these
> interfaces and all classes annotated with these annotations!") would
> be more beneficial than repeated runtime checks. Another solution
> could be, JAX-RS should not ask for compatibility with _instances_
> but just with _classes_, since the annotation will not change at
> runtime. Whether or not the class has a specific annotation can be
> checked easily. That would prevent unnecessary repeated checks.
>
> Regards
> Markus
>
> Stephan Koops schrieb:
>> Hi Markus,
>>
>> if you build an MessageBodyWriter for e.g. JAXB, you have to check,
>> if
>> the given class is annotated with JAXB annotations.
>>
>> You could join the mailing list users_at_jsr311.dev.java.net. So you
>> miss no email. If we click "reply", than the sender of the message
>> to replay is not in the list of the recepients of the new email.
>>
>> Thanks for give feedback.
>>
>> best regards
>> Stephan
>>
>> Markus KARG schrieb:
>>> Dear JAX-RS Specification Authors,
>>>
>>> thank you so much for the invention of JAX-RS!
>>>
>>> Today I came across one thing that I think is not clear in the
>>> current draft of the API, and I want to propose an improvement.
>>>
>>> When implementing my own entity provider, I have to mark it as
>>> @Provider, and I have to implement MessageReader and / or
>>> MessageWriter. Both, MessageReader and MessageWriter are generic,
>>> so I can do "implements MessageReader<Product> to specify that my
>>> Provider actually is not "any" MessageReader but can only decode
>>> Product instances. So far, so good.
>>>
>>> But what I do not understand is: For what is the additional
>>> "isReadable" / "isWriteable" is needed? Actually, it is obvious
>>> that a MessageReader<Product> will only aswer "true" when it got
>>> passed a Product instance. In fact, I noticed that my
>>> MessageReader<Product> got asked for "isReadable(String)" at
>>> Runtime -- what makes no sense in my opinion.
>>>
>>> Is there something inside of isReadable that I did not see yet?
>>> For me, it looks like the "isReadable" / "isWriteable" methods can
>>> just be dropped in favour of the generic type provided at
>>> "implements MessageReader<T>". Another proposal could be to add
>>> the handled types at the @Provider annotation: @Provider(types =
>>> {T.class}) could be used as a nice replacement for implementing
>>> "isReadable" / "isWriteable".
>>>
>>> Thanks
>>> Markus
>>
>
>
> --
> http://www.xing.com/go/invita/58469
>

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.