@Override
  public void dispatch (TaskExecution aTask) {
    List<Object> list = aTask.getList("list", Object.class);
    Assert.notNull(list,"'list' property can't be null");
    Map<String, Object> iteratee = aTask.getMap("iteratee");
    Assert.notNull(iteratee,"'iteratee' property can't be null");
    
    SimpleTaskExecution parentEachTask = SimpleTaskExecution.of(aTask);
    parentEachTask.setStartTime(new Date ());
    parentEachTask.setStatus(TaskStatus.STARTED);
    taskExecutionRepo.merge(parentEachTask);
    
    if(list.size() > 0) {
      counterRepository.set(aTask.getId(), list.size());
      for(int i=0; i<list.size(); i++) {
        Object item = list.get(i);
        SimpleTaskExecution eachTask = SimpleTaskExecution.of(iteratee);
        eachTask.setId(UUIDGenerator.generate());
        eachTask.setParentId(aTask.getId());
        eachTask.setStatus(TaskStatus.CREATED);
        eachTask.setJobId(aTask.getJobId());
        eachTask.setCreateTime(new Date());
        eachTask.setPriority(aTask.getPriority());
        eachTask.setTaskNumber(i+1);
        MapContext context = new MapContext (contextRepository.peek(aTask.getId()));
        context.set(aTask.getString("itemVar","item"), item);
        context.set(aTask.getString("itemIndex","itemIndex"), i);
        contextRepository.push(eachTask.getId(), context);
        TaskExecution evaluatedEachTask = taskEvaluator.evaluate(eachTask, context);
        taskExecutionRepo.create(evaluatedEachTask);
        taskDispatcher.dispatch(evaluatedEachTask);
      }
    }
    else {
      SimpleTaskExecution completion = SimpleTaskExecution.of(aTask);
      completion.setEndTime(new Date());
      messageBroker.send(Queues.COMPLETIONS, completion);
    }
  }
A {@link TaskDispatcher} implementation which implements a parallel
for-each construct. The dispatcher works by executing 
the <code>iteratee</code> function on each item on the <code>list</code>.

@author Arik Cohen
@since Apr 25, 2017
src/main/java/com/creactiviti/piper/core/task/EachTaskDispatcher.java