Spring Batch主要类之间的关系
Spring Batch主要类之间的关系
类关系图
相关类源码
JobParameters
package org.springframework.batch.core;
import java.io.Serializable;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
public class JobParameters implements Serializable {
private final Map<String, JobParameter> parameters;
public JobParameters() {
this.parameters = new LinkedHashMap();
}
public JobParameters(Map<String, JobParameter> parameters) {
this.parameters = new LinkedHashMap(parameters);
}
public Long getLong(String key) {
if (!this.parameters.containsKey(key)) {
return 0L;
} else {
Object value = ((JobParameter)this.parameters.get(key)).getValue();
return value == null ? 0L : (Long)value;
}
}
public Long getLong(String key, long defaultValue) {
return this.parameters.containsKey(key) ? this.getLong(key) : defaultValue;
}
public String getString(String key) {
JobParameter value = (JobParameter)this.parameters.get(key);
return value == null ? null : value.toString();
}
public String getString(String key, String defaultValue) {
return this.parameters.containsKey(key) ? this.getString(key) : defaultValue;
}
public Double getDouble(String key) {
if (!this.parameters.containsKey(key)) {
return 0.0;
} else {
Double value = (Double)((JobParameter)this.parameters.get(key)).getValue();
return value == null ? 0.0 : value;
}
}
public Double getDouble(String key, double defaultValue) {
return this.parameters.containsKey(key) ? this.getDouble(key) : defaultValue;
}
public Date getDate(String key) {
return this.getDate(key, (Date)null);
}
public Date getDate(String key, Date defaultValue) {
return this.parameters.containsKey(key) ? (Date)((JobParameter)this.parameters.get(key)).getValue() : defaultValue;
}
public Map<String, JobParameter> getParameters() {
return new LinkedHashMap(this.parameters);
}
public boolean isEmpty() {
return this.parameters.isEmpty();
}
public boolean equals(Object obj) {
if (!(obj instanceof JobParameters)) {
return false;
} else if (obj == this) {
return true;
} else {
JobParameters rhs = (JobParameters)obj;
return this.parameters.equals(rhs.parameters);
}
}
public int hashCode() {
return 17 + 23 * this.parameters.hashCode();
}
public String toString() {
return this.parameters.toString();
}
}
JobInstance
package org.springframework.batch.core;
import org.springframework.util.Assert;
public class JobInstance extends Entity {
private final String jobName;
public JobInstance(Long id, String jobName) {
super(id);
Assert.hasLength(jobName);
this.jobName = jobName;
}
public String getJobName() {
return this.jobName;
}
public String toString() {
return super.toString() + ", Job=[" + this.jobName + "]";
}
}
JobExecution
package org.springframework.batch.core;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;
import org.springframework.batch.item.ExecutionContext;
public class JobExecution extends Entity {
private final JobParameters jobParameters;
private JobInstance jobInstance;
private volatile Collection<StepExecution> stepExecutions;
private volatile BatchStatus status;
private volatile Date startTime;
private volatile Date createTime;
private volatile Date endTime;
private volatile Date lastUpdated;
private volatile ExitStatus exitStatus;
private volatile ExecutionContext executionContext;
private transient volatile List<Throwable> failureExceptions;
public JobExecution(JobInstance job, Long id, JobParameters jobParameters) {
super(id);
this.stepExecutions = new CopyOnWriteArraySet();
this.status = BatchStatus.STARTING;
this.startTime = null;
this.createTime = new Date(System.currentTimeMillis());
this.endTime = null;
this.lastUpdated = null;
this.exitStatus = ExitStatus.UNKNOWN;
this.executionContext = new ExecutionContext();
this.failureExceptions = new CopyOnWriteArrayList();
this.jobInstance = job;
this.jobParameters = jobParameters == null ? new JobParameters() : jobParameters;
}
public JobExecution(JobInstance job, JobParameters jobParameters) {
this(job, (Long)null, jobParameters);
}
public JobExecution(Long id, JobParameters jobParameters) {
this((JobInstance)null, id, jobParameters);
}
public JobExecution(Long id) {
this((JobInstance)null, id, (JobParameters)null);
}
public JobParameters getJobParameters() {
return this.jobParameters;
}
public Date getEndTime() {
return this.endTime;
}
public void setJobInstance(JobInstance jobInstance) {
this.jobInstance = jobInstance;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public Date getStartTime() {
return this.startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public BatchStatus getStatus() {
return this.status;
}
public void setStatus(BatchStatus status) {
this.status = status;
}
public void upgradeStatus(BatchStatus status) {
this.status = this.status.upgradeTo(status);
}
public Long getJobId() {
return this.jobInstance != null ? this.jobInstance.getId() : null;
}
public void setExitStatus(ExitStatus exitStatus) {
this.exitStatus = exitStatus;
}
public ExitStatus getExitStatus() {
return this.exitStatus;
}
public JobInstance getJobInstance() {
return this.jobInstance;
}
public Collection<StepExecution> getStepExecutions() {
return Collections.unmodifiableList(new ArrayList(this.stepExecutions));
}
public StepExecution createStepExecution(String stepName) {
StepExecution stepExecution = new StepExecution(stepName, this);
this.stepExecutions.add(stepExecution);
return stepExecution;
}
public boolean isRunning() {
return this.endTime == null;
}
public boolean isStopping() {
return this.status == BatchStatus.STOPPING;
}
public void stop() {
Iterator i$ = this.stepExecutions.iterator();
while(i$.hasNext()) {
StepExecution stepExecution = (StepExecution)i$.next();
stepExecution.setTerminateOnly();
}
this.status = BatchStatus.STOPPING;
}
public void setExecutionContext(ExecutionContext executionContext) {
this.executionContext = executionContext;
}
public ExecutionContext getExecutionContext() {
return this.executionContext;
}
public Date getCreateTime() {
return this.createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
void addStepExecution(StepExecution stepExecution) {
this.stepExecutions.add(stepExecution);
}
public Date getLastUpdated() {
return this.lastUpdated;
}
public void setLastUpdated(Date lastUpdated) {
this.lastUpdated = lastUpdated;
}
public List<Throwable> getFailureExceptions() {
return this.failureExceptions;
}
public synchronized void addFailureException(Throwable t) {
this.failureExceptions.add(t);
}
public synchronized List<Throwable> getAllFailureExceptions() {
Set<Throwable> allExceptions = new HashSet(this.failureExceptions);
Iterator i$ = this.stepExecutions.iterator();
while(i$.hasNext()) {
StepExecution stepExecution = (StepExecution)i$.next();
allExceptions.addAll(stepExecution.getFailureExceptions());
}
return new ArrayList(allExceptions);
}
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
this.failureExceptions = new ArrayList();
}
public String toString() {
return super.toString() + String.format(", startTime=%s, endTime=%s, lastUpdated=%s, status=%s, exitStatus=%s, job=[%s], jobParameters=[%s]", this.startTime, this.endTime, this.lastUpdated, this.status, this.exitStatus, this.jobInstance, this.jobParameters);
}
public void addStepExecutions(List<StepExecution> stepExecutions) {
if (stepExecutions != null) {
this.stepExecutions.removeAll(stepExecutions);
this.stepExecutions.addAll(stepExecutions);
}
}
}
BatchStatus
package org.springframework.batch.core;
public enum BatchStatus {
COMPLETED,
STARTING,
STARTED,
STOPPING,
STOPPED,
FAILED,
ABANDONED,
UNKNOWN;
private BatchStatus() {
}
public static BatchStatus max(BatchStatus status1, BatchStatus status2) {
return status1.isGreaterThan(status2) ? status1 : status2;
}
public boolean isRunning() {
return this == STARTING || this == STARTED;
}
public boolean isUnsuccessful() {
return this == FAILED || this.isGreaterThan(FAILED);
}
public BatchStatus upgradeTo(BatchStatus other) {
if (!this.isGreaterThan(STARTED) && !other.isGreaterThan(STARTED)) {
return this != COMPLETED && other != COMPLETED ? max(this, other) : COMPLETED;
} else {
return max(this, other);
}
}
public boolean isGreaterThan(BatchStatus other) {
return this.compareTo(other) > 0;
}
public boolean isLessThan(BatchStatus other) {
return this.compareTo(other) < 0;
}
public boolean isLessThanOrEqualTo(BatchStatus other) {
return this.compareTo(other) <= 0;
}
public static BatchStatus match(String value) {
BatchStatus[] arr$ = values();
int len$ = arr$.length;
for(int i$ = 0; i$ < len$; ++i$) {
BatchStatus status = arr$[i$];
if (value.startsWith(status.toString())) {
return status;
}
}
return COMPLETED;
}
}
ExecutionContext
package org.springframework.batch.item;
import java.io.Serializable;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.springframework.util.Assert;
public class ExecutionContext implements Serializable {
private volatile boolean dirty;
private final Map<String, Object> map;
public ExecutionContext() {
this.dirty = false;
this.map = new ConcurrentHashMap();
}
public ExecutionContext(Map<String, Object> map) {
this.dirty = false;
this.map = new ConcurrentHashMap(map);
}
public ExecutionContext(ExecutionContext executionContext) {
this();
if (executionContext != null) {
Iterator i$ = executionContext.entrySet().iterator();
while(i$.hasNext()) {
Map.Entry<String, Object> entry = (Map.Entry)i$.next();
this.map.put(entry.getKey(), entry.getValue());
}
}
}
public void putString(String key, String value) {
this.put(key, value);
}
public void putLong(String key, long value) {
this.put(key, value);
}
public void putInt(String key, int value) {
this.put(key, value);
}
public void putDouble(String key, double value) {
this.put(key, value);
}
public void put(String key, Object value) {
Object result;
if (value != null) {
Assert.isInstanceOf(Serializable.class, value, "Value: [ " + value + "must be serializable.");
result = this.map.put(key, value);
this.dirty = result == null || result != null && !result.equals(value);
} else {
result = this.map.remove(key);
this.dirty = result != null;
}
}
public boolean isDirty() {
return this.dirty;
}
public String getString(String key) {
return (String)this.readAndValidate(key, String.class);
}
public String getString(String key, String defaultString) {
return !this.map.containsKey(key) ? defaultString : (String)this.readAndValidate(key, String.class);
}
public long getLong(String key) {
return (Long)this.readAndValidate(key, Long.class);
}
public long getLong(String key, long defaultLong) {
return !this.map.containsKey(key) ? defaultLong : (Long)this.readAndValidate(key, Long.class);
}
public int getInt(String key) {
return (Integer)this.readAndValidate(key, Integer.class);
}
public int getInt(String key, int defaultInt) {
return !this.map.containsKey(key) ? defaultInt : (Integer)this.readAndValidate(key, Integer.class);
}
public double getDouble(String key) {
return (Double)this.readAndValidate(key, Double.class);
}
public double getDouble(String key, double defaultDouble) {
return !this.map.containsKey(key) ? defaultDouble : (Double)this.readAndValidate(key, Double.class);
}
public Object get(String key) {
return this.map.get(key);
}
private Object readAndValidate(String key, Class<?> type) {
Object value = this.map.get(key);
if (!type.isInstance(value)) {
throw new ClassCastException("Value for key=[" + key + "] is not of type: [" + type + "], it is [" + (value == null ? null : "(" + value.getClass() + ")" + value) + "]");
} else {
return value;
}
}
public boolean isEmpty() {
return this.map.isEmpty();
}
public void clearDirtyFlag() {
this.dirty = false;
}
public Set<Map.Entry<String, Object>> entrySet() {
return this.map.entrySet();
}
public boolean containsKey(String key) {
return this.map.containsKey(key);
}
public Object remove(String key) {
return this.map.remove(key);
}
public boolean containsValue(Object value) {
return this.map.containsValue(value);
}
public boolean equals(Object obj) {
if (!(obj instanceof ExecutionContext)) {
return false;
} else if (this == obj) {
return true;
} else {
ExecutionContext rhs = (ExecutionContext)obj;
return this.entrySet().equals(rhs.entrySet());
}
}
public int hashCode() {
return this.map.hashCode();
}
public String toString() {
return this.map.toString();
}
public int size() {
return this.map.size();
}
}
ExitStatus
package org.springframework.batch.core;
import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
import org.springframework.util.StringUtils;
public class ExitStatus implements Serializable, Comparable<ExitStatus> {
public static final ExitStatus UNKNOWN = new ExitStatus("UNKNOWN");
public static final ExitStatus EXECUTING = new ExitStatus("EXECUTING");
public static final ExitStatus COMPLETED = new ExitStatus("COMPLETED");
public static final ExitStatus NOOP = new ExitStatus("NOOP");
public static final ExitStatus FAILED = new ExitStatus("FAILED");
public static final ExitStatus STOPPED = new ExitStatus("STOPPED");
private final String exitCode;
private final String exitDescription;
public ExitStatus(String exitCode) {
this(exitCode, "");
}
public ExitStatus(String exitCode, String exitDescription) {
this.exitCode = exitCode;
this.exitDescription = exitDescription == null ? "" : exitDescription;
}
public String getExitCode() {
return this.exitCode;
}
public String getExitDescription() {
return this.exitDescription;
}
public ExitStatus and(ExitStatus status) {
if (status == null) {
return this;
} else {
ExitStatus result = this.addExitDescription(status.exitDescription);
if (this.compareTo(status) < 0) {
result = result.replaceExitCode(status.exitCode);
}
return result;
}
}
public int compareTo(ExitStatus status) {
if (this.severity(status) > this.severity(this)) {
return -1;
} else {
return this.severity(status) < this.severity(this) ? 1 : this.getExitCode().compareTo(status.getExitCode());
}
}
private int severity(ExitStatus status) {
if (status.exitCode.startsWith(EXECUTING.exitCode)) {
return 1;
} else if (status.exitCode.startsWith(COMPLETED.exitCode)) {
return 2;
} else if (status.exitCode.startsWith(NOOP.exitCode)) {
return 3;
} else if (status.exitCode.startsWith(STOPPED.exitCode)) {
return 4;
} else if (status.exitCode.startsWith(FAILED.exitCode)) {
return 5;
} else {
return status.exitCode.startsWith(UNKNOWN.exitCode) ? 6 : 7;
}
}
public String toString() {
return String.format("exitCode=%s;exitDescription=%s", this.exitCode, this.exitDescription);
}
public boolean equals(Object obj) {
return obj == null ? false : this.toString().equals(obj.toString());
}
public int hashCode() {
return this.toString().hashCode();
}
public ExitStatus replaceExitCode(String code) {
return new ExitStatus(code, this.exitDescription);
}
public boolean isRunning() {
return "RUNNING".equals(this.exitCode) || "UNKNOWN".equals(this.exitCode);
}
public ExitStatus addExitDescription(String description) {
StringBuffer buffer = new StringBuffer();
boolean changed = StringUtils.hasText(description) && !this.exitDescription.equals(description);
if (StringUtils.hasText(this.exitDescription)) {
buffer.append(this.exitDescription);
if (changed) {
buffer.append("; ");
}
}
if (changed) {
buffer.append(description);
}
return new ExitStatus(this.exitCode, buffer.toString());
}
public ExitStatus addExitDescription(Throwable throwable) {
StringWriter writer = new StringWriter();
throwable.printStackTrace(new PrintWriter(writer));
String message = writer.toString();
return this.addExitDescription(message);
}
}
StepContribution
package org.springframework.batch.core;
import java.io.Serializable;
public class StepContribution implements Serializable {
private volatile int readCount = 0;
private volatile int writeCount = 0;
private volatile int filterCount = 0;
private final int parentSkipCount;
private volatile int readSkipCount;
private volatile int writeSkipCount;
private volatile int processSkipCount;
private ExitStatus exitStatus;
public StepContribution(StepExecution execution) {
this.exitStatus = ExitStatus.EXECUTING;
this.parentSkipCount = execution.getSkipCount();
}
public void setExitStatus(ExitStatus status) {
this.exitStatus = status;
}
public ExitStatus getExitStatus() {
return this.exitStatus;
}
public void incrementFilterCount(int count) {
this.filterCount += count;
}
public void incrementReadCount() {
++this.readCount;
}
public void incrementWriteCount(int count) {
this.writeCount += count;
}
public int getReadCount() {
return this.readCount;
}
public int getWriteCount() {
return this.writeCount;
}
public int getFilterCount() {
return this.filterCount;
}
public int getStepSkipCount() {
return this.readSkipCount + this.writeSkipCount + this.processSkipCount + this.parentSkipCount;
}
public int getSkipCount() {
return this.readSkipCount + this.writeSkipCount + this.processSkipCount;
}
public void incrementReadSkipCount() {
++this.readSkipCount;
}
public void incrementReadSkipCount(int count) {
this.readSkipCount += count;
}
public void incrementWriteSkipCount() {
++this.writeSkipCount;
}
public void incrementProcessSkipCount() {
++this.processSkipCount;
}
public int getReadSkipCount() {
return this.readSkipCount;
}
public int getWriteSkipCount() {
return this.writeSkipCount;
}
public int getProcessSkipCount() {
return this.processSkipCount;
}
public String toString() {
return "[StepContribution: read=" + this.readCount + ", written=" + this.writeCount + ", filtered=" + this.filterCount + ", readSkips=" + this.readSkipCount + ", writeSkips=" + this.writeSkipCount + ", processSkips=" + this.processSkipCount + ", exitStatus=" + this.exitStatus.getExitCode() + "]";
}
public boolean equals(Object obj) {
if (!(obj instanceof StepContribution)) {
return false;
} else {
StepContribution other = (StepContribution)obj;
return this.toString().equals(other.toString());
}
}
public int hashCode() {
return 11 + this.toString().hashCode() * 43;
}
}
StepExecution
package org.springframework.batch.core;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.util.Assert;
public class StepExecution extends Entity {
private final JobExecution jobExecution;
private final String stepName;
private volatile BatchStatus status;
private volatile int readCount;
private volatile int writeCount;
private volatile int commitCount;
private volatile int rollbackCount;
private volatile int readSkipCount;
private volatile int processSkipCount;
private volatile int writeSkipCount;
private volatile Date startTime;
private volatile Date endTime;
private volatile Date lastUpdated;
private volatile ExecutionContext executionContext;
private volatile ExitStatus exitStatus;
private volatile boolean terminateOnly;
private volatile int filterCount;
private transient volatile List<Throwable> failureExceptions;
public StepExecution(String stepName, JobExecution jobExecution, Long id) {
this(stepName, jobExecution);
Assert.notNull(jobExecution, "JobExecution must be provided to re-hydrate an existing StepExecution");
Assert.notNull(id, "The entity Id must be provided to re-hydrate an existing StepExecution");
this.setId(id);
jobExecution.addStepExecution(this);
}
public StepExecution(String stepName, JobExecution jobExecution) {
this.status = BatchStatus.STARTING;
this.readCount = 0;
this.writeCount = 0;
this.commitCount = 0;
this.rollbackCount = 0;
this.readSkipCount = 0;
this.processSkipCount = 0;
this.writeSkipCount = 0;
this.startTime = new Date(System.currentTimeMillis());
this.endTime = null;
this.lastUpdated = null;
this.executionContext = new ExecutionContext();
this.exitStatus = ExitStatus.EXECUTING;
this.failureExceptions = new CopyOnWriteArrayList();
Assert.hasLength(stepName);
this.stepName = stepName;
this.jobExecution = jobExecution;
}
public ExecutionContext getExecutionContext() {
return this.executionContext;
}
public void setExecutionContext(ExecutionContext executionContext) {
this.executionContext = executionContext;
}
public int getCommitCount() {
return this.commitCount;
}
public void setCommitCount(int commitCount) {
this.commitCount = commitCount;
}
public Date getEndTime() {
return this.endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public int getReadCount() {
return this.readCount;
}
public void setReadCount(int readCount) {
this.readCount = readCount;
}
public int getWriteCount() {
return this.writeCount;
}
public void setWriteCount(int writeCount) {
this.writeCount = writeCount;
}
public int getRollbackCount() {
return this.rollbackCount;
}
public int getFilterCount() {
return this.filterCount;
}
public void setFilterCount(int filterCount) {
this.filterCount = filterCount;
}
public void setRollbackCount(int rollbackCount) {
this.rollbackCount = rollbackCount;
}
public Date getStartTime() {
return this.startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public BatchStatus getStatus() {
return this.status;
}
public void setStatus(BatchStatus status) {
this.status = status;
}
public void upgradeStatus(BatchStatus status) {
this.status = this.status.upgradeTo(status);
}
public String getStepName() {
return this.stepName;
}
public Long getJobExecutionId() {
return this.jobExecution != null ? this.jobExecution.getId() : null;
}
public void setExitStatus(ExitStatus exitStatus) {
this.exitStatus = exitStatus;
}
public ExitStatus getExitStatus() {
return this.exitStatus;
}
public JobExecution getJobExecution() {
return this.jobExecution;
}
public StepContribution createStepContribution() {
return new StepContribution(this);
}
public synchronized void apply(StepContribution contribution) {
this.readSkipCount += contribution.getReadSkipCount();
this.writeSkipCount += contribution.getWriteSkipCount();
this.processSkipCount += contribution.getProcessSkipCount();
this.filterCount += contribution.getFilterCount();
this.readCount += contribution.getReadCount();
this.writeCount += contribution.getWriteCount();
this.exitStatus = this.exitStatus.and(contribution.getExitStatus());
}
public synchronized void incrementRollbackCount() {
++this.rollbackCount;
}
public boolean isTerminateOnly() {
return this.terminateOnly;
}
public void setTerminateOnly() {
this.terminateOnly = true;
}
public int getSkipCount() {
return this.readSkipCount + this.processSkipCount + this.writeSkipCount;
}
public void incrementCommitCount() {
++this.commitCount;
}
public JobParameters getJobParameters() {
return this.jobExecution == null ? new JobParameters() : this.jobExecution.getJobParameters();
}
public int getReadSkipCount() {
return this.readSkipCount;
}
public int getWriteSkipCount() {
return this.writeSkipCount;
}
public void setReadSkipCount(int readSkipCount) {
this.readSkipCount = readSkipCount;
}
public void setWriteSkipCount(int writeSkipCount) {
this.writeSkipCount = writeSkipCount;
}
public int getProcessSkipCount() {
return this.processSkipCount;
}
public void setProcessSkipCount(int processSkipCount) {
this.processSkipCount = processSkipCount;
}
public Date getLastUpdated() {
return this.lastUpdated;
}
public void setLastUpdated(Date lastUpdated) {
this.lastUpdated = lastUpdated;
}
public List<Throwable> getFailureExceptions() {
return this.failureExceptions;
}
public void addFailureException(Throwable throwable) {
this.failureExceptions.add(throwable);
}
public boolean equals(Object obj) {
Object jobExecutionId = this.getJobExecutionId();
if (jobExecutionId != null && obj instanceof StepExecution && this.getId() != null) {
StepExecution other = (StepExecution)obj;
return this.stepName.equals(other.getStepName()) && jobExecutionId.equals(other.getJobExecutionId()) && this.getId().equals(other.getId());
} else {
return super.equals(obj);
}
}
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
this.failureExceptions = new ArrayList();
}
public int hashCode() {
Object jobExecutionId = this.getJobExecutionId();
Long id = this.getId();
return super.hashCode() + 31 * (this.stepName != null ? this.stepName.hashCode() : 0) + 91 * (jobExecutionId != null ? jobExecutionId.hashCode() : 0) + 59 * (id != null ? id.hashCode() : 0);
}
public String toString() {
return String.format(this.getSummary() + ", exitDescription=%s", this.exitStatus.getExitDescription());
}
public String getSummary() {
return super.toString() + String.format(", name=%s, status=%s, exitStatus=%s, readCount=%d, filterCount=%d, writeCount=%d readSkipCount=%d, writeSkipCount=%d, processSkipCount=%d, commitCount=%d, rollbackCount=%d", this.stepName, this.status, this.exitStatus.getExitCode(), this.readCount, this.filterCount, this.writeCount, this.readSkipCount, this.writeSkipCount, this.processSkipCount, this.commitCount, this.rollbackCount);
}
}
StepContext
package org.springframework.batch.core.scope.context;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.springframework.batch.core.JobParameter;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.UnexpectedJobExecutionException;
import org.springframework.batch.repeat.context.SynchronizedAttributeAccessor;
import org.springframework.util.Assert;
public class StepContext extends SynchronizedAttributeAccessor {
private StepExecution stepExecution;
private Map<String, Set<Runnable>> callbacks = new HashMap();
public StepContext(StepExecution stepExecution) {
Assert.notNull(stepExecution, "A StepContext must have a non-null StepExecution");
this.stepExecution = stepExecution;
}
public String getStepName() {
return this.stepExecution.getStepName();
}
public String getJobName() {
Assert.state(this.stepExecution.getJobExecution() != null, "StepExecution does not have a JobExecution");
Assert.state(this.stepExecution.getJobExecution().getJobInstance() != null, "StepExecution does not have a JobInstance");
return this.stepExecution.getJobExecution().getJobInstance().getJobName();
}
public Properties getSystemProperties() {
return System.getProperties();
}
public Map<String, Object> getStepExecutionContext() {
Map<String, Object> result = new HashMap();
Iterator i$ = this.stepExecution.getExecutionContext().entrySet().iterator();
while(i$.hasNext()) {
Map.Entry<String, Object> entry = (Map.Entry)i$.next();
result.put(entry.getKey(), entry.getValue());
}
return Collections.unmodifiableMap(result);
}
public Map<String, Object> getJobExecutionContext() {
Map<String, Object> result = new HashMap();
Iterator i$ = this.stepExecution.getJobExecution().getExecutionContext().entrySet().iterator();
while(i$.hasNext()) {
Map.Entry<String, Object> entry = (Map.Entry)i$.next();
result.put(entry.getKey(), entry.getValue());
}
return Collections.unmodifiableMap(result);
}
public Map<String, Object> getJobParameters() {
Map<String, Object> result = new HashMap();
Iterator i$ = this.stepExecution.getJobParameters().getParameters().entrySet().iterator();
while(i$.hasNext()) {
Map.Entry<String, JobParameter> entry = (Map.Entry)i$.next();
result.put(entry.getKey(), ((JobParameter)entry.getValue()).getValue());
}
return Collections.unmodifiableMap(result);
}
public void registerDestructionCallback(String name, Runnable callback) {
synchronized(this.callbacks) {
Set<Runnable> set = (Set)this.callbacks.get(name);
if (set == null) {
set = new HashSet();
this.callbacks.put(name, set);
}
((Set)set).add(callback);
}
}
private void unregisterDestructionCallbacks(String name) {
synchronized(this.callbacks) {
this.callbacks.remove(name);
}
}
public Object removeAttribute(String name) {
this.unregisterDestructionCallbacks(name);
return super.removeAttribute(name);
}
public void close() {
List<Exception> errors = new ArrayList();
Map<String, Set<Runnable>> copy = Collections.unmodifiableMap(this.callbacks);
Iterator i$ = copy.entrySet().iterator();
while(i$.hasNext()) {
Map.Entry<String, Set<Runnable>> entry = (Map.Entry)i$.next();
Set<Runnable> set = (Set)entry.getValue();
Iterator i$ = set.iterator();
while(i$.hasNext()) {
Runnable callback = (Runnable)i$.next();
if (callback != null) {
try {
callback.run();
} catch (RuntimeException var9) {
errors.add(var9);
}
}
}
}
if (!errors.isEmpty()) {
Exception error = (Exception)errors.get(0);
if (error instanceof RuntimeException) {
throw (RuntimeException)error;
} else {
throw new UnexpectedJobExecutionException("Could not close step context, rethrowing first of " + errors.size() + " exceptions.", error);
}
}
}
public StepExecution getStepExecution() {
return this.stepExecution;
}
public String getId() {
Assert.state(this.stepExecution.getId() != null, "StepExecution has no id. It must be saved before it can be used in step scope.");
return "execution#" + this.stepExecution.getId();
}
public boolean equals(Object other) {
if (!(other instanceof StepContext)) {
return false;
} else if (other == this) {
return true;
} else {
StepContext context = (StepContext)other;
return context.stepExecution == this.stepExecution ? true : this.stepExecution.equals(context.stepExecution);
}
}
public int hashCode() {
return this.stepExecution.hashCode();
}
public String toString() {
return super.toString() + ", stepExecutionContext=" + this.getStepExecutionContext() + ", jobExecutionContext=" + this.getJobExecutionContext() + ", jobParameters=" + this.getJobParameters();
}
}
ChunkContext
package org.springframework.batch.core.scope.context;
import java.util.Arrays;
import org.springframework.core.AttributeAccessorSupport;
public class ChunkContext extends AttributeAccessorSupport {
private final StepContext stepContext;
private boolean complete = false;
public ChunkContext(StepContext stepContext) {
this.stepContext = stepContext;
}
public StepContext getStepContext() {
return this.stepContext;
}
public boolean isComplete() {
return this.complete;
}
public void setComplete() {
this.complete = true;
}
public String toString() {
return String.format("ChunkContext: attributes=%s, complete=%b, stepContext=%s", Arrays.asList(this.attributeNames()), this.complete, this.stepContext);
}
}