class RemoteStepExecutionAggregator implements StepExecutionAggregator, InitializingBean {

	private StepExecutionAggregator delegate = new DefaultStepExecutionAggregator();

	private JobExplorer jobExplorer;

	/**
	 * Create a new instance (useful for configuration purposes).
	 */
	public RemoteStepExecutionAggregator() {
	}

	/**
	 * Create a new instance with a job explorer that can be used to refresh the data when
	 * aggregating.
	 * @param jobExplorer the {@link JobExplorer} to use
	 */
	public RemoteStepExecutionAggregator(JobExplorer jobExplorer) {
		super();
		this.jobExplorer = jobExplorer;
	}

	/**
	 * @param jobExplorer the jobExplorer to set
	 */
	public void setJobExplorer(JobExplorer jobExplorer) {
		this.jobExplorer = jobExplorer;
	}

	/**
	 * @param delegate the delegate to set
	 */
	public void setDelegate(StepExecutionAggregator delegate) {
		this.delegate = delegate;
	}

	/**
	 * @throws Exception if the job explorer is not provided
	 */
	@Override
	public void afterPropertiesSet() throws Exception {
		Assert.state(jobExplorer != null, "A JobExplorer must be provided");
	}

	/**
	 * Aggregates the input executions into the result {@link StepExecution} delegating to
	 * the delegate aggregator once the input has been refreshed from the
	 * {@link JobExplorer}.
	 *
	 * @see StepExecutionAggregator #aggregate(StepExecution, Collection)
	 */
	@Override
	public void aggregate(StepExecution result, Collection<StepExecution> executions) {<FILL_FUNCTION_BODY>}

}

		Assert.notNull(result, "To aggregate into a result it must be non-null.");
		if (executions == null) {
			return;
		}
		Set<Long> stepExecutionIds = executions.stream().map(stepExecution -> {
			Long id = stepExecution.getId();
			Assert.state(id != null, "StepExecution has null id. It must be saved first: " + stepExecution);
			return id;
		}).collect(Collectors.toSet());
		JobExecution jobExecution = jobExplorer.getJobExecution(result.getJobExecutionId());
		Assert.state(jobExecution != null,
				"Could not load JobExecution from JobRepository for id " + result.getJobExecutionId());
		List<StepExecution> updates = jobExecution.getStepExecutions()
			.stream()
			.filter(stepExecution -> stepExecutionIds.contains(stepExecution.getId()))
			.collect(Collectors.toList());
		delegate.aggregate(result, updates);
	
<no_super_class>