Bill,
I think you have a point. Not sure how we missed that in testing. Let me check with Lance.
-- Santiago
On Aug 29, 2013, at 3:08 PM, Bill Burke <bburke_at_redhat.com> wrote:
> It seems I'm not allowed to fix this problem in Resteasy until a Maintenance Release of JAx-RS is done to fix the problem. From Lance Andersen:
>
> "Any changes to the API like you suggest would require an MR to the JAXRS spec and adding a method without an MR would not be allowed.
>
> Please work with Marek and Santiago on your request for enhancement.
> "
>
> Is there any way to get a waver for this? This seems rather absurd IMO as this is a bug fix, not an enhancement. Its just a damn setter method!
>
> As it is, I'm going to have to explain to thousands of readers why my JAX-RS book uses a Resteasy specific JAXB adapter for LInk rather than the one provided by the spec API.
>
> On 8/28/2013 8:11 PM, Bill Burke wrote:
>> The problem stems from a missing setter method in Link.JaxbLink
>>
>> public void setUri(URI uri) {
>> this.uri = uri;
>> }
>>
>> If you add that then unmarshalling works. If you don't add this then
>> the URI property will always be NULL.
>>
>> The concern I have is, if I fix this I will fail the signature tests of
>> the TCK. Is this something that can be challenged?
>>
>> https://java.net/jira/browse/JAX_RS_SPEC-422
>>
>> On 8/28/2013 11:27 AM, Bill Burke wrote:
>>> Unmarshalling Link doesn't seem to work. Try this out:
>>>
>>> @XmlRootElement(name="list")
>>> public static class LinksList
>>> {
>>> protected Link other;
>>>
>>> protected List<Link> links = new ArrayList<Link>();
>>>
>>> @XmlElement(name="link")
>>> @XmlJavaTypeAdapter(value=Link.JaxbAdapter.class, type=Link.class)
>>> public List<Link> getLinks()
>>> {
>>> return links;
>>> }
>>>
>>> public void setLinks(List<Link> links)
>>> {
>>> this.links = links;
>>> }
>>>
>>> @XmlElement(name="other")
>>> @XmlJavaTypeAdapter(value=Link.JaxbAdapter.class)
>>> public Link getOther()
>>> {
>>> return other;
>>> }
>>>
>>> public void setOther(Link other)
>>> {
>>> this.other = other;
>>> }
>>> }
>>>
>>> @Test
>>> public void testLinks() throws Exception
>>> {
>>> JAXBContext context = JAXBContext.newInstance(LinksList.class);
>>> LinksList list = new LinksList();
>>> list.getLinks().add(Link.fromUri("/a").rel("self").build());
>>> list.getLinks().add(Link.fromUri("/b").rel("father").build());
>>> list.setOther(Link.fromUri("/c").rel("other").build());
>>>
>>> StringWriter writer = new StringWriter();
>>> context.createMarshaller().marshal(list, writer);
>>> String xml = writer.getBuffer().toString();
>>> System.out.println(xml);
>>>
>>> System.out.println("----");
>>> list = (LinksList)context.createUnmarshaller().unmarshal(new
>>> ByteArrayInputStream(xml.getBytes()));
>>> context.createMarshaller().marshal(list, System.out);
>>>
>>> }
>>>
>>
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com