vendredi 6 octobre 2017

Can i get a reference to an object constructed inside a function?

I have the following problem: I need to send some query parameters to send to a database from inside a java function inside a rest controller. However depending on the method exposed as an API, I need to update my query object dynamically. The function API looks like the following:

@RequestMapping(value = "/getItems, method = { RequestMethod.POST }, produces = { "application/json" })
public List<Item> getItems(){
  QueryObject queryObject = new QueryObject();
  queryObject.setParam(param);
  List<Item> items = dao.getItems(queryObject);
}

What I would like to do is make some sort of a mechanism, that by simply annotating the exposed API methods for which I want the enrichment of the query object, to add query params to the query object. Reflection can't achieve that, neither AOP feature of Spring. I wasn't able to find a mechanism that gives me a reference to an object instantiated inside a method.





Aucun commentaire:

Enregistrer un commentaire