BATCH-1915: Reformatting

This commit is contained in:
Michael Minella
2012-12-31 08:10:08 -06:00
parent a583c3a421
commit 96c818e86f
294 changed files with 3154 additions and 3034 deletions

View File

@@ -93,3 +93,4 @@ proxied
payloads
unflushed
memento
michael

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,11 +25,12 @@ import org.springframework.util.ClassUtils;
* from another should subclass from Entity. More information on this pattern
* and the difference between Entities and Value Objects can be found in Domain
* Driven Design by Eric Evans.
*
*
* @author Lucas Ward
* @author Dave Syer
*
*
*/
@SuppressWarnings("serial")
public class Entity implements Serializable {
private Long id;
@@ -42,7 +43,7 @@ public class Entity implements Serializable {
public Entity(Long id) {
super();
//Commented out because StepExecutions are still created in a disconnected
//manner. The Repository should create them, then this can be uncommented.
//Assert.notNull(id, "Entity id must not be null.");
@@ -63,7 +64,7 @@ public class Entity implements Serializable {
public Integer getVersion() {
return version;
}
/**
* Public setter for the version needed only by repository methods.
* @param version the version to set
@@ -91,7 +92,7 @@ public class Entity implements Serializable {
/**
* Attempt to establish identity based on id if both exist. If either id
* does not exist use Object.equals().
*
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
@@ -121,10 +122,10 @@ public class Entity implements Serializable {
* {@link Entity} after it is saved. Spring Batch does not store any of its
* entities in Sets as a matter of course, so internally this is consistent.
* Clients should not be exposed to unsaved entities.
*
*
* @see java.lang.Object#hashCode()
*/
@Override
@Override
public int hashCode() {
if (id == null) {
return super.hashCode();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,12 +24,13 @@ import org.springframework.util.StringUtils;
/**
* Value object used to carry information about the status of a
* job or step execution.
*
*
* ExitStatus is immutable and therefore thread-safe.
*
*
* @author Dave Syer
*
*
*/
@SuppressWarnings("serial")
public class ExitStatus implements Serializable, Comparable<ExitStatus> {
/**
@@ -85,7 +86,7 @@ public class ExitStatus implements Serializable, Comparable<ExitStatus> {
/**
* Getter for the exit code (defaults to blank).
*
*
* @return the exit code.
*/
public String getExitCode() {
@@ -106,7 +107,7 @@ public class ExitStatus implements Serializable, Comparable<ExitStatus> {
* case of equal severity, the exit code is replaced if the new value is
* alphabetically greater.<br/>
* <br/>
*
*
* Severity is defined by the exit code:
* <ul>
* <li>Codes beginning with EXECUTING have severity 1</li>
@@ -117,9 +118,9 @@ public class ExitStatus implements Serializable, Comparable<ExitStatus> {
* <li>Codes beginning with UNKNOWN have severity 6</li>
* </ul>
* Others have severity 7, so custom exit codes always win.<br/>
*
*
* If the input is null just return this.
*
*
* @param status an {@link ExitStatus} to combine with this one.
* @return a new {@link ExitStatus} combining the current value and the
* argument provided.
@@ -134,12 +135,12 @@ public class ExitStatus implements Serializable, Comparable<ExitStatus> {
}
return result;
}
/**
* @param status an {@link ExitStatus} to compare
* @return 1,0,-1 according to the severity and exit code
*/
@Override
@Override
public int compareTo(ExitStatus status) {
if (severity(status) > severity(this)) {
return -1;
@@ -178,20 +179,20 @@ public class ExitStatus implements Serializable, Comparable<ExitStatus> {
/*
* (non-Javadoc)
*
*
* @see java.lang.Object#toString()
*/
@Override
@Override
public String toString() {
return String.format("exitCode=%s;exitDescription=%s", exitCode, exitDescription);
}
/**
* Compare the fields one by one.
*
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
@@ -201,10 +202,10 @@ public class ExitStatus implements Serializable, Comparable<ExitStatus> {
/**
* Compatible with the equals implementation.
*
*
* @see java.lang.Object#hashCode()
*/
@Override
@Override
public int hashCode() {
return toString().hashCode();
}
@@ -212,7 +213,7 @@ public class ExitStatus implements Serializable, Comparable<ExitStatus> {
/**
* Add an exit code to an existing {@link ExitStatus}. If there is already a
* code present tit will be replaced.
*
*
* @param code the code to add
* @return a new {@link ExitStatus} with the same properties but a new exit
* code.
@@ -223,7 +224,7 @@ public class ExitStatus implements Serializable, Comparable<ExitStatus> {
/**
* Check if this status represents a running process.
*
*
* @return true if the exit code is "RUNNING" or "UNKNOWN"
*/
public boolean isRunning() {
@@ -234,7 +235,7 @@ public class ExitStatus implements Serializable, Comparable<ExitStatus> {
* Add an exit description to an existing {@link ExitStatus}. If there is
* already a description present the two will be concatenated with a
* semicolon.
*
*
* @param description the description to add
* @return a new {@link ExitStatus} with the same properties but a new exit
* description
@@ -257,7 +258,7 @@ public class ExitStatus implements Serializable, Comparable<ExitStatus> {
/**
* Extract the stack trace from the throwable provided and append it to
* the exist description.
*
*
* @param throwable
* @return a new ExitStatus with the stack trace appended
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,10 +32,11 @@ import org.springframework.batch.item.ExecutionContext;
/**
* Batch domain object representing the execution of a job.
*
*
* @author Lucas Ward
*
*
*/
@SuppressWarnings("serial")
public class JobExecution extends Entity {
private JobInstance jobInstance;
@@ -61,7 +62,7 @@ public class JobExecution extends Entity {
/**
* Because a JobExecution isn't valid unless the job is set, this
* constructor is the only valid one from a modelling point of view.
*
*
* @param job the job of which this execution is a part
*/
public JobExecution(JobInstance job, Long id) {
@@ -71,7 +72,7 @@ public class JobExecution extends Entity {
/**
* Constructor for transient (unsaved) instances.
*
*
* @param job the enclosing {@link JobInstance}
*/
public JobExecution(JobInstance job) {
@@ -108,7 +109,7 @@ public class JobExecution extends Entity {
/**
* Set the value of the status field.
*
*
* @param status the status to set
*/
public void setStatus(BatchStatus status) {
@@ -119,7 +120,7 @@ public class JobExecution extends Entity {
* Upgrade the status field if the provided value is greater than the
* existing one. Clients using this method to set the status can be sure
* that they don't overwrite a failed status with an successful one.
*
*
* @param status the new status value
*/
public void upgradeStatus(BatchStatus status) {
@@ -129,7 +130,7 @@ public class JobExecution extends Entity {
/**
* Convenience getter for for the id of the enclosing job. Useful for DAO
* implementations.
*
*
* @return the id of the enclosing job
*/
public Long getJobId() {
@@ -162,7 +163,7 @@ public class JobExecution extends Entity {
/**
* Accessor for the step executions.
*
*
* @return the step executions that were registered
*/
public Collection<StepExecution> getStepExecutions() {
@@ -201,7 +202,7 @@ public class JobExecution extends Entity {
/**
* Signal the {@link JobExecution} to stop. Iterates through the associated
* {@link StepExecution}s, calling {@link StepExecution#setTerminateOnly()}.
*
*
*/
public void stop() {
for (StepExecution stepExecution : stepExecutions) {
@@ -212,7 +213,7 @@ public class JobExecution extends Entity {
/**
* Sets the {@link ExecutionContext} for this execution
*
*
* @param executionContext the context
*/
public void setExecutionContext(ExecutionContext executionContext) {
@@ -222,7 +223,7 @@ public class JobExecution extends Entity {
/**
* Returns the {@link ExecutionContext} for this execution. The content is
* expected to be persisted after each step completion (successful or not).
*
*
* @return the context
*/
public ExecutionContext getExecutionContext() {
@@ -255,7 +256,7 @@ public class JobExecution extends Entity {
/**
* Get the date representing the last time this JobExecution was updated in
* the JobRepository.
*
*
* @return Date representing the last time this JobExecution was updated.
*/
public Date getLastUpdated() {
@@ -264,7 +265,7 @@ public class JobExecution extends Entity {
/**
* Set the last time this JobExecution was updated.
*
*
* @param lastUpdated
*/
public void setLastUpdated(Date lastUpdated) {
@@ -277,7 +278,7 @@ public class JobExecution extends Entity {
/**
* Add the provided throwable to the failure exception list.
*
*
* @param t
*/
public synchronized void addFailureException(Throwable t) {
@@ -287,7 +288,7 @@ public class JobExecution extends Entity {
/**
* Return all failure causing exceptions for this JobExecution, including
* step executions.
*
*
* @return List<Throwable> containing all exceptions causing failure for
* this JobExecution.
*/
@@ -312,10 +313,10 @@ public class JobExecution extends Entity {
/*
* (non-Javadoc)
*
*
* @see org.springframework.batch.core.domain.Entity#toString()
*/
@Override
@Override
public String toString() {
return super.toString()
+ String.format(", startTime=%s, endTime=%s, lastUpdated=%s, status=%s, exitStatus=%s, job=[%s]",

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2008 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,15 +20,15 @@ package org.springframework.batch.core;
* Implementations can be stateful if they are careful to either ensure thread
* safety, or to use one instance of a listener per job, assuming that job
* instances themselves are not used by more than one thread.
*
*
* @author Dave Syer
*
*
*/
public interface JobExecutionListener {
/**
* Callback before a job executes.
*
*
* @param jobExecution the current {@link JobExecution}
*/
void beforeJob(JobExecution jobExecution);
@@ -37,7 +37,7 @@ public interface JobExecutionListener {
* Callback after completion of a job. Called after both both successful and
* failed executions. To perform logic on a particular status, use
* "if (jobExecution.getStatus() == BatchStatus.X)".
*
*
* @param jobExecution the current {@link JobExecution}
*/
void afterJob(JobExecution jobExecution);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,20 +23,21 @@ import org.springframework.util.Assert;
* identity is given by the pair {@link Job} and {@link JobParameters}.
* JobInstance can be restarted multiple times in case of execution failure and
* it's lifecycle ends with first successful execution.
*
*
* Trying to execute an existing JobIntance that has already completed
* successfully will result in error. Error will be raised also for an attempt
* to restart a failed JobInstance if the Job is not restartable.
*
*
* @see Job
* @see JobParameters
* @see JobExecution
*
*
* @author Lucas Ward
* @author Dave Syer
* @author Robert Kasanicky
*
*
*/
@SuppressWarnings("unchecked")
public class JobInstance extends Entity {
private final JobParameters jobParameters;
@@ -65,7 +66,7 @@ public class JobInstance extends Entity {
return jobName;
}
@Override
@Override
public String toString() {
return super.toString() + ", JobParameters=[" + jobParameters + "]" + ", Job=[" + jobName + "]";
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,12 +22,13 @@ import java.util.Date;
/**
* Domain representation of a parameter to a batch job. Only the following types
* can be parameters: String, Long, Date, and Double.
*
*
* @author Lucas Ward
* @author Dave Syer
* @since 2.0
*
*
*/
@SuppressWarnings("serial")
public class JobParameter implements Serializable {
private final Object parameter;
@@ -44,7 +45,7 @@ public class JobParameter implements Serializable {
/**
* Construct a new JobParameter as a Long.
*
*
* @param parameter
*/
public JobParameter(Long parameter) {
@@ -54,7 +55,7 @@ public class JobParameter implements Serializable {
/**
* Construct a new JobParameter as a Date.
*
*
* @param parameter
*/
public JobParameter(Date parameter) {
@@ -64,7 +65,7 @@ public class JobParameter implements Serializable {
/**
* Construct a new JobParameter as a Double.
*
*
* @param parameter
*/
public JobParameter(Double parameter) {
@@ -112,7 +113,7 @@ public class JobParameter implements Serializable {
: parameter.toString());
}
@Override
@Override
public int hashCode() {
return 7 + 21 * (parameter == null ? parameterType.hashCode() : parameter.hashCode());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,10 +20,11 @@ import java.io.Serializable;
/**
* Represents a contribution to a {@link StepExecution}, buffering changes until
* they can be applied at a chunk boundary.
*
*
* @author Dave Syer
*
*
*/
@SuppressWarnings("serial")
public class StepContribution implements Serializable {
private volatile int readCount = 0;
@@ -51,7 +52,7 @@ public class StepContribution implements Serializable {
/**
* Set the {@link ExitStatus} for this contribution.
*
*
* @param status
*/
public void setExitStatus(ExitStatus status) {
@@ -60,7 +61,7 @@ public class StepContribution implements Serializable {
/**
* Public getter for the status.
*
*
* @return the {@link ExitStatus} for this contribution
*/
public ExitStatus getExitStatus() {
@@ -90,7 +91,7 @@ public class StepContribution implements Serializable {
/**
* Public access to the read counter.
*
*
* @return the item counter.
*/
public int getReadCount() {
@@ -99,7 +100,7 @@ public class StepContribution implements Serializable {
/**
* Public access to the write counter.
*
*
* @return the item counter.
*/
public int getWriteCount() {
@@ -153,7 +154,7 @@ public class StepContribution implements Serializable {
}
/**
*
*
*/
public void incrementProcessSkipCount() {
processSkipCount++;
@@ -183,10 +184,10 @@ public class StepContribution implements Serializable {
/*
* (non-Javadoc)
*
*
* @see java.lang.Object#toString()
*/
@Override
@Override
public String toString() {
return "[StepContribution: read=" + readCount + ", written=" + writeCount + ", filtered=" + filterCount
+ ", readSkips=" + readSkipCount + ", writeSkips=" + writeSkipCount + ", processSkips="

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,11 +30,12 @@ import org.springframework.util.Assert;
* Batch domain object representation the execution of a step. Unlike
* {@link JobExecution}, there are additional properties related the processing
* of items such as commit count, etc.
*
*
* @author Lucas Ward
* @author Dave Syer
*
*
*/
@SuppressWarnings("serial")
public class StepExecution extends Entity {
private final JobExecution jobExecution;
@@ -75,7 +76,7 @@ public class StepExecution extends Entity {
/**
* Constructor with mandatory properties.
*
*
* @param stepName the step to which this execution belongs
* @param jobExecution the current job execution
* @param id the id of this execution
@@ -90,7 +91,7 @@ public class StepExecution extends Entity {
/**
* Constructor that substitutes in null for the execution id
*
*
* @param stepName the step to which this execution belongs
* @param jobExecution the current job execution
*/
@@ -103,7 +104,7 @@ public class StepExecution extends Entity {
/**
* Returns the {@link ExecutionContext} for this execution
*
*
* @return the attributes
*/
public ExecutionContext getExecutionContext() {
@@ -112,7 +113,7 @@ public class StepExecution extends Entity {
/**
* Sets the {@link ExecutionContext} for this execution
*
*
* @param executionContext the attributes
*/
public void setExecutionContext(ExecutionContext executionContext) {
@@ -121,7 +122,7 @@ public class StepExecution extends Entity {
/**
* Returns the current number of commits for this execution
*
*
* @return the current number of commits
*/
public int getCommitCount() {
@@ -130,7 +131,7 @@ public class StepExecution extends Entity {
/**
* Sets the current number of commits for this execution
*
*
* @param commitCount the current number of commits
*/
public void setCommitCount(int commitCount) {
@@ -139,7 +140,7 @@ public class StepExecution extends Entity {
/**
* Returns the time that this execution ended
*
*
* @return the time that this execution ended
*/
public Date getEndTime() {
@@ -148,7 +149,7 @@ public class StepExecution extends Entity {
/**
* Sets the time that this execution ended
*
*
* @param endTime the time that this execution ended
*/
public void setEndTime(Date endTime) {
@@ -157,7 +158,7 @@ public class StepExecution extends Entity {
/**
* Returns the current number of items read for this execution
*
*
* @return the current number of items read for this execution
*/
public int getReadCount() {
@@ -166,7 +167,7 @@ public class StepExecution extends Entity {
/**
* Sets the current number of read items for this execution
*
*
* @param readCount the current number of read items for this execution
*/
public void setReadCount(int readCount) {
@@ -175,7 +176,7 @@ public class StepExecution extends Entity {
/**
* Returns the current number of items written for this execution
*
*
* @return the current number of items written for this execution
*/
public int getWriteCount() {
@@ -184,7 +185,7 @@ public class StepExecution extends Entity {
/**
* Sets the current number of written items for this execution
*
*
* @param writeCount the current number of written items for this execution
*/
public void setWriteCount(int writeCount) {
@@ -193,7 +194,7 @@ public class StepExecution extends Entity {
/**
* Returns the current number of rollbacks for this execution
*
*
* @return the current number of rollbacks for this execution
*/
public int getRollbackCount() {
@@ -202,7 +203,7 @@ public class StepExecution extends Entity {
/**
* Returns the current number of items filtered out of this execution
*
*
* @return the current number of items filtered out of this execution
*/
public int getFilterCount() {
@@ -227,7 +228,7 @@ public class StepExecution extends Entity {
/**
* Gets the time this execution started
*
*
* @return the time this execution started
*/
public Date getStartTime() {
@@ -236,7 +237,7 @@ public class StepExecution extends Entity {
/**
* Sets the time this execution started
*
*
* @param startTime the time this execution started
*/
public void setStartTime(Date startTime) {
@@ -245,7 +246,7 @@ public class StepExecution extends Entity {
/**
* Returns the current status of this step
*
*
* @return the current status of this step
*/
public BatchStatus getStatus() {
@@ -254,7 +255,7 @@ public class StepExecution extends Entity {
/**
* Sets the current status of this step
*
*
* @param status the current status of this step
*/
public void setStatus(BatchStatus status) {
@@ -265,7 +266,7 @@ public class StepExecution extends Entity {
* Upgrade the status field if the provided value is greater than the
* existing one. Clients using this method to set the status can be sure
* that they don't overwrite a failed status with an successful one.
*
*
* @param status the new status value
*/
public void upgradeStatus(BatchStatus status) {
@@ -281,7 +282,7 @@ public class StepExecution extends Entity {
/**
* Accessor for the job execution id.
*
*
* @return the jobExecutionId
*/
public Long getJobExecutionId() {
@@ -307,7 +308,7 @@ public class StepExecution extends Entity {
/**
* Accessor for the execution context information of the enclosing job.
*
*
* @return the {@link JobExecution} that was used to start this step
* execution.
*/
@@ -317,7 +318,7 @@ public class StepExecution extends Entity {
/**
* Factory method for {@link StepContribution}.
*
*
* @return a new {@link StepContribution}
*/
public StepContribution createStepContribution() {
@@ -328,7 +329,7 @@ public class StepExecution extends Entity {
* On successful execution just before a chunk commit, this method should be
* called. Synchronizes access to the {@link StepExecution} so that changes
* are atomic.
*
*
* @param contribution
*/
public synchronized void apply(StepContribution contribution) {
@@ -379,7 +380,7 @@ public class StepExecution extends Entity {
/**
* Convenience method to get the current job parameters.
*
*
* @return the {@link JobParameters} from the enclosing job, or empty if
* that is null
*/
@@ -406,7 +407,7 @@ public class StepExecution extends Entity {
/**
* Set the number of records skipped on read
*
*
* @param readSkipCount
*/
public void setReadSkipCount(int readSkipCount) {
@@ -415,7 +416,7 @@ public class StepExecution extends Entity {
/**
* Set the number of records skipped on write
*
*
* @param writeSkipCount
*/
public void setWriteSkipCount(int writeSkipCount) {
@@ -431,7 +432,7 @@ public class StepExecution extends Entity {
/**
* Set the number of records skipped during processing.
*
*
* @param processSkipCount
*/
public void setProcessSkipCount(int processSkipCount) {
@@ -447,7 +448,7 @@ public class StepExecution extends Entity {
/**
* Set the time when the StepExecution was last updated before persisting
*
*
* @param lastUpdated
*/
public void setLastUpdated(Date lastUpdated) {
@@ -464,12 +465,12 @@ public class StepExecution extends Entity {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.container.common.domain.Entity#equals(java.
* lang.Object)
*/
@Override
@Override
public boolean equals(Object obj) {
Object jobExecutionId = getJobExecutionId();
@@ -493,10 +494,10 @@ public class StepExecution extends Entity {
/*
* (non-Javadoc)
*
*
* @see org.springframework.batch.container.common.domain.Entity#hashCode()
*/
@Override
@Override
public int hashCode() {
Object jobExecutionId = getJobExecutionId();
Long id = getId();
@@ -504,7 +505,7 @@ public class StepExecution extends Entity {
* (jobExecutionId != null ? jobExecutionId.hashCode() : 0) + 59 * (id != null ? id.hashCode() : 0);
}
@Override
@Override
public String toString() {
return String.format(getSummary() + ", exitDescription=%s", exitStatus.getExitDescription());
}
@@ -514,8 +515,8 @@ public class StepExecution extends Entity {
+ String.format(
", name=%s, status=%s, exitStatus=%s, readCount=%d, filterCount=%d, writeCount=%d readSkipCount=%d, writeSkipCount=%d"
+ ", processSkipCount=%d, commitCount=%d, rollbackCount=%d", stepName, status,
exitStatus.getExitCode(), readCount, filterCount, writeCount, readSkipCount, writeSkipCount,
processSkipCount, commitCount, rollbackCount);
exitStatus.getExitCode(), readCount, filterCount, writeCount, readSkipCount, writeSkipCount,
processSkipCount, commitCount, rollbackCount);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2008 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,17 +18,17 @@ package org.springframework.batch.core;
/**
* Listener interface for the lifecycle of a {@link Step}.
*
*
* @author Lucas Ward
* @author Dave Syer
*
*
*/
public interface StepExecutionListener extends StepListener {
/**
* Initialize the state of the listener with the {@link StepExecution} from
* the current scope.
*
*
* @param stepExecution
*/
void beforeStep(StepExecution stepExecution);
@@ -37,11 +37,11 @@ public interface StepExecutionListener extends StepListener {
* Give a listener a chance to modify the exit status from a step. The value
* returned will be combined with the normal exit status using
* {@link ExitStatus#and(ExitStatus)}.
*
*
* Called after execution of step's processing logic (both successful or
* failed). Throwing exception in this method has no effect, it will only be
* logged.
*
*
* @return an {@link ExitStatus} to combine with the normal value. Return
* null to leave the old value unchanged.
*/

View File

@@ -31,7 +31,7 @@ import org.springframework.transaction.PlatformTransactionManager;
/**
* Base {@code Configuration} class providing common structure for enabling and using Spring Batch. Customization is
* available by implementing the {@link BatchConfigurer} interface.
*
*
* @author Dave Syer
* @since 2.2
* @see EnableBatchProcessing
@@ -47,19 +47,19 @@ public class ModularBatchConfiguration extends AbstractBatchConfiguration {
private AutomaticJobRegistrar registrar = new AutomaticJobRegistrar();
@Override
@Override
@Bean
public JobRepository jobRepository() throws Exception {
return getConfigurer(configurers).getJobRepository();
}
@Override
@Override
@Bean
public JobLauncher jobLauncher() throws Exception {
return getConfigurer(configurers).getJobLauncher();
}
@Override
@Override
@Bean
public PlatformTransactionManager transactionManager() throws Exception {
return getConfigurer(configurers).getTransactionManager();

View File

@@ -37,7 +37,7 @@ import org.springframework.transaction.PlatformTransactionManager;
* only initialize when a method is called. This is to prevent (as much as possible) configuration cycles from
* developing when these components are needed in a configuration resource that itself provides a
* {@link BatchConfigurer}.
*
*
* @author Dave Syer
* @since 2.2
* @see EnableBatchProcessing
@@ -47,7 +47,7 @@ public class SimpleBatchConfiguration extends AbstractBatchConfiguration {
@Autowired
private ApplicationContext context;
private boolean initialized = false;
private AtomicReference<JobRepository> jobRepository = new AtomicReference<JobRepository>();
@@ -58,25 +58,25 @@ public class SimpleBatchConfiguration extends AbstractBatchConfiguration {
private AtomicReference<PlatformTransactionManager> transactionManager = new AtomicReference<PlatformTransactionManager>();
@Override
@Override
@Bean
public JobRepository jobRepository() throws Exception {
return createLazyProxy(jobRepository, JobRepository.class);
}
@Override
@Override
@Bean
public JobLauncher jobLauncher() throws Exception {
return createLazyProxy(jobLauncher, JobLauncher.class);
}
@Override
@Override
@Bean
public JobRegistry jobRegistry() throws Exception {
return createLazyProxy(jobRegistry, JobRegistry.class);
}
@Override
@Override
@Bean
public PlatformTransactionManager transactionManager() throws Exception {
return createLazyProxy(transactionManager, PlatformTransactionManager.class);
@@ -95,7 +95,7 @@ public class SimpleBatchConfiguration extends AbstractBatchConfiguration {
/**
* Sets up the basic components by extracting them from the {@link BatchConfigurer configurer}, defaulting to some
* sensible values as long as a unique DataSource is available.
*
*
* @throws Exception if there is a problem in the configurer
*/
protected void initialize() throws Exception {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,9 +23,9 @@ import org.springframework.context.ConfigurableApplicationContext;
/**
* A {@link JobFactory} that creates its own {@link ApplicationContext} and
* pulls a bean out when asked to create a {@link Job}.
*
*
* @author Dave Syer
*
*
*/
public class ApplicationContextJobFactory implements JobFactory {
@@ -39,26 +39,26 @@ public class ApplicationContextJobFactory implements JobFactory {
*/
public ApplicationContextJobFactory(String jobName, ApplicationContextFactory applicationContextFactory) {
ConfigurableApplicationContext context = applicationContextFactory.createApplicationContext();
this.job = (Job) context.getBean(jobName, Job.class);
this.job = context.getBean(jobName, Job.class);
}
/**
* Create an {@link ApplicationContext} from the factory provided and pull
* out a bean with the name given during initialization.
*
*
* @see org.springframework.batch.core.configuration.JobFactory#createJob()
*/
@Override
@Override
public final Job createJob() {
return job;
}
/**
* Just return the name of instance passed in on initialization.
*
*
* @see JobFactory#getJobName()
*/
@Override
@Override
public String getJobName() {
return job.getName();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2010 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,7 +50,7 @@ public class DefaultJobLoader implements JobLoader, InitializingBean {
private static Log logger = LogFactory.getLog(DefaultJobLoader.class);
private JobRegistry jobRegistry;
private StepRegistry stepRegistry;
private StepRegistry stepRegistry;
private Map<ApplicationContextFactory, ConfigurableApplicationContext> contexts = new ConcurrentHashMap<ApplicationContextFactory, ConfigurableApplicationContext>();
@@ -63,24 +63,24 @@ public class DefaultJobLoader implements JobLoader, InitializingBean {
this(null, null);
}
/**
* Creates a job loader with the job registry provided.
*
* @param jobRegistry a {@link JobRegistry}
*/
public DefaultJobLoader(JobRegistry jobRegistry) {
this(jobRegistry, null);
}
/**
* Creates a job loader with the job registry provided.
*
* @param jobRegistry a {@link JobRegistry}
*/
public DefaultJobLoader(JobRegistry jobRegistry) {
this(jobRegistry, null);
}
/**
* Creates a job loader with the job and step registries provided.
*
*
* @param jobRegistry a {@link JobRegistry}
* @param stepRegistry a {@link StepRegistry}
* @param stepRegistry a {@link StepRegistry}
*/
public DefaultJobLoader(JobRegistry jobRegistry, StepRegistry stepRegistry) {
this.jobRegistry = jobRegistry;
this.stepRegistry = stepRegistry;
this.stepRegistry = stepRegistry;
}
/**
@@ -92,14 +92,14 @@ public class DefaultJobLoader implements JobLoader, InitializingBean {
this.jobRegistry = jobRegistry;
}
/**
* The {@link StepRegistry} to use for the steps of created jobs.
*
* @param stepRegistry the step registry
*/
public void setStepRegistry(StepRegistry stepRegistry) {
this.stepRegistry = stepRegistry;
}
/**
* The {@link StepRegistry} to use for the steps of created jobs.
*
* @param stepRegistry the step registry
*/
public void setStepRegistry(StepRegistry stepRegistry) {
this.stepRegistry = stepRegistry;
}
/**
* Unregister all the jobs and close all the contexts created by this
@@ -107,7 +107,7 @@ public class DefaultJobLoader implements JobLoader, InitializingBean {
*
* @see JobLoader#clear()
*/
@Override
@Override
public void clear() {
for (ConfigurableApplicationContext context : contexts.values()) {
if (context.isActive()) {
@@ -115,12 +115,12 @@ public class DefaultJobLoader implements JobLoader, InitializingBean {
}
}
for (String jobName : jobRegistry.getJobNames()) {
doUnregister(jobName);
doUnregister(jobName);
}
contexts.clear();
}
@Override
@Override
public Collection<Job> reload(ApplicationContextFactory factory) {
// If the same factory is loaded twice the context can be closed
@@ -142,7 +142,7 @@ public class DefaultJobLoader implements JobLoader, InitializingBean {
}
}
@Override
@Override
public Collection<Job> load(ApplicationContextFactory factory) throws DuplicateJobException {
return doLoad(factory, false);
}
@@ -205,74 +205,74 @@ public class DefaultJobLoader implements JobLoader, InitializingBean {
}
/**
* Returns all the {@link Step} instances defined by the specified {@link StepLocator}.
* <p/>
* The specified <tt>jobApplicationContext</tt> is used to collect additional steps that
* are not exposed by the step locator
*
* @param stepLocator the given step locator
* @param jobApplicationContext the application context of the job
* @return all the {@link Step} defined by the given step locator and context
* @see StepLocator
*/
private Collection<Step> getSteps(final StepLocator stepLocator, final ApplicationContext jobApplicationContext) {
final Collection<String> stepNames = stepLocator.getStepNames();
final Collection<Step> result = new ArrayList<Step>();
for (String stepName : stepNames) {
result.add(stepLocator.getStep(stepName));
}
/**
* Returns all the {@link Step} instances defined by the specified {@link StepLocator}.
* <p/>
* The specified <tt>jobApplicationContext</tt> is used to collect additional steps that
* are not exposed by the step locator
*
* @param stepLocator the given step locator
* @param jobApplicationContext the application context of the job
* @return all the {@link Step} defined by the given step locator and context
* @see StepLocator
*/
private Collection<Step> getSteps(final StepLocator stepLocator, final ApplicationContext jobApplicationContext) {
final Collection<String> stepNames = stepLocator.getStepNames();
final Collection<Step> result = new ArrayList<Step>();
for (String stepName : stepNames) {
result.add(stepLocator.getStep(stepName));
}
// Because some steps are referenced by name, we need to look in the context to see if there
// are more Step instances defined. Right now they are registered as being available in the
// context of the job but we have no idea if they are linked to that Job or not.
@SuppressWarnings("unchecked")
final Map<String, Step> allSteps = jobApplicationContext.getBeansOfType(Step.class);
for (Map.Entry<String, Step> entry : allSteps.entrySet()) {
if (!stepNames.contains(entry.getKey())) {
result.add(entry.getValue());
}
}
return result;
}
// Because some steps are referenced by name, we need to look in the context to see if there
// are more Step instances defined. Right now they are registered as being available in the
// context of the job but we have no idea if they are linked to that Job or not.
@SuppressWarnings("unchecked")
final Map<String, Step> allSteps = jobApplicationContext.getBeansOfType(Step.class);
for (Map.Entry<String, Step> entry : allSteps.entrySet()) {
if (!stepNames.contains(entry.getKey())) {
result.add(entry.getValue());
}
}
return result;
}
/**
* Registers the specified {@link Job} defined in the specified {@link ConfigurableApplicationContext}.
* <p/>
* Makes sure to update the {@link StepRegistry} if it is available.
*
* @param context the context in which the job is defined
* @param job the job to register
* @throws DuplicateJobException if that job is already registered
*/
private void doRegister(ConfigurableApplicationContext context, Job job) throws DuplicateJobException {
final JobFactory jobFactory = new ReferenceJobFactory(job);
jobRegistry.register(jobFactory);
/**
* Registers the specified {@link Job} defined in the specified {@link ConfigurableApplicationContext}.
* <p/>
* Makes sure to update the {@link StepRegistry} if it is available.
*
* @param context the context in which the job is defined
* @param job the job to register
* @throws DuplicateJobException if that job is already registered
*/
private void doRegister(ConfigurableApplicationContext context, Job job) throws DuplicateJobException {
final JobFactory jobFactory = new ReferenceJobFactory(job);
jobRegistry.register(jobFactory);
if (stepRegistry != null) {
if (!(job instanceof StepLocator)) {
throw new UnsupportedOperationException("Cannot locate steps from a Job that is not a StepLocator: job="
+ job.getName() + " does not implement StepLocator");
}
stepRegistry.register(job.getName(), getSteps((StepLocator) job, context));
}
}
if (stepRegistry != null) {
if (!(job instanceof StepLocator)) {
throw new UnsupportedOperationException("Cannot locate steps from a Job that is not a StepLocator: job="
+ job.getName() + " does not implement StepLocator");
}
stepRegistry.register(job.getName(), getSteps((StepLocator) job, context));
}
}
/**
* Unregisters the job identified by the specified <tt>jobName</tt>.
*
* @param jobName the name of the job to unregister
*/
private void doUnregister(String jobName) {
jobRegistry.unregister(jobName);
if (stepRegistry != null) {
stepRegistry.unregisterStepsFromJob(jobName);
}
/**
* Unregisters the job identified by the specified <tt>jobName</tt>.
*
* @param jobName the name of the job to unregister
*/
private void doUnregister(String jobName) {
jobRegistry.unregister(jobName);
if (stepRegistry != null) {
stepRegistry.unregisterStepsFromJob(jobName);
}
}
}
@Override
public void afterPropertiesSet() {
Assert.notNull(jobRegistry, "Job registry could not be null.");
}
@Override
public void afterPropertiesSet() {
Assert.notNull(jobRegistry, "Job registry could not be null.");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,10 +29,10 @@ import org.springframework.util.ClassUtils;
* identical functionality but named <code>financeDepartment.overnightJob</code>
* . The use of a "." separator for elements is deliberate, since it is a "safe"
* character in a <a href="http://www.w3.org/Addressing/URL">URL</a>.
*
*
*
*
* @author Dave Syer
*
*
*/
public class GroupAwareJob implements Job {
@@ -48,7 +48,7 @@ public class GroupAwareJob implements Job {
/**
* Create a new {@link Job} with the delegate and no group name.
*
*
* @param delegate a delegate for the features of a regular Job
*/
public GroupAwareJob(Job delegate) {
@@ -57,7 +57,7 @@ public class GroupAwareJob implements Job {
/**
* Create a new {@link Job} with the given group name and delegate.
*
*
* @param groupName the group name to prepend
* @param delegate a delegate for the features of a regular Job
*/
@@ -67,40 +67,40 @@ public class GroupAwareJob implements Job {
this.delegate = delegate;
}
@Override
@Override
public void execute(JobExecution execution) {
delegate.execute(execution);
}
/**
* Concatenates the group name and the delegate job name (joining with a
* ".").
*
*
* @see org.springframework.batch.core.Job#getName()
*/
@Override
@Override
public String getName() {
return groupName==null ? delegate.getName() : groupName + SEPARATOR + delegate.getName();
}
@Override
@Override
public boolean isRestartable() {
return delegate.isRestartable();
}
@Override
@Override
public JobParametersIncrementer getJobParametersIncrementer() {
return delegate.getJobParametersIncrementer();
}
@Override
@Override
public JobParametersValidator getJobParametersValidator() {
return delegate.getJobParametersValidator();
}
/*
* (non-Javadoc)
*
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
@@ -113,14 +113,14 @@ public class GroupAwareJob implements Job {
/*
* (non-Javadoc)
*
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return delegate.hashCode();
}
@Override
public String toString() {
return ClassUtils.getShortName(delegate.getClass()) + ": [name=" + getName() + "]";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,12 +40,12 @@ import org.springframework.util.Assert;
* {@link JobRegistry}. Include a bean of this type along with your job
* configuration, and use the same {@link JobRegistry} as a {@link JobLocator}
* when you need to locate a {@link Job} to launch.
*
*
* @author Dave Syer
*
*
*/
public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFactoryAware, InitializingBean,
DisposableBean {
DisposableBean {
private static Log logger = LogFactory.getLog(JobRegistryBeanPostProcessor.class);
@@ -65,7 +65,7 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFact
* contributing to the same {@link JobRegistry}: child contexts can then
* define an instance with a unique group name to avoid clashes between job
* names.
*
*
* @param groupName the groupName to set
*/
public void setGroupName(String groupName) {
@@ -74,7 +74,7 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFact
/**
* Injection setter for {@link JobRegistry}.
*
*
* @param jobRegistry the jobConfigurationRegistry to set
*/
public void setJobRegistry(JobRegistry jobRegistry) {
@@ -83,12 +83,12 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFact
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org
* .springframework.beans.factory.BeanFactory)
*/
@Override
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
if (beanFactory instanceof DefaultListableBeanFactory) {
this.beanFactory = (DefaultListableBeanFactory) beanFactory;
@@ -97,10 +97,10 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFact
/**
* Make sure the registry is set before use.
*
*
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
@Override
@Override
public void afterPropertiesSet() throws Exception {
Assert.notNull(jobRegistry, "JobRegistry must not be null");
}
@@ -110,7 +110,7 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFact
* post processor.
* @see org.springframework.beans.factory.DisposableBean#destroy()
*/
@Override
@Override
public void destroy() throws Exception {
for (String name : jobNames) {
logger.debug("Unregistering job: " + name);
@@ -122,11 +122,11 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFact
/**
* If the bean is an instance of {@link Job} then register it.
* @throws FatalBeanException if there is a {@link DuplicateJobException}.
*
*
* @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object,
* java.lang.String)
*/
@Override
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof Job) {
Job job = (Job) bean;
@@ -154,7 +154,7 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFact
* Determine a group name for the job to be registered. Default
* implementation just returns the {@link #setGroupName(String) groupName}
* configured. Provides an extension point for specialised subclasses.
*
*
* @param beanDefinition the bean definition for the job
* @param job the job
* @return a group name for the job (or null if not needed)
@@ -165,11 +165,11 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFact
/**
* Do nothing.
*
*
* @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object,
* java.lang.String)
*/
@Override
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
return bean;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,11 @@
*/
package org.springframework.batch.core.configuration.support;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.configuration.DuplicateJobException;
import org.springframework.batch.core.configuration.JobFactory;
@@ -22,11 +27,6 @@ import org.springframework.batch.core.configuration.JobRegistry;
import org.springframework.batch.core.launch.NoSuchJobException;
import org.springframework.util.Assert;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* Simple, thread-safe, map-based implementation of {@link JobRegistry}.
*
@@ -35,46 +35,46 @@ import java.util.concurrent.ConcurrentMap;
*/
public class MapJobRegistry implements JobRegistry {
/**
* The map holding the registered job factories.
*/
// The "final" ensures that it is visible and initialized when the constructor resolves.
private final ConcurrentMap<String, JobFactory> map = new ConcurrentHashMap<String, JobFactory>();
/**
* The map holding the registered job factories.
*/
// The "final" ensures that it is visible and initialized when the constructor resolves.
private final ConcurrentMap<String, JobFactory> map = new ConcurrentHashMap<String, JobFactory>();
@Override
public void register(JobFactory jobFactory) throws DuplicateJobException {
Assert.notNull(jobFactory);
String name = jobFactory.getJobName();
Assert.notNull(name, "Job configuration must have a name.");
JobFactory previousValue = map.putIfAbsent(name, jobFactory);
if (previousValue != null) {
throw new DuplicateJobException("A job configuration with this name [" + name
+ "] was already registered");
}
}
@Override
public void register(JobFactory jobFactory) throws DuplicateJobException {
Assert.notNull(jobFactory);
String name = jobFactory.getJobName();
Assert.notNull(name, "Job configuration must have a name.");
JobFactory previousValue = map.putIfAbsent(name, jobFactory);
if (previousValue != null) {
throw new DuplicateJobException("A job configuration with this name [" + name
+ "] was already registered");
}
}
@Override
public void unregister(String name) {
Assert.notNull(name, "Job configuration must have a name.");
map.remove(name);
}
@Override
public void unregister(String name) {
Assert.notNull(name, "Job configuration must have a name.");
map.remove(name);
}
@Override
public Job getJob(String name) throws NoSuchJobException {
JobFactory factory = map.get(name);
if (factory == null) {
throw new NoSuchJobException("No job configuration with the name [" + name + "] was registered");
} else {
return factory.createJob();
}
}
@Override
public Job getJob(String name) throws NoSuchJobException {
JobFactory factory = map.get(name);
if (factory == null) {
throw new NoSuchJobException("No job configuration with the name [" + name + "] was registered");
} else {
return factory.createJob();
}
}
/**
* Provides an unmodifiable view of the job names.
*/
@Override
public Set<String> getJobNames() {
return Collections.unmodifiableSet(map.keySet());
}
/**
* Provides an unmodifiable view of the job names.
*/
@Override
public Set<String> getJobNames() {
return Collections.unmodifiableSet(map.keySet());
}
}

View File

@@ -1,5 +1,26 @@
/*
* Copyright 2012-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.configuration.support;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.DuplicateJobException;
import org.springframework.batch.core.configuration.StepRegistry;
@@ -7,12 +28,6 @@ import org.springframework.batch.core.launch.NoSuchJobException;
import org.springframework.batch.core.step.NoSuchStepException;
import org.springframework.util.Assert;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* Simple map-based implementation of {@link StepRegistry}. Access to the map is
* synchronized, guarded by an internal lock.
@@ -22,46 +37,46 @@ import java.util.concurrent.ConcurrentMap;
*/
public class MapStepRegistry implements StepRegistry {
private final ConcurrentMap<String, Map<String, Step>> map = new ConcurrentHashMap<String, Map<String, Step>>();
private final ConcurrentMap<String, Map<String, Step>> map = new ConcurrentHashMap<String, Map<String, Step>>();
@Override
public void register(String jobName, Collection<Step> steps) throws DuplicateJobException {
Assert.notNull(jobName, "The job name cannot be null.");
Assert.notNull(steps, "The job steps cannot be null.");
@Override
public void register(String jobName, Collection<Step> steps) throws DuplicateJobException {
Assert.notNull(jobName, "The job name cannot be null.");
Assert.notNull(steps, "The job steps cannot be null.");
final Map<String, Step> jobSteps = new HashMap<String, Step>();
for (Step step : steps) {
jobSteps.put(step.getName(), step);
}
final Object previousValue = map.putIfAbsent(jobName, jobSteps);
if (previousValue != null) {
throw new DuplicateJobException("A job configuration with this name [" + jobName
+ "] was already registered");
}
}
final Map<String, Step> jobSteps = new HashMap<String, Step>();
for (Step step : steps) {
jobSteps.put(step.getName(), step);
}
final Object previousValue = map.putIfAbsent(jobName, jobSteps);
if (previousValue != null) {
throw new DuplicateJobException("A job configuration with this name [" + jobName
+ "] was already registered");
}
}
@Override
public void unregisterStepsFromJob(String jobName) {
Assert.notNull(jobName, "Job configuration must have a name.");
map.remove(jobName);
}
@Override
public void unregisterStepsFromJob(String jobName) {
Assert.notNull(jobName, "Job configuration must have a name.");
map.remove(jobName);
}
@Override
public Step getStep(String jobName, String stepName) throws NoSuchJobException {
Assert.notNull(jobName, "The job name cannot be null.");
Assert.notNull(stepName, "The step name cannot be null.");
if (!map.containsKey(jobName)) {
throw new NoSuchJobException("No job configuration with the name [" + jobName + "] was registered");
} else {
final Map<String, Step> jobSteps = map.get(jobName);
if (jobSteps.containsKey(stepName)) {
return jobSteps.get(stepName);
} else {
throw new NoSuchStepException("The step called [" + stepName + "] does not exist in the job [" +
jobName + "]");
}
}
}
@Override
public Step getStep(String jobName, String stepName) throws NoSuchJobException {
Assert.notNull(jobName, "The job name cannot be null.");
Assert.notNull(stepName, "The step name cannot be null.");
if (!map.containsKey(jobName)) {
throw new NoSuchJobException("No job configuration with the name [" + jobName + "] was registered");
} else {
final Map<String, Step> jobSteps = map.get(jobName);
if (jobSteps.containsKey(stepName)) {
return jobSteps.get(stepName);
} else {
throw new NoSuchStepException("The step called [" + stepName + "] does not exist in the job [" +
jobName + "]");
}
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,12 +27,12 @@ import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
/**
* {@link ApplicationContextFactory} that can be used to load a context from an
* XML location in a bundle.
*
*
* @author Dave Syer
*
*
*/
public class OsgiBundleXmlApplicationContextFactory implements BundleContextAware, ApplicationContextFactory,
ApplicationContextAware {
ApplicationContextAware {
private BundleContext bundleContext;
@@ -58,10 +58,10 @@ public class OsgiBundleXmlApplicationContextFactory implements BundleContextAwar
/**
* Setter for the parent application context.
*
*
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
*/
@Override
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
parent = applicationContext;
}
@@ -69,10 +69,10 @@ public class OsgiBundleXmlApplicationContextFactory implements BundleContextAwar
/**
* Stash the {@link BundleContext} for creating a job application context
* later.
*
*
* @see org.springframework.osgi.context.BundleContextAware#setBundleContext(org.osgi.framework.BundleContext)
*/
@Override
@Override
public void setBundleContext(BundleContext context) {
this.bundleContext = context;
}
@@ -81,10 +81,10 @@ public class OsgiBundleXmlApplicationContextFactory implements BundleContextAwar
* Create an application context from the provided path, using the current
* OSGi {@link BundleContext} and the enclosing Spring
* {@link ApplicationContext} as a parent context.
*
*
* @see ApplicationContextFactory#createApplicationContext()
*/
@Override
@Override
public ConfigurableApplicationContext createApplicationContext() {
OsgiBundleXmlApplicationContext context = new OsgiBundleXmlApplicationContext(new String[] { path }, parent);
String displayName = bundleContext.getBundle().getSymbolicName() + ":" + this.displayName;
@@ -108,10 +108,12 @@ public class OsgiBundleXmlApplicationContextFactory implements BundleContextAwar
@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;
if (obj == null)
}
if (obj == null) {
return false;
}
return toString().equals(obj.toString());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,9 +21,9 @@ import org.springframework.batch.core.configuration.JobFactory;
/**
* A {@link JobFactory} that just keeps a reference to a {@link Job}. It never
* modifies its {@link Job}.
*
*
* @author Dave Syer
*
*
*/
public class ReferenceJobFactory implements JobFactory {
@@ -38,20 +38,20 @@ public class ReferenceJobFactory implements JobFactory {
/**
* Just return the instance passed in on initialization.
*
*
* @see JobFactory#createJob()
*/
@Override
@Override
public final Job createJob() {
return job;
}
/**
* Just return the name of instance passed in on initialization.
*
*
* @see JobFactory#getJobName()
*/
@Override
@Override
public String getJobName() {
return job.getName();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,17 +19,17 @@ import org.springframework.beans.factory.xml.NamespaceHandler;
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
/**
*
*
*
* @author Dave Syer
*
*
*/
public class CoreNamespaceHandler extends NamespaceHandlerSupport {
/**
* @see NamespaceHandler#init()
*/
@Override
@Override
public void init() {
this.registerBeanDefinitionParser("job", new JobParser());
this.registerBeanDefinitionParser("flow", new TopLevelFlowParser());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2009 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ import org.springframework.transaction.PlatformTransactionManager;
/**
* Post-process jobs and steps defined using the batch namespace to inject
* dependencies.
*
*
* @author Dan Garrette
* @since 2.0.1
*/
@@ -49,7 +49,7 @@ public class CoreNamespacePostProcessor implements BeanPostProcessor, BeanFactor
private ApplicationContext applicationContext;
@Override
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
for (String beanName : beanFactory.getBeanDefinitionNames()) {
injectJobRepositoryIntoSteps(beanName, beanFactory);
@@ -60,7 +60,7 @@ public class CoreNamespacePostProcessor implements BeanPostProcessor, BeanFactor
/**
* Automatically inject job-repository from a job into its steps. Only
* inject if the step is an AbstractStep or StepParserStepFactoryBean.
*
*
* @param beanName
* @param beanFactory
*/
@@ -89,7 +89,7 @@ public class CoreNamespacePostProcessor implements BeanPostProcessor, BeanFactor
* If any of the beans in the parent hierarchy is a &lt;step/&gt; with a
* &lt;tasklet/&gt;, then the bean class must be
* {@link StepParserStepFactoryBean}.
*
*
* @param beanName
* @param beanFactory
*/
@@ -102,7 +102,7 @@ public class CoreNamespacePostProcessor implements BeanPostProcessor, BeanFactor
}
}
@Override
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
return injectDefaults(bean);
}
@@ -115,7 +115,7 @@ public class CoreNamespacePostProcessor implements BeanPostProcessor, BeanFactor
* <li>Inject "transactionManager" into any
* {@link StepParserStepFactoryBean} without a transactionManager.
* </ul>
*
*
* @param bean
* @return
*/
@@ -142,12 +142,12 @@ public class CoreNamespacePostProcessor implements BeanPostProcessor, BeanFactor
return bean;
}
@Override
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
@Override
@Override
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,19 +24,19 @@ import org.springframework.batch.core.listener.ListenerMetaData;
/**
* Parser for a step listener element. Builds a {@link JobListenerFactoryBean}
* using attributes from the configuration.
*
*
* @author Dan Garrette
* @since 2.0
* @see AbstractListenerParser
*/
public class JobExecutionListenerParser extends AbstractListenerParser {
@Override
@Override
protected Class<? extends AbstractListenerFactoryBean> getBeanClass() {
return JobListenerFactoryBean.class;
}
@Override
@Override
protected ListenerMetaData[] getMetaDataValues() {
return JobListenerMetaData.values();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2009 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ import org.springframework.util.StringUtils;
* This {@link FactoryBean} is used by the batch namespace parser to create
* {@link FlowJob} objects. It stores all of the properties that are
* configurable on the &lt;job/&gt;.
*
*
* @author Dan Garrette
* @author Dave Syer
* @since 2.0.1
@@ -55,7 +55,7 @@ class JobParserJobFactoryBean implements SmartFactoryBean {
this.name = name;
}
@Override
@Override
public final Object getObject() throws Exception {
Assert.isTrue(StringUtils.hasText(name), "The job must have an id.");
FlowJob flowJob = new FlowJob(name);
@@ -95,7 +95,7 @@ class JobParserJobFactoryBean implements SmartFactoryBean {
public void setJobRepository(JobRepository jobRepository) {
this.jobRepository = jobRepository;
}
public void setJobParametersValidator(JobParametersValidator jobParametersValidator) {
this.jobParametersValidator = jobParametersValidator;
}
@@ -116,22 +116,22 @@ class JobParserJobFactoryBean implements SmartFactoryBean {
this.flow = flow;
}
@Override
@Override
public Class<FlowJob> getObjectType() {
return FlowJob.class;
}
@Override
@Override
public boolean isSingleton() {
return true;
}
@Override
@Override
public boolean isEagerInit() {
return true;
}
@Override
@Override
public boolean isPrototype() {
return false;
}

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2012-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.configuration.xml;
import java.util.ArrayList;
@@ -23,10 +38,11 @@ import org.springframework.util.Assert;
* replaces the states in the input with proxies that have a unique name formed
* from the flow name and the original state name (unless the name is already in
* that form, in which case it is not modified).
*
*
* @author Dave Syer
*
*
*/
@SuppressWarnings("rawtypes")
public class SimpleFlowFactoryBean implements FactoryBean, InitializingBean {
private String name;
@@ -37,7 +53,7 @@ public class SimpleFlowFactoryBean implements FactoryBean, InitializingBean {
/**
* The name of the flow that is created by this factory.
*
*
* @param name the value of the name
*/
public void setName(String name) {
@@ -47,10 +63,10 @@ public class SimpleFlowFactoryBean implements FactoryBean, InitializingBean {
/**
* The raw state transitions for the flow. They will be transformed into
* proxies that have the same behaviour but unique names prefixed with the
* proxies that have the same behavior but unique names prefixed with the
* flow name.
*
* @param name the value of the name
*
* @param stateTransitions the list of transitions
*/
public void setStateTransitions(List<StateTransition> stateTransitions) {
this.stateTransitions = stateTransitions;
@@ -58,15 +74,15 @@ public class SimpleFlowFactoryBean implements FactoryBean, InitializingBean {
/**
* Check mandatory properties (name).
*
*
* @throws Exception
*/
@Override
@Override
public void afterPropertiesSet() throws Exception {
Assert.hasText(name, "The flow must have a name");
}
@Override
@Override
public Object getObject() throws Exception {
SimpleFlow flow = new SimpleFlow(name);
@@ -95,7 +111,7 @@ public class SimpleFlowFactoryBean implements FactoryBean, InitializingBean {
* Convenience method to get a state that proxies the input but with a
* different name, appropriate to this flow. If the state is a StepState
* then the step name is also changed.
*
*
* @param state
* @return
*/
@@ -111,22 +127,22 @@ public class SimpleFlowFactoryBean implements FactoryBean, InitializingBean {
return new DelegateState(stateName, state);
}
@Override
@Override
public Class<?> getObjectType() {
return SimpleFlow.class;
}
@Override
@Override
public boolean isSingleton() {
return true;
}
/**
* A State that proxies a delegate and changes its name but leaves its
* behaviour unchanged.
*
* behavior unchanged.
*
* @author Dave Syer
*
*
*/
private static class DelegateState extends AbstractState implements FlowHolder {
private final State state;
@@ -136,7 +152,7 @@ public class SimpleFlowFactoryBean implements FactoryBean, InitializingBean {
this.state = state;
}
@Override
@Override
public boolean isEndState() {
return state.isEndState();
}
@@ -146,11 +162,11 @@ public class SimpleFlowFactoryBean implements FactoryBean, InitializingBean {
return state.handle(executor);
}
@Override
@Override
public Collection<Flow> getFlows() {
return (state instanceof FlowHolder) ? ((FlowHolder)state).getFlows() : Collections.<Flow>emptyList();
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2009 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,13 +32,13 @@ import org.w3c.dom.Element;
/**
* Parser for a step listener element. Builds a {@link StepListenerFactoryBean}
* using attributes from the configuration.
*
*
* @author Dan Garrette
* @since 2.0
* @see AbstractListenerParser
*/
public class StepListenerParser extends AbstractListenerParser {
private static final String LISTENERS_ELE = "listeners";
private static final String MERGE_ATTR = "merge";
@@ -53,17 +53,17 @@ public class StepListenerParser extends AbstractListenerParser {
this.listenerMetaData = listenerMetaData;
}
@Override
@Override
protected Class<? extends AbstractListenerFactoryBean> getBeanClass() {
return StepListenerFactoryBean.class;
}
@Override
@Override
protected ListenerMetaData[] getMetaDataValues() {
return listenerMetaData;
}
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "rawtypes"})
public void handleListenersElement(Element stepElement, BeanDefinition beanDefinition,
ParserContext parserContext) {
MutablePropertyValues propertyValues = beanDefinition.getPropertyValues();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -80,7 +80,7 @@ import org.springframework.util.Assert;
* This {@link FactoryBean} is used by the batch namespace parser to create {@link Step} objects. Stores all of the
* properties that are configurable on the &lt;step/&gt; (and its inner &lt;tasklet/&gt;). Based on which properties are
* configured, the {@link #getObject()} method will delegate to the appropriate class for generating the {@link Step}.
*
*
* @author Dan Garrette
* @author Josh Long
* @see SimpleStepFactoryBean
@@ -88,6 +88,7 @@ import org.springframework.util.Assert;
* @see TaskletStep
* @since 2.0
*/
@SuppressWarnings("rawtypes")
class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
//
@@ -217,10 +218,10 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* Create a {@link Step} from the configuration provided.
*
*
* @see FactoryBean#getObject()
*/
@Override
@Override
public final Object getObject() throws Exception {
if (hasChunkElement) {
Assert.isNull(tasklet, "Step [" + name
@@ -382,7 +383,6 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
@SuppressWarnings("unchecked")
private Step createSimpleStep() {
@SuppressWarnings("rawtypes")
SimpleStepBuilder builder = new SimpleStepBuilder(new StepBuilder(name));
if (commitInterval != null) {
builder.chunk(commitInterval);
@@ -402,6 +402,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
return builder.build();
}
@SuppressWarnings("serial")
private void enhanceTaskletStepBuilder(AbstractTaskletStepBuilder<?> builder) {
enhanceCommonStep(builder);
@@ -474,7 +475,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* Check if a field is present then a second is also. If the twoWayDependency flag is set then the opposite must
* also be true: if the second value is present, the first must also be.
*
*
* @param dependentName the name of the first field
* @param dependentValue the value of the first field
* @param name the name of the other field (which should be absent if the first is present)
@@ -496,7 +497,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* Is the object non-null (or if an Integer, non-zero)?
*
*
* @param o an object
* @return true if the object has a value
*/
@@ -526,12 +527,12 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
return n != null && n > 0;
}
@Override
@Override
public Class<TaskletStep> getObjectType() {
return TaskletStep.class;
}
@Override
@Override
public boolean isSingleton() {
return true;
}
@@ -542,10 +543,10 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* Set the bean name property, which will become the name of the {@link Step} when it is created.
*
*
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
*/
@Override
@Override
public void setBeanName(String name) {
if (this.name == null) {
this.name = name;
@@ -632,7 +633,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* Public setter for the flag to indicate that the step should be replayed on a restart, even if successful the
* first time.
*
*
* @param allowStartIfComplete the shouldAllowStartIfComplete to set
*/
public void setAllowStartIfComplete(boolean allowStartIfComplete) {
@@ -649,7 +650,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* Public setter for {@link JobRepository}.
*
*
* @param jobRepository
*/
public void setJobRepository(JobRepository jobRepository) {
@@ -658,7 +659,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* The number of times that the step should be allowed to start
*
*
* @param startLimit
*/
public void setStartLimit(int startLimit) {
@@ -667,7 +668,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* A preconfigured {@link Tasklet} to use.
*
*
* @param tasklet
*/
public void setTasklet(Tasklet tasklet) {
@@ -695,7 +696,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* The listeners to inject into the {@link Step}. Any instance of {@link StepListener} can be used, and will then
* receive callbacks at the appropriate stage in the step.
*
*
* @param listeners an array of listeners
*/
public void setListeners(StepListener[] listeners) {
@@ -734,7 +735,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* Exception classes that may not cause a rollback if encountered in the right place.
*
*
* @param noRollbackExceptionClasses the noRollbackExceptionClasses to set
*/
public void setNoRollbackExceptionClasses(Collection<Class<? extends Throwable>> noRollbackExceptionClasses) {
@@ -768,7 +769,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* A backoff policy to be applied to retry process.
*
*
* @param backOffPolicy the {@link BackOffPolicy} to set
*/
public void setBackOffPolicy(BackOffPolicy backOffPolicy) {
@@ -778,7 +779,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* A retry policy to apply when exceptions occur. If this is specified then the retry limit and retryable exceptions
* will be ignored.
*
*
* @param retryPolicy the {@link RetryPolicy} to set
*/
public void setRetryPolicy(RetryPolicy retryPolicy) {
@@ -795,7 +796,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* A key generator that can be used to compare items with previously recorded items in a retry. Only used if the
* reader is a transactional queue.
*
*
* @param keyGenerator the {@link KeyGenerator} to set
*/
public void setKeyGenerator(KeyGenerator keyGenerator) {
@@ -814,7 +815,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
* The default value should be high enough and more for most purposes. To breach the limit in a single-threaded step
* typically you have to have this many failures in a single transaction. Defaults to the value in the
* {@link MapRetryContextCache}.<br/>
*
*
* @param cacheCapacity the cache capacity to set (greater than 0 else ignored)
*/
public void setCacheCapacity(int cacheCapacity) {
@@ -825,7 +826,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
* Public setter for the {@link CompletionPolicy} applying to the chunk level. A transaction will be committed when
* this policy decides to complete. Defaults to a {@link SimpleCompletionPolicy} with chunk size equal to the
* commitInterval property.
*
*
* @param chunkCompletionPolicy the chunkCompletionPolicy to set
*/
public void setChunkCompletionPolicy(CompletionPolicy chunkCompletionPolicy) {
@@ -834,7 +835,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* Set the commit interval. Either set this or the chunkCompletionPolicy but not both.
*
*
* @param commitInterval 1 by default
*/
public void setCommitInterval(int commitInterval) {
@@ -844,7 +845,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* Flag to signal that the reader is transactional (usually a JMS consumer) so that items are re-presented after a
* rollback. The default is false and readers are assumed to be forward-only.
*
*
* @param isReaderTransactionalQueue the value of the flag
*/
public void setIsReaderTransactionalQueue(boolean isReaderTransactionalQueue) {
@@ -854,7 +855,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* Flag to signal that the processor is transactional, in which case it should be called for every item in every
* transaction. If false then we can cache the processor results between transactions in the case of a rollback.
*
*
* @param processorTransactional the value to set
*/
public void setProcessorTransactional(Boolean processorTransactional) {
@@ -864,7 +865,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* Public setter for the retry limit. Each item can be retried up to this limit. Note this limit includes the
* initial attempt to process the item, therefore <code>retryLimit == 1</code> by default.
*
*
* @param retryLimit the retry limit to set, must be greater or equal to 1.
*/
public void setRetryLimit(int retryLimit) {
@@ -875,7 +876,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
* Public setter for a limit that determines skip policy. If this value is positive then an exception in chunk
* processing will cause the item to be skipped and no exception propagated until the limit is reached. If it is
* zero then all exceptions will be propagated from the chunk and cause the step to abort.
*
*
* @param skipLimit the value to set. Default is 0 (never skip).
*/
public void setSkipLimit(int skipLimit) {
@@ -884,7 +885,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* Public setter for a skip policy. If this value is set then the skip limit and skippable exceptions are ignored.
*
*
* @param skipPolicy the {@link SkipPolicy} to set
*/
public void setSkipPolicy(SkipPolicy skipPolicy) {
@@ -894,7 +895,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* Public setter for the {@link TaskExecutor}. If this is set, then it will be used to execute the chunk processing
* inside the {@link Step}.
*
*
* @param taskExecutor the taskExecutor to set
*/
public void setTaskExecutor(TaskExecutor taskExecutor) {
@@ -904,7 +905,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* Public setter for the throttle limit. This limits the number of tasks queued for concurrent processing to prevent
* thread pools from being overwhelmed. Defaults to {@link TaskExecutorRepeatTemplate#DEFAULT_THROTTLE_LIMIT}.
*
*
* @param throttleLimit the throttle limit to set.
*/
public void setThrottleLimit(Integer throttleLimit) {
@@ -938,7 +939,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* Public setter for the {@link RetryListener}s.
*
*
* @param retryListeners the {@link RetryListener}s to set
*/
public void setRetryListeners(RetryListener... retryListeners) {
@@ -948,7 +949,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* Public setter for exception classes that when raised won't crash the job but will result in transaction rollback
* and the item which handling caused the exception will be skipped.
*
*
* @param exceptionClasses
*/
public void setSkippableExceptionClasses(Map<Class<? extends Throwable>, Boolean> exceptionClasses) {
@@ -957,7 +958,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* Public setter for exception classes that will retry the item when raised.
*
*
* @param retryableExceptionClasses the retryableExceptionClasses to set
*/
public void setRetryableExceptionClasses(Map<Class<? extends Throwable>, Boolean> retryableExceptionClasses) {
@@ -967,7 +968,7 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
/**
* The streams to inject into the {@link Step}. Any instance of {@link ItemStream} can be used, and will then
* receive callbacks at the appropriate stage in the step.
*
*
* @param streams an array of listeners
*/
public void setStreams(ItemStream[] streams) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2008 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,23 +38,23 @@ import org.springframework.util.StringUtils;
* convention for property keys. Key names ending with "(&lt;type&gt;)" where
* type is one of string, date, long are converted to the corresponding type.
* The default type is string. E.g.
*
*
* <pre>
* schedule.date(date)=2007/12/11
* department.id(long)=2345
* </pre>
*
*
* The literal values are converted to the correct type using the default Spring
* strategies, augmented if necessary by the custom editors provided.
*
*
* <br/>
*
*
* If you need to be able to parse and format local-specific dates and numbers,
* you can inject formatters ({@link #setDateFormat(DateFormat)} and
* {@link #setNumberFormat(NumberFormat)}).
*
*
* @author Dave Syer
*
*
*/
public class DefaultJobParametersConverter implements JobParametersConverter {
@@ -77,13 +77,13 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
/**
* Check for suffix on keys and use those to decide how to convert the
* value.
*
*
* @throws IllegalArgumentException if a number or date is passed in that
* cannot be parsed, or cast to the correct type.
*
*
* @see org.springframework.batch.core.converter.JobParametersConverter#getJobParameters(java.util.Properties)
*/
@Override
@Override
public JobParameters getJobParameters(Properties props) {
if (props == null || props.isEmpty()) {
@@ -104,7 +104,7 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
catch (ParseException ex) {
String suffix = (dateFormat instanceof SimpleDateFormat) ? ", use "
+ ((SimpleDateFormat) dateFormat).toPattern() : "";
throw new IllegalArgumentException("Date format is invalid: [" + value + "]" + suffix);
throw new IllegalArgumentException("Date format is invalid: [" + value + "]" + suffix);
}
propertiesBuilder.addDate(StringUtils.replace(key, DATE_TYPE, ""), date);
}
@@ -144,17 +144,17 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
catch (ParseException ex) {
String suffix = (numberFormat instanceof DecimalFormat) ? ", use "
+ ((DecimalFormat) numberFormat).toPattern() : "";
throw new IllegalArgumentException("Number format is invalid: [" + value + "], use " + suffix);
throw new IllegalArgumentException("Number format is invalid: [" + value + "], use " + suffix);
}
}
/**
* Use the same suffixes to create properties (omitting the string suffix
* because it is the default).
*
*
* @see org.springframework.batch.core.converter.JobParametersConverter#getProperties(org.springframework.batch.core.JobParameters)
*/
@Override
@Override
public Properties getProperties(JobParameters params) {
if (params == null || params.isEmpty()) {
@@ -199,7 +199,7 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
/**
* Public setter for injecting a date format.
*
*
* @param dateFormat a {@link DateFormat}, defaults to "yyyy/MM/dd"
*/
public void setDateFormat(DateFormat dateFormat) {
@@ -209,7 +209,7 @@ public class DefaultJobParametersConverter implements JobParametersConverter {
/**
* Public setter for the {@link NumberFormat}. Used to parse longs and
* doubles, so must not contain decimal place (e.g. use "#" or "#,###").
*
*
* @param numberFormat the {@link NumberFormat} to set
*/
public void setNumberFormat(NumberFormat numberFormat) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,13 +27,14 @@ import org.springframework.beans.factory.FactoryBean;
* A {@link FactoryBean} that automates the creation of a
* {@link SimpleJobExplorer}. Declares abstract methods for providing DAO
* object implementations.
*
*
* @see JobExplorerFactoryBean
* @see MapJobExplorerFactoryBean
*
*
* @author Dave Syer
* @since 2.0
*/
@SuppressWarnings("rawtypes")
public abstract class AbstractJobExplorerFactoryBean implements FactoryBean {
/**
@@ -45,23 +46,23 @@ public abstract class AbstractJobExplorerFactoryBean implements FactoryBean {
* @return fully configured {@link JobExecutionDao} implementation.
*/
protected abstract JobExecutionDao createJobExecutionDao() throws Exception;
protected abstract StepExecutionDao createStepExecutionDao() throws Exception;
protected abstract ExecutionContextDao createExecutionContextDao() throws Exception;
/**
* The type of object to be returned from {@link #getObject()}.
*
*
* @return JobExplorer.class
* @see org.springframework.beans.factory.FactoryBean#getObjectType()
*/
@Override
@Override
public Class<JobExplorer> getObjectType() {
return JobExplorer.class;
}
@Override
@Override
public boolean isSingleton() {
return true;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,7 +48,7 @@ import org.springframework.util.Assert;
* @since 2.0
*/
public class JobExplorerFactoryBean extends AbstractJobExplorerFactoryBean
implements InitializingBean {
implements InitializingBean {
private DataSource dataSource;
@@ -107,7 +107,7 @@ public class JobExplorerFactoryBean extends AbstractJobExplorerFactoryBean
this.lobHandler = lobHandler;
}
@Override
@Override
public void afterPropertiesSet() throws Exception {
Assert.notNull(dataSource, "DataSource must not be null.");
@@ -169,7 +169,7 @@ public class JobExplorerFactoryBean extends AbstractJobExplorerFactoryBean
return dao;
}
@Override
@Override
public Object getObject() throws Exception {
return getTarget();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ import org.springframework.util.Assert;
/**
* A {@link FactoryBean} that automates the creation of a
* {@link SimpleJobExplorer} using in-memory DAO implementations.
*
*
* @author Dave Syer
* @since 2.0
*/
@@ -54,7 +54,7 @@ public class MapJobExplorerFactoryBean extends AbstractJobExplorerFactoryBean im
/**
* The repository factory that can be used to create daos for the explorer.
*
*
* @param repositoryFactory a {@link MapJobExplorerFactoryBean}
*/
public void setRepositoryFactory(MapJobRepositoryFactoryBean repositoryFactory) {
@@ -65,7 +65,7 @@ public class MapJobExplorerFactoryBean extends AbstractJobExplorerFactoryBean im
* @throws Exception
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
@Override
@Override
public void afterPropertiesSet() throws Exception {
Assert.state(repositoryFactory != null, "A MapJobRepositoryFactoryBean must be provided");
repositoryFactory.afterPropertiesSet();
@@ -91,7 +91,7 @@ public class MapJobExplorerFactoryBean extends AbstractJobExplorerFactoryBean im
return repositoryFactory.getExecutionContextDao();
}
@Override
@Override
public Object getObject() throws Exception {
return new SimpleJobExplorer(createJobInstanceDao(), createJobExecutionDao(), createStepExecutionDao(),
createExecutionContextDao());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,10 +30,10 @@ import org.springframework.batch.core.repository.dao.StepExecutionDao;
/**
* Implementation of {@link JobExplorer} using the injected DAOs.
*
*
* @author Dave Syer
* @author Lucas Ward
*
*
* @see JobExplorer
* @see JobInstanceDao
* @see JobExecutionDao
@@ -68,12 +68,12 @@ public class SimpleJobExplorer implements JobExplorer {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.explore.JobExplorer#findJobExecutions(
* org.springframework.batch.core.JobInstance)
*/
@Override
@Override
public List<JobExecution> getJobExecutions(JobInstance jobInstance) {
List<JobExecution> executions = jobExecutionDao.findJobExecutions(jobInstance);
for (JobExecution jobExecution : executions) {
@@ -87,12 +87,12 @@ public class SimpleJobExplorer implements JobExplorer {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.explore.JobExplorer#findRunningJobExecutions
* (java.lang.String)
*/
@Override
@Override
public Set<JobExecution> findRunningJobExecutions(String jobName) {
Set<JobExecution> executions = jobExecutionDao.findRunningJobExecutions(jobName);
for (JobExecution jobExecution : executions) {
@@ -106,12 +106,12 @@ public class SimpleJobExplorer implements JobExplorer {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.explore.JobExplorer#getJobExecution(java
* .lang.Long)
*/
@Override
@Override
public JobExecution getJobExecution(Long executionId) {
if (executionId == null) {
return null;
@@ -129,12 +129,12 @@ public class SimpleJobExplorer implements JobExplorer {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.explore.JobExplorer#getStepExecution(java
* .lang.Long)
*/
@Override
@Override
public StepExecution getStepExecution(Long jobExecutionId, Long executionId) {
JobExecution jobExecution = jobExecutionDao.getJobExecution(jobExecutionId);
if (jobExecution == null) {
@@ -147,34 +147,34 @@ public class SimpleJobExplorer implements JobExplorer {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.explore.JobExplorer#getJobInstance(java
* .lang.Long)
*/
@Override
@Override
public JobInstance getJobInstance(Long instanceId) {
return jobInstanceDao.getJobInstance(instanceId);
}
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.explore.JobExplorer#getLastJobInstances
* (java.lang.String, int)
*/
@Override
@Override
public List<JobInstance> getJobInstances(String jobName, int start, int count) {
return jobInstanceDao.getJobInstances(jobName, start, count);
}
/*
* (non-Javadoc)
*
*
* @see org.springframework.batch.core.explore.JobExplorer#getJobNames()
*/
@Override
@Override
public List<String> getJobNames() {
return jobInstanceDao.getJobNames();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2009 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,12 +50,12 @@ import org.springframework.util.ClassUtils;
* such as a {@link JobRepository}, {@link JobExecutionListener}s, and various
* configuration parameters are set here. Therefore, common error handling and
* listener calling activities are abstracted away from implementations.
*
*
* @author Lucas Ward
* @author Dave Syer
*/
public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
InitializingBean {
InitializingBean {
protected static final Log logger = LogFactory.getLog(AbstractJob.class);
@@ -83,7 +83,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
/**
* Convenience constructor to immediately add name (which is mandatory but
* not final).
*
*
* @param name
*/
public AbstractJob(String name) {
@@ -94,7 +94,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
/**
* A validator for job parameters. Defaults to a vanilla
* {@link DefaultJobParametersValidator}.
*
*
* @param jobParametersValidator
* a validator instance
*/
@@ -105,10 +105,10 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
/**
* Assert mandatory properties: {@link JobRepository}.
*
*
* @see InitializingBean#afterPropertiesSet()
*/
@Override
@Override
public void afterPropertiesSet() throws Exception {
Assert.notNull(jobRepository, "JobRepository must be set");
}
@@ -119,10 +119,10 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
* if it is present. Care is needed with bean definition inheritance - if a
* parent bean has a name, then its children need an explicit name as well,
* otherwise they will not be unique.
*
*
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
*/
@Override
@Override
public void setBeanName(String name) {
if (this.name == null) {
this.name = name;
@@ -132,7 +132,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
/**
* Set the name property. Always overrides the default value if this object
* is a Spring bean.
*
*
* @see #setBeanName(java.lang.String)
*/
public void setName(String name) {
@@ -141,10 +141,10 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
/*
* (non-Javadoc)
*
*
* @see org.springframework.batch.core.domain.IJob#getName()
*/
@Override
@Override
public String getName() {
return name;
}
@@ -152,22 +152,22 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
/**
* Retrieve the step with the given name. If there is no Step with the given
* name, then return null.
*
*
* @param stepName
* @return the Step
*/
@Override
@Override
public abstract Step getStep(String stepName);
/**
* Retrieve the step names.
*
*
* @return the step names
*/
@Override
@Override
public abstract Collection<String> getStepNames();
@Override
@Override
public JobParametersValidator getJobParametersValidator() {
return jobParametersValidator;
}
@@ -175,7 +175,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
/**
* Boolean flag to prevent categorically a job from restarting, even if it
* has failed previously.
*
*
* @param restartable
* the value of the flag to set (default true)
*/
@@ -186,14 +186,14 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
/**
* @see Job#isRestartable()
*/
@Override
@Override
public boolean isRestartable() {
return restartable;
}
/**
* Public setter for the {@link JobParametersIncrementer}.
*
*
* @param jobParametersIncrementer
* the {@link JobParametersIncrementer} to set
*/
@@ -204,10 +204,10 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
/*
* (non-Javadoc)
*
*
* @see org.springframework.batch.core.Job#getJobParametersIncrementer()
*/
@Override
@Override
public JobParametersIncrementer getJobParametersIncrementer() {
return this.jobParametersIncrementer;
}
@@ -215,7 +215,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
/**
* Public setter for injecting {@link JobExecutionListener}s. They will all
* be given the listener callbacks at the appropriate point in the job.
*
*
* @param listeners
* the listeners to set.
*/
@@ -228,7 +228,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
/**
* Register a single listener for the {@link JobExecutionListener}
* callbacks.
*
*
* @param listener
* a {@link JobExecutionListener}
*/
@@ -240,7 +240,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
* Public setter for the {@link JobRepository} that is needed to manage the
* state of the batch meta domain (jobs, steps, executions) during the life
* of a job.
*
*
* @param jobRepository
*/
public void setJobRepository(JobRepository jobRepository) {
@@ -250,7 +250,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
/**
* Convenience method for subclasses to access the job repository.
*
*
* @return the jobRepository
*/
protected JobRepository getJobRepository() {
@@ -262,10 +262,10 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
* logic and ignore listeners and repository calls. Implementations usually
* are concerned with the ordering of steps, and delegate actual step
* processing to {@link #handleStep(Step, JobExecution)}.
*
*
* @param execution
* the current {@link JobExecution}
*
*
* @throws JobExecutionException
* to signal a fatal batch framework error (not a business or
* validation exception)
@@ -276,12 +276,12 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
/**
* Run the specified job, handling all listener and repository calls, and
* delegating the actual processing to {@link #doExecute(JobExecution)}.
*
*
* @see Job#execute(JobExecution)
* @throws StartLimitExceededException
* if start limit of one of the steps was exceeded
*/
@Override
@Override
public final void execute(JobExecution execution) {
logger.debug("Job execution starting: " + execution);
@@ -334,8 +334,8 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
&& execution.getStepExecutions().isEmpty()) {
ExitStatus exitStatus = execution.getExitStatus();
execution
.setExitStatus(exitStatus.and(ExitStatus.NOOP
.addExitDescription("All steps already completed or no steps configured for this job.")));
.setExitStatus(exitStatus.and(ExitStatus.NOOP
.addExitDescription("All steps already completed or no steps configured for this job.")));
}
execution.setEndTime(new Date());
@@ -358,13 +358,13 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
* method do not need access to the {@link JobRepository}, nor do they need
* to worry about populating the execution context on a restart, nor
* detecting the interrupted state (in job or step execution).
*
*
* @param step
* the {@link Step} to execute
* @param execution
* the current {@link JobExecution}
* @return the {@link StepExecution} corresponding to this step
*
*
* @throws JobInterruptedException
* if the {@link JobExecution} has been interrupted, and in
* particular if {@link BatchStatus#ABANDONED} or
@@ -384,7 +384,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
/**
* Default mapping from throwable to {@link ExitStatus}.
*
*
* @param ex
* the cause of the failure
* @return an {@link ExitStatus}
@@ -411,7 +411,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,
jobRepository.update(jobExecution);
}
@Override
@Override
public String toString() {
return ClassUtils.getShortName(getClass()) + ": [name=" + name + "]";
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011 the original author or authors.
* Copyright 2011-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,29 +25,29 @@ import org.springframework.util.Assert;
/**
* Composite {@link JobParametersValidator} that passes the job parameters through a sequence of
* injected <code>JobParametersValidator</code>s
*
* injected <code>JobParametersValidator</code>s
*
* @author Morten Andersen-Gott
*
*/
public class CompositeJobParametersValidator implements JobParametersValidator, InitializingBean {
private List<JobParametersValidator> validators;
/**
* Validates the JobParameters according to the injected JobParameterValidators
* Validation stops and exception is thrown on first validation error
*
*
* @param parameters some {@link JobParameters}
* @throws JobParametersInvalidException if the parameters are invalid
*/
@Override
@Override
public void validate(JobParameters parameters) throws JobParametersInvalidException {
for (JobParametersValidator validator : validators) {
validator.validate(parameters);
}
}
/**
* Public setter for the validators
* @param validators
@@ -56,12 +56,12 @@ public class CompositeJobParametersValidator implements JobParametersValidator,
this.validators = validators;
}
@Override
@Override
public void afterPropertiesSet() throws Exception {
Assert.notNull(validators, "The 'validators' may not be null");
Assert.notEmpty(validators, "The 'validators' may not be empty");
}
}

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2012-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.job;
import java.util.Arrays;
@@ -13,9 +28,9 @@ import org.springframework.util.Assert;
/**
* Default implementation of {@link JobParametersValidator}.
*
*
* @author Dave Syer
*
*
*/
public class DefaultJobParametersValidator implements JobParametersValidator, InitializingBean {
@@ -33,10 +48,10 @@ public class DefaultJobParametersValidator implements JobParametersValidator, In
/**
* Create a new validator with the required and optional job parameter keys
* provided.
*
*
* @see DefaultJobParametersValidator#setOptionalKeys(String[])
* @see DefaultJobParametersValidator#setRequiredKeys(String[])
*
*
* @param requiredKeys the required keys
* @param optionalKeys the optional keys
*/
@@ -50,7 +65,7 @@ public class DefaultJobParametersValidator implements JobParametersValidator, In
* Check that there are no overlaps between required and optional keys.
* @throws IllegalStateException if there is an overlap
*/
@Override
@Override
public void afterPropertiesSet() throws IllegalStateException {
for (String key : requiredKeys) {
Assert.state(!optionalKeys.contains(key), "Optional keys canot be required: " + key);
@@ -62,12 +77,12 @@ public class DefaultJobParametersValidator implements JobParametersValidator, In
* are explicitly specified then all keys must be in that list, or in the
* required list. Otherwise all keys that are specified as required must be
* present.
*
*
* @see JobParametersValidator#validate(JobParameters)
*
*
* @throws JobParametersInvalidException if the parameters are not valid
*/
@Override
@Override
public void validate(JobParameters parameters) throws JobParametersInvalidException {
if (parameters == null) {
@@ -109,9 +124,9 @@ public class DefaultJobParametersValidator implements JobParametersValidator, In
* The keys that are required in the parameters. The default is empty,
* meaning that all parameters are optional, unless optional keys are
* explicitly specified.
*
*
* @param requiredKeys the required key values
*
*
* @see #setOptionalKeys(String[])
*/
public final void setRequiredKeys(String[] requiredKeys) {
@@ -123,9 +138,9 @@ public class DefaultJobParametersValidator implements JobParametersValidator, In
* optional, then to be valid all other keys must be explicitly required.
* The default is empty, meaning that all parameters that are not required
* are optional.
*
*
* @param optionalKeys the optional key values
*
*
* @see #setRequiredKeys(String[])
*/
public final void setOptionalKeys(String[] optionalKeys) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ import org.springframework.batch.core.repository.JobRestartException;
* {@link JobExecution}. Sequentially executes a job by iterating through its
* list of steps. Any {@link Step} that fails will fail the job. The job is
* considered complete when all steps have been executed.
*
*
* @author Lucas Ward
* @author Dave Syer
*/
@@ -59,7 +59,7 @@ public class SimpleJob extends AbstractJob {
/**
* Public setter for the steps in this job. Overrides any calls to
* {@link #addStep(Step)}.
*
*
* @param steps the steps to execute
*/
public void setSteps(List<Step> steps) {
@@ -69,10 +69,10 @@ public class SimpleJob extends AbstractJob {
/**
* Convenience method for clients to inspect the steps for this job.
*
*
* @return the step names for this job
*/
@Override
@Override
public Collection<String> getStepNames() {
List<String> names = new ArrayList<String>();
for (Step step : steps) {
@@ -83,7 +83,7 @@ public class SimpleJob extends AbstractJob {
/**
* Convenience method for adding a single step to the job.
*
*
* @param step a {@link Step} to add
*/
public void addStep(Step step) {
@@ -92,11 +92,11 @@ public class SimpleJob extends AbstractJob {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.job.AbstractJob#getStep(java.lang.String)
*/
@Override
@Override
public Step getStep(String stepName) {
for (Step step : this.steps) {
if (step.getName().equals(stepName)) {
@@ -110,14 +110,14 @@ public class SimpleJob extends AbstractJob {
* Handler of steps sequentially as provided, checking each one for success
* before moving to the next. Returns the last {@link StepExecution}
* successfully processed if it exists, and null if none were processed.
*
*
* @param execution the current {@link JobExecution}
*
*
* @see AbstractJob#handleStep(Step, JobExecution)
*/
@Override
@Override
protected void doExecute(JobExecution execution) throws JobInterruptedException, JobRestartException,
StartLimitExceededException {
StartLimitExceededException {
StepExecution stepExecution = null;
for (Step step : steps) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2009 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,9 +34,9 @@ import org.springframework.util.Assert;
/**
* Implementation of {@link StepHandler} that manages repository and restart
* concerns.
*
*
* @author Dave Syer
*
*
*/
public class SimpleStepHandler implements StepHandler, InitializingBean {
@@ -71,10 +71,10 @@ public class SimpleStepHandler implements StepHandler, InitializingBean {
/**
* Check mandatory properties (jobRepository).
*
*
* @see InitializingBean#afterPropertiesSet()
*/
@Override
@Override
public void afterPropertiesSet() throws Exception {
Assert.state(jobRepository != null, "A JobRepository must be provided");
}
@@ -89,16 +89,16 @@ public class SimpleStepHandler implements StepHandler, InitializingBean {
/**
* A context containing values to be added to the step execution before it
* is handled.
*
*
* @param executionContext the execution context to set
*/
public void setExecutionContext(ExecutionContext executionContext) {
this.executionContext = executionContext;
}
@Override
@Override
public StepExecution handleStep(Step step, JobExecution execution) throws JobInterruptedException,
JobRestartException, StartLimitExceededException {
JobRestartException, StartLimitExceededException {
if (execution.isStopping()) {
throw new JobInterruptedException("JobExecution interrupted.");
}
@@ -178,7 +178,7 @@ public class SimpleStepHandler implements StepHandler, InitializingBean {
* @param lastStepExecution the last step execution
* @param jobInstance
* @param step
*
*
* @throws StartLimitExceededException if the start limit has been exceeded
* for this step
* @throws JobRestartException if the job is in an inconsistent state from

View File

@@ -21,7 +21,7 @@ import org.springframework.batch.core.job.flow.JobExecutionDecider;
/**
* @author Dave Syer
*
*
*/
public class JobFlowBuilder extends FlowBuilder<FlowJobBuilder> {
@@ -53,10 +53,10 @@ public class JobFlowBuilder extends FlowBuilder<FlowJobBuilder> {
/**
* Build a flow and inject it into the parent builder. The parent builder is then returned so it can be enhanced
* before building an actual job. Normally called explicitly via {@link #end()}.
*
*
* @see org.springframework.batch.core.job.builder.FlowBuilder#build()
*/
@Override
@Override
public FlowJobBuilder build() {
Flow flow = flow();
parent.flow(flow);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,13 +51,13 @@ public class FlowExecution implements Comparable<FlowExecution> {
/**
* Create an ordering on {@link FlowExecution} instances by comparing their
* statuses.
*
*
* @see Comparable#compareTo(Object)
*
*
* @param other
* @return negative, zero or positive as per the contract
*/
@Override
@Override
public int compareTo(FlowExecution other) {
return this.status.compareTo(other.getStatus());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@ package org.springframework.batch.core.job.flow;
/**
* Represents the status of {@link FlowExecution}.
*
*
* @author Dan Garrette
* @author Dave Syer
* @since 2.0
@@ -101,13 +101,13 @@ public class FlowExecutionStatus implements Comparable<FlowExecutionStatus> {
/**
* Create an ordering on {@link FlowExecutionStatus} instances by comparing
* their statuses.
*
*
* @see Comparable#compareTo(Object)
*
*
* @param other
* @return negative, zero or positive as per the contract
*/
@Override
@Override
public int compareTo(FlowExecutionStatus other) {
Status one = Status.match(this.name);
Status two = Status.match(other.name);
@@ -120,7 +120,7 @@ public class FlowExecutionStatus implements Comparable<FlowExecutionStatus> {
/**
* Check the equality of the statuses.
*
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2009 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,9 +30,9 @@ import org.springframework.batch.core.repository.JobRestartException;
/**
* Implementation of {@link FlowExecutor} for use in components that need to
* execute a flow related to a {@link JobExecution}.
*
*
* @author Dave Syer
*
*
*/
public class JobFlowExecutor implements FlowExecutor {
@@ -56,13 +56,13 @@ public class JobFlowExecutor implements FlowExecutor {
stepExecutionHolder.set(null);
}
@Override
@Override
public String executeStep(Step step) throws JobInterruptedException, JobRestartException,
StartLimitExceededException {
StartLimitExceededException {
StepExecution stepExecution = stepHandler.handleStep(step, execution);
stepExecutionHolder.set(stepExecution);
if (stepExecution == null) {
return ExitStatus.COMPLETED.getExitCode();
return ExitStatus.COMPLETED.getExitCode();
}
if (stepExecution.isTerminateOnly()) {
throw new JobInterruptedException("Step requested termination: "+stepExecution, stepExecution.getStatus());
@@ -70,7 +70,7 @@ public class JobFlowExecutor implements FlowExecutor {
return stepExecution.getExitStatus().getExitCode();
}
@Override
@Override
public void abandonStepExecution() {
StepExecution lastStepExecution = stepExecutionHolder.get();
if (lastStepExecution != null && lastStepExecution.getStatus().isGreaterThan(BatchStatus.STOPPING)) {
@@ -79,29 +79,29 @@ public class JobFlowExecutor implements FlowExecutor {
}
}
@Override
@Override
public void updateJobExecutionStatus(FlowExecutionStatus status) {
execution.setStatus(findBatchStatus(status));
exitStatus = exitStatus.and(new ExitStatus(status.getName()));
execution.setExitStatus(exitStatus);
}
@Override
@Override
public JobExecution getJobExecution() {
return execution;
}
@Override
@Override
public StepExecution getStepExecution() {
return stepExecutionHolder.get();
}
@Override
@Override
public void close(FlowExecution result) {
stepExecutionHolder.set(null);
}
@Override
@Override
public boolean isRestart() {
if (getStepExecution() != null && getStepExecution().getStatus() == BatchStatus.ABANDONED) {
/*
@@ -114,7 +114,7 @@ public class JobFlowExecutor implements FlowExecutor {
return execution.getStepExecutions().isEmpty();
}
@Override
@Override
public void addExitStatus(String code) {
exitStatus = exitStatus.and(new ExitStatus(code));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@ import org.springframework.beans.factory.InitializingBean;
* particular order). The start state name can be specified explicitly (and must
* exist in the set of transitions), or computed from the existing transitions,
* if unambiguous.
*
*
* @author Dave Syer
* @since 2.0
*/
@@ -63,7 +63,7 @@ public class SimpleFlow implements Flow, InitializingBean {
/**
* Create a flow with the given name.
*
*
* @param name the name of the flow
*/
public SimpleFlow(String name) {
@@ -72,17 +72,17 @@ public class SimpleFlow implements Flow, InitializingBean {
/**
* Get the name for this flow.
*
*
* @see Flow#getName()
*/
@Override
@Override
public String getName() {
return name;
}
/**
* Public setter for the stateTransitions.
*
*
* @param stateTransitions the stateTransitions to set
*/
public void setStateTransitions(List<StateTransition> stateTransitions) {
@@ -93,25 +93,25 @@ public class SimpleFlow implements Flow, InitializingBean {
/**
* {@inheritDoc}
*/
@Override
@Override
public State getState(String stateName) {
return stateMap.get(stateName);
}
/**
* {@inheritDoc}
*/
@Override
@Override
public Collection<State> getStates() {
return new HashSet<State>(stateMap.values());
}
/**
* Locate start state and pre-populate data structures needed for execution.
*
*
* @see InitializingBean#afterPropertiesSet()
*/
@Override
@Override
public void afterPropertiesSet() throws Exception {
initializeTransitions();
}
@@ -119,7 +119,7 @@ public class SimpleFlow implements Flow, InitializingBean {
/**
* @see Flow#start(FlowExecutor)
*/
@Override
@Override
public FlowExecution start(FlowExecutor executor) throws FlowExecutionException {
if (startState == null) {
initializeTransitions();
@@ -132,7 +132,7 @@ public class SimpleFlow implements Flow, InitializingBean {
/**
* @see Flow#resume(String, FlowExecutor)
*/
@Override
@Override
public FlowExecution resume(String stateName, FlowExecutor executor) throws FlowExecutionException {
FlowExecutionStatus status = FlowExecutionStatus.UNKNOWN;
@@ -158,7 +158,7 @@ public class SimpleFlow implements Flow, InitializingBean {
throw new FlowExecutionException(String.format("Ended flow=%s at state=%s with exception", name,
stateName), e);
}
logger.debug("Completed state="+stateName+" with status="+status);
state = nextState(stateName, status);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import org.springframework.util.StringUtils;
* another. The originating State name and the next {@link State} to execute are
* linked by a pattern for the {@link ExitStatus#getExitCode() exit code} of an
* execution of the originating State.
*
*
* @author Dave Syer
* @since 2.0
*/
@@ -42,7 +42,7 @@ public final class StateTransition implements Comparable<StateTransition> {
* Create a new end state {@link StateTransition} specification. This
* transition explicitly goes unconditionally to an end state (i.e. no more
* executions).
*
*
* @param state the {@link State} used to generate the outcome for this
* transition
*/
@@ -54,7 +54,7 @@ public final class StateTransition implements Comparable<StateTransition> {
* Create a new end state {@link StateTransition} specification. This
* transition explicitly goes to an end state (i.e. no more processing) if
* the outcome matches the pattern.
*
*
* @param state the {@link State} used to generate the outcome for this
* transition
* @param pattern the pattern to match in the exit status of the
@@ -67,11 +67,11 @@ public final class StateTransition implements Comparable<StateTransition> {
/**
* Convenience method to switch the origin and destination of a transition,
* creating a new instance.
*
*
* @param stateTransition an existing state transition
* @param state the new state for the origin
* @param next the new name for the destination
*
*
* @return a {@link StateTransition}
*/
public static StateTransition switchOriginAndDestination(StateTransition stateTransition, State state, String next) {
@@ -81,7 +81,7 @@ public final class StateTransition implements Comparable<StateTransition> {
/**
* Create a new state {@link StateTransition} specification with a wildcard
* pattern that matches all outcomes.
*
*
* @param state the {@link State} used to generate the outcome for this
* transition
* @param next the name of the next {@link State} to execute
@@ -93,7 +93,7 @@ public final class StateTransition implements Comparable<StateTransition> {
/**
* Create a new {@link StateTransition} specification from one {@link State}
* to another (by name).
*
*
* @param state the {@link State} used to generate the outcome for this
* transition
* @param pattern the pattern to match in the exit status of the
@@ -141,7 +141,7 @@ public final class StateTransition implements Comparable<StateTransition> {
/**
* Check if the provided status matches the pattern, signalling that the
* next State should be executed.
*
*
* @param status the status to compare
* @return true if the pattern matches this status
*/
@@ -151,7 +151,7 @@ public final class StateTransition implements Comparable<StateTransition> {
/**
* Check for a special next State signalling the end of a job.
*
*
* @return true if this transition goes nowhere (there is no next)
*/
public boolean isEnd() {
@@ -165,7 +165,7 @@ public final class StateTransition implements Comparable<StateTransition> {
* fo? > foo.
* @see Comparable#compareTo(Object)
*/
@Override
@Override
public int compareTo(StateTransition other) {
String value = other.pattern;
if (pattern.equals(value)) {
@@ -192,7 +192,7 @@ public final class StateTransition implements Comparable<StateTransition> {
/*
* (non-Javadoc)
*
*
* @see java.lang.Object#toString()
*/
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,21 +25,21 @@ import org.springframework.batch.core.job.flow.State;
* @since 2.0
*/
public abstract class AbstractState implements State {
private final String name;
/**
*
*
*/
public AbstractState(String name) {
this.name = name;
}
@Override
@Override
public String getName() {
return name;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@@ -47,8 +47,8 @@ public abstract class AbstractState implements State {
public String toString() {
return getClass().getSimpleName()+": name=["+name+"]";
}
@Override
@Override
public abstract FlowExecutionStatus handle(FlowExecutor executor) throws Exception;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@ import org.springframework.batch.core.job.flow.JobExecutionDecider;
/**
* State that requires a decider to make the status decision.
*
*
* @author Dave Syer
* @since 2.0
*/
@@ -42,11 +42,11 @@ public class DecisionState extends AbstractState {
public FlowExecutionStatus handle(FlowExecutor executor) throws Exception {
return decider.decide(executor.getJobExecution(), executor.getStepExecution());
}
/* (non-Javadoc)
* @see org.springframework.batch.core.job.flow.State#isEndState()
*/
@Override
@Override
public boolean isEndState() {
return false;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@ import org.springframework.batch.core.job.flow.State;
/**
* {@link State} implementation for ending a job if it is in progress and
* continuing if just starting.
*
*
* @author Dave Syer
* @since 2.0
*/
@@ -58,7 +58,7 @@ public class EndState extends AbstractState {
* @param name The name of the state
* @param abandon flag to indicate that previous step execution can be
* marked as abandoned (if there is one)
*
*
*/
public EndState(FlowExecutionStatus status, String code, String name, boolean abandon) {
super(name);
@@ -69,7 +69,7 @@ public class EndState extends AbstractState {
/**
* Return the {@link FlowExecutionStatus} stored.
*
*
* @see State#handle(FlowExecutor)
*/
@Override
@@ -116,17 +116,17 @@ public class EndState extends AbstractState {
/*
* (non-Javadoc)
*
*
* @see org.springframework.batch.core.job.flow.State#isEndState()
*/
@Override
@Override
public boolean isEndState() {
return !status.isStop();
}
/*
* (non-Javadoc)
*
*
* @see java.lang.Object#toString()
*/
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import org.springframework.batch.core.job.flow.FlowHolder;
/**
* State that delegates to a Flow
*
*
* @author Dave Syer
* @since 2.0
*/
@@ -41,11 +41,11 @@ public class FlowState extends AbstractState implements FlowHolder {
super(name);
this.flow = flow;
}
/**
* @return the flows
*/
@Override
@Override
public Collection<Flow> getFlows() {
return Collections.singleton(flow);
}
@@ -54,11 +54,11 @@ public class FlowState extends AbstractState implements FlowHolder {
public FlowExecutionStatus handle(FlowExecutor executor) throws Exception {
return flow.start(executor).getStatus();
}
/* (non-Javadoc)
* @see org.springframework.batch.core.job.flow.State#isEndState()
*/
@Override
@Override
public boolean isEndState() {
return false;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import org.springframework.batch.core.job.flow.FlowExecutionStatus;
* {@link FlowExecutionStatus}', using the status with the high precedence as the
* aggregate status. See {@link FlowExecutionStatus} for details on status
* precedence.
*
*
* @author Dave Syer
* @since 2.0
*/
@@ -36,10 +36,10 @@ public class MaxValueFlowExecutionAggregator implements FlowExecutionAggregator
* Aggregate all of the {@link FlowExecutionStatus}es of the
* {@link FlowExecution}s into one status. The aggregate status will be the
* status with the highest precedence.
*
*
* @see FlowExecutionAggregator#aggregate(Collection)
*/
@Override
@Override
public FlowExecutionStatus aggregate(Collection<FlowExecution> executions) {
if (executions == null || executions.size() == 0) {
return FlowExecutionStatus.UNKNOWN;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ import org.springframework.core.task.TaskRejectedException;
/**
* A {@link State} implementation that splits a {@link Flow} into multiple
* parallel subflows.
*
*
* @author Dave Syer
* @since 2.0
*/
@@ -63,11 +63,11 @@ public class SplitState extends AbstractState implements FlowHolder {
public void setTaskExecutor(TaskExecutor taskExecutor) {
this.taskExecutor = taskExecutor;
}
/**
* @return the flows
*/
@Override
@Override
public Collection<Flow> getFlows() {
return flows;
}
@@ -75,7 +75,7 @@ public class SplitState extends AbstractState implements FlowHolder {
/**
* Execute the flows in parallel by passing them to the {@link TaskExecutor}
* and wait for all of them to finish before proceeding.
*
*
* @see State#handle(FlowExecutor)
*/
@Override
@@ -88,7 +88,7 @@ public class SplitState extends AbstractState implements FlowHolder {
for (final Flow flow : flows) {
final FutureTask<FlowExecution> task = new FutureTask<FlowExecution>(new Callable<FlowExecution>() {
@Override
@Override
public FlowExecution call() throws Exception {
return flow.start(executor);
}
@@ -129,10 +129,10 @@ public class SplitState extends AbstractState implements FlowHolder {
/*
* (non-Javadoc)
*
*
* @see org.springframework.batch.core.job.flow.State#isEndState()
*/
@Override
@Override
public boolean isEndState() {
return false;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@ import org.springframework.batch.core.step.StepHolder;
/**
* {@link State} implementation that delegates to a {@link FlowExecutor} to
* execute the specified {@link Step}.
*
*
* @author Dave Syer
* @since 2.0
*/
@@ -63,15 +63,15 @@ public class StepState extends AbstractState implements StepHolder {
/**
* @return the step
*/
@Override
@Override
public Step getStep() {
return step;
}
/* (non-Javadoc)
* @see org.springframework.batch.core.job.flow.State#isEndState()
*/
@Override
@Override
public boolean isEndState() {
return false;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,7 +45,7 @@ import org.springframework.util.Assert;
* jobs registered, e.g. a JMX MBean wrapper for a {@link JobLauncher}, or a
* Quartz trigger.
* </p>
*
*
* <p>
* With any launch of a batch job within Spring Batch, a Spring context
* containing the {@link Job} has to be created. Using this launcher, the jobs
@@ -56,9 +56,9 @@ import org.springframework.util.Assert;
* {@link JobRegistry}. Therefore, if autowiring fails to set it then an
* exception will be thrown.
* </p>
*
*
* @author Dave Syer
*
*
*/
public class JobRegistryBackgroundJobRunner {
@@ -93,16 +93,16 @@ public class JobRegistryBackgroundJobRunner {
/**
* A loader for the jobs that are going to be registered.
*
*
* @param jobLoader the {@link JobLoader} to set
*/
public void setJobLoader(JobLoader jobLoader) {
this.jobLoader = jobLoader;
}
/**
* A job registry that can be used to create a job loader (if none is provided).
*
*
* @param jobRegistry the {@link JobRegistry} to set
*/
public void setJobRegistry(JobRegistry jobRegistry) {
@@ -155,7 +155,7 @@ public class JobRegistryBackgroundJobRunner {
String[] names = parentContext.getBeanNamesForType(JobLoader.class);
if (names.length == 0) {
if (parentContext.containsBean("jobLoader")) {
jobLoader = (JobLoader) parentContext.getBean("jobLoader", JobLoader.class);
jobLoader = parentContext.getBean("jobLoader", JobLoader.class);
return;
}
if (jobRegistry != null) {
@@ -164,7 +164,7 @@ public class JobRegistryBackgroundJobRunner {
}
}
jobLoader = (JobLoader) parentContext.getBean(names[0], JobLoader.class);
jobLoader = parentContext.getBean(names[0], JobLoader.class);
return;
}
@@ -175,20 +175,20 @@ public class JobRegistryBackgroundJobRunner {
* {@link JobRegistry} and the child contexts are expected to contain
* {@link Job} definitions, each of which will be registered wit the
* registry.
*
*
* Example usage:
*
*
* <pre>
* $ java -classpath ... JobRegistryBackgroundJobRunner job-registry-context.xml job1.xml job2.xml ...
* </pre>
*
*
* The child contexts are created only when needed though the
* {@link JobFactory} interface (but the XML is validated on startup by
* using it to create a {@link BeanFactory} which is then discarded).
*
*
* The parent context is created in a separate thread, and the program will
* pause for input in an infinite loop until the user hits any key.
*
*
* @param args the context locations to use (first one is for parent)
* @throws Exception if anything goes wrong with the context creation
*/
@@ -202,7 +202,7 @@ public class JobRegistryBackgroundJobRunner {
logger.info("Starting job registry in parent context from XML at: [" + args[0] + "]");
new Thread(new Runnable() {
@Override
@Override
public void run() {
try {
launcher.run();
@@ -241,7 +241,7 @@ public class JobRegistryBackgroundJobRunner {
synchronized (JobRegistryBackgroundJobRunner.class) {
System.out
.println("Started application. Interrupt (CTRL-C) or call JobRegistryBackgroundJobRunner.stop() to exit.");
.println("Started application. Interrupt (CTRL-C) or call JobRegistryBackgroundJobRunner.stop() to exit.");
JobRegistryBackgroundJobRunner.class.wait();
}
launcher.destroy();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,10 +20,10 @@ package org.springframework.batch.core.launch.support;
* System.exit method. It should be noted that there will be no unit tests for
* this class, since there is only one line of actual code, that would only be
* testable by mocking System or Runtime.
*
*
* @author Lucas Ward
* @author Dave Syer
*
*
*/
public class JvmSystemExiter implements SystemExiter {
@@ -31,10 +31,10 @@ public class JvmSystemExiter implements SystemExiter {
* Delegate call to System.exit() with the argument provided. This should only
* be used in a scenario where a particular status needs to be returned to
* a Batch scheduler.
*
*
* @see org.springframework.batch.core.launch.support.SystemExiter#exit(int)
*/
@Override
@Override
public void exit(int status) {
System.exit(status);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,12 +25,12 @@ import org.springframework.batch.core.JobParametersIncrementer;
public class RunIdIncrementer implements JobParametersIncrementer {
private static String RUN_ID_KEY = "run.id";
private String key = RUN_ID_KEY;
/**
* The name of the run id in the job parameters. Defaults to "run.id".
*
*
* @param key the key to set
*/
public void setKey(String key) {
@@ -40,11 +40,11 @@ public class RunIdIncrementer implements JobParametersIncrementer {
/**
* Increment the run.id parameter (starting with 1).
*/
@Override
@Override
public JobParameters getNext(JobParameters parameters) {
JobParameters params = (parameters == null) ? new JobParameters() : parameters;
long id = params.getLong(key, 0L) + 1;
return new JobParametersBuilder(params).addLong(key, id).toJobParameters();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ public class RuntimeExceptionTranslator implements MethodInterceptor {
/* (non-Javadoc)
* @see org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation)
*/
@Override
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
try {
return invocation.proceed();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2008 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +20,8 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.Properties;
import java.util.Map.Entry;
import java.util.Properties;
import org.springframework.batch.core.JobParameter;
import org.springframework.batch.core.JobParameters;
@@ -30,7 +30,7 @@ import org.springframework.batch.core.converter.JobParametersConverter;
/**
* @author Lucas Ward
*
*
*/
public class ScheduledJobParametersFactory implements JobParametersConverter {
@@ -40,10 +40,10 @@ public class ScheduledJobParametersFactory implements JobParametersConverter {
/*
* (non-Javadoc)
*
*
* @see org.springframework.batch.core.runtime.JobParametersFactory#getJobParameters(java.util.Properties)
*/
@Override
@Override
public JobParameters getJobParameters(Properties props) {
if (props == null || props.isEmpty()) {
@@ -71,10 +71,10 @@ public class ScheduledJobParametersFactory implements JobParametersConverter {
/**
* Convert schedule date to Date, and assume all other parameters can be represented by their default string value.
*
*
* @see org.springframework.batch.core.converter.JobParametersConverter#getProperties(org.springframework.batch.core.JobParameters)
*/
@Override
@Override
public Properties getProperties(JobParameters params) {
if (params == null || params.isEmpty()) {
@@ -97,7 +97,7 @@ public class ScheduledJobParametersFactory implements JobParametersConverter {
/**
* Public setter for injecting a date format.
*
*
* @param dateFormat a {@link DateFormat}, defaults to "yyyy/MM/dd"
*/
public void setDateFormat(DateFormat dateFormat) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2008 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,18 +44,18 @@ import org.springframework.util.Assert;
* be taken to ensure any users of this class understand fully whether or not
* the implementation of TaskExecutor used will start tasks synchronously or
* asynchronously. The default setting uses a synchronous task executor.
*
*
* There is only one required dependency of this Launcher, a
* {@link JobRepository}. The JobRepository is used to obtain a valid
* JobExecution. The Repository must be used because the provided {@link Job}
* could be a restart of an existing {@link JobInstance}, and only the
* Repository can reliably recreate it.
*
*
* @author Lucas Ward
* @Author Dave Syer
*
*
* @since 1.0
*
*
* @see JobRepository
* @see TaskExecutor
*/
@@ -71,7 +71,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean {
* Run the provided job with the given {@link JobParameters}. The
* {@link JobParameters} will be used to determine if this is an execution
* of an existing job instance, or if a new one should be created.
*
*
* @param job the job to be run.
* @param jobParameters the {@link JobParameters} for this particular
* execution.
@@ -83,7 +83,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean {
* completed successfully
* @throws JobParametersInvalidException
*/
@Override
@Override
public JobExecution run(final Job job, final JobParameters jobParameters)
throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException,
JobParametersInvalidException {
@@ -114,7 +114,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean {
try {
taskExecutor.execute(new Runnable() {
@Override
@Override
public void run() {
try {
logger.info("Job: [" + job + "] launched with the following parameters: [" + jobParameters
@@ -155,7 +155,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean {
/**
* Set the JobRepsitory.
*
*
* @param jobRepository
*/
public void setJobRepository(JobRepository jobRepository) {
@@ -164,7 +164,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean {
/**
* Set the TaskExecutor. (Optional)
*
*
* @param taskExecutor
*/
public void setTaskExecutor(TaskExecutor taskExecutor) {
@@ -175,7 +175,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean {
* Ensure the required dependencies of a {@link JobRepository} have been
* set.
*/
@Override
@Override
public void afterPropertiesSet() throws Exception {
Assert.state(jobRepository != null, "A JobRepository has not been set.");
if (taskExecutor == null) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,17 +58,17 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
/**
* Simple implementation of the JobOperator interface. Due to the amount of
* Simple implementation of the JobOperator interface. Due to the amount of
* functionality the implementation is combining, the following dependencies
* are required:
*
*
* <ul>
* <li> {@link JobLauncher}
* <li> {@link JobExplorer}
* <li> {@link JobRepository}
* <li> {@link JobRegistry}
* </ul>
*
*
* @author Dave Syer
* @author Lucas Ward
* @since 2.0
@@ -76,7 +76,7 @@ import org.springframework.util.Assert;
public class SimpleJobOperator implements JobOperator, InitializingBean {
/**
*
*
*/
private static final String ILLEGAL_STATE_MSG = "Illegal state (only happens on a race condition): "
+ "%s with name=%s and parameters=%s";
@@ -95,10 +95,10 @@ public class SimpleJobOperator implements JobOperator, InitializingBean {
/**
* Check mandatory properties.
*
*
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
@Override
@Override
public void afterPropertiesSet() throws Exception {
Assert.notNull(jobLauncher, "JobLauncher must be provided");
Assert.notNull(jobRegistry, "JobLocator must be provided");
@@ -144,10 +144,10 @@ public class SimpleJobOperator implements JobOperator, InitializingBean {
/*
* (non-Javadoc)
*
*
* @see org.springframework.batch.core.launch.JobOperator#getExecutions(java.lang.Long)
*/
@Override
@Override
public List<Long> getExecutions(long instanceId) throws NoSuchJobInstanceException {
JobInstance jobInstance = jobExplorer.getJobInstance(instanceId);
if (jobInstance == null) {
@@ -162,20 +162,20 @@ public class SimpleJobOperator implements JobOperator, InitializingBean {
/*
* (non-Javadoc)
*
*
* @see org.springframework.batch.core.launch.JobOperator#getJobNames()
*/
@Override
@Override
public Set<String> getJobNames() {
return new TreeSet<String>(jobRegistry.getJobNames());
}
/*
* (non-Javadoc)
*
*
* @see JobOperator#getLastInstances(String, int, int)
*/
@Override
@Override
public List<Long> getJobInstances(String jobName, int start, int count) throws NoSuchJobException {
List<Long> list = new ArrayList<Long>();
for (JobInstance jobInstance : jobExplorer.getJobInstances(jobName, start, count)) {
@@ -189,12 +189,12 @@ public class SimpleJobOperator implements JobOperator, InitializingBean {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.launch.JobOperator#getParameters(java.
* lang.Long)
*/
@Override
@Override
public String getParameters(long executionId) throws NoSuchJobExecutionException {
JobExecution jobExecution = findExecutionById(executionId);
@@ -204,12 +204,12 @@ public class SimpleJobOperator implements JobOperator, InitializingBean {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.launch.JobOperator#getRunningExecutions
* (java.lang.String)
*/
@Override
@Override
public Set<Long> getRunningExecutions(String jobName) throws NoSuchJobException {
Set<Long> set = new LinkedHashSet<Long>();
for (JobExecution jobExecution : jobExplorer.findRunningJobExecutions(jobName)) {
@@ -223,12 +223,12 @@ public class SimpleJobOperator implements JobOperator, InitializingBean {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.launch.JobOperator#getStepExecutionSummaries
* (java.lang.Long)
*/
@Override
@Override
public Map<Long, String> getStepExecutionSummaries(long executionId) throws NoSuchJobExecutionException {
JobExecution jobExecution = findExecutionById(executionId);
@@ -241,12 +241,12 @@ public class SimpleJobOperator implements JobOperator, InitializingBean {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.launch.JobOperator#getSummary(java.lang
* .Long)
*/
@Override
@Override
public String getSummary(long executionId) throws NoSuchJobExecutionException {
JobExecution jobExecution = findExecutionById(executionId);
return jobExecution.toString();
@@ -254,11 +254,11 @@ public class SimpleJobOperator implements JobOperator, InitializingBean {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.launch.JobOperator#resume(java.lang.Long)
*/
@Override
@Override
public Long restart(long executionId) throws JobInstanceAlreadyCompleteException, NoSuchJobExecutionException, NoSuchJobException, JobRestartException, JobParametersInvalidException {
logger.info("Checking status of job execution with id=" + executionId);
@@ -282,12 +282,12 @@ public class SimpleJobOperator implements JobOperator, InitializingBean {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.launch.JobOperator#start(java.lang.String,
* java.lang.String)
*/
@Override
@Override
public Long start(String jobName, String parameters) throws NoSuchJobException, JobInstanceAlreadyExistsException, JobParametersInvalidException {
logger.info("Checking status of job with name=" + jobName);
@@ -324,12 +324,12 @@ public class SimpleJobOperator implements JobOperator, InitializingBean {
/*
* (non-Javadoc)
*
*
* @see JobOperator#startNextInstance(String )
*/
@Override
@Override
public Long startNextInstance(String jobName) throws NoSuchJobException, JobParametersNotFoundException,
UnexpectedJobExecutionException, JobParametersInvalidException {
UnexpectedJobExecutionException, JobParametersInvalidException {
logger.info("Locating parameters for next instance of job with name=" + jobName);
@@ -373,11 +373,11 @@ public class SimpleJobOperator implements JobOperator, InitializingBean {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.launch.JobOperator#stop(java.lang.Long)
*/
@Override
@Override
@Transactional
public boolean stop(long executionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException {
@@ -395,22 +395,22 @@ public class SimpleJobOperator implements JobOperator, InitializingBean {
return true;
}
@Override
public JobExecution abandon(long jobExecutionId) throws NoSuchJobExecutionException, JobExecutionAlreadyRunningException {
JobExecution jobExecution = findExecutionById(jobExecutionId);
@Override
public JobExecution abandon(long jobExecutionId) throws NoSuchJobExecutionException, JobExecutionAlreadyRunningException {
JobExecution jobExecution = findExecutionById(jobExecutionId);
if (jobExecution.getStatus().isLessThan(BatchStatus.STOPPING)) {
throw new JobExecutionAlreadyRunningException(
"JobExecution is running or complete and therefore cannot be aborted");
}
if (jobExecution.getStatus().isLessThan(BatchStatus.STOPPING)) {
throw new JobExecutionAlreadyRunningException(
"JobExecution is running or complete and therefore cannot be aborted");
}
logger.info("Aborting job execution: " + jobExecution);
jobExecution.upgradeStatus(BatchStatus.ABANDONED);
jobExecution.setEndTime(new Date());
jobRepository.update(jobExecution);
logger.info("Aborting job execution: " + jobExecution);
jobExecution.upgradeStatus(BatchStatus.ABANDONED);
jobExecution.setEndTime(new Date());
jobRepository.update(jobExecution);
return jobExecution;
}
return jobExecution;
}
private JobExecution findExecutionById(long executionId) throws NoSuchJobExecutionException {
JobExecution jobExecution = jobExplorer.getJobExecution(executionId);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ import org.springframework.batch.core.ExitStatus;
* An implementation of {@link ExitCodeMapper} that can be configured through a
* map from batch exit codes (String) to integer results. Some default entries
* are set up to recognise common cases. Any that are injected are added to these.
*
*
* @author Stijn Maller
* @author Lucas Ward
* @author Dave Syer
@@ -67,7 +67,7 @@ public class SimpleJvmExitCodeMapper implements ExitCodeMapper {
* Framework
* @return The exitCode of the Batch Job as known by the JVM
*/
@Override
@Override
public int intValue(String exitCode) {
Integer statusCode = null;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@ import org.springframework.util.Assert;
* {@link FactoryBean} implementation that builds a listener based on the
* various lifecycle methods or annotations that are provided. There are three
* possible ways of having a method called as part of a listener lifecycle:
*
*
* <ul>
* <li>Interface implementation: By implementing any of the subclasses of a
* listener interface, methods on said interface will be called
@@ -47,7 +47,7 @@ import org.springframework.util.Assert;
* <li>String name of the method to be called, which is tied to a
* {@link ListenerMetaData} value in the metaDataMap.
* </ul>
*
*
* It should be noted that methods obtained by name or annotation that don't
* match the listener method signatures to which they belong will cause errors.
* However, it is acceptable to have no parameters at all. If the same method is
@@ -56,19 +56,20 @@ import org.springframework.util.Assert;
* has multiple methods tied to a particular listener, each method will be
* called. Also note that the same annotations cannot be applied to two separate
* methods in a single class.
*
*
* @author Lucas Ward
* @author Dan Garrette
* @since 2.0
* @see ListenerMetaData
*/
@SuppressWarnings("rawtypes")
public abstract class AbstractListenerFactoryBean implements FactoryBean, InitializingBean {
private Object delegate;
private Map<String, String> metaDataMap;
@Override
@Override
public Object getObject() {
if (metaDataMap == null) {
@@ -102,7 +103,7 @@ public abstract class AbstractListenerFactoryBean implements FactoryBean, Initia
if (invoker != null) {
invokers.add(invoker);
}
invoker = getMethodInvokerByName(entry.getValue(), delegate, metaData.getParamTypes());
if (invoker != null) {
invokers.add(invoker);
@@ -175,7 +176,7 @@ public abstract class AbstractListenerFactoryBean implements FactoryBean, Initia
}
}
@Override
@Override
public boolean isSingleton() {
return true;
}
@@ -188,7 +189,7 @@ public abstract class AbstractListenerFactoryBean implements FactoryBean, Initia
this.metaDataMap = metaDataMap;
}
@Override
@Override
public void afterPropertiesSet() throws Exception {
Assert.notNull(delegate, "Delegate must not be null");
}
@@ -196,7 +197,7 @@ public abstract class AbstractListenerFactoryBean implements FactoryBean, Initia
/**
* Convenience method to check whether the given object is or can be made
* into a listener.
*
*
* @param target the object to check
* @return true if the delegate is an instance of any of the listener
* interface, or contains the marker annotations

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2008 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ import org.springframework.batch.core.ChunkListener;
/**
* Basic support implementation of {@link ChunkListener}
*
*
* @author Lucas Ward
*
*/
@@ -28,14 +28,14 @@ public class ChunkListenerSupport implements ChunkListener {
/* (non-Javadoc)
* @see org.springframework.batch.core.domain.ChunkListener#afterChunk()
*/
@Override
@Override
public void afterChunk() {
}
/* (non-Javadoc)
* @see org.springframework.batch.core.domain.ChunkListener#beforeChunk()
*/
@Override
@Override
public void beforeChunk() {
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@ import org.springframework.core.Ordered;
/**
* @author Lucas Ward
*
*
*/
public class CompositeChunkListener implements ChunkListener {
@@ -31,7 +31,7 @@ public class CompositeChunkListener implements ChunkListener {
/**
* Public setter for the listeners.
*
*
* @param listeners
*/
public void setListeners(List<? extends ChunkListener> listeners) {
@@ -40,7 +40,7 @@ public class CompositeChunkListener implements ChunkListener {
/**
* Register additional listener.
*
*
* @param chunkListener
*/
public void register(ChunkListener chunkListener) {
@@ -50,10 +50,10 @@ public class CompositeChunkListener implements ChunkListener {
/**
* Call the registered listeners in order, respecting and prioritising those
* that implement {@link Ordered}.
*
*
* @see org.springframework.batch.core.ChunkListener#afterChunk()
*/
@Override
@Override
public void afterChunk() {
for (Iterator<ChunkListener> iterator = listeners.iterator(); iterator.hasNext();) {
ChunkListener listener = iterator.next();
@@ -63,10 +63,10 @@ public class CompositeChunkListener implements ChunkListener {
/**
* Call the registered listeners in reverse order.
*
*
* @see org.springframework.batch.core.ChunkListener#beforeChunk()
*/
@Override
@Override
public void beforeChunk() {
for (Iterator<ChunkListener> iterator = listeners.reverse(); iterator.hasNext();) {
ChunkListener listener = iterator.next();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@ import org.springframework.core.Ordered;
/**
* @author Dave Syer
*
*
*/
public class CompositeItemProcessListener<T, S> implements ItemProcessListener<T, S> {
@@ -31,7 +31,7 @@ public class CompositeItemProcessListener<T, S> implements ItemProcessListener<T
/**
* Public setter for the listeners.
*
*
* @param itemReadListeners
*/
public void setListeners(List<? extends ItemProcessListener<? super T, ? super S>> itemReadListeners) {
@@ -40,7 +40,7 @@ public class CompositeItemProcessListener<T, S> implements ItemProcessListener<T
/**
* Register additional listener.
*
*
* @param itemReaderListener
*/
public void register(ItemProcessListener<? super T, ? super S> itemReaderListener) {
@@ -53,7 +53,7 @@ public class CompositeItemProcessListener<T, S> implements ItemProcessListener<T
* @see org.springframework.batch.core.ItemProcessListener#afterProcess(java.lang.Object,
* java.lang.Object)
*/
@Override
@Override
public void afterProcess(T item, S result) {
for (Iterator<ItemProcessListener<? super T, ? super S>> iterator = listeners.reverse(); iterator.hasNext();) {
ItemProcessListener<? super T, ? super S> listener = iterator.next();
@@ -66,7 +66,7 @@ public class CompositeItemProcessListener<T, S> implements ItemProcessListener<T
* that implement {@link Ordered}.
* @see org.springframework.batch.core.ItemProcessListener#beforeProcess(java.lang.Object)
*/
@Override
@Override
public void beforeProcess(T item) {
for (Iterator<ItemProcessListener<? super T, ? super S>> iterator = listeners.iterator(); iterator.hasNext();) {
ItemProcessListener<? super T, ? super S> listener = iterator.next();
@@ -80,7 +80,7 @@ public class CompositeItemProcessListener<T, S> implements ItemProcessListener<T
* @see org.springframework.batch.core.ItemProcessListener#onProcessError(java.lang.Object,
* java.lang.Exception)
*/
@Override
@Override
public void onProcessError(T item, Exception e) {
for (Iterator<ItemProcessListener<? super T, ? super S>> iterator = listeners.reverse(); iterator.hasNext();) {
ItemProcessListener<? super T, ? super S> listener = iterator.next();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ import org.springframework.core.Ordered;
/**
* @author Lucas Ward
* @author Dave Syer
*
*
*/
public class CompositeItemReadListener<T> implements ItemReadListener<T> {
@@ -32,7 +32,7 @@ public class CompositeItemReadListener<T> implements ItemReadListener<T> {
/**
* Public setter for the listeners.
*
*
* @param itemReadListeners
*/
public void setListeners(List<? extends ItemReadListener<? super T>> itemReadListeners) {
@@ -41,7 +41,7 @@ public class CompositeItemReadListener<T> implements ItemReadListener<T> {
/**
* Register additional listener.
*
*
* @param itemReaderListener
*/
public void register(ItemReadListener<? super T> itemReaderListener) {
@@ -53,7 +53,7 @@ public class CompositeItemReadListener<T> implements ItemReadListener<T> {
* prioritising those that implement {@link Ordered}.
* @see org.springframework.batch.core.ItemReadListener#afterRead(java.lang.Object)
*/
@Override
@Override
public void afterRead(T item) {
for (Iterator<ItemReadListener<? super T>> iterator = listeners.reverse(); iterator.hasNext();) {
ItemReadListener<? super T> listener = iterator.next();
@@ -66,7 +66,7 @@ public class CompositeItemReadListener<T> implements ItemReadListener<T> {
* that implement {@link Ordered}.
* @see org.springframework.batch.core.ItemReadListener#beforeRead()
*/
@Override
@Override
public void beforeRead() {
for (Iterator<ItemReadListener<? super T>> iterator = listeners.iterator(); iterator.hasNext();) {
ItemReadListener<? super T> listener = iterator.next();
@@ -79,7 +79,7 @@ public class CompositeItemReadListener<T> implements ItemReadListener<T> {
* prioritising those that implement {@link Ordered}.
* @see org.springframework.batch.core.ItemReadListener#onReadError(java.lang.Exception)
*/
@Override
@Override
public void onReadError(Exception ex) {
for (Iterator<ItemReadListener<? super T>> iterator = listeners.iterator(); iterator.hasNext();) {
ItemReadListener<? super T> listener = iterator.next();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ import org.springframework.core.Ordered;
/**
* @author Lucas Ward
* @author Dave Syer
*
*
*/
public class CompositeItemWriteListener<S> implements ItemWriteListener<S> {
@@ -32,7 +32,7 @@ public class CompositeItemWriteListener<S> implements ItemWriteListener<S> {
/**
* Public setter for the listeners.
*
*
* @param itemWriteListeners
*/
public void setListeners(List<? extends ItemWriteListener<? super S>> itemWriteListeners) {
@@ -41,7 +41,7 @@ public class CompositeItemWriteListener<S> implements ItemWriteListener<S> {
/**
* Register additional listener.
*
*
* @param itemWriteListener
*/
public void register(ItemWriteListener<? super S> itemWriteListener) {
@@ -53,7 +53,7 @@ public class CompositeItemWriteListener<S> implements ItemWriteListener<S> {
* prioritising those that implement {@link Ordered}.
* @see ItemWriteListener#afterWrite(java.util.List)
*/
@Override
@Override
public void afterWrite(List<? extends S> items) {
for (Iterator<ItemWriteListener<? super S>> iterator = listeners.reverse(); iterator.hasNext();) {
ItemWriteListener<? super S> listener = iterator.next();
@@ -66,7 +66,7 @@ public class CompositeItemWriteListener<S> implements ItemWriteListener<S> {
* that implement {@link Ordered}.
* @see ItemWriteListener#beforeWrite(List)
*/
@Override
@Override
public void beforeWrite(List<? extends S> items) {
for (Iterator<ItemWriteListener<? super S>> iterator = listeners.iterator(); iterator.hasNext();) {
ItemWriteListener<? super S> listener = iterator.next();
@@ -79,7 +79,7 @@ public class CompositeItemWriteListener<S> implements ItemWriteListener<S> {
* prioritising those that implement {@link Ordered}.
* @see ItemWriteListener#onWriteError(Exception, List)
*/
@Override
@Override
public void onWriteError(Exception ex, List<? extends S> items) {
for (Iterator<ItemWriteListener<? super S>> iterator = listeners.reverse(); iterator.hasNext();) {
ItemWriteListener<? super S> listener = iterator.next();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ import org.springframework.core.Ordered;
/**
* @author Dave Syer
*
*
*/
public class CompositeJobExecutionListener implements JobExecutionListener {
@@ -32,7 +32,7 @@ public class CompositeJobExecutionListener implements JobExecutionListener {
/**
* Public setter for the listeners.
*
*
* @param listeners
*/
public void setListeners(List<? extends JobExecutionListener> listeners) {
@@ -41,7 +41,7 @@ public class CompositeJobExecutionListener implements JobExecutionListener {
/**
* Register additional listener.
*
*
* @param jobExecutionListener
*/
public void register(JobExecutionListener jobExecutionListener) {
@@ -53,7 +53,7 @@ public class CompositeJobExecutionListener implements JobExecutionListener {
* prioritising those that implement {@link Ordered}.
* @see org.springframework.batch.core.JobExecutionListener#afterJob(org.springframework.batch.core.JobExecution)
*/
@Override
@Override
public void afterJob(JobExecution jobExecution) {
for (Iterator<JobExecutionListener> iterator = listeners.reverse(); iterator.hasNext();) {
JobExecutionListener listener = iterator.next();
@@ -66,7 +66,7 @@ public class CompositeJobExecutionListener implements JobExecutionListener {
* that implement {@link Ordered}.
* @see org.springframework.batch.core.JobExecutionListener#beforeJob(org.springframework.batch.core.JobExecution)
*/
@Override
@Override
public void beforeJob(JobExecution jobExecution) {
for (Iterator<JobExecutionListener> iterator = listeners.iterator(); iterator.hasNext();) {
JobExecutionListener listener = iterator.next();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@ import org.springframework.core.Ordered;
/**
* @author Dave Syer
*
*
*/
public class CompositeSkipListener<T,S> implements SkipListener<T,S> {
@@ -31,7 +31,7 @@ public class CompositeSkipListener<T,S> implements SkipListener<T,S> {
/**
* Public setter for the listeners.
*
*
* @param listeners
*/
public void setListeners(List<? extends SkipListener<? super T,? super S>> listeners) {
@@ -40,7 +40,7 @@ public class CompositeSkipListener<T,S> implements SkipListener<T,S> {
/**
* Register additional listener.
*
*
* @param listener
*/
public void register(SkipListener<? super T,? super S> listener) {
@@ -52,7 +52,7 @@ public class CompositeSkipListener<T,S> implements SkipListener<T,S> {
* that implement {@link Ordered}.
* @see org.springframework.batch.core.SkipListener#onSkipInRead(java.lang.Throwable)
*/
@Override
@Override
public void onSkipInRead(Throwable t) {
for (Iterator<SkipListener<? super T,? super S>> iterator = listeners.iterator(); iterator.hasNext();) {
SkipListener<? super T,? super S> listener = iterator.next();
@@ -66,7 +66,7 @@ public class CompositeSkipListener<T,S> implements SkipListener<T,S> {
* @see org.springframework.batch.core.SkipListener#onSkipInWrite(java.lang.Object,
* java.lang.Throwable)
*/
@Override
@Override
public void onSkipInWrite(S item, Throwable t) {
for (Iterator<SkipListener<? super T,? super S>> iterator = listeners.iterator(); iterator.hasNext();) {
SkipListener<? super T,? super S> listener = iterator.next();
@@ -80,7 +80,7 @@ public class CompositeSkipListener<T,S> implements SkipListener<T,S> {
* @see org.springframework.batch.core.SkipListener#onSkipInWrite(java.lang.Object,
* java.lang.Throwable)
*/
@Override
@Override
public void onSkipInProcess(T item, Throwable t) {
for (Iterator<SkipListener<? super T,? super S>> iterator = listeners.iterator(); iterator.hasNext();) {
SkipListener<? super T,? super S> listener = iterator.next();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import org.springframework.core.Ordered;
/**
* @author Lucas Ward
* @author Dave Syer
*
*
*/
public class CompositeStepExecutionListener implements StepExecutionListener {
@@ -34,7 +34,7 @@ public class CompositeStepExecutionListener implements StepExecutionListener {
/**
* Public setter for the listeners.
*
*
* @param listeners
*/
public void setListeners(StepExecutionListener[] listeners) {
@@ -43,7 +43,7 @@ public class CompositeStepExecutionListener implements StepExecutionListener {
/**
* Register additional listener.
*
*
* @param stepExecutionListener
*/
public void register(StepExecutionListener stepExecutionListener) {
@@ -52,10 +52,10 @@ public class CompositeStepExecutionListener implements StepExecutionListener {
/**
* Call the registered listeners in reverse order, respecting and
* prioritising those that implement {@link Ordered}.
* prioritizing those that implement {@link Ordered}.
* @see org.springframework.batch.core.StepExecutionListener#afterStep(StepExecution)
*/
@Override
@Override
public ExitStatus afterStep(StepExecution stepExecution) {
ExitStatus status = null;
for (Iterator<StepExecutionListener> iterator = list.reverse(); iterator.hasNext();) {
@@ -67,11 +67,11 @@ public class CompositeStepExecutionListener implements StepExecutionListener {
}
/**
* Call the registered listeners in order, respecting and prioritising those
* Call the registered listeners in order, respecting and prioritizing those
* that implement {@link Ordered}.
* @see org.springframework.batch.core.StepExecutionListener#beforeStep(StepExecution)
*/
@Override
@Override
public void beforeStep(StepExecution stepExecution) {
for (Iterator<StepExecutionListener> iterator = list.iterator(); iterator.hasNext();) {
StepExecutionListener listener = iterator.next();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,12 +29,12 @@ import org.springframework.util.Assert;
* {@link ExecutionContext} to the {@link Job} {@link ExecutionContext} at the
* end of a step. A list of keys should be provided that correspond to the items
* in the {@link Step} {@link ExecutionContext} that should be promoted.
*
*
* Additionally, an optional list of statuses can be set to indicate for which
* exit status codes the promotion should occur. These statuses will be checked
* using the {@link PatternMatcher}, so wildcards are allowed. By default,
* promotion will only occur for steps with an exit code of "COMPLETED".
*
*
* @author Dan Garrette
* @since 2.0
*/
@@ -46,7 +46,7 @@ public class ExecutionContextPromotionListener extends StepExecutionListenerSupp
private boolean strict = false;
@Override
@Override
public ExitStatus afterStep(StepExecution stepExecution) {
ExecutionContext stepContext = stepExecution.getExecutionContext();
ExecutionContext jobContext = stepExecution.getJobExecution().getExecutionContext();
@@ -60,7 +60,7 @@ public class ExecutionContextPromotionListener extends StepExecutionListenerSupp
if (strict) {
throw new IllegalArgumentException("The key [" + key
+ "] was not found in the Step's ExecutionContext.");
}
}
}
}
break;
@@ -70,7 +70,7 @@ public class ExecutionContextPromotionListener extends StepExecutionListenerSupp
return null;
}
@Override
@Override
public void afterPropertiesSet() throws Exception {
Assert.notNull(this.keys, "The 'keys' property must be provided");
Assert.notEmpty(this.keys, "The 'keys' property must not be empty");
@@ -98,7 +98,7 @@ public class ExecutionContextPromotionListener extends StepExecutionListenerSupp
/**
* If set to TRUE, the listener will throw an exception if any 'key' is not
* found in the Step {@link ExecutionContext}. FALSE by default.
*
*
* @param strict
*/
public void setStrict(boolean strict) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2008 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,93 +26,93 @@ import org.springframework.batch.core.ItemWriteListener;
* {@link ItemProcessListener}, and {@link ItemWriteListener} interfaces. All
* are implemented, since it is very common that all may need to be implemented
* at once.
*
*
* @author Lucas Ward
*
*
*/
public class ItemListenerSupport<I, O> implements ItemReadListener<I>, ItemProcessListener<I, O>, ItemWriteListener<O> {
/*
* (non-Javadoc)
*
*
* @see org.springframework.batch.core.domain.ItemReadListener#afterRead(java.lang.Object)
*/
@Override
@Override
public void afterRead(I item) {
}
/*
* (non-Javadoc)
*
*
* @see org.springframework.batch.core.domain.ItemReadListener#beforeRead()
*/
@Override
@Override
public void beforeRead() {
}
/*
* (non-Javadoc)
*
*
* @see org.springframework.batch.core.domain.ItemReadListener#onReadError(java.lang.Exception)
*/
@Override
@Override
public void onReadError(Exception ex) {
}
/*
* (non-Javadoc)
*
*
* @see org.springframework.batch.core.ItemProcessListener#afterProcess(java.lang.Object,
* java.lang.Object)
*/
@Override
@Override
public void afterProcess(I item, O result) {
}
/*
* (non-Javadoc)
*
*
* @see org.springframework.batch.core.ItemProcessListener#beforeProcess(java.lang.Object)
*/
@Override
@Override
public void beforeProcess(I item) {
}
/*
* (non-Javadoc)
*
*
* @see org.springframework.batch.core.ItemProcessListener#onProcessError(java.lang.Object,
* java.lang.Exception)
*/
@Override
@Override
public void onProcessError(I item, Exception e) {
}
/*
* (non-Javadoc)
*
*
* @see org.springframework.batch.core.domain.ItemWriteListener#afterWrite()
*/
@Override
@Override
public void afterWrite(List<? extends O> item) {
}
/*
* (non-Javadoc)
*
*
* @see org.springframework.batch.core.domain.ItemWriteListener#beforeWrite(java.lang.Object)
*/
@Override
@Override
public void beforeWrite(List<? extends O> item) {
}
/*
* (non-Javadoc)
*
*
* @see org.springframework.batch.core.domain.ItemWriteListener#onWriteError(java.lang.Exception,
* java.lang.Object)
*/
@Override
@Override
public void onWriteError(Exception ex, List<? extends O> item) {
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,14 +27,14 @@ public class JobExecutionListenerSupport implements JobExecutionListener {
/* (non-Javadoc)
* @see org.springframework.batch.core.domain.JobListener#afterJob()
*/
@Override
@Override
public void afterJob(JobExecution jobExecution) {
}
/* (non-Javadoc)
* @see org.springframework.batch.core.domain.JobListener#beforeJob(org.springframework.batch.core.domain.JobExecution)
*/
@Override
@Override
public void beforeJob(JobExecution jobExecution) {
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ import org.springframework.batch.core.JobExecutionListener;
/**
* This {@link AbstractListenerFactoryBean} implementation is used to create a
* {@link JobExecutionListener}.
*
*
* @author Lucas Ward
* @author Dan Garrette
* @since 2.0
@@ -29,22 +29,22 @@ import org.springframework.batch.core.JobExecutionListener;
*/
public class JobListenerFactoryBean extends AbstractListenerFactoryBean {
@Override
@Override
protected ListenerMetaData getMetaDataFromPropertyName(String propertyName) {
return JobListenerMetaData.fromPropertyName(propertyName);
}
@Override
@Override
protected ListenerMetaData[] getMetaDataValues() {
return JobListenerMetaData.values();
}
@Override
@Override
protected Class<?> getDefaultListenerClass() {
return JobExecutionListener.class;
}
@Override
@Override
public Class<?> getObjectType() {
return JobExecutionListener.class;
}
@@ -52,7 +52,7 @@ public class JobListenerFactoryBean extends AbstractListenerFactoryBean {
/**
* Convenience method to wrap any object and expose the appropriate
* {@link JobExecutionListener} interfaces.
*
*
* @param delegate a delegate object
* @return a JobListener instance constructed from the delegate
*/
@@ -65,7 +65,7 @@ public class JobListenerFactoryBean extends AbstractListenerFactoryBean {
/**
* Convenience method to check whether the given object is or can be made
* into a {@link JobExecutionListener}.
*
*
* @param delegate the object to check
* @return true if the delegate is an instance of
* {@link JobExecutionListener}, or contains the marker annotations

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ import org.springframework.batch.core.annotation.BeforeJob;
/**
* Enumeration for {@link JobExecutionListener} meta data, which ties together the names
* of methods, their interfaces, annotation, and expected arguments.
*
*
* @author Lucas Ward
* @since 2.0
* @see JobListenerFactoryBean
@@ -36,19 +36,19 @@ public enum JobListenerMetaData implements ListenerMetaData {
BEFORE_JOB("beforeJob", "before-job-method", BeforeJob.class),
AFTER_JOB("afterJob", "after-job-method", AfterJob.class);
private final String methodName;
private final String propertyName;
private final Class<? extends Annotation> annotation;
private static final Map<String, JobListenerMetaData> propertyMap;
JobListenerMetaData(String methodName, String propertyName, Class<? extends Annotation> annotation) {
this.methodName = methodName;
this.propertyName = propertyName;
this.annotation = annotation;
}
static{
propertyMap = new HashMap<String, JobListenerMetaData>();
for(JobListenerMetaData metaData : values()){
@@ -56,34 +56,34 @@ public enum JobListenerMetaData implements ListenerMetaData {
}
}
@Override
@Override
public String getMethodName() {
return methodName;
}
@Override
@Override
public Class<? extends Annotation> getAnnotation() {
return annotation;
}
@Override
@Override
public Class<?> getListenerInterface() {
return JobExecutionListener.class;
}
@Override
@Override
public String getPropertyName() {
return propertyName;
}
@Override
@Override
public Class<?>[] getParamTypes() {
return new Class<?>[]{ JobExecution.class };
}
/**
* Return the relevant meta data for the provided property name.
*
*
* @param propertyName
* @return meta data with supplied property name, null if none exists.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@ import org.springframework.batch.support.MethodInvoker;
* that isn't void is
* {@link StepExecutionListener#afterStep(org.springframework.batch.core.StepExecution)}
* , which returns ExitStatus.
*
*
* @author Lucas Ward
* @since 2.0
* @see MethodInvoker
@@ -51,7 +51,7 @@ public class MethodInvokerMethodInterceptor implements MethodInterceptor {
this.invokerMap = invokerMap;
}
@Override
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
String methodName = invocation.getMethod().getName();
@@ -92,7 +92,7 @@ public class MethodInvokerMethodInterceptor implements MethodInterceptor {
MethodInvokerMethodInterceptor other = (MethodInvokerMethodInterceptor) obj;
return invokerMap.equals(other.invokerMap);
}
/**
* {@inheritDoc}
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2012 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ import org.springframework.batch.item.ItemStream;
* @author Michael Minella
*/
public class MulticasterBatchListener<T, S> implements StepExecutionListener, ChunkListener, ItemReadListener<T>,
ItemProcessListener<T, S>, ItemWriteListener<S>, SkipListener<T, S> {
ItemProcessListener<T, S>, ItemWriteListener<S>, SkipListener<T, S> {
private CompositeStepExecutionListener stepListener = new CompositeStepExecutionListener();
@@ -106,7 +106,7 @@ public class MulticasterBatchListener<T, S> implements StepExecutionListener, Ch
* @see org.springframework.batch.core.listener.CompositeItemProcessListener#afterProcess(java.lang.Object,
* java.lang.Object)
*/
@Override
@Override
public void afterProcess(T item, S result) {
try {
itemProcessListener.afterProcess(item, result);
@@ -120,7 +120,7 @@ public class MulticasterBatchListener<T, S> implements StepExecutionListener, Ch
* @param item
* @see org.springframework.batch.core.listener.CompositeItemProcessListener#beforeProcess(java.lang.Object)
*/
@Override
@Override
public void beforeProcess(T item) {
try {
itemProcessListener.beforeProcess(item);
@@ -136,7 +136,7 @@ public class MulticasterBatchListener<T, S> implements StepExecutionListener, Ch
* @see org.springframework.batch.core.listener.CompositeItemProcessListener#onProcessError(java.lang.Object,
* java.lang.Exception)
*/
@Override
@Override
public void onProcessError(T item, Exception ex) {
try {
itemProcessListener.onProcessError(item, ex);
@@ -149,7 +149,7 @@ public class MulticasterBatchListener<T, S> implements StepExecutionListener, Ch
/**
* @see org.springframework.batch.core.listener.CompositeStepExecutionListener#afterStep(StepExecution)
*/
@Override
@Override
public ExitStatus afterStep(StepExecution stepExecution) {
try {
return stepListener.afterStep(stepExecution);
@@ -163,7 +163,7 @@ public class MulticasterBatchListener<T, S> implements StepExecutionListener, Ch
* @param stepExecution
* @see org.springframework.batch.core.listener.CompositeStepExecutionListener#beforeStep(org.springframework.batch.core.StepExecution)
*/
@Override
@Override
public void beforeStep(StepExecution stepExecution) {
try {
stepListener.beforeStep(stepExecution);
@@ -177,7 +177,7 @@ public class MulticasterBatchListener<T, S> implements StepExecutionListener, Ch
*
* @see org.springframework.batch.core.listener.CompositeChunkListener#afterChunk()
*/
@Override
@Override
public void afterChunk() {
try {
chunkListener.afterChunk();
@@ -191,7 +191,7 @@ public class MulticasterBatchListener<T, S> implements StepExecutionListener, Ch
*
* @see org.springframework.batch.core.listener.CompositeChunkListener#beforeChunk()
*/
@Override
@Override
public void beforeChunk() {
try {
chunkListener.beforeChunk();
@@ -205,7 +205,7 @@ public class MulticasterBatchListener<T, S> implements StepExecutionListener, Ch
* @param item
* @see org.springframework.batch.core.listener.CompositeItemReadListener#afterRead(java.lang.Object)
*/
@Override
@Override
public void afterRead(T item) {
try {
itemReadListener.afterRead(item);
@@ -219,7 +219,7 @@ public class MulticasterBatchListener<T, S> implements StepExecutionListener, Ch
*
* @see org.springframework.batch.core.listener.CompositeItemReadListener#beforeRead()
*/
@Override
@Override
public void beforeRead() {
try {
itemReadListener.beforeRead();
@@ -233,7 +233,7 @@ public class MulticasterBatchListener<T, S> implements StepExecutionListener, Ch
* @param ex
* @see org.springframework.batch.core.listener.CompositeItemReadListener#onReadError(java.lang.Exception)
*/
@Override
@Override
public void onReadError(Exception ex) {
try {
itemReadListener.onReadError(ex);
@@ -247,7 +247,7 @@ public class MulticasterBatchListener<T, S> implements StepExecutionListener, Ch
*
* @see ItemWriteListener#afterWrite(List)
*/
@Override
@Override
public void afterWrite(List<? extends S> items) {
try {
itemWriteListener.afterWrite(items);
@@ -261,7 +261,7 @@ public class MulticasterBatchListener<T, S> implements StepExecutionListener, Ch
* @param items
* @see ItemWriteListener#beforeWrite(List)
*/
@Override
@Override
public void beforeWrite(List<? extends S> items) {
try {
itemWriteListener.beforeWrite(items);
@@ -276,7 +276,7 @@ public class MulticasterBatchListener<T, S> implements StepExecutionListener, Ch
* @param items
* @see ItemWriteListener#onWriteError(Exception, List)
*/
@Override
@Override
public void onWriteError(Exception ex, List<? extends S> items) {
try {
itemWriteListener.onWriteError(ex, items);
@@ -290,7 +290,7 @@ public class MulticasterBatchListener<T, S> implements StepExecutionListener, Ch
* @param t
* @see org.springframework.batch.core.listener.CompositeSkipListener#onSkipInRead(java.lang.Throwable)
*/
@Override
@Override
public void onSkipInRead(Throwable t) {
skipListener.onSkipInRead(t);
}
@@ -301,7 +301,7 @@ public class MulticasterBatchListener<T, S> implements StepExecutionListener, Ch
* @see org.springframework.batch.core.listener.CompositeSkipListener#onSkipInWrite(java.lang.Object,
* java.lang.Throwable)
*/
@Override
@Override
public void onSkipInWrite(S item, Throwable t) {
skipListener.onSkipInWrite(item, t);
}
@@ -312,7 +312,7 @@ public class MulticasterBatchListener<T, S> implements StepExecutionListener, Ch
* @see org.springframework.batch.core.listener.CompositeSkipListener#onSkipInProcess(Object,
* Throwable)
*/
@Override
@Override
public void onSkipInProcess(T item, Throwable t) {
skipListener.onSkipInProcess(item, t);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2008 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ import org.springframework.batch.core.SkipListener;
/**
* Basic no-op implementations of all {@link SkipListener} implementations.
*
*
* @author Dave Syer
*
*/
@@ -28,21 +28,21 @@ public class SkipListenerSupport<T,S> implements SkipListener<T,S> {
/* (non-Javadoc)
* @see org.springframework.batch.core.SkipListener#onSkipInRead(java.lang.Throwable)
*/
@Override
@Override
public void onSkipInRead(Throwable t) {
}
/* (non-Javadoc)
* @see org.springframework.batch.core.SkipListener#onSkipInWrite(java.lang.Object, java.lang.Throwable)
*/
@Override
@Override
public void onSkipInWrite(S item, Throwable t) {
}
/* (non-Javadoc)
* @see org.springframework.batch.core.SkipListener#onSkipInProcess(java.lang.Object, java.lang.Throwable)
*/
@Override
@Override
public void onSkipInProcess(T item, Throwable t) {
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ public class StepExecutionListenerSupport implements StepExecutionListener {
/* (non-Javadoc)
* @see org.springframework.batch.core.domain.StepListener#afterStep(StepExecution stepExecution)
*/
@Override
@Override
public ExitStatus afterStep(StepExecution stepExecution) {
return null;
}
@@ -36,7 +36,7 @@ public class StepExecutionListenerSupport implements StepExecutionListener {
/* (non-Javadoc)
* @see org.springframework.batch.core.domain.StepListener#open(org.springframework.batch.item.ExecutionContext)
*/
@Override
@Override
public void beforeStep(StepExecution stepExecution) {
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ import org.springframework.batch.core.StepListener;
/**
* This {@link AbstractListenerFactoryBean} implementation is used to create a
* {@link StepListener}.
*
*
* @author Lucas Ward
* @author Dan Garrette
* @since 2.0
@@ -29,22 +29,22 @@ import org.springframework.batch.core.StepListener;
*/
public class StepListenerFactoryBean extends AbstractListenerFactoryBean {
@Override
@Override
protected ListenerMetaData getMetaDataFromPropertyName(String propertyName) {
return StepListenerMetaData.fromPropertyName(propertyName);
}
@Override
@Override
protected ListenerMetaData[] getMetaDataValues() {
return StepListenerMetaData.values();
}
@Override
@Override
protected Class<?> getDefaultListenerClass() {
return StepListener.class;
}
@Override
@Override
@SuppressWarnings("rawtypes")
public Class getObjectType() {
return StepListener.class;
@@ -53,7 +53,7 @@ public class StepListenerFactoryBean extends AbstractListenerFactoryBean {
/**
* Convenience method to wrap any object and expose the appropriate
* {@link StepListener} interfaces.
*
*
* @param delegate a delegate object
* @return a StepListener instance constructed from the delegate
*/
@@ -66,7 +66,7 @@ public class StepListenerFactoryBean extends AbstractListenerFactoryBean {
/**
* Convenience method to check whether the given object is or can be made
* into a {@link StepListener}.
*
*
* @param delegate the object to check
* @return true if the delegate is an instance of any of the
* {@link StepListener} interfaces, or contains the marker

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,7 +48,7 @@ import org.springframework.batch.core.annotation.OnWriteError;
/**
* Enumeration for {@link StepListener} meta data, which ties together the names
* of methods, their interfaces, annotation, and expected arguments.
*
*
* @author Lucas Ward
* @since 2.0
* @see StepListenerFactoryBean
@@ -71,14 +71,14 @@ public enum StepListenerMetaData implements ListenerMetaData {
ON_SKIP_IN_READ("onSkipInRead", "on-skip-in-read-method", OnSkipInRead.class, SkipListener.class, Throwable.class),
ON_SKIP_IN_PROCESS("onSkipInProcess", "on-skip-in-process-method", OnSkipInProcess.class, SkipListener.class, Object.class, Throwable.class),
ON_SKIP_IN_WRITE("onSkipInWrite", "on-skip-in-write-method", OnSkipInWrite.class, SkipListener.class, Object.class, Throwable.class);
private final String methodName;
private final String propertyName;
private final Class<? extends Annotation> annotation;
private final Class<? extends StepListener> listenerInterface;
private final Class<?>[] paramTypes;
private static final Map<String, StepListenerMetaData> propertyMap;
StepListenerMetaData(String methodName, String propertyName, Class<? extends Annotation> annotation, Class<? extends StepListener> listenerInterface, Class<?>... paramTypes) {
this.methodName = methodName;
this.propertyName = propertyName;
@@ -86,7 +86,7 @@ public enum StepListenerMetaData implements ListenerMetaData {
this.listenerInterface = listenerInterface;
this.paramTypes = paramTypes;
}
static{
propertyMap = new HashMap<String, StepListenerMetaData>();
for(StepListenerMetaData metaData : values()){
@@ -94,41 +94,41 @@ public enum StepListenerMetaData implements ListenerMetaData {
}
}
@Override
@Override
public String getMethodName() {
return methodName;
}
@Override
@Override
public Class<? extends Annotation> getAnnotation() {
return annotation;
}
@Override
@Override
public Class<?> getListenerInterface() {
return listenerInterface;
}
@Override
@Override
public Class<?>[] getParamTypes() {
return paramTypes;
}
@Override
@Override
public String getPropertyName() {
return propertyName;
}
/**
* Return the relevant meta data for the provided property name.
*
*
* @param propertyName
* @return meta data with supplied property name, null if none exists.
*/
public static StepListenerMetaData fromPropertyName(String propertyName){
return propertyMap.get(propertyName);
}
public static ListenerMetaData[] itemListenerMetaData() {
return new ListenerMetaData[] {BEFORE_WRITE, AFTER_WRITE, ON_WRITE_ERROR, BEFORE_PROCESS, AFTER_PROCESS, ON_PROCESS_ERROR, BEFORE_READ, AFTER_READ, ON_READ_ERROR, ON_SKIP_IN_WRITE, ON_SKIP_IN_PROCESS, ON_SKIP_IN_READ};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2008 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,17 +29,17 @@ import org.springframework.batch.core.StepListener;
/**
* Basic no-op implementations of all {@link StepListener} interfaces.
*
*
* @author Lucas Ward
* @author Robert Kasanicky
*/
public class StepListenerSupport<T,S> implements StepExecutionListener, ChunkListener,
ItemReadListener<T>, ItemProcessListener<T,S>, ItemWriteListener<S>, SkipListener<T, S> {
ItemReadListener<T>, ItemProcessListener<T,S>, ItemWriteListener<S>, SkipListener<T, S> {
/* (non-Javadoc)
* @see org.springframework.batch.core.StepExecutionListener#afterStep(org.springframework.batch.core.StepExecution)
*/
@Override
@Override
public ExitStatus afterStep(StepExecution stepExecution) {
return null;
}
@@ -47,105 +47,105 @@ public class StepListenerSupport<T,S> implements StepExecutionListener, ChunkLis
/* (non-Javadoc)
* @see org.springframework.batch.core.StepExecutionListener#beforeStep(org.springframework.batch.core.StepExecution)
*/
@Override
@Override
public void beforeStep(StepExecution stepExecution) {
}
/* (non-Javadoc)
* @see org.springframework.batch.core.domain.ChunkListener#afterChunk()
*/
@Override
@Override
public void afterChunk() {
}
/* (non-Javadoc)
* @see org.springframework.batch.core.domain.ChunkListener#beforeChunk()
*/
@Override
@Override
public void beforeChunk() {
}
/* (non-Javadoc)
* @see org.springframework.batch.core.domain.ItemReadListener#afterRead(java.lang.Object)
*/
@Override
@Override
public void afterRead(T item) {
}
/* (non-Javadoc)
* @see org.springframework.batch.core.domain.ItemReadListener#beforeRead()
*/
@Override
@Override
public void beforeRead() {
}
/* (non-Javadoc)
* @see org.springframework.batch.core.domain.ItemReadListener#onReadError(java.lang.Exception)
*/
@Override
@Override
public void onReadError(Exception ex) {
}
/* (non-Javadoc)
* @see org.springframework.batch.core.ItemWriteListener#afterWrite(java.util.List)
*/
@Override
@Override
public void afterWrite(List<? extends S> items) {
}
/* (non-Javadoc)
* @see org.springframework.batch.core.ItemWriteListener#beforeWrite(java.util.List)
*/
@Override
@Override
public void beforeWrite(List<? extends S> items) {
}
/* (non-Javadoc)
* @see org.springframework.batch.core.ItemWriteListener#onWriteError(java.lang.Exception, java.util.List)
*/
@Override
@Override
public void onWriteError(Exception exception, List<? extends S> items) {
}
/* (non-Javadoc)
* @see org.springframework.batch.core.ItemProcessListener#afterProcess(java.lang.Object, java.lang.Object)
*/
@Override
@Override
public void afterProcess(T item, S result) {
}
/* (non-Javadoc)
* @see org.springframework.batch.core.ItemProcessListener#beforeProcess(java.lang.Object)
*/
@Override
@Override
public void beforeProcess(T item) {
}
/* (non-Javadoc)
* @see org.springframework.batch.core.ItemProcessListener#onProcessError(java.lang.Object, java.lang.Exception)
*/
@Override
@Override
public void onProcessError(T item, Exception e) {
}
/* (non-Javadoc)
* @see org.springframework.batch.core.SkipListener#onSkipInProcess(java.lang.Object, java.lang.Throwable)
*/
@Override
@Override
public void onSkipInProcess(T item, Throwable t) {
}
/* (non-Javadoc)
* @see org.springframework.batch.core.SkipListener#onSkipInRead(java.lang.Throwable)
*/
@Override
@Override
public void onSkipInRead(Throwable t) {
}
/* (non-Javadoc)
* @see org.springframework.batch.core.SkipListener#onSkipInWrite(java.lang.Object, java.lang.Throwable)
*/
@Override
@Override
public void onSkipInWrite(S item, Throwable t) {
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2012 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,43 +34,43 @@ import org.springframework.batch.core.partition.StepExecutionSplitter;
*/
public abstract class AbstractPartitionHandler implements PartitionHandler {
private int gridSize = 1;
private int gridSize = 1;
/**
* Executes the specified {@link StepExecution} instances and returns an updated
* view of them. Throws an {@link Exception} if anything goes wrong.
*
* @param masterStepExecution the whole partition execution
* @param partitionStepExecutions the {@link StepExecution} instances to execute
* @return an updated view of these completed {@link StepExecution} instances
* @throws Exception if anything goes wrong. This allows implementations to
* be liberal and rely on the caller to translate an exception into a step
* failure as necessary.
*/
protected abstract Set<StepExecution> doHandle(StepExecution masterStepExecution,
Set<StepExecution> partitionStepExecutions) throws Exception;
/**
* Executes the specified {@link StepExecution} instances and returns an updated
* view of them. Throws an {@link Exception} if anything goes wrong.
*
* @param masterStepExecution the whole partition execution
* @param partitionStepExecutions the {@link StepExecution} instances to execute
* @return an updated view of these completed {@link StepExecution} instances
* @throws Exception if anything goes wrong. This allows implementations to
* be liberal and rely on the caller to translate an exception into a step
* failure as necessary.
*/
protected abstract Set<StepExecution> doHandle(StepExecution masterStepExecution,
Set<StepExecution> partitionStepExecutions) throws Exception;
/**
* @see PartitionHandler#handle(StepExecutionSplitter, StepExecution)
*/
@Override
public Collection<StepExecution> handle(final StepExecutionSplitter stepSplitter,
final StepExecution masterStepExecution) throws Exception {
final Set<StepExecution> stepExecutions = stepSplitter.split(masterStepExecution, gridSize);
@Override
public Collection<StepExecution> handle(final StepExecutionSplitter stepSplitter,
final StepExecution masterStepExecution) throws Exception {
final Set<StepExecution> stepExecutions = stepSplitter.split(masterStepExecution, gridSize);
return doHandle(masterStepExecution, stepExecutions);
}
return doHandle(masterStepExecution, stepExecutions);
}
/**
* Returns the number of step executions.
*
* @return the number of step executions
*/
public int getGridSize() {
return gridSize;
}
/**
* Returns the number of step executions.
*
* @return the number of step executions
*/
public int getGridSize() {
return gridSize;
}
/**
/**
* Passed to the {@link StepExecutionSplitter} in the
* {@link #handle(StepExecutionSplitter, StepExecution)} method, instructing
* it how many {@link StepExecution} instances are required, ideally. The
@@ -79,9 +79,9 @@ public abstract class AbstractPartitionHandler implements PartitionHandler {
*
* @param gridSize the number of step executions that will be created
*/
public void setGridSize(int gridSize) {
this.gridSize = gridSize;
}
public void setGridSize(int gridSize) {
this.gridSize = gridSize;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import org.springframework.util.Assert;
/**
* Convenience class for aggregating a set of {@link StepExecution} instances
* into a single result.
*
*
* @author Dave Syer
* @since 2.1
*/
@@ -43,7 +43,7 @@ public class DefaultStepExecutionAggregator implements StepExecutionAggregator {
* </ul>
* @see StepExecutionAggregator #aggregate(StepExecution, Collection)
*/
@Override
@Override
public void aggregate(StepExecution result, Collection<StepExecution> executions) {
Assert.notNull(result, "To aggregate into a result it must be non-null.");
if (executions == null) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ import org.springframework.util.Assert;
* {@link ExecutionContext} per resource, and labels them as
* <code>{partition0, partition1, ..., partitionN}</code>. The grid size is
* ignored.
*
*
* @author Dave Syer
* @since 2.0
*/
@@ -65,10 +65,10 @@ public class MultiResourcePartitioner implements Partitioner {
/**
* Assign the filename of each of the injected resources to an
* {@link ExecutionContext}.
*
*
* @see Partitioner#partition(int)
*/
@Override
@Override
public Map<String, ExecutionContext> partition(int gridSize) {
Map<String, ExecutionContext> map = new HashMap<String, ExecutionContext>(gridSize);
int i = 0;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ import org.springframework.util.Assert;
/**
* Implementation of {@link Step} which partitions the execution and spreads the
* load using a {@link PartitionHandler}.
*
*
* @author Dave Syer
* @since 2.0
*/
@@ -46,7 +46,7 @@ public class PartitionStep extends AbstractStep {
/**
* A {@link PartitionHandler} which can send out step executions for remote
* processing and bring back the results.
*
*
* @param partitionHandler the {@link PartitionHandler} to set
*/
public void setPartitionHandler(PartitionHandler partitionHandler) {
@@ -57,7 +57,7 @@ public class PartitionStep extends AbstractStep {
* A {@link StepExecutionAggregator} that can aggregate step executions when
* they come back from the handler. Defaults to a
* {@link DefaultStepExecutionAggregator}.
*
*
* @param stepExecutionAggregator the {@link StepExecutionAggregator} to set
*/
public void setStepExecutionAggregator(StepExecutionAggregator stepExecutionAggregator) {
@@ -75,10 +75,10 @@ public class PartitionStep extends AbstractStep {
/**
* Assert that mandatory properties are set (stepExecutionSplitter,
* partitionHandler) and delegate top superclass.
*
*
* @see AbstractStep#afterPropertiesSet()
*/
@Override
@Override
public void afterPropertiesSet() throws Exception {
Assert.notNull(stepExecutionSplitter, "StepExecutionSplitter must be provided");
Assert.notNull(partitionHandler, "PartitionHandler must be provided");
@@ -93,9 +93,9 @@ public class PartitionStep extends AbstractStep {
* individual step executions and their input parameters (through
* {@link ExecutionContext}) for the partition elements are provided by the
* {@link StepExecutionSplitter}.
*
*
* @param stepExecution the master step execution for the partition
*
*
* @see Step#execute(StepExecution)
*/
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ import org.springframework.util.Assert;
* Convenience class for aggregating a set of {@link StepExecution} instances
* when the input comes from remote steps, so the data need to be refreshed from
* the repository.
*
*
* @author Dave Syer
* @since 2.1
*/
@@ -47,7 +47,7 @@ public class RemoteStepExecutionAggregator implements StepExecutionAggregator, I
/**
* 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) {
@@ -72,7 +72,7 @@ public class RemoteStepExecutionAggregator implements StepExecutionAggregator, I
/**
* @throws Exception if the job explorer is not provided
*/
@Override
@Override
public void afterPropertiesSet() throws Exception {
Assert.state(jobExplorer != null, "A JobExplorer must be provided");
}
@@ -81,10 +81,10 @@ public class RemoteStepExecutionAggregator implements StepExecutionAggregator, I
* 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
@Override
public void aggregate(StepExecution result, Collection<StepExecution> executions) {
Assert.notNull(result, "To aggregate into a result it must be non-null.");
if (executions == null) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import org.springframework.batch.item.ExecutionContext;
* of empty {@link ExecutionContext} instances, and labels them as
* <code>{partition0, partition1, ..., partitionN}</code>, where <code>N</code> is the grid
* size.
*
*
* @author Dave Syer
* @since 2.0
*/
@@ -34,7 +34,7 @@ public class SimplePartitioner implements Partitioner {
private static final String PARTITION_KEY = "partition";
@Override
@Override
public Map<String, ExecutionContext> partition(int gridSize) {
Map<String, ExecutionContext> map = new HashMap<String, ExecutionContext>(gridSize);
for (int i = 0; i < gridSize; i++) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +20,8 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import java.util.Set;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.JobExecution;
@@ -44,7 +44,7 @@ import org.springframework.util.Assert;
* base (name of the target step) plus a suffix taken from the
* {@link Partitioner} identifiers, separated by a colon, e.g.
* <code>{step1:partition0, step1:partition1, ...}</code>.
*
*
* @author Dave Syer
* @since 2.0
*/
@@ -69,7 +69,7 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi
/**
* Construct a {@link SimpleStepExecutionSplitter} from its mandatory
* properties.
*
*
* @param jobRepository the {@link JobRepository}
* @param allowStartIfComplete flag specifying preferences on restart
* @param stepName the target step name
@@ -86,13 +86,13 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi
/**
* Construct a {@link SimpleStepExecutionSplitter} from its mandatory
* properties.
*
*
* @param jobRepository the {@link JobRepository}
* @param step the target step (a local version of it), used to extract the
* name and allowStartIfComplete flags
* @param partitioner a {@link Partitioner} to use for generating input
* parameters
*
*
* @deprecated use {@link #SimpleStepExecutionSplitter(JobRepository, boolean, String, Partitioner)} instead
*/
@Deprecated
@@ -105,10 +105,10 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi
/**
* Check mandatory properties (step name, job repository and partitioner).
*
*
* @see InitializingBean#afterPropertiesSet()
*/
@Override
@Override
public void afterPropertiesSet() throws Exception {
Assert.state(jobRepository != null, "A JobRepository is required");
Assert.state(stepName != null, "A step name is required");
@@ -119,9 +119,9 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi
* Flag to indicate that the partition target step is allowed to start if an
* execution is complete. Defaults to the same value as the underlying step.
* Set this manually to override the underlying step properties.
*
*
* @see Step#isAllowStartIfComplete()
*
*
* @param allowStartIfComplete the value to set
*/
public void setAllowStartIfComplete(boolean allowStartIfComplete) {
@@ -131,7 +131,7 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi
/**
* The job repository that will be used to manage the persistence of the
* delegate step executions.
*
*
* @param jobRepository the JobRepository to set
*/
public void setJobRepository(JobRepository jobRepository) {
@@ -141,7 +141,7 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi
/**
* The {@link Partitioner} that will be used to generate step execution meta
* data for the target step.
*
*
* @param partitioner the partitioner to set
*/
public void setPartitioner(Partitioner partitioner) {
@@ -151,7 +151,7 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi
/**
* The name of the target step that will be executed across the partitions.
* Mandatory with no default.
*
*
* @param stepName the step name to set
*/
public void setStepName(String stepName) {
@@ -161,7 +161,7 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi
/**
* @see StepExecutionSplitter#getStepName()
*/
@Override
@Override
public String getStepName() {
return this.stepName;
}
@@ -169,7 +169,7 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi
/**
* @see StepExecutionSplitter#split(StepExecution, int)
*/
@Override
@Override
public Set<StepExecution> split(StepExecution stepExecution, int gridSize) throws JobExecutionException {
JobExecution jobExecution = stepExecution.getJobExecution();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2012 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -71,17 +71,17 @@ public class TaskExecutorPartitionHandler extends AbstractPartitionHandler imple
* {@link StepExecution}. This is a regular Spring Batch step, with all the
* business logic required to complete an execution based on the input
* parameters in its {@link StepExecution} context.
*
*
* @param step the {@link Step} instance to use to execute business logic
*/
@Required
public void setStep(Step step) {
this.step = step;
}
/**
* The step instance that will be executed in parallel by this handler.
*
*
* @return the step instance that will be used
* @see StepHolder#getStep()
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import org.springframework.util.StringUtils;
/**
* Encapsulates common functionality needed by JDBC batch metadata DAOs -
* provides jdbcTemplate for subclasses and handles table prefixes.
*
*
* @author Robert Kasanicky
*/
public abstract class AbstractJdbcBatchMetadataDao implements InitializingBean {
@@ -35,11 +35,11 @@ public abstract class AbstractJdbcBatchMetadataDao implements InitializingBean {
* Default value for the table prefix property.
*/
public static final String DEFAULT_TABLE_PREFIX = "BATCH_";
public static final int DEFAULT_EXIT_MESSAGE_LENGTH = 2500;
private String tablePrefix = DEFAULT_TABLE_PREFIX;
private int clobTypeToUse = Types.CLOB;
private JdbcOperations jdbcTemplate;
@@ -47,7 +47,7 @@ public abstract class AbstractJdbcBatchMetadataDao implements InitializingBean {
protected String getQuery(String base) {
return StringUtils.replace(base, "%PREFIX%", tablePrefix);
}
protected String getTablePrefix() {
return tablePrefix;
}
@@ -56,7 +56,7 @@ public abstract class AbstractJdbcBatchMetadataDao implements InitializingBean {
* Public setter for the table prefix property. This will be prefixed to all
* the table names before queries are executed. Defaults to
* {@link #DEFAULT_TABLE_PREFIX}.
*
*
* @param tablePrefix the tablePrefix to set
*/
public void setTablePrefix(String tablePrefix) {
@@ -70,7 +70,7 @@ public abstract class AbstractJdbcBatchMetadataDao implements InitializingBean {
protected JdbcOperations getJdbcTemplate() {
return jdbcTemplate;
}
public int getClobTypeToUse() {
return clobTypeToUse;
}
@@ -79,7 +79,7 @@ public abstract class AbstractJdbcBatchMetadataDao implements InitializingBean {
this.clobTypeToUse = clobTypeToUse;
}
@Override
@Override
public void afterPropertiesSet() throws Exception {
Assert.notNull(jdbcTemplate);
}

View File

@@ -1,5 +1,17 @@
/**
/*
* Copyright 2012-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.repository.dao;
@@ -22,6 +34,7 @@ import org.springframework.util.Assert;
* @author Michael Minella
* @since 2.2
*/
@SuppressWarnings("rawtypes")
public class DefaultExecutionContextSerializer implements ExecutionContextSerializer {
private Serializer serializer = new DefaultSerializer();
@@ -34,7 +47,7 @@ public class DefaultExecutionContextSerializer implements ExecutionContextSerial
* @param context
* @param out
*/
@Override
@Override
@SuppressWarnings("unchecked")
public void serialize(Object context, OutputStream out) throws IOException {
Assert.notNull(context);
@@ -49,7 +62,7 @@ public class DefaultExecutionContextSerializer implements ExecutionContextSerial
* @param inputStream
* @return the object serialized in the provided {@link InputStream}
*/
@Override
@Override
public Object deserialize(InputStream inputStream) throws IOException {
return deserializer.deserialize(inputStream);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2008 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -100,7 +100,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem
this.shortContextLength = shortContextLength;
}
@Override
@Override
public ExecutionContext getExecutionContext(JobExecution jobExecution) {
Long executionId = jobExecution.getId();
Assert.notNull(executionId, "ExecutionId must not be null.");
@@ -115,7 +115,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem
}
}
@Override
@Override
public ExecutionContext getExecutionContext(StepExecution stepExecution) {
Long executionId = stepExecution.getId();
Assert.notNull(executionId, "ExecutionId must not be null.");
@@ -130,7 +130,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem
}
}
@Override
@Override
public void updateExecutionContext(final JobExecution jobExecution) {
Long executionId = jobExecution.getId();
ExecutionContext executionContext = jobExecution.getExecutionContext();
@@ -142,7 +142,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem
persistSerializedContext(executionId, serializedContext, UPDATE_JOB_EXECUTION_CONTEXT);
}
@Override
@Override
public void updateExecutionContext(final StepExecution stepExecution) {
Long executionId = stepExecution.getId();
@@ -155,7 +155,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem
persistSerializedContext(executionId, serializedContext, UPDATE_STEP_EXECUTION_CONTEXT);
}
@Override
@Override
public void saveExecutionContext(JobExecution jobExecution) {
Long executionId = jobExecution.getId();
@@ -168,7 +168,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem
persistSerializedContext(executionId, serializedContext, INSERT_JOB_EXECUTION_CONTEXT);
}
@Override
@Override
public void saveExecutionContext(StepExecution stepExecution) {
Long executionId = stepExecution.getId();
ExecutionContext executionContext = stepExecution.getExecutionContext();
@@ -210,7 +210,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem
}
getJdbcTemplate().update(getQuery(sql), new PreparedStatementSetter() {
@Override
@Override
public void setValues(PreparedStatement ps) throws SQLException {
ps.setString(1, shortContext);
if (longContext != null) {
@@ -224,6 +224,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem
});
}
@SuppressWarnings("unchecked")
private String serializeContext(ExecutionContext ctx) {
Map<String, Object> m = new HashMap<String, Object>();
for (Entry<String, Object> me : ctx.entrySet()) {
@@ -247,7 +248,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem
@SuppressWarnings("unchecked")
private class ExecutionContextRowMapper implements ParameterizedRowMapper<ExecutionContext> {
@Override
@Override
public ExecutionContext mapRow(ResultSet rs, int i) throws SQLException {
ExecutionContext executionContext = new ExecutionContext();
String serializedContext = rs.getString("SERIALIZED_CONTEXT");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2012 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,14 +38,14 @@ import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer
import org.springframework.util.Assert;
/**
* Jdbc implementation of {@link JobExecutionDao}. Uses sequences (via Spring's
* JDBC implementation of {@link JobExecutionDao}. Uses sequences (via Spring's
* {@link DataFieldMaxValueIncrementer} abstraction) to create all primary keys
* before inserting a new row. Objects are checked to ensure all mandatory
* fields to be stored are not null. If any are found to be null, an
* IllegalArgumentException will be thrown. This could be left to JdbcTemplate,
* however, the exception will be fairly vague, and fails to highlight which
* field caused the exception.
*
*
* @author Lucas Ward
* @author Dave Syer
* @author Robert Kasanicky
@@ -95,20 +95,20 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
/**
* Setter for {@link DataFieldMaxValueIncrementer} to be used when
* generating primary keys for {@link JobExecution} instances.
*
*
* @param jobExecutionIncrementer the {@link DataFieldMaxValueIncrementer}
*/
public void setJobExecutionIncrementer(DataFieldMaxValueIncrementer jobExecutionIncrementer) {
this.jobExecutionIncrementer = jobExecutionIncrementer;
}
@Override
@Override
public void afterPropertiesSet() throws Exception {
super.afterPropertiesSet();
Assert.notNull(jobExecutionIncrementer, "The jobExecutionIncrementer must not be null.");
}
@Override
@Override
public List<JobExecution> findJobExecutions(final JobInstance job) {
Assert.notNull(job, "Job cannot be null.");
@@ -118,16 +118,16 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
}
/**
*
*
* SQL implementation using Sequences via the Spring incrementer
* abstraction. Once a new id has been obtained, the JobExecution is saved
* via a SQL INSERT statement.
*
*
* @see JobExecutionDao#saveJobExecution(JobExecution)
* @throws IllegalArgumentException if jobExecution is null, as well as any
* of it's fields to be persisted.
*/
@Override
@Override
public void saveJobExecution(JobExecution jobExecution) {
validateJobExecution(jobExecution);
@@ -143,13 +143,13 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
getQuery(SAVE_JOB_EXECUTION),
parameters,
new int[] { Types.BIGINT, Types.BIGINT, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR,
Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.TIMESTAMP, Types.TIMESTAMP });
Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.TIMESTAMP, Types.TIMESTAMP });
}
/**
* Validate JobExecution. At a minimum, JobId, StartTime, EndTime, and
* Status cannot be null.
*
*
* @param jobExecution
* @throws IllegalArgumentException
*/
@@ -166,10 +166,10 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
* is first checked to ensure all fields are not null, and that it has an
* ID. The database is then queried to ensure that the ID exists, which
* ensures that it is valid.
*
*
* @see JobExecutionDao#updateJobExecution(JobExecution)
*/
@Override
@Override
public void updateJobExecution(JobExecution jobExecution) {
validateJobExecution(jobExecution);
@@ -206,7 +206,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
getQuery(UPDATE_JOB_EXECUTION),
parameters,
new int[] { Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
Types.INTEGER, Types.TIMESTAMP, Types.TIMESTAMP, Types.BIGINT, Types.INTEGER });
Types.INTEGER, Types.TIMESTAMP, Types.TIMESTAMP, Types.BIGINT, Types.INTEGER });
// Avoid concurrent modifications...
if (count == 0) {
@@ -221,7 +221,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
}
}
@Override
@Override
public JobExecution getLastJobExecution(JobInstance jobInstance) {
Long id = jobInstance.getId();
@@ -241,11 +241,11 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
/*
* (non-Javadoc)
*
*
* @seeorg.springframework.batch.core.repository.dao.JobExecutionDao#
* getLastJobExecution(java.lang.String)
*/
@Override
@Override
public JobExecution getJobExecution(Long executionId) {
try {
JobExecution jobExecution = getJdbcTemplate().queryForObject(getQuery(GET_EXECUTION_BY_ID),
@@ -259,16 +259,16 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
/*
* (non-Javadoc)
*
*
* @seeorg.springframework.batch.core.repository.dao.JobExecutionDao#
* findRunningJobExecutions(java.lang.String)
*/
@Override
@Override
public Set<JobExecution> findRunningJobExecutions(String jobName) {
final Set<JobExecution> result = new HashSet<JobExecution>();
RowCallbackHandler handler = new RowCallbackHandler() {
@Override
@Override
public void processRow(ResultSet rs) throws SQLException {
JobExecutionRowMapper mapper = new JobExecutionRowMapper();
result.add(mapper.mapRow(rs, 0));
@@ -279,7 +279,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
return result;
}
@Override
@Override
public void synchronizeStatus(JobExecution jobExecution) {
int currentVersion = getJdbcTemplate().queryForInt(getQuery(CURRENT_VERSION_JOB_EXECUTION),
jobExecution.getId());
@@ -293,9 +293,9 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
/**
* Re-usable mapper for {@link JobExecution} instances.
*
*
* @author Dave Syer
*
*
*/
private static class JobExecutionRowMapper implements ParameterizedRowMapper<JobExecution> {
@@ -308,7 +308,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
this.jobInstance = jobInstance;
}
@Override
@Override
public JobExecution mapRow(ResultSet rs, int rowNum) throws SQLException {
Long id = rs.getLong(1);
JobExecution jobExecution;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,8 +34,8 @@ import java.util.Map.Entry;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobParameter;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParameter.ParameterType;
import org.springframework.batch.core.JobParameters;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.EmptyResultDataAccessException;
@@ -47,20 +47,20 @@ import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* Jdbc implementation of {@link JobInstanceDao}. Uses sequences (via Spring's
* JDBC implementation of {@link JobInstanceDao}. Uses sequences (via Spring's
* {@link DataFieldMaxValueIncrementer} abstraction) to create all primary keys
* before inserting a new row. Objects are checked to ensure all mandatory
* fields to be stored are not null. If any are found to be null, an
* IllegalArgumentException will be thrown. This could be left to JdbcTemplate,
* however, the exception will be fairly vague, and fails to highlight which
* field caused the exception.
*
*
* @author Lucas Ward
* @author Dave Syer
* @author Robert Kasanicky
*/
public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
JobInstanceDao, InitializingBean {
JobInstanceDao, InitializingBean {
private static final String CREATE_JOB_INSTANCE = "INSERT into %PREFIX%JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION)"
+ " values (?, ?, ?, ?)";
@@ -93,12 +93,12 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
* In this jdbc implementation a job id is obtained by asking the
* jobIncrementer (which is likely a sequence) for the next long value, and
* then passing the Id and parameter values into an INSERT statement.
*
*
* @see JobInstanceDao#createJobInstance(String, JobParameters)
* @throws IllegalArgumentException
* if any {@link JobParameters} fields are null.
*/
@Override
@Override
public JobInstance createJobInstance(String jobName,
JobParameters jobParameters) {
@@ -119,7 +119,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
getQuery(CREATE_JOB_INSTANCE),
parameters,
new int[] { Types.BIGINT, Types.VARCHAR, Types.VARCHAR,
Types.INTEGER });
Types.INTEGER });
insertJobParameters(jobId, jobParameters);
@@ -159,7 +159,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
/**
* Convenience method that inserts all parameters from the provided
* JobParameters.
*
*
*/
private void insertJobParameters(Long jobId, JobParameters jobParameters) {
@@ -202,12 +202,12 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
/**
* The job table is queried for <strong>any</strong> jobs that match the
* given identifier, adding them to a list via the RowMapper callback.
*
*
* @see JobInstanceDao#getJobInstance(String, JobParameters)
* @throws IllegalArgumentException
* if any {@link JobParameters} fields are null.
*/
@Override
@Override
public JobInstance getJobInstance(final String jobName,
final JobParameters jobParameters) {
@@ -239,12 +239,12 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.repository.dao.JobInstanceDao#getJobInstance
* (java.lang.Long)
*/
@Override
@Override
public JobInstance getJobInstance(Long instanceId) {
try {
@@ -263,7 +263,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
private JobParameters getJobParameters(Long instanceId) {
final Map<String, JobParameter> map = new HashMap<String, JobParameter>();
RowCallbackHandler handler = new RowCallbackHandler() {
@Override
@Override
public void processRow(ResultSet rs) throws SQLException {
ParameterType type = ParameterType.valueOf(rs.getString(3));
JobParameter value = null;
@@ -286,30 +286,31 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.repository.dao.JobInstanceDao#getJobNames
* ()
*/
@Override
@Override
public List<String> getJobNames() {
return getJdbcTemplate().query(getQuery(FIND_JOB_NAMES),
new ParameterizedRowMapper<String>() {
@Override
public String mapRow(ResultSet rs, int rowNum)
throws SQLException {
return rs.getString(1);
}
});
@Override
public String mapRow(ResultSet rs, int rowNum)
throws SQLException {
return rs.getString(1);
}
});
}
/*
* (non-Javadoc)
*
*
* @seeorg.springframework.batch.core.repository.dao.JobInstanceDao#
* getLastJobInstances(java.lang.String, int)
*/
@Override
@Override
@SuppressWarnings("rawtypes")
public List<JobInstance> getJobInstances(String jobName, final int start,
final int count) {
@@ -317,9 +318,9 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
private List<JobInstance> list = new ArrayList<JobInstance>();
@Override
@Override
public Object extractData(ResultSet rs) throws SQLException,
DataAccessException {
DataAccessException {
int rowNum = 0;
while (rowNum < start && rs.next()) {
rowNum++;
@@ -336,19 +337,19 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
@SuppressWarnings("unchecked")
List<JobInstance> result = (List<JobInstance>) getJdbcTemplate().query(getQuery(FIND_LAST_JOBS_BY_NAME),
new Object[] { jobName }, extractor);
new Object[] { jobName }, extractor);
return result;
}
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.repository.dao.JobInstanceDao#getJobInstance
* (org.springframework.batch.core.JobExecution)
*/
@Override
@Override
public JobInstance getJobInstance(JobExecution jobExecution) {
try {
@@ -363,7 +364,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
/**
* Setter for {@link DataFieldMaxValueIncrementer} to be used when
* generating primary keys for {@link JobInstance} instances.
*
*
* @param jobIncrementer
* the {@link DataFieldMaxValueIncrementer}
*/
@@ -371,7 +372,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
this.jobIncrementer = jobIncrementer;
}
@Override
@Override
public void afterPropertiesSet() throws Exception {
super.afterPropertiesSet();
Assert.notNull(jobIncrementer);
@@ -379,10 +380,10 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
/**
* @author Dave Syer
*
*
*/
private final class JobInstanceRowMapper implements
ParameterizedRowMapper<JobInstance> {
ParameterizedRowMapper<JobInstance> {
private JobParameters jobParameters;
@@ -393,7 +394,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
this.jobParameters = jobParameters;
}
@Override
@Override
public JobInstance mapRow(ResultSet rs, int rowNum) throws SQLException {
Long id = rs.getLong(1);
if (jobParameters == null) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,22 +34,22 @@ import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer
import org.springframework.util.Assert;
/**
* Jdbc implementation of {@link StepExecutionDao}.<br/>
*
* JDBC implementation of {@link StepExecutionDao}.<br/>
*
* Allows customization of the tables names used by Spring Batch for step meta
* data via a prefix property.<br/>
*
*
* Uses sequences or tables (via Spring's {@link DataFieldMaxValueIncrementer}
* abstraction) to create all primary keys before inserting a new row. All
* objects are checked to ensure all fields to be stored are not null. If any
* are found to be null, an IllegalArgumentException will be thrown. This could
* be left to JdbcTemplate, however, the exception will be fairly vague, and
* fails to highlight which field caused the exception.<br/>
*
*
* @author Lucas Ward
* @author Dave Syer
* @author Robert Kasanicky
*
*
* @see StepExecutionDao
*/
public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implements StepExecutionDao, InitializingBean {
@@ -91,7 +91,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
this.stepExecutionIncrementer = stepExecutionIncrementer;
}
@Override
@Override
public void afterPropertiesSet() throws Exception {
super.afterPropertiesSet();
Assert.notNull(stepExecutionIncrementer, "StepExecutionIncrementer cannot be null.");
@@ -101,10 +101,10 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
* Save a StepExecution. A unique id will be generated by the
* stepExecutionIncrementor, and then set in the StepExecution. All values
* will then be stored via an INSERT statement.
*
*
* @see StepExecutionDao#saveStepExecution(StepExecution)
*/
@Override
@Override
public void saveStepExecution(StepExecution stepExecution) {
Assert.isNull(stepExecution.getId(),
@@ -129,15 +129,15 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
getQuery(SAVE_STEP_EXECUTION),
parameters,
new int[] { Types.BIGINT, Types.INTEGER, Types.VARCHAR, Types.BIGINT, Types.TIMESTAMP,
Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER,
Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER,
Types.TIMESTAMP });
Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER,
Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER,
Types.TIMESTAMP });
}
/**
* Validate StepExecution. At a minimum, JobId, StartTime, and Status cannot
* be null. EndTime can be null for an unfinished job.
*
*
* @throws IllegalArgumentException
*/
private void validateStepExecution(StepExecution stepExecution) {
@@ -147,7 +147,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
Assert.notNull(stepExecution.getStatus(), "StepExecution status cannot be null.");
}
@Override
@Override
public void updateStepExecution(StepExecution stepExecution) {
validateStepExecution(stepExecution);
@@ -172,12 +172,12 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
stepExecution.getWriteSkipCount(), stepExecution.getRollbackCount(),
stepExecution.getLastUpdated(), stepExecution.getId(), stepExecution.getVersion() };
int count = getJdbcTemplate().update(
getQuery(UPDATE_STEP_EXECUTION),
parameters,
new int[] { Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER,
Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.INTEGER,
Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.TIMESTAMP,
Types.BIGINT, Types.INTEGER });
getQuery(UPDATE_STEP_EXECUTION),
parameters,
new int[] { Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER,
Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.INTEGER,
Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.TIMESTAMP,
Types.BIGINT, Types.INTEGER });
// Avoid concurrent modifications...
if (count == 0) {
@@ -209,7 +209,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
}
}
@Override
@Override
public StepExecution getStepExecution(JobExecution jobExecution, Long stepExecutionId) {
List<StepExecution> executions = getJdbcTemplate().query(getQuery(GET_STEP_EXECUTION),
new StepExecutionRowMapper(jobExecution), jobExecution.getId(), stepExecutionId);
@@ -224,7 +224,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
}
}
@Override
@Override
public void addStepExecutions(JobExecution jobExecution) {
getJdbcTemplate().query(getQuery(GET_STEP_EXECUTIONS), new StepExecutionRowMapper(jobExecution),
jobExecution.getId());
@@ -238,7 +238,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
this.jobExecution = jobExecution;
}
@Override
@Override
public StepExecution mapRow(ResultSet rs, int rowNum) throws SQLException {
StepExecution stepExecution = new StepExecution(rs.getString(2), jobExecution, rs.getLong(1));
stepExecution.setStartTime(rs.getTimestamp(3));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,10 +27,11 @@ import org.springframework.batch.support.transaction.TransactionAwareProxyFactor
/**
* In-memory implementation of {@link ExecutionContextDao} backed by maps.
*
*
* @author Robert Kasanicky
* @author Dave Syer
*/
@SuppressWarnings("serial")
public class MapExecutionContextDao implements ExecutionContextDao {
private final ConcurrentMap<ContextKey, ExecutionContext> contexts = TransactionAwareProxyFactory
@@ -44,30 +45,44 @@ public class MapExecutionContextDao implements ExecutionContextDao {
private final long id;
private ContextKey(Type type, long id) {
if(type == null) throw new IllegalStateException("Need a non-null type for a context");
if(type == null) {
throw new IllegalStateException("Need a non-null type for a context");
}
this.type = type;
this.id = id;
}
@Override
@Override
public int compareTo(ContextKey them) {
if(them == null) return 1;
if(them == null) {
return 1;
}
final int idCompare = new Long(this.id).compareTo(new Long(them.id)); // JDK6 Make this Long.compare(x,y)
if(idCompare != 0) return idCompare;
if(idCompare != 0) {
return idCompare;
}
final int typeCompare = this.type.compareTo(them.type);
if(typeCompare != 0) return typeCompare;
if(typeCompare != 0) {
return typeCompare;
}
return 0;
}
@Override
public boolean equals(Object them) {
if(them == null) return false;
if(them instanceof ContextKey) return this.equals((ContextKey)them);
if(them == null) {
return false;
}
if(them instanceof ContextKey) {
return this.equals((ContextKey)them);
}
return false;
}
public boolean equals(ContextKey them) {
if(them == null) return false;
if(them == null) {
return false;
}
return this.id == them.id && this.type.equals(them.type);
}
@@ -75,9 +90,9 @@ public class MapExecutionContextDao implements ExecutionContextDao {
public int hashCode() {
int value = (int)(id^(id>>>32));
switch(type) {
case STEP: return value;
case JOB: return ~value;
default: throw new IllegalStateException("Unknown type encountered in switch: " + type);
case STEP: return value;
case JOB: return ~value;
default: throw new IllegalStateException("Unknown type encountered in switch: " + type);
}
}
@@ -86,7 +101,7 @@ public class MapExecutionContextDao implements ExecutionContextDao {
public static ContextKey job(long id) { return new ContextKey(Type.JOB, id); }
}
public void clear() {
public void clear() {
contexts.clear();
}
@@ -94,12 +109,12 @@ public class MapExecutionContextDao implements ExecutionContextDao {
return (ExecutionContext) SerializationUtils.deserialize(SerializationUtils.serialize(original));
}
@Override
@Override
public ExecutionContext getExecutionContext(StepExecution stepExecution) {
return copy(contexts.get(ContextKey.step(stepExecution.getId())));
}
@Override
@Override
public void updateExecutionContext(StepExecution stepExecution) {
ExecutionContext executionContext = stepExecution.getExecutionContext();
if (executionContext != null) {
@@ -107,12 +122,12 @@ public class MapExecutionContextDao implements ExecutionContextDao {
}
}
@Override
@Override
public ExecutionContext getExecutionContext(JobExecution jobExecution) {
return copy(contexts.get(ContextKey.job(jobExecution.getId())));
}
@Override
@Override
public void updateExecutionContext(JobExecution jobExecution) {
ExecutionContext executionContext = jobExecution.getExecutionContext();
if (executionContext != null) {
@@ -120,12 +135,12 @@ public class MapExecutionContextDao implements ExecutionContextDao {
}
}
@Override
@Override
public void saveExecutionContext(JobExecution jobExecution) {
updateExecutionContext(jobExecution);
}
@Override
@Override
public void saveExecutionContext(StepExecution stepExecution) {
updateExecutionContext(stepExecution);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,10 +22,8 @@ import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong;
import org.springframework.batch.core.JobExecution;
@@ -53,7 +51,7 @@ public class MapJobExecutionDao implements JobExecutionDao {
return copy;
}
@Override
@Override
public void saveJobExecution(JobExecution jobExecution) {
Assert.isTrue(jobExecution.getId() == null);
Long newId = currentId.getAndIncrement();
@@ -62,7 +60,7 @@ public class MapJobExecutionDao implements JobExecutionDao {
executionsById.put(newId, copy(jobExecution));
}
@Override
@Override
public List<JobExecution> findJobExecutions(JobInstance jobInstance) {
List<JobExecution> executions = new ArrayList<JobExecution>();
for (JobExecution exec : executionsById.values()) {
@@ -72,7 +70,7 @@ public class MapJobExecutionDao implements JobExecutionDao {
}
Collections.sort(executions, new Comparator<JobExecution>() {
@Override
@Override
public int compare(JobExecution e1, JobExecution e2) {
long result = (e1.getId() - e2.getId());
if (result > 0) {
@@ -89,7 +87,7 @@ public class MapJobExecutionDao implements JobExecutionDao {
return executions;
}
@Override
@Override
public void updateJobExecution(JobExecution jobExecution) {
Long id = jobExecution.getId();
Assert.notNull(id, "JobExecution is expected to have an id (should be saved already)");
@@ -107,7 +105,7 @@ public class MapJobExecutionDao implements JobExecutionDao {
}
}
@Override
@Override
public JobExecution getLastJobExecution(JobInstance jobInstance) {
JobExecution lastExec = null;
for (JobExecution exec : executionsById.values()) {
@@ -126,11 +124,11 @@ public class MapJobExecutionDao implements JobExecutionDao {
/*
* (non-Javadoc)
*
*
* @seeorg.springframework.batch.core.repository.dao.JobExecutionDao#
* findRunningJobExecutions(java.lang.String)
*/
@Override
@Override
public Set<JobExecution> findRunningJobExecutions(String jobName) {
Set<JobExecution> result = new HashSet<JobExecution>();
for (JobExecution exec : executionsById.values()) {
@@ -144,17 +142,17 @@ public class MapJobExecutionDao implements JobExecutionDao {
/*
* (non-Javadoc)
*
*
* @see
* org.springframework.batch.core.repository.dao.JobExecutionDao#getJobExecution
* (java.lang.Long)
*/
@Override
@Override
public JobExecution getJobExecution(Long executionId) {
return copy(executionsById.get(executionId));
}
@Override
@Override
public void synchronizeStatus(JobExecution jobExecution) {
JobExecution saved = getJobExecution(jobExecution.getId());
if (saved.getVersion().intValue() != jobExecution.getVersion().intValue()) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,9 +21,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.atomic.AtomicLong;
import org.springframework.batch.core.JobExecution;
@@ -45,7 +43,7 @@ public class MapJobInstanceDao implements JobInstanceDao {
jobInstances.clear();
}
@Override
@Override
public JobInstance createJobInstance(String jobName, JobParameters jobParameters) {
Assert.state(getJobInstance(jobName, jobParameters) == null, "JobInstance must not already exist");
@@ -57,7 +55,7 @@ public class MapJobInstanceDao implements JobInstanceDao {
return jobInstance;
}
@Override
@Override
public JobInstance getJobInstance(String jobName, JobParameters jobParameters) {
for (JobInstance instance : jobInstances) {
@@ -69,7 +67,7 @@ public class MapJobInstanceDao implements JobInstanceDao {
}
@Override
@Override
public JobInstance getJobInstance(Long instanceId) {
for (JobInstance instance : jobInstances) {
if (instance.getId().equals(instanceId)) {
@@ -79,7 +77,7 @@ public class MapJobInstanceDao implements JobInstanceDao {
return null;
}
@Override
@Override
public List<String> getJobNames() {
List<String> result = new ArrayList<String>();
for (JobInstance instance : jobInstances) {
@@ -89,7 +87,7 @@ public class MapJobInstanceDao implements JobInstanceDao {
return result;
}
@Override
@Override
public List<JobInstance> getJobInstances(String jobName, int start, int count) {
List<JobInstance> result = new ArrayList<JobInstance>();
for (JobInstance instance : jobInstances) {
@@ -99,7 +97,7 @@ public class MapJobInstanceDao implements JobInstanceDao {
}
Collections.sort(result, new Comparator<JobInstance>() {
// sort by ID descending
@Override
@Override
public int compare(JobInstance o1, JobInstance o2) {
return Long.signum(o2.getId() - o1.getId());
}
@@ -110,7 +108,7 @@ public class MapJobInstanceDao implements JobInstanceDao {
return result.subList(startIndex, endIndex);
}
@Override
@Override
public JobInstance getJobInstance(JobExecution jobExecution) {
return jobExecution.getJobInstance();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,7 +56,7 @@ public class MapStepExecutionDao implements StepExecutionDao {
// Cheaper than full serialization is a reflective field copy, which is
// fine for volatile storage
ReflectionUtils.doWithFields(StepExecution.class, new ReflectionUtils.FieldCallback() {
@Override
@Override
public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {
field.setAccessible(true);
field.set(targetExecution, field.get(sourceExecution));
@@ -64,7 +64,7 @@ public class MapStepExecutionDao implements StepExecutionDao {
});
}
@Override
@Override
public void saveStepExecution(StepExecution stepExecution) {
Assert.isTrue(stepExecution.getId() == null);
@@ -85,7 +85,7 @@ public class MapStepExecutionDao implements StepExecutionDao {
}
@Override
@Override
public void updateStepExecution(StepExecution stepExecution) {
Assert.notNull(stepExecution.getJobExecutionId());
@@ -111,12 +111,12 @@ public class MapStepExecutionDao implements StepExecutionDao {
}
}
@Override
@Override
public StepExecution getStepExecution(JobExecution jobExecution, Long stepExecutionId) {
return executionsByStepExecutionId.get(stepExecutionId);
}
@Override
@Override
public void addStepExecutions(JobExecution jobExecution) {
Map<Long, StepExecution> executions = executionsByJobExecutionId.get(jobExecution.getId());
if (executions == null || executions.isEmpty()) {
@@ -125,7 +125,7 @@ public class MapStepExecutionDao implements StepExecutionDao {
List<StepExecution> result = new ArrayList<StepExecution>(executions.values());
Collections.sort(result, new Comparator<Entity>() {
@Override
@Override
public int compare(Entity o1, Entity o2) {
return Long.signum(o2.getId() - o1.getId());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2008 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@ public class XStreamExecutionContextStringSerializer implements ExecutionContext
this.hierarchicalStreamDriver = hierarchicalStreamDriver;
}
@Override
@Override
public void afterPropertiesSet() throws Exception {
init();
}
@@ -81,7 +81,7 @@ public class XStreamExecutionContextStringSerializer implements ExecutionContext
* @param out
* @see Serializer#serialize(Object, OutputStream)
*/
@Override
@Override
public void serialize(Object context, OutputStream out) throws IOException {
Assert.notNull(context);
Assert.notNull(out);
@@ -96,8 +96,7 @@ public class XStreamExecutionContextStringSerializer implements ExecutionContext
* @return a reconstructed execution context
* @see Deserializer#deserialize(InputStream)
*/
@Override
@SuppressWarnings("unchecked")
@Override
public Object deserialize(InputStream in) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(in));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,14 +38,15 @@ import org.springframework.util.Assert;
* A {@link FactoryBean} that automates the creation of a
* {@link SimpleJobRepository}. Declares abstract methods for providing DAO
* object implementations.
*
*
* @see JobRepositoryFactoryBean
* @see MapJobRepositoryFactoryBean
*
*
* @author Ben Hale
* @author Lucas Ward
* @author Robert Kasanicky
*/
@SuppressWarnings("rawtypes")
public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, InitializingBean {
private PlatformTransactionManager transactionManager;
@@ -83,16 +84,16 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I
/**
* The type of object to be returned from {@link #getObject()}.
*
*
* @return JobRepository.class
* @see org.springframework.beans.factory.FactoryBean#getObjectType()
*/
@Override
@Override
public Class<JobRepository> getObjectType() {
return JobRepository.class;
}
@Override
@Override
public boolean isSingleton() {
return true;
}
@@ -102,7 +103,7 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I
* JobExecution is created. Defaults to true because it is usually a
* mistake, and leads to problems with restartability and also to deadlocks
* in multi-threaded steps.
*
*
* @param validateTransactionState the flag to set
*/
public void setValidateTransactionState(boolean validateTransactionState) {
@@ -114,9 +115,9 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I
* job execution entities are initially created. The default is
* ISOLATION_SERIALIZABLE, which prevents accidental concurrent execution of
* the same job (ISOLATION_REPEATABLE_READ would work as well).
*
*
* @param isolationLevelForCreate the isolation level name to set
*
*
* @see SimpleJobRepository#createJobExecution(String,
* org.springframework.batch.core.JobParameters)
*/
@@ -135,7 +136,7 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I
/**
* The transaction manager used in this factory. Useful to inject into steps
* and jobs, to ensure that they are using the same instance.
*
*
* @return the transactionManager
*/
public PlatformTransactionManager getTransactionManager() {
@@ -161,7 +162,7 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I
+ isolationLevelForCreate + "\n*=PROPAGATION_REQUIRED"));
if (validateTransactionState) {
DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(new MethodInterceptor() {
@Override
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
if (TransactionSynchronizationManager.isActualTransactionActive()) {
throw new IllegalStateException(
@@ -183,7 +184,7 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I
}
}
@Override
@Override
public void afterPropertiesSet() throws Exception {
Assert.notNull(transactionManager, "TransactionManager must not be null.");
@@ -195,7 +196,7 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I
createExecutionContextDao());
}
@Override
@Override
public Object getObject() throws Exception {
if (proxyFactory == null) {
afterPropertiesSet();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,21 +39,21 @@ import org.springframework.batch.item.ExecutionContext;
import org.springframework.util.Assert;
/**
*
*
* <p>
* Implementation of {@link JobRepository} that stores JobInstances,
* JobExecutions, and StepExecutions using the injected DAOs.
* <p>
*
*
* @author Lucas Ward
* @author Dave Syer
* @author Robert Kasanicky
*
*
* @see JobRepository
* @see JobInstanceDao
* @see JobExecutionDao
* @see StepExecutionDao
*
*
*/
public class SimpleJobRepository implements JobRepository {
@@ -83,12 +83,12 @@ public class SimpleJobRepository implements JobRepository {
this.ecDao = ecDao;
}
@Override
@Override
public boolean isJobInstanceExists(String jobName, JobParameters jobParameters) {
return jobInstanceDao.getJobInstance(jobName, jobParameters) != null;
}
@Override
@Override
public JobExecution createJobExecution(String jobName, JobParameters jobParameters)
throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException {
@@ -97,7 +97,7 @@ public class SimpleJobRepository implements JobRepository {
/*
* Find all jobs matching the runtime information.
*
*
* If this method is transactional, and the isolation level is
* REPEATABLE_READ or better, another launcher trying to start the same
* job in another thread or process will block until this transaction
@@ -118,12 +118,12 @@ public class SimpleJobRepository implements JobRepository {
throw new JobExecutionAlreadyRunningException("A job execution for this job is already running: "
+ jobInstance);
}
BatchStatus status = execution.getStatus();
if (status == BatchStatus.COMPLETED || status == BatchStatus.ABANDONED) {
throw new JobInstanceAlreadyCompleteException(
"A job instance already exists and is complete for parameters=" + jobParameters
+ ". If you want to run this job again, change the parameters.");
+ ". If you want to run this job again, change the parameters.");
}
}
executionContext = ecDao.getExecutionContext(jobExecutionDao.getLastJobExecution(jobInstance));
@@ -147,7 +147,7 @@ public class SimpleJobRepository implements JobRepository {
}
@Override
@Override
public void update(JobExecution jobExecution) {
Assert.notNull(jobExecution, "JobExecution cannot be null.");
@@ -158,7 +158,7 @@ public class SimpleJobRepository implements JobRepository {
jobExecutionDao.updateJobExecution(jobExecution);
}
@Override
@Override
public void add(StepExecution stepExecution) {
validateStepExecution(stepExecution);
@@ -167,7 +167,7 @@ public class SimpleJobRepository implements JobRepository {
ecDao.saveExecutionContext(stepExecution);
}
@Override
@Override
public void update(StepExecution stepExecution) {
validateStepExecution(stepExecution);
Assert.notNull(stepExecution.getId(), "StepExecution must already be saved (have an id assigned)");
@@ -183,19 +183,19 @@ public class SimpleJobRepository implements JobRepository {
Assert.notNull(stepExecution.getJobExecutionId(), "StepExecution must belong to persisted JobExecution");
}
@Override
@Override
public void updateExecutionContext(StepExecution stepExecution) {
validateStepExecution(stepExecution);
Assert.notNull(stepExecution.getId(), "StepExecution must already be saved (have an id assigned)");
ecDao.updateExecutionContext(stepExecution);
}
@Override
@Override
public void updateExecutionContext(JobExecution jobExecution) {
ecDao.updateExecutionContext(jobExecution);
}
@Override
@Override
public StepExecution getLastStepExecution(JobInstance jobInstance, String stepName) {
List<JobExecution> jobExecutions = jobExecutionDao.findJobExecutions(jobInstance);
List<StepExecution> stepExecutions = new ArrayList<StepExecution>(jobExecutions.size());
@@ -226,7 +226,7 @@ public class SimpleJobRepository implements JobRepository {
/**
* @return number of executions of the step within given job instance
*/
@Override
@Override
public int getStepExecutionCount(JobInstance jobInstance, String stepName) {
int count = 0;
List<JobExecution> jobExecutions = jobExecutionDao.findJobExecutions(jobInstance);
@@ -246,7 +246,7 @@ public class SimpleJobRepository implements JobRepository {
* the provided StepExecution has been interrupted. If, after synchronizing
* the status with the database, the status has been updated to STOPPING,
* then the job has been interrupted.
*
*
* @param stepExecution
*/
private void checkForInterruption(StepExecution stepExecution) {
@@ -258,14 +258,14 @@ public class SimpleJobRepository implements JobRepository {
}
}
@Override
@Override
public JobExecution getLastJobExecution(String jobName, JobParameters jobParameters) {
JobInstance jobInstance = jobInstanceDao.getJobInstance(jobName, jobParameters);
if (jobInstance == null) {
return null;
}
JobExecution jobExecution = jobExecutionDao.getLastJobExecution(jobInstance);
if (jobExecution != null) {
jobExecution.setExecutionContext(ecDao.getExecutionContext(jobExecution));
}

Some files were not shown because too many files have changed in this diff Show More