I have a localService which I want to access via our restful api:
@GET
@Path("/some/path")
OutputObject doSomeSpecialCalculation(@QueryParam("input") InputObject obj);
Following problem/problems - what would be the best approach:
- To be able to create the InputObject, I need a lot of different input data -> the consturctor looks something like that: new InputObject(Obj1 o1, Obj2 o2, ..., Obj6 o6);
Q1: Is it possible to map many queryParams into a single object?
- The next problem is that most of the parameters (obj_n) need a special ParamProvider for construction. (e.g. the rest call for Obj2 o2 is an id number and the ParamConverter maps the id to the correct object)
I could create a new local service method like that:
@GET
@Path("/some/path")
OutputObject doSomeSpecialCalculation(@QueryParam("obj1") Obj1 ob1, @QueryParam("obj2") Obj2 ob2, ...);
Then I could create multiple ParamProviders for each obj_n and it would work, but I don't want to create duplicated methods in our localservices.
Q2: Would there be a better solution for my particular problem?
TL;DR:
- I have a local service method which takes a ComplexObject as an input parameter
- I want to access that method via a rest call
- To create that ComplexObject I need multiple objects as parameters for the constructor
- The most of the multiple parameters need a special mapper/converter: Restful-Input: id -> Object
It would be awesome if I could solve this problem just with annotations: @JsonTypeInfo on the complex object, and some "use-that-converter"-annotations on the input objects of the complex object's constructor.
Regards,
(using jackson 1.9/jboss eap 6.2)