samedi 15 juillet 2017

Design pattern for consuming REST services with Java Webclient

I need to consume few REST services in sequential order and parse them into Java Objects and persist those Java Objects in DB.

I have written a web client which sent the request, parse the response and return the response in RootNodeObject.

public clas RootNodeObject {

private Auth;

private DeviceDetails;

private HostDetails;

}

When I sent webclient.get("/Auth") it returns RootNodeObject which contains Auth object populated in it. When I sent webclient.get("/deviceDetails") it returns RootNodeObject which contains DeviceDetails object populated in it.

In a similar way, I have to sent 8-10 request to get all required data.

After that, I have written a mapper class which will convert Auth and DeviceDetails object into Hibernate Entity classes and persist it in DB.

This looks very rigid design.Any design pattern for the above code or any better design that I can use?

Aucun commentaire:

Enregistrer un commentaire