1

As the title says. For context, although not terrible important, I'd like to trigger a WebSocket notification in the AfterSave event listener, and I'd like the resource or collection URI to correspond to the subscription endpoint. Of course, I could hard code these values, but then I'm losing some benefit of using SDR.

So, does Spring offer a way to retrieve this information, the collection or entity URI, solely based off of the Object that the event listeners receive?

bvulaj
  • 5,023
  • 5
  • 31
  • 45

1 Answers1

2

If I'm understanding your question correctly, you can do this by autowiring EntityLinks and then getting the link like this:

Link link = entityLinks.linkToSingleResource(MyResource.class, id);
String href = link.getHref();
gyoder
  • 4,530
  • 5
  • 29
  • 37