java - Where to add code which filters results returned from Spring service -
java - Where to add code which filters results returned from Spring service -
in spring controller receiving list of items service , using custom code within controller create new filtered list subset of list retured service.
i don't think filtering code should take place in controller ?
here controller :
@controller public class mycontroller { @autowired private myservice myservice; @rendermapping public string getvalues(modelmap modelmap){ list<string> = myservice.getnewvalues(); list<string> filteredlist = ...... /** code here process list , convert specific list */ modelmap.addattribute("values", filteredlist); } }
should filtering take place @ service implementation layer ?
so instead of myservice.getnewvalues();
should utilize new method filters results : myservice.getnewfilteredvalues();
?
note : method myservice.getnewfilteredvalues()
new method , contain same code filtering code specified in mycontroller
personally expose myservice.getvalues();
, allow service hide filtering , other logic caller.
java spring design-patterns
Comments
Post a Comment