I have a Roo 2 application with 6 jpa entities. One of those entities needs to fetch data from an external REST service and update another REST service before writing the final entity to the DB.
My question is this: Where do I add the code? Everything is driven by Annotations and I cannot find the right place to add my logic and REST client code.
web mvc controller --entity ~.EventExecute --responseType THYMELEAF
Creates
@RooController(entity = EventExecute.class, type = ControllerType.ITEM)
@RooThymeleaf
public class EventExecutesItemThymeleafController {
}
And
EventExecuteServiceImpl_Roo_Service_Impl
Now I fully expect I need to Push In some aspects to give me the place to add my code, but having a heck of a time finding which one. I don't want to push in everything or even more than I absolutely need because I want to retain the Roo capability to make changes.
As you said, to be able to include the necessary logic to consume a REST service, you need to make push-in of a method
The bussines logic should be included always in the service layer to ensure that all the calls make it to that operation from the web layer will execute the same process.
In this case, you need to make push-in of the save(EventExecute entity)
method from the service implementation. In that implementation you can include all the necessary logic to consume the REST service before to save the entity.
You could find an example about how to consume an external service in a Spring Roo application here:
https://github.com/DISID/disid-proofs/tree/master/spring-integration
Hope it helps,