What is the best way to implement associations for HATEOAS in XML?

We have a Java server web application in which the core of the system contains a very complex domain model, which was developed in accordance with the principles of domain-driven design. For the most part, these domain objects have been very much affected by applications of other problems.

Now we are trying to install the REST APIs in front of the system, and I am struggling with how best to implement the HATEOAS links that are part of our own new type of media. For example, suppose we have a domain class foothat has id and name properties with JAX-B annotations:

@XmlType(name = "foo")
public class FooImpl implements Foo {

    private String name;
    private String id;

    ...snip....

@XmlID
@XmlAttribute
@Override
public String getId() {
    return id;
}

    @XmlElement
    @Override
    public String getName() {
        return name;
    }

    @Override
    public void setName(final String name) {
        this.name = name;
    }
}

But the XML I want to return is as follows:

<foo id="123" href="http://myserver.com/foos/123">
   <name>myFoo</name>
   <links>
          <link rel="previous" href="http://myserver.com/foos/122" type="application/mything+xml" />
          <link rel="next" href="http://myserver.com/foos/124" type="application/mything+xml" />
          <link rel="edit" href="http://myserver.com/foos/123" type="application/mything+xml" />
          <link rel="revise" href="http://myserver.com/foos/123" method="put" type="application/mything+xml" />
          <link rel="cancel" href="http://myserver.com/foos/123?op="cancel"" method="post" type="application/mything+xml" />
   </links>
</foo>

, , JAX-B XML? :

1) JAX-B. XML . ? ? ?

2) DTO Layer. REST, DTO. DTO. , , .

3) . , , ( ), -. XML, /hrefs .. , , . !

, DTO ?

+5
2

, , , , , , JAXB : , URL- . , , ; , , , , URL-, - , .

, - - ( JAXB- ), DAO . , , . .

+2

RESTEasy . , . . 8 RESTEasy.

0

All Articles