1

So let's assume I have two applications, the Person application that manages people, and the Pants application that manages Pants. In the Person application the Domain object Person has a List pantsId that refers to the id of a pair of pants from the Pants application.

I'm not sure how to model this using Spring Data Rest so that when I serialize the person, I am able to embed a link to the external Pants application's pants instances. [or even to have /person/123/pants return a list of those external pants resources]

Looking for something along the lines of the below:

GET http://www.mydomain.com/personapp/person/123:
{
  "name" : "bob",
  "age": "30",

  "_links" : {
    "self" : {
      "href" : "http://www.mydomain.com/personapp/person/123"
    },
    "pants" : {
      "href" : "http://www.mydomain.com/pantsapp/pants/456"
      "href" : "http://www.mydomain.com/pantsapp/pants/789"
    }
  }
Ben M
  • 1,833
  • 1
  • 15
  • 24
  • On a side note, does anyone know if Spring-Data-Rest plans to support any sort of declarative hyperlinking? I could imagine some annotation added to the Person's List like @Link("http://www.domain.com/pantsapp/pants{pantsId} that would allow this sort of behaviour – Ben M Mar 24 '14 at 16:50

1 Answers1

0

You could use a ResourceProcessor to add those links. There's a sample project here that implements something very similar to what you want to do.

It uses Hystrix (via the spring-cloud-netflix project) to monitor the external service and only adds the link if it is available.

adam p
  • 1,214
  • 9
  • 18