IN PROGRESS - issue BATCH-159: JobExecutor should return a JobExecution (which itself contains the ExitStatus)
http://opensource.atlassian.com/projects/spring/browse/BATCH-159 Use package access instead of reflection to get to registry inside facade
This commit is contained in:
@@ -59,7 +59,8 @@ public class SimpleJobExecutorFacade implements JobExecutorFacade,
|
||||
|
||||
private JobRepository jobRepository;
|
||||
|
||||
private Map jobExecutionRegistry = new HashMap();
|
||||
// Package access for unit testing...
|
||||
Map jobExecutionRegistry = new HashMap();
|
||||
|
||||
// there is no sensible default for this
|
||||
private JobConfigurationLocator jobConfigurationLocator;
|
||||
@@ -141,7 +142,6 @@ public class SimpleJobExecutorFacade implements JobExecutorFacade,
|
||||
JobInstance job = jobRepository.findOrCreateJob(jobConfiguration,
|
||||
jobIdentifier);
|
||||
JobExecution jobExecution = new JobExecution(job);
|
||||
jobExecutionRegistry.put(jobIdentifier, jobExecution);
|
||||
|
||||
try {
|
||||
|
||||
@@ -152,7 +152,6 @@ public class SimpleJobExecutorFacade implements JobExecutorFacade,
|
||||
} finally {
|
||||
|
||||
this.after(jobExecution);
|
||||
jobExecutionRegistry.remove(jobIdentifier);
|
||||
|
||||
}
|
||||
|
||||
@@ -169,6 +168,7 @@ public class SimpleJobExecutorFacade implements JobExecutorFacade,
|
||||
public void before(JobExecution execution) {
|
||||
synchronized (mutex) {
|
||||
running++;
|
||||
jobExecutionRegistry.put(execution.getJobIdentifier(), execution);
|
||||
}
|
||||
for (Iterator iterator = listeners.iterator(); iterator.hasNext();) {
|
||||
JobExecutionListener listener = (JobExecutionListener) iterator
|
||||
@@ -195,6 +195,7 @@ public class SimpleJobExecutorFacade implements JobExecutorFacade,
|
||||
synchronized (mutex) {
|
||||
// assume execution is synchronous so when we get to here we are
|
||||
// not running any more
|
||||
jobExecutionRegistry.remove(execution.getJobIdentifier());
|
||||
running--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.batch.execution.facade;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -36,7 +35,6 @@ import org.springframework.batch.core.runtime.SimpleJobIdentifier;
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.batch.repeat.context.RepeatContextSupport;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* SimpleBatchContainer unit tests.
|
||||
@@ -248,9 +246,7 @@ public class SimpleJobExecutorFacadeTests extends TestCase {
|
||||
private void registerExecution(SimpleJobIdentifier runtimeInformation,
|
||||
JobExecution execution) throws NoSuchFieldException,
|
||||
IllegalAccessException {
|
||||
Field field = SimpleJobExecutorFacade.class.getDeclaredField("jobExecutionRegistry");
|
||||
ReflectionUtils.makeAccessible(field);
|
||||
Map map = (Map) field.get(jobExecutorFacade);
|
||||
Map map = (Map) jobExecutorFacade.jobExecutionRegistry;
|
||||
map.put(runtimeInformation, execution);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user