Migrating ResourceProcessor to HATEOAS 1.0.0 M1
Asked Answered
H

1

8

In my current Spring HATEOAS 0.25.1.RELEASE project I make heavy use of ResourceProcessor interfaces:

 @Bean
 public ResourceProcessor<Resource<Person>> personProcessor() {
    return new ResourceProcessor<Resource<Person>>() {
      @Override
      public Resource<Person> process(Resource<Person> resource) {
       resource.add(new Link("http://localhost:8080/people", "added-link"));
       return resource;
      }
    };
 }

How can can I migrate my ResourceProcessors to Spring HATEOAS 1.0.0 M1?

Hellas answered 13/5, 2019 at 19:38 Comment(0)
C
21

In Spring HATEOAS 1.0 M1, a lot of types and APIs have changed naming conventions.

In your example ResourceProcessor is now RepresentationModelProcessor, and Resource<T> is now EntityModel<T>, like so:

public RepresentationModelProcessor<EntityModel<Person>> personProcessor() {
return new RepresentationModelProcessor<EntityModel<Person>>() {
  @Override
  public EntityModel<Person> process(EntityModel<Person> entityModel) {
    entityModel.add(new Link("http://localhost:8080/people", "added-link"));
    return entityModel;
  }
};

}

See the full change notes here

Caplan answered 14/5, 2019 at 9:11 Comment(2)
Thanks for the quick reply. Have you found any documentation regarding this in particular?Hellas
Seems like this is missing from the documentation however, so thank for this!Ewall

© 2022 - 2024 — McMap. All rights reserved.