On 04/28/2015 03:27 AM, Jacopo Cappellato wrote:
On Apr 28, 2015, at 10:16 AM, Jacques Le Roux <[email protected]> 
wrote:

So you would like to suppress the concept of event?
Most of the events are currently implemented in Java and are already under src 
folder.

Not what I mean.  The following method definition pattern is the problem:

==
public static String $methodName(HttpServletRequest request, HttpServletResponse response) { Integer pageNum = NumberParsingUtil.parseInt(request.getParameter("page"));
  ...
  // core logic starts here
List<Map<String, Object>> searchDataResults = dispatcher.runSync("doSearch", context);
  Map<String, Object> parsedData = new HashMap<>();
  int largeSizeCount = 0, smallSizeCount = 0;
  for (Map<String, Object> data: searchDataResults) {
    if (data.size() > 10) largeSizeCount++;
    if (data.size() > 5) smallSizeCount++;
  }
  parsedData.put("largeSizeCount", largeSizeCount);
  parsedData.put("smallSizeCount", smallSizeCount);
  parsedData.put("totalCount", searchDataResults.size());
  parsedData.put("results", searchDataResults);
  ..
  request.setAttribute("search:parsedData", parsedData);
  return "success";
}
==

There are 3 things going on here. The first part reads the incoming request data, fetching whatever it needs. The second does some kind of business logic. The third then places the results of that back into the request for later processing by further code.

The middle part needs to be extracted into a separate location that is callable through the service engine.

ps: this is pseudo code

Reply via email to