diff --git a/archetypes/simple-cli/pom.xml b/archetypes/simple-cli/pom.xml index ad3ed2ae9..c9a6e712a 100644 --- a/archetypes/simple-cli/pom.xml +++ b/archetypes/simple-cli/pom.xml @@ -200,8 +200,8 @@ org.apache.maven.plugins maven-compiler-plugin - 1.5 - 1.5 + 1.6 + 1.6 diff --git a/dictionary.txt b/dictionary.txt index c97425432..90d2baced 100644 --- a/dictionary.txt +++ b/dictionary.txt @@ -93,3 +93,4 @@ proxied payloads unflushed memento +michael diff --git a/spring-batch-core-tests/pom.xml b/spring-batch-core-tests/pom.xml index 2fcb89c9d..d505f1caf 100644 --- a/spring-batch-core-tests/pom.xml +++ b/spring-batch-core-tests/pom.xml @@ -12,18 +12,6 @@ ../spring-batch-parent - - tiger - - 1.5 - - - - stax - stax - - - default diff --git a/spring-batch-core/pom.xml b/spring-batch-core/pom.xml index c36143482..728ab88a2 100644 --- a/spring-batch-core/pom.xml +++ b/spring-batch-core/pom.xml @@ -12,24 +12,6 @@ 2.2.0.BUILD-SNAPSHOT ../spring-batch-parent - - - tiger - - 1.5 - - - - stax - stax - - - javax.annotation - jsr250-api - - - - org.springframework.batch diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/Entity.java b/spring-batch-core/src/main/java/org/springframework/batch/core/Entity.java index 4b7b95b10..53cd33e1b 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/Entity.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/Entity.java @@ -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,9 +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 public int hashCode() { if (id == null) { return super.hashCode(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/ExitStatus.java b/spring-batch-core/src/main/java/org/springframework/batch/core/ExitStatus.java index 8146a8c55..66225cdef 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/ExitStatus.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/ExitStatus.java @@ -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 { /** @@ -85,7 +86,7 @@ public class ExitStatus implements Serializable, Comparable { /** * 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 { * case of equal severity, the exit code is replaced if the new value is * alphabetically greater.
*
- * + * * Severity is defined by the exit code: *
    *
  • Codes beginning with EXECUTING have severity 1
  • @@ -117,9 +118,9 @@ public class ExitStatus implements Serializable, Comparable { *
  • Codes beginning with UNKNOWN have severity 6
  • *
* Others have severity 7, so custom exit codes always win.
- * + * * 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,11 +135,12 @@ public class ExitStatus implements Serializable, Comparable { } return result; } - + /** * @param status an {@link ExitStatus} to compare * @return 1,0,-1 according to the severity and exit code */ + @Override public int compareTo(ExitStatus status) { if (severity(status) > severity(this)) { return -1; @@ -177,18 +179,20 @@ public class ExitStatus implements Serializable, Comparable { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ + @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 public boolean equals(Object obj) { if (obj == null) { return false; @@ -198,9 +202,10 @@ public class ExitStatus implements Serializable, Comparable { /** * Compatible with the equals implementation. - * + * * @see java.lang.Object#hashCode() */ + @Override public int hashCode() { return toString().hashCode(); } @@ -208,7 +213,7 @@ public class ExitStatus implements Serializable, Comparable { /** * 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. @@ -219,7 +224,7 @@ public class ExitStatus implements Serializable, Comparable { /** * Check if this status represents a running process. - * + * * @return true if the exit code is "RUNNING" or "UNKNOWN" */ public boolean isRunning() { @@ -230,7 +235,7 @@ public class ExitStatus implements Serializable, Comparable { * 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 @@ -253,7 +258,7 @@ public class ExitStatus implements Serializable, Comparable { /** * 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 */ diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java b/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java index 328dda516..9d7b50a20 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java @@ -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 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 containing all exceptions causing failure for * this JobExecution. */ @@ -312,9 +313,10 @@ public class JobExecution extends Entity { /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.Entity#toString() */ + @Override public String toString() { return super.toString() + String.format(", startTime=%s, endTime=%s, lastUpdated=%s, status=%s, exitStatus=%s, job=[%s]", @@ -332,4 +334,4 @@ public class JobExecution extends Entity { } } -} \ No newline at end of file +} diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecutionListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecutionListener.java index ab98c4919..1cd2fd2b4 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecutionListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecutionListener.java @@ -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); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/JobInstance.java b/spring-batch-core/src/main/java/org/springframework/batch/core/JobInstance.java index 86482451c..a1320dcda 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/JobInstance.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/JobInstance.java @@ -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,6 +66,7 @@ public class JobInstance extends Entity { return jobName; } + @Override public String toString() { return super.toString() + ", JobParameters=[" + jobParameters + "]" + ", Job=[" + jobName + "]"; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/JobParameter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/JobParameter.java index f774b303b..6fc74b992 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/JobParameter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/JobParameter.java @@ -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,6 +113,7 @@ public class JobParameter implements Serializable { : parameter.toString()); } + @Override public int hashCode() { return 7 + 21 * (parameter == null ? parameterType.hashCode() : parameter.hashCode()); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/StepContribution.java b/spring-batch-core/src/main/java/org/springframework/batch/core/StepContribution.java index 171de9130..6bffd54f3 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/StepContribution.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/StepContribution.java @@ -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,9 +184,10 @@ public class StepContribution implements Serializable { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ + @Override public String toString() { return "[StepContribution: read=" + readCount + ", written=" + writeCount + ", filtered=" + filterCount + ", readSkips=" + readSkipCount + ", writeSkips=" + writeSkipCount + ", processSkips=" diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java b/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java index 4d46bb266..07b20ffb7 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java @@ -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,11 +465,12 @@ public class StepExecution extends Entity { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.container.common.domain.Entity#equals(java. * lang.Object) */ + @Override public boolean equals(Object obj) { Object jobExecutionId = getJobExecutionId(); @@ -492,9 +494,10 @@ public class StepExecution extends Entity { /* * (non-Javadoc) - * + * * @see org.springframework.batch.container.common.domain.Entity#hashCode() */ + @Override public int hashCode() { Object jobExecutionId = getJobExecutionId(); Long id = getId(); @@ -502,6 +505,7 @@ public class StepExecution extends Entity { * (jobExecutionId != null ? jobExecutionId.hashCode() : 0) + 59 * (id != null ? id.hashCode() : 0); } + @Override public String toString() { return String.format(getSummary() + ", exitDescription=%s", exitStatus.getExitDescription()); } @@ -511,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); } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecutionListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecutionListener.java index f969e2409..04a668e6a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecutionListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecutionListener.java @@ -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. */ diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/ModularBatchConfiguration.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/ModularBatchConfiguration.java index 37d44d5e1..1d5217946 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/ModularBatchConfiguration.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/ModularBatchConfiguration.java @@ -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,16 +47,19 @@ public class ModularBatchConfiguration extends AbstractBatchConfiguration { private AutomaticJobRegistrar registrar = new AutomaticJobRegistrar(); + @Override @Bean public JobRepository jobRepository() throws Exception { return getConfigurer(configurers).getJobRepository(); } + @Override @Bean public JobLauncher jobLauncher() throws Exception { return getConfigurer(configurers).getJobLauncher(); } + @Override @Bean public PlatformTransactionManager transactionManager() throws Exception { return getConfigurer(configurers).getTransactionManager(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.java index 65b1c2ce1..b3310a267 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.java @@ -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 = new AtomicReference(); @@ -58,21 +58,25 @@ public class SimpleBatchConfiguration extends AbstractBatchConfiguration { private AtomicReference transactionManager = new AtomicReference(); + @Override @Bean public JobRepository jobRepository() throws Exception { return createLazyProxy(jobRepository, JobRepository.class); } + @Override @Bean public JobLauncher jobLauncher() throws Exception { return createLazyProxy(jobLauncher, JobLauncher.class); } + @Override @Bean public JobRegistry jobRegistry() throws Exception { return createLazyProxy(jobRegistry, JobRegistry.class); } + @Override @Bean public PlatformTransactionManager transactionManager() throws Exception { return createLazyProxy(transactionManager, PlatformTransactionManager.class); @@ -91,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 { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ApplicationContextJobFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ApplicationContextJobFactory.java index b68b3cb94..125e3daa9 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ApplicationContextJobFactory.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ApplicationContextJobFactory.java @@ -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,24 +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 public final Job createJob() { return job; } - + /** * Just return the name of instance passed in on initialization. - * + * * @see JobFactory#getJobName() */ + @Override public String getJobName() { return job.getName(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/DefaultJobLoader.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/DefaultJobLoader.java index 6acefcfc6..cf3bc97db 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/DefaultJobLoader.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/DefaultJobLoader.java @@ -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 contexts = new ConcurrentHashMap(); @@ -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,6 +107,7 @@ public class DefaultJobLoader implements JobLoader, InitializingBean { * * @see JobLoader#clear() */ + @Override public void clear() { for (ConfigurableApplicationContext context : contexts.values()) { if (context.isActive()) { @@ -114,11 +115,12 @@ public class DefaultJobLoader implements JobLoader, InitializingBean { } } for (String jobName : jobRegistry.getJobNames()) { - doUnregister(jobName); + doUnregister(jobName); } contexts.clear(); } + @Override public Collection reload(ApplicationContextFactory factory) { // If the same factory is loaded twice the context can be closed @@ -140,6 +142,7 @@ public class DefaultJobLoader implements JobLoader, InitializingBean { } } + @Override public Collection load(ApplicationContextFactory factory) throws DuplicateJobException { return doLoad(factory, false); } @@ -202,73 +205,74 @@ public class DefaultJobLoader implements JobLoader, InitializingBean { } - /** - * Returns all the {@link Step} instances defined by the specified {@link StepLocator}. - *

- * The specified jobApplicationContext 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 getSteps(final StepLocator stepLocator, final ApplicationContext jobApplicationContext) { - final Collection stepNames = stepLocator.getStepNames(); - final Collection result = new ArrayList(); - for (String stepName : stepNames) { - result.add(stepLocator.getStep(stepName)); - } + /** + * Returns all the {@link Step} instances defined by the specified {@link StepLocator}. + *

+ * The specified jobApplicationContext 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 getSteps(final StepLocator stepLocator, final ApplicationContext jobApplicationContext) { + final Collection stepNames = stepLocator.getStepNames(); + final Collection result = new ArrayList(); + 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 allSteps = jobApplicationContext.getBeansOfType(Step.class); - for (Map.Entry 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 allSteps = jobApplicationContext.getBeansOfType(Step.class); + for (Map.Entry 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}. - *

- * 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}. + *

+ * 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 jobName. - * - * @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 jobName. + * + * @param jobName the name of the job to unregister + */ + private void doUnregister(String jobName) { + jobRegistry.unregister(jobName); + if (stepRegistry != null) { + stepRegistry.unregisterStepsFromJob(jobName); + } - } + } - 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."); + } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/GroupAwareJob.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/GroupAwareJob.java index 31af67c13..be40fc985 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/GroupAwareJob.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/GroupAwareJob.java @@ -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 financeDepartment.overnightJob * . The use of a "." separator for elements is deliberate, since it is a "safe" * character in a URL. - * - * + * + * * @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,35 +67,40 @@ public class GroupAwareJob implements Job { this.delegate = delegate; } + @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 public String getName() { return groupName==null ? delegate.getName() : groupName + SEPARATOR + delegate.getName(); } + @Override public boolean isRestartable() { return delegate.isRestartable(); } + @Override public JobParametersIncrementer getJobParametersIncrementer() { return delegate.getJobParametersIncrementer(); } + @Override public JobParametersValidator getJobParametersValidator() { return delegate.getJobParametersValidator(); } /* * (non-Javadoc) - * + * * @see java.lang.Object#equals(java.lang.Object) */ @Override @@ -108,17 +113,17 @@ 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() + "]"; } -} \ No newline at end of file +} diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobRegistryBeanPostProcessor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobRegistryBeanPostProcessor.java index f8dccf717..643e9c439 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobRegistryBeanPostProcessor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobRegistryBeanPostProcessor.java @@ -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,11 +83,12 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFact /* * (non-Javadoc) - * + * * @see * org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org * .springframework.beans.factory.BeanFactory) */ + @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { if (beanFactory instanceof DefaultListableBeanFactory) { this.beanFactory = (DefaultListableBeanFactory) beanFactory; @@ -96,9 +97,10 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFact /** * Make sure the registry is set before use. - * + * * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(jobRegistry, "JobRegistry must not be null"); } @@ -108,6 +110,7 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFact * post processor. * @see org.springframework.beans.factory.DisposableBean#destroy() */ + @Override public void destroy() throws Exception { for (String name : jobNames) { logger.debug("Unregistering job: " + name); @@ -119,10 +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 public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof Job) { Job job = (Job) bean; @@ -150,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) @@ -161,10 +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 public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { return bean; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapJobRegistry.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapJobRegistry.java index 0787440d0..9cd93cb54 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapJobRegistry.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapJobRegistry.java @@ -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,42 +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 map = new ConcurrentHashMap(); + /** + * The map holding the registered job factories. + */ + // The "final" ensures that it is visible and initialized when the constructor resolves. + private final ConcurrentMap map = new ConcurrentHashMap(); - 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"); + } + } - 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); + } - 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. - */ - public Set getJobNames() { - return Collections.unmodifiableSet(map.keySet()); - } + /** + * Provides an unmodifiable view of the job names. + */ + @Override + public Set getJobNames() { + return Collections.unmodifiableSet(map.keySet()); + } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapStepRegistry.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapStepRegistry.java index d4d4dffc2..fea8816e7 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapStepRegistry.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapStepRegistry.java @@ -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,43 +37,46 @@ import java.util.concurrent.ConcurrentMap; */ public class MapStepRegistry implements StepRegistry { - private final ConcurrentMap> map = new ConcurrentHashMap>(); + private final ConcurrentMap> map = new ConcurrentHashMap>(); - public void register(String jobName, Collection 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 steps) throws DuplicateJobException { + Assert.notNull(jobName, "The job name cannot be null."); + Assert.notNull(steps, "The job steps cannot be null."); - final Map jobSteps = new HashMap(); - 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 jobSteps = new HashMap(); + 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"); + } + } - 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); + } - 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 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 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 + "]"); + } + } + } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/OsgiBundleXmlApplicationContextFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/OsgiBundleXmlApplicationContextFactory.java index e83d7fc3c..82c2942fa 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/OsgiBundleXmlApplicationContextFactory.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/OsgiBundleXmlApplicationContextFactory.java @@ -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,9 +58,10 @@ public class OsgiBundleXmlApplicationContextFactory implements BundleContextAwar /** * Setter for the parent application context. - * + * * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) */ + @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { parent = applicationContext; } @@ -68,9 +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 public void setBundleContext(BundleContext context) { this.bundleContext = context; } @@ -79,9 +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 public ConfigurableApplicationContext createApplicationContext() { OsgiBundleXmlApplicationContext context = new OsgiBundleXmlApplicationContext(new String[] { path }, parent); String displayName = bundleContext.getBundle().getSymbolicName() + ":" + this.displayName; @@ -105,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()); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ReferenceJobFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ReferenceJobFactory.java index e4f60fef0..0427aebe3 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ReferenceJobFactory.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ReferenceJobFactory.java @@ -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,18 +38,20 @@ public class ReferenceJobFactory implements JobFactory { /** * Just return the instance passed in on initialization. - * + * * @see JobFactory#createJob() */ + @Override public final Job createJob() { return job; } - + /** * Just return the name of instance passed in on initialization. - * + * * @see JobFactory#getJobName() */ + @Override public String getJobName() { return job.getName(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceHandler.java index 2ff043353..53890ac24 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceHandler.java @@ -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,16 +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 public void init() { this.registerBeanDefinitionParser("job", new JobParser()); this.registerBeanDefinitionParser("flow", new TopLevelFlowParser()); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespacePostProcessor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespacePostProcessor.java index 0fca4ea9b..e7223c8fa 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespacePostProcessor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespacePostProcessor.java @@ -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,6 +49,7 @@ public class CoreNamespacePostProcessor implements BeanPostProcessor, BeanFactor private ApplicationContext applicationContext; + @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { for (String beanName : beanFactory.getBeanDefinitionNames()) { injectJobRepositoryIntoSteps(beanName, beanFactory); @@ -59,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 */ @@ -88,7 +89,7 @@ public class CoreNamespacePostProcessor implements BeanPostProcessor, BeanFactor * If any of the beans in the parent hierarchy is a <step/> with a * <tasklet/>, then the bean class must be * {@link StepParserStepFactoryBean}. - * + * * @param beanName * @param beanFactory */ @@ -101,6 +102,7 @@ public class CoreNamespacePostProcessor implements BeanPostProcessor, BeanFactor } } + @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { return injectDefaults(bean); } @@ -113,7 +115,7 @@ public class CoreNamespacePostProcessor implements BeanPostProcessor, BeanFactor *

  • Inject "transactionManager" into any * {@link StepParserStepFactoryBean} without a transactionManager. * - * + * * @param bean * @return */ @@ -140,10 +142,12 @@ public class CoreNamespacePostProcessor implements BeanPostProcessor, BeanFactor return bean; } + @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { return bean; } + @Override public void setApplicationContext(ApplicationContext applicationContext) { this.applicationContext = applicationContext; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobExecutionListenerParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobExecutionListenerParser.java index 899c8f5ee..7065b75f6 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobExecutionListenerParser.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobExecutionListenerParser.java @@ -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,17 +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 protected Class getBeanClass() { return JobListenerFactoryBean.class; } + @Override protected ListenerMetaData[] getMetaDataValues() { return JobListenerMetaData.values(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobParserJobFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobParserJobFactoryBean.java index 5e56019e8..202281f63 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobParserJobFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobParserJobFactoryBean.java @@ -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 <job/>. - * + * * @author Dan Garrette * @author Dave Syer * @since 2.0.1 @@ -55,6 +55,7 @@ class JobParserJobFactoryBean implements SmartFactoryBean { this.name = name; } + @Override public final Object getObject() throws Exception { Assert.isTrue(StringUtils.hasText(name), "The job must have an id."); FlowJob flowJob = new FlowJob(name); @@ -94,7 +95,7 @@ class JobParserJobFactoryBean implements SmartFactoryBean { public void setJobRepository(JobRepository jobRepository) { this.jobRepository = jobRepository; } - + public void setJobParametersValidator(JobParametersValidator jobParametersValidator) { this.jobParametersValidator = jobParametersValidator; } @@ -115,18 +116,22 @@ class JobParserJobFactoryBean implements SmartFactoryBean { this.flow = flow; } + @Override public Class getObjectType() { return FlowJob.class; } + @Override public boolean isSingleton() { return true; } - + + @Override public boolean isEagerInit() { return true; } - + + @Override public boolean isPrototype() { return false; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/SimpleFlowFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/SimpleFlowFactoryBean.java index 73549227b..b963d1d05 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/SimpleFlowFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/SimpleFlowFactoryBean.java @@ -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 stateTransitions) { this.stateTransitions = stateTransitions; @@ -58,13 +74,15 @@ public class SimpleFlowFactoryBean implements FactoryBean, InitializingBean { /** * Check mandatory properties (name). - * + * * @throws Exception */ + @Override public void afterPropertiesSet() throws Exception { Assert.hasText(name, "The flow must have a name"); } + @Override public Object getObject() throws Exception { SimpleFlow flow = new SimpleFlow(name); @@ -93,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 */ @@ -109,20 +127,22 @@ public class SimpleFlowFactoryBean implements FactoryBean, InitializingBean { return new DelegateState(stateName, state); } + @Override public Class getObjectType() { return SimpleFlow.class; } + @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; @@ -132,6 +152,7 @@ public class SimpleFlowFactoryBean implements FactoryBean, InitializingBean { this.state = state; } + @Override public boolean isEndState() { return state.isEndState(); } @@ -141,10 +162,11 @@ public class SimpleFlowFactoryBean implements FactoryBean, InitializingBean { return state.handle(executor); } + @Override public Collection getFlows() { return (state instanceof FlowHolder) ? ((FlowHolder)state).getFlows() : Collections.emptyList(); } - + } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepListenerParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepListenerParser.java index c85bbcc5d..bc33146f6 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepListenerParser.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepListenerParser.java @@ -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,15 +53,17 @@ public class StepListenerParser extends AbstractListenerParser { this.listenerMetaData = listenerMetaData; } + @Override protected Class getBeanClass() { return StepListenerFactoryBean.class; } + @Override protected ListenerMetaData[] getMetaDataValues() { return listenerMetaData; } - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "rawtypes"}) public void handleListenersElement(Element stepElement, BeanDefinition beanDefinition, ParserContext parserContext) { MutablePropertyValues propertyValues = beanDefinition.getPropertyValues(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java index 0012c76bb..9cecd4c43 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java @@ -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 <step/> (and its inner <tasklet/>). 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 implements FactoryBean, BeanNameAware { // @@ -217,9 +218,10 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * Create a {@link Step} from the configuration provided. - * + * * @see FactoryBean#getObject() */ + @Override public final Object getObject() throws Exception { if (hasChunkElement) { Assert.isNull(tasklet, "Step [" + name @@ -381,7 +383,6 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { @SuppressWarnings("unchecked") private Step createSimpleStep() { - @SuppressWarnings("rawtypes") SimpleStepBuilder builder = new SimpleStepBuilder(new StepBuilder(name)); if (commitInterval != null) { builder.chunk(commitInterval); @@ -401,6 +402,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { return builder.build(); } + @SuppressWarnings("serial") private void enhanceTaskletStepBuilder(AbstractTaskletStepBuilder builder) { enhanceCommonStep(builder); @@ -473,7 +475,7 @@ class StepParserStepFactoryBean 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) @@ -495,7 +497,7 @@ class StepParserStepFactoryBean 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 */ @@ -525,10 +527,12 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { return n != null && n > 0; } + @Override public Class getObjectType() { return TaskletStep.class; } + @Override public boolean isSingleton() { return true; } @@ -539,9 +543,10 @@ class StepParserStepFactoryBean 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 public void setBeanName(String name) { if (this.name == null) { this.name = name; @@ -628,7 +633,7 @@ class StepParserStepFactoryBean 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) { @@ -645,7 +650,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * Public setter for {@link JobRepository}. - * + * * @param jobRepository */ public void setJobRepository(JobRepository jobRepository) { @@ -654,7 +659,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * The number of times that the step should be allowed to start - * + * * @param startLimit */ public void setStartLimit(int startLimit) { @@ -663,7 +668,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * A preconfigured {@link Tasklet} to use. - * + * * @param tasklet */ public void setTasklet(Tasklet tasklet) { @@ -691,7 +696,7 @@ class StepParserStepFactoryBean 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) { @@ -730,7 +735,7 @@ class StepParserStepFactoryBean 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> noRollbackExceptionClasses) { @@ -764,7 +769,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * A backoff policy to be applied to retry process. - * + * * @param backOffPolicy the {@link BackOffPolicy} to set */ public void setBackOffPolicy(BackOffPolicy backOffPolicy) { @@ -774,7 +779,7 @@ class StepParserStepFactoryBean 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) { @@ -791,7 +796,7 @@ class StepParserStepFactoryBean 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) { @@ -810,7 +815,7 @@ class StepParserStepFactoryBean 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}.
    - * + * * @param cacheCapacity the cache capacity to set (greater than 0 else ignored) */ public void setCacheCapacity(int cacheCapacity) { @@ -821,7 +826,7 @@ class StepParserStepFactoryBean 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) { @@ -830,7 +835,7 @@ class StepParserStepFactoryBean 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) { @@ -840,7 +845,7 @@ class StepParserStepFactoryBean 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) { @@ -850,7 +855,7 @@ class StepParserStepFactoryBean 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) { @@ -860,7 +865,7 @@ class StepParserStepFactoryBean 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 retryLimit == 1 by default. - * + * * @param retryLimit the retry limit to set, must be greater or equal to 1. */ public void setRetryLimit(int retryLimit) { @@ -871,7 +876,7 @@ class StepParserStepFactoryBean 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) { @@ -880,7 +885,7 @@ class StepParserStepFactoryBean 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) { @@ -890,7 +895,7 @@ class StepParserStepFactoryBean 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) { @@ -900,7 +905,7 @@ class StepParserStepFactoryBean 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) { @@ -934,7 +939,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * Public setter for the {@link RetryListener}s. - * + * * @param retryListeners the {@link RetryListener}s to set */ public void setRetryListeners(RetryListener... retryListeners) { @@ -944,7 +949,7 @@ class StepParserStepFactoryBean 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, Boolean> exceptionClasses) { @@ -953,7 +958,7 @@ class StepParserStepFactoryBean 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, Boolean> retryableExceptionClasses) { @@ -963,7 +968,7 @@ class StepParserStepFactoryBean 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) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java index 1b4a73959..7c1d8c000 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java @@ -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 "(<type>)" where * type is one of string, date, long are converted to the corresponding type. * The default type is string. E.g. - * + * *
      * schedule.date(date)=2007/12/11
      * department.id(long)=2345
      * 
    - * + * * The literal values are converted to the correct type using the default Spring * strategies, augmented if necessary by the custom editors provided. - * + * *
    - * + * * 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,12 +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 public JobParameters getJobParameters(Properties props) { if (props == null || props.isEmpty()) { @@ -103,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); } @@ -143,16 +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 public Properties getProperties(JobParameters params) { if (params == null || params.isEmpty()) { @@ -197,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) { @@ -207,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) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/AbstractJobExplorerFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/AbstractJobExplorerFactoryBean.java index 8a1753335..a6219d8d1 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/AbstractJobExplorerFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/AbstractJobExplorerFactoryBean.java @@ -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,21 +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 public Class getObjectType() { return JobExplorer.class; } + @Override public boolean isSingleton() { return true; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/JobExplorerFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/JobExplorerFactoryBean.java index c14e305de..f60b57920 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/JobExplorerFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/JobExplorerFactoryBean.java @@ -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,6 +107,7 @@ public class JobExplorerFactoryBean extends AbstractJobExplorerFactoryBean this.lobHandler = lobHandler; } + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(dataSource, "DataSource must not be null."); @@ -168,6 +169,7 @@ public class JobExplorerFactoryBean extends AbstractJobExplorerFactoryBean return dao; } + @Override public Object getObject() throws Exception { return getTarget(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/MapJobExplorerFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/MapJobExplorerFactoryBean.java index a8f63dbb1..b8df7e977 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/MapJobExplorerFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/MapJobExplorerFactoryBean.java @@ -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,6 +65,7 @@ public class MapJobExplorerFactoryBean extends AbstractJobExplorerFactoryBean im * @throws Exception * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { Assert.state(repositoryFactory != null, "A MapJobRepositoryFactoryBean must be provided"); repositoryFactory.afterPropertiesSet(); @@ -90,6 +91,7 @@ public class MapJobExplorerFactoryBean extends AbstractJobExplorerFactoryBean im return repositoryFactory.getExecutionContextDao(); } + @Override public Object getObject() throws Exception { return new SimpleJobExplorer(createJobInstanceDao(), createJobExecutionDao(), createStepExecutionDao(), createExecutionContextDao()); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/SimpleJobExplorer.java b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/SimpleJobExplorer.java index bc5924de1..6839d6953 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/SimpleJobExplorer.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/SimpleJobExplorer.java @@ -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,11 +68,12 @@ public class SimpleJobExplorer implements JobExplorer { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.explore.JobExplorer#findJobExecutions( * org.springframework.batch.core.JobInstance) */ + @Override public List getJobExecutions(JobInstance jobInstance) { List executions = jobExecutionDao.findJobExecutions(jobInstance); for (JobExecution jobExecution : executions) { @@ -86,11 +87,12 @@ public class SimpleJobExplorer implements JobExplorer { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.explore.JobExplorer#findRunningJobExecutions * (java.lang.String) */ + @Override public Set findRunningJobExecutions(String jobName) { Set executions = jobExecutionDao.findRunningJobExecutions(jobName); for (JobExecution jobExecution : executions) { @@ -104,11 +106,12 @@ public class SimpleJobExplorer implements JobExplorer { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.explore.JobExplorer#getJobExecution(java * .lang.Long) */ + @Override public JobExecution getJobExecution(Long executionId) { if (executionId == null) { return null; @@ -126,11 +129,12 @@ public class SimpleJobExplorer implements JobExplorer { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.explore.JobExplorer#getStepExecution(java * .lang.Long) */ + @Override public StepExecution getStepExecution(Long jobExecutionId, Long executionId) { JobExecution jobExecution = jobExecutionDao.getJobExecution(jobExecutionId); if (jobExecution == null) { @@ -143,31 +147,34 @@ public class SimpleJobExplorer implements JobExplorer { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.explore.JobExplorer#getJobInstance(java * .lang.Long) */ + @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 public List getJobInstances(String jobName, int start, int count) { return jobInstanceDao.getJobInstances(jobName, start, count); } /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.explore.JobExplorer#getJobNames() */ + @Override public List getJobNames() { return jobInstanceDao.getJobNames(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java index 25ffc629b..b8941b3c5 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java @@ -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,9 +105,10 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, /** * Assert mandatory properties: {@link JobRepository}. - * + * * @see InitializingBean#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(jobRepository, "JobRepository must be set"); } @@ -118,9 +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 public void setBeanName(String name) { if (this.name == null) { this.name = name; @@ -130,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) { @@ -139,9 +141,10 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.IJob#getName() */ + @Override public String getName() { return name; } @@ -149,19 +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 public abstract Step getStep(String stepName); /** * Retrieve the step names. - * + * * @return the step names */ + @Override public abstract Collection getStepNames(); + @Override public JobParametersValidator getJobParametersValidator() { return jobParametersValidator; } @@ -169,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) */ @@ -180,13 +186,14 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, /** * @see Job#isRestartable() */ + @Override public boolean isRestartable() { return restartable; } /** * Public setter for the {@link JobParametersIncrementer}. - * + * * @param jobParametersIncrementer * the {@link JobParametersIncrementer} to set */ @@ -197,9 +204,10 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.Job#getJobParametersIncrementer() */ + @Override public JobParametersIncrementer getJobParametersIncrementer() { return this.jobParametersIncrementer; } @@ -207,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. */ @@ -220,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} */ @@ -232,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) { @@ -242,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() { @@ -254,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) @@ -268,11 +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 public final void execute(JobExecution execution) { logger.debug("Job execution starting: " + execution); @@ -325,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()); @@ -349,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 @@ -375,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} @@ -402,6 +411,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, jobRepository.update(jobExecution); } + @Override public String toString() { return ClassUtils.getShortName(getClass()) + ": [name=" + name + "]"; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/CompositeJobParametersValidator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/CompositeJobParametersValidator.java index d9a3d006d..c8e449aec 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/CompositeJobParametersValidator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/CompositeJobParametersValidator.java @@ -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,28 +25,29 @@ import org.springframework.util.Assert; /** * Composite {@link JobParametersValidator} that passes the job parameters through a sequence of - * injected JobParametersValidators - * + * injected JobParametersValidators + * * @author Morten Andersen-Gott * */ public class CompositeJobParametersValidator implements JobParametersValidator, InitializingBean { private List 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 public void validate(JobParameters parameters) throws JobParametersInvalidException { for (JobParametersValidator validator : validators) { validator.validate(parameters); } } - + /** * Public setter for the validators * @param validators @@ -55,11 +56,12 @@ public class CompositeJobParametersValidator implements JobParametersValidator, this.validators = validators; } + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(validators, "The 'validators' may not be null"); Assert.notEmpty(validators, "The 'validators' may not be empty"); } - - + + } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/DefaultJobParametersValidator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/DefaultJobParametersValidator.java index 259a2d472..2e81f4731 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/DefaultJobParametersValidator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/DefaultJobParametersValidator.java @@ -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,6 +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 public void afterPropertiesSet() throws IllegalStateException { for (String key : requiredKeys) { Assert.state(!optionalKeys.contains(key), "Optional keys canot be required: " + key); @@ -61,11 +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 public void validate(JobParameters parameters) throws JobParametersInvalidException { if (parameters == null) { @@ -107,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) { @@ -121,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) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java index f9e4363f9..3ea13e82a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java @@ -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 steps) { @@ -69,9 +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 public Collection getStepNames() { List names = new ArrayList(); for (Step step : steps) { @@ -82,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) { @@ -91,10 +92,11 @@ public class SimpleJob extends AbstractJob { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.job.AbstractJob#getStep(java.lang.String) */ + @Override public Step getStep(String stepName) { for (Step step : this.steps) { if (step.getName().equals(stepName)) { @@ -108,13 +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 protected void doExecute(JobExecution execution) throws JobInterruptedException, JobRestartException, - StartLimitExceededException { + StartLimitExceededException { StepExecution stepExecution = null; for (Step step : steps) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleStepHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleStepHandler.java index 33a2e52f7..21a494085 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleStepHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleStepHandler.java @@ -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,9 +71,10 @@ public class SimpleStepHandler implements StepHandler, InitializingBean { /** * Check mandatory properties (jobRepository). - * + * * @see InitializingBean#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { Assert.state(jobRepository != null, "A JobRepository must be provided"); } @@ -88,15 +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 public StepExecution handleStep(Step step, JobExecution execution) throws JobInterruptedException, - JobRestartException, StartLimitExceededException { + JobRestartException, StartLimitExceededException { if (execution.isStopping()) { throw new JobInterruptedException("JobExecution interrupted."); } @@ -176,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 diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/builder/JobFlowBuilder.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/builder/JobFlowBuilder.java index 55e7ec971..091ebece1 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/builder/JobFlowBuilder.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/builder/JobFlowBuilder.java @@ -21,7 +21,7 @@ import org.springframework.batch.core.job.flow.JobExecutionDecider; /** * @author Dave Syer - * + * */ public class JobFlowBuilder extends FlowBuilder { @@ -53,9 +53,10 @@ public class JobFlowBuilder extends FlowBuilder { /** * 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 public FlowJobBuilder build() { Flow flow = flow(); parent.flow(flow); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowExecution.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowExecution.java index 07dca573a..c20c35612 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowExecution.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowExecution.java @@ -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,12 +51,13 @@ public class FlowExecution implements Comparable { /** * 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 public int compareTo(FlowExecution other) { return this.status.compareTo(other.getStatus()); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowExecutionStatus.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowExecutionStatus.java index 42a4131c2..24416fe93 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowExecutionStatus.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowExecutionStatus.java @@ -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,12 +101,13 @@ public class FlowExecutionStatus implements Comparable { /** * 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 public int compareTo(FlowExecutionStatus other) { Status one = Status.match(this.name); Status two = Status.match(other.name); @@ -119,7 +120,7 @@ public class FlowExecutionStatus implements Comparable { /** * Check the equality of the statuses. - * + * * @see java.lang.Object#equals(java.lang.Object) */ @Override diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/JobFlowExecutor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/JobFlowExecutor.java index 6017d086e..35eb94382 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/JobFlowExecutor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/JobFlowExecutor.java @@ -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,12 +56,13 @@ public class JobFlowExecutor implements FlowExecutor { stepExecutionHolder.set(null); } + @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()); @@ -69,6 +70,7 @@ public class JobFlowExecutor implements FlowExecutor { return stepExecution.getExitStatus().getExitCode(); } + @Override public void abandonStepExecution() { StepExecution lastStepExecution = stepExecutionHolder.get(); if (lastStepExecution != null && lastStepExecution.getStatus().isGreaterThan(BatchStatus.STOPPING)) { @@ -77,24 +79,29 @@ public class JobFlowExecutor implements FlowExecutor { } } + @Override public void updateJobExecutionStatus(FlowExecutionStatus status) { execution.setStatus(findBatchStatus(status)); exitStatus = exitStatus.and(new ExitStatus(status.getName())); execution.setExitStatus(exitStatus); } + @Override public JobExecution getJobExecution() { return execution; } + @Override public StepExecution getStepExecution() { return stepExecutionHolder.get(); } + @Override public void close(FlowExecution result) { stepExecutionHolder.set(null); } + @Override public boolean isRestart() { if (getStepExecution() != null && getStepExecution().getStatus() == BatchStatus.ABANDONED) { /* @@ -107,6 +114,7 @@ public class JobFlowExecutor implements FlowExecutor { return execution.getStepExecutions().isEmpty(); } + @Override public void addExitStatus(String code) { exitStatus = exitStatus.and(new ExitStatus(code)); } @@ -124,4 +132,4 @@ public class JobFlowExecutor implements FlowExecutor { return BatchStatus.UNKNOWN; } -} \ No newline at end of file +} diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/SimpleFlow.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/SimpleFlow.java index e3662dc26..08d2f460c 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/SimpleFlow.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/SimpleFlow.java @@ -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,16 +72,17 @@ public class SimpleFlow implements Flow, InitializingBean { /** * Get the name for this flow. - * + * * @see Flow#getName() */ + @Override public String getName() { return name; } /** * Public setter for the stateTransitions. - * + * * @param stateTransitions the stateTransitions to set */ public void setStateTransitions(List stateTransitions) { @@ -92,22 +93,25 @@ public class SimpleFlow implements Flow, InitializingBean { /** * {@inheritDoc} */ + @Override public State getState(String stateName) { return stateMap.get(stateName); } - + /** * {@inheritDoc} */ + @Override public Collection getStates() { return new HashSet(stateMap.values()); } /** * Locate start state and pre-populate data structures needed for execution. - * + * * @see InitializingBean#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { initializeTransitions(); } @@ -115,6 +119,7 @@ public class SimpleFlow implements Flow, InitializingBean { /** * @see Flow#start(FlowExecutor) */ + @Override public FlowExecution start(FlowExecutor executor) throws FlowExecutionException { if (startState == null) { initializeTransitions(); @@ -127,6 +132,7 @@ public class SimpleFlow implements Flow, InitializingBean { /** * @see Flow#resume(String, FlowExecutor) */ + @Override public FlowExecution resume(String stateName, FlowExecutor executor) throws FlowExecutionException { FlowExecutionStatus status = FlowExecutionStatus.UNKNOWN; @@ -152,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); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/StateTransition.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/StateTransition.java index 35c136166..4afafcead 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/StateTransition.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/StateTransition.java @@ -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 { * 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 { * 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 { /** * 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 { /** * 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 { /** * 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 { /** * 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 { /** * 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,6 +165,7 @@ public final class StateTransition implements Comparable { * fo? > foo. * @see Comparable#compareTo(Object) */ + @Override public int compareTo(StateTransition other) { String value = other.pattern; if (pattern.equals(value)) { @@ -191,7 +192,7 @@ public final class StateTransition implements Comparable { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/AbstractState.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/AbstractState.java index 7104dacb9..ee531dfa7 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/AbstractState.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/AbstractState.java @@ -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,20 +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 public String getName() { return name; } - + /* (non-Javadoc) * @see java.lang.Object#toString() */ @@ -46,7 +47,8 @@ public abstract class AbstractState implements State { public String toString() { return getClass().getSimpleName()+": name=["+name+"]"; } - + + @Override public abstract FlowExecutionStatus handle(FlowExecutor executor) throws Exception; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/DecisionState.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/DecisionState.java index 3265397a8..704ebba5b 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/DecisionState.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/DecisionState.java @@ -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,12 +42,13 @@ 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 public boolean isEndState() { return false; } -} \ No newline at end of file +} diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/EndState.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/EndState.java index 046228a23..c8782ff31 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/EndState.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/EndState.java @@ -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,20 +116,21 @@ public class EndState extends AbstractState { /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.job.flow.State#isEndState() */ + @Override public boolean isEndState() { return !status.isStop(); } /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override public String toString() { return super.toString() + " status=[" + status + "]"; } -} \ No newline at end of file +} diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/FlowState.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/FlowState.java index 1f8f141a4..4c75971e9 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/FlowState.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/FlowState.java @@ -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,10 +41,11 @@ public class FlowState extends AbstractState implements FlowHolder { super(name); this.flow = flow; } - + /** * @return the flows */ + @Override public Collection getFlows() { return Collections.singleton(flow); } @@ -53,12 +54,13 @@ 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 public boolean isEndState() { return false; } -} \ No newline at end of file +} diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/MaxValueFlowExecutionAggregator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/MaxValueFlowExecutionAggregator.java index 718811833..b66b3e275 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/MaxValueFlowExecutionAggregator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/MaxValueFlowExecutionAggregator.java @@ -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,9 +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 public FlowExecutionStatus aggregate(Collection executions) { if (executions == null || executions.size() == 0) { return FlowExecutionStatus.UNKNOWN; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/SplitState.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/SplitState.java index 887b611a7..a5e7ed3ae 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/SplitState.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/SplitState.java @@ -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,10 +63,11 @@ public class SplitState extends AbstractState implements FlowHolder { public void setTaskExecutor(TaskExecutor taskExecutor) { this.taskExecutor = taskExecutor; } - + /** * @return the flows */ + @Override public Collection getFlows() { return flows; } @@ -74,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 @@ -87,6 +88,7 @@ public class SplitState extends AbstractState implements FlowHolder { for (final Flow flow : flows) { final FutureTask task = new FutureTask(new Callable() { + @Override public FlowExecution call() throws Exception { return flow.start(executor); } @@ -127,9 +129,10 @@ public class SplitState extends AbstractState implements FlowHolder { /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.job.flow.State#isEndState() */ + @Override public boolean isEndState() { return false; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/StepState.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/StepState.java index f9b0b1a0c..b319908b4 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/StepState.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/StepState.java @@ -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,13 +63,15 @@ public class StepState extends AbstractState implements StepHolder { /** * @return the step */ + @Override public Step getStep() { return step; } - + /* (non-Javadoc) * @see org.springframework.batch.core.job.flow.State#isEndState() */ + @Override public boolean isEndState() { return false; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/JobRegistryBackgroundJobRunner.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/JobRegistryBackgroundJobRunner.java index 08b6e5293..0cffcdfd7 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/JobRegistryBackgroundJobRunner.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/JobRegistryBackgroundJobRunner.java @@ -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. *

    - * + * *

    * 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. *

    - * + * * @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: - * + * *
     	 * $ java -classpath ... JobRegistryBackgroundJobRunner job-registry-context.xml job1.xml job2.xml ...
     	 * 
    - * + * * 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,6 +202,7 @@ public class JobRegistryBackgroundJobRunner { logger.info("Starting job registry in parent context from XML at: [" + args[0] + "]"); new Thread(new Runnable() { + @Override public void run() { try { launcher.run(); @@ -240,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(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/JvmSystemExiter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/JvmSystemExiter.java index 4dafcb42f..733d15b04 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/JvmSystemExiter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/JvmSystemExiter.java @@ -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,9 +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 public void exit(int status) { System.exit(status); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/RunIdIncrementer.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/RunIdIncrementer.java index 6bea1f53d..25abace0a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/RunIdIncrementer.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/RunIdIncrementer.java @@ -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,10 +40,11 @@ public class RunIdIncrementer implements JobParametersIncrementer { /** * Increment the run.id parameter (starting with 1). */ + @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(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/RuntimeExceptionTranslator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/RuntimeExceptionTranslator.java index 1321a2217..3b30b8bbf 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/RuntimeExceptionTranslator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/RuntimeExceptionTranslator.java @@ -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,6 +27,7 @@ public class RuntimeExceptionTranslator implements MethodInterceptor { /* (non-Javadoc) * @see org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation) */ + @Override public Object invoke(MethodInvocation invocation) throws Throwable { try { return invocation.proceed(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/ScheduledJobParametersFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/ScheduledJobParametersFactory.java index eadc1c40f..520990817 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/ScheduledJobParametersFactory.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/ScheduledJobParametersFactory.java @@ -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,9 +40,10 @@ public class ScheduledJobParametersFactory implements JobParametersConverter { /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.runtime.JobParametersFactory#getJobParameters(java.util.Properties) */ + @Override public JobParameters getJobParameters(Properties props) { if (props == null || props.isEmpty()) { @@ -70,9 +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 public Properties getProperties(JobParameters params) { if (params == null || params.isEmpty()) { @@ -95,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) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobLauncher.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobLauncher.java index 44fddf184..68e3d2df3 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobLauncher.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobLauncher.java @@ -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,6 +83,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean { * completed successfully * @throws JobParametersInvalidException */ + @Override public JobExecution run(final Job job, final JobParameters jobParameters) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException, JobParametersInvalidException { @@ -113,6 +114,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean { try { taskExecutor.execute(new Runnable() { + @Override public void run() { try { logger.info("Job: [" + job + "] launched with the following parameters: [" + jobParameters @@ -153,7 +155,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean { /** * Set the JobRepsitory. - * + * * @param jobRepository */ public void setJobRepository(JobRepository jobRepository) { @@ -162,7 +164,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean { /** * Set the TaskExecutor. (Optional) - * + * * @param taskExecutor */ public void setTaskExecutor(TaskExecutor taskExecutor) { @@ -173,6 +175,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean { * Ensure the required dependencies of a {@link JobRepository} have been * set. */ + @Override public void afterPropertiesSet() throws Exception { Assert.state(jobRepository != null, "A JobRepository has not been set."); if (taskExecutor == null) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobOperator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobOperator.java index 0556879b0..c57c54492 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobOperator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobOperator.java @@ -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: - * + * *
      *
    • {@link JobLauncher} *
    • {@link JobExplorer} *
    • {@link JobRepository} *
    • {@link JobRegistry} *
    - * + * * @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,9 +95,10 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /** * Check mandatory properties. - * + * * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(jobLauncher, "JobLauncher must be provided"); Assert.notNull(jobRegistry, "JobLocator must be provided"); @@ -143,9 +144,10 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.launch.JobOperator#getExecutions(java.lang.Long) */ + @Override public List getExecutions(long instanceId) throws NoSuchJobInstanceException { JobInstance jobInstance = jobExplorer.getJobInstance(instanceId); if (jobInstance == null) { @@ -160,18 +162,20 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.launch.JobOperator#getJobNames() */ + @Override public Set getJobNames() { return new TreeSet(jobRegistry.getJobNames()); } /* * (non-Javadoc) - * + * * @see JobOperator#getLastInstances(String, int, int) */ + @Override public List getJobInstances(String jobName, int start, int count) throws NoSuchJobException { List list = new ArrayList(); for (JobInstance jobInstance : jobExplorer.getJobInstances(jobName, start, count)) { @@ -185,11 +189,12 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.launch.JobOperator#getParameters(java. * lang.Long) */ + @Override public String getParameters(long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = findExecutionById(executionId); @@ -199,11 +204,12 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.launch.JobOperator#getRunningExecutions * (java.lang.String) */ + @Override public Set getRunningExecutions(String jobName) throws NoSuchJobException { Set set = new LinkedHashSet(); for (JobExecution jobExecution : jobExplorer.findRunningJobExecutions(jobName)) { @@ -217,11 +223,12 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.launch.JobOperator#getStepExecutionSummaries * (java.lang.Long) */ + @Override public Map getStepExecutionSummaries(long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = findExecutionById(executionId); @@ -234,11 +241,12 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.launch.JobOperator#getSummary(java.lang * .Long) */ + @Override public String getSummary(long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = findExecutionById(executionId); return jobExecution.toString(); @@ -246,10 +254,11 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.launch.JobOperator#resume(java.lang.Long) */ + @Override public Long restart(long executionId) throws JobInstanceAlreadyCompleteException, NoSuchJobExecutionException, NoSuchJobException, JobRestartException, JobParametersInvalidException { logger.info("Checking status of job execution with id=" + executionId); @@ -273,11 +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 public Long start(String jobName, String parameters) throws NoSuchJobException, JobInstanceAlreadyExistsException, JobParametersInvalidException { logger.info("Checking status of job with name=" + jobName); @@ -314,11 +324,12 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /* * (non-Javadoc) - * + * * @see JobOperator#startNextInstance(String ) */ + @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); @@ -362,10 +373,11 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.launch.JobOperator#stop(java.lang.Long) */ + @Override @Transactional public boolean stop(long executionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException { @@ -383,21 +395,22 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { return true; } - 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); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapper.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapper.java index 43002b512..e97776b24 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapper.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapper.java @@ -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,6 +67,7 @@ public class SimpleJvmExitCodeMapper implements ExitCodeMapper { * Framework * @return The exitCode of the Batch Job as known by the JVM */ + @Override public int intValue(String exitCode) { Integer statusCode = null; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/AbstractListenerFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/AbstractListenerFactoryBean.java index 3bd6bb8c1..23604e4e4 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/AbstractListenerFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/AbstractListenerFactoryBean.java @@ -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: - * + * *
      *
    • 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; *
    • String name of the method to be called, which is tied to a * {@link ListenerMetaData} value in the metaDataMap. *
    - * + * * 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,18 +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 metaDataMap; + @Override public Object getObject() { if (metaDataMap == null) { @@ -101,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); @@ -174,6 +176,7 @@ public abstract class AbstractListenerFactoryBean implements FactoryBean, Initia } } + @Override public boolean isSingleton() { return true; } @@ -186,6 +189,7 @@ public abstract class AbstractListenerFactoryBean implements FactoryBean, Initia this.metaDataMap = metaDataMap; } + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(delegate, "Delegate must not be null"); } @@ -193,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 diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ChunkListenerSupport.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ChunkListenerSupport.java index 06635cebb..8d7979de5 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ChunkListenerSupport.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ChunkListenerSupport.java @@ -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,12 +28,14 @@ public class ChunkListenerSupport implements ChunkListener { /* (non-Javadoc) * @see org.springframework.batch.core.domain.ChunkListener#afterChunk() */ + @Override public void afterChunk() { } /* (non-Javadoc) * @see org.springframework.batch.core.domain.ChunkListener#beforeChunk() */ + @Override public void beforeChunk() { } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeChunkListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeChunkListener.java index 98c411972..2109fba0b 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeChunkListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeChunkListener.java @@ -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 listeners) { @@ -40,7 +40,7 @@ public class CompositeChunkListener implements ChunkListener { /** * Register additional listener. - * + * * @param chunkListener */ public void register(ChunkListener chunkListener) { @@ -50,9 +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 public void afterChunk() { for (Iterator iterator = listeners.iterator(); iterator.hasNext();) { ChunkListener listener = iterator.next(); @@ -62,9 +63,10 @@ public class CompositeChunkListener implements ChunkListener { /** * Call the registered listeners in reverse order. - * + * * @see org.springframework.batch.core.ChunkListener#beforeChunk() */ + @Override public void beforeChunk() { for (Iterator iterator = listeners.reverse(); iterator.hasNext();) { ChunkListener listener = iterator.next(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemProcessListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemProcessListener.java index a0b05dec1..8a85ac1fb 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemProcessListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemProcessListener.java @@ -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 implements ItemProcessListener { @@ -31,7 +31,7 @@ public class CompositeItemProcessListener implements ItemProcessListener> itemReadListeners) { @@ -40,7 +40,7 @@ public class CompositeItemProcessListener implements ItemProcessListener itemReaderListener) { @@ -53,6 +53,7 @@ public class CompositeItemProcessListener implements ItemProcessListener> iterator = listeners.reverse(); iterator.hasNext();) { ItemProcessListener listener = iterator.next(); @@ -65,6 +66,7 @@ public class CompositeItemProcessListener implements ItemProcessListener> iterator = listeners.iterator(); iterator.hasNext();) { ItemProcessListener listener = iterator.next(); @@ -78,6 +80,7 @@ public class CompositeItemProcessListener implements ItemProcessListener> iterator = listeners.reverse(); iterator.hasNext();) { ItemProcessListener listener = iterator.next(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemReadListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemReadListener.java index e1841d1aa..18c782bb7 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemReadListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemReadListener.java @@ -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 implements ItemReadListener { @@ -32,7 +32,7 @@ public class CompositeItemReadListener implements ItemReadListener { /** * Public setter for the listeners. - * + * * @param itemReadListeners */ public void setListeners(List> itemReadListeners) { @@ -41,7 +41,7 @@ public class CompositeItemReadListener implements ItemReadListener { /** * Register additional listener. - * + * * @param itemReaderListener */ public void register(ItemReadListener itemReaderListener) { @@ -53,6 +53,7 @@ public class CompositeItemReadListener implements ItemReadListener { * prioritising those that implement {@link Ordered}. * @see org.springframework.batch.core.ItemReadListener#afterRead(java.lang.Object) */ + @Override public void afterRead(T item) { for (Iterator> iterator = listeners.reverse(); iterator.hasNext();) { ItemReadListener listener = iterator.next(); @@ -65,6 +66,7 @@ public class CompositeItemReadListener implements ItemReadListener { * that implement {@link Ordered}. * @see org.springframework.batch.core.ItemReadListener#beforeRead() */ + @Override public void beforeRead() { for (Iterator> iterator = listeners.iterator(); iterator.hasNext();) { ItemReadListener listener = iterator.next(); @@ -77,6 +79,7 @@ public class CompositeItemReadListener implements ItemReadListener { * prioritising those that implement {@link Ordered}. * @see org.springframework.batch.core.ItemReadListener#onReadError(java.lang.Exception) */ + @Override public void onReadError(Exception ex) { for (Iterator> iterator = listeners.iterator(); iterator.hasNext();) { ItemReadListener listener = iterator.next(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemWriteListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemWriteListener.java index 9aae1476b..d7ecb635e 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemWriteListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemWriteListener.java @@ -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 implements ItemWriteListener { @@ -32,7 +32,7 @@ public class CompositeItemWriteListener implements ItemWriteListener { /** * Public setter for the listeners. - * + * * @param itemWriteListeners */ public void setListeners(List> itemWriteListeners) { @@ -41,7 +41,7 @@ public class CompositeItemWriteListener implements ItemWriteListener { /** * Register additional listener. - * + * * @param itemWriteListener */ public void register(ItemWriteListener itemWriteListener) { @@ -53,6 +53,7 @@ public class CompositeItemWriteListener implements ItemWriteListener { * prioritising those that implement {@link Ordered}. * @see ItemWriteListener#afterWrite(java.util.List) */ + @Override public void afterWrite(List items) { for (Iterator> iterator = listeners.reverse(); iterator.hasNext();) { ItemWriteListener listener = iterator.next(); @@ -65,6 +66,7 @@ public class CompositeItemWriteListener implements ItemWriteListener { * that implement {@link Ordered}. * @see ItemWriteListener#beforeWrite(List) */ + @Override public void beforeWrite(List items) { for (Iterator> iterator = listeners.iterator(); iterator.hasNext();) { ItemWriteListener listener = iterator.next(); @@ -77,6 +79,7 @@ public class CompositeItemWriteListener implements ItemWriteListener { * prioritising those that implement {@link Ordered}. * @see ItemWriteListener#onWriteError(Exception, List) */ + @Override public void onWriteError(Exception ex, List items) { for (Iterator> iterator = listeners.reverse(); iterator.hasNext();) { ItemWriteListener listener = iterator.next(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeJobExecutionListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeJobExecutionListener.java index 7506b3689..699073ec4 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeJobExecutionListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeJobExecutionListener.java @@ -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 listeners) { @@ -41,7 +41,7 @@ public class CompositeJobExecutionListener implements JobExecutionListener { /** * Register additional listener. - * + * * @param jobExecutionListener */ public void register(JobExecutionListener jobExecutionListener) { @@ -53,6 +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 public void afterJob(JobExecution jobExecution) { for (Iterator iterator = listeners.reverse(); iterator.hasNext();) { JobExecutionListener listener = iterator.next(); @@ -65,6 +66,7 @@ public class CompositeJobExecutionListener implements JobExecutionListener { * that implement {@link Ordered}. * @see org.springframework.batch.core.JobExecutionListener#beforeJob(org.springframework.batch.core.JobExecution) */ + @Override public void beforeJob(JobExecution jobExecution) { for (Iterator iterator = listeners.iterator(); iterator.hasNext();) { JobExecutionListener listener = iterator.next(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeSkipListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeSkipListener.java index 9db7313be..2e39c4e6f 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeSkipListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeSkipListener.java @@ -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 implements SkipListener { @@ -31,7 +31,7 @@ public class CompositeSkipListener implements SkipListener { /** * Public setter for the listeners. - * + * * @param listeners */ public void setListeners(List> listeners) { @@ -40,7 +40,7 @@ public class CompositeSkipListener implements SkipListener { /** * Register additional listener. - * + * * @param listener */ public void register(SkipListener listener) { @@ -52,6 +52,7 @@ public class CompositeSkipListener implements SkipListener { * that implement {@link Ordered}. * @see org.springframework.batch.core.SkipListener#onSkipInRead(java.lang.Throwable) */ + @Override public void onSkipInRead(Throwable t) { for (Iterator> iterator = listeners.iterator(); iterator.hasNext();) { SkipListener listener = iterator.next(); @@ -65,6 +66,7 @@ public class CompositeSkipListener implements SkipListener { * @see org.springframework.batch.core.SkipListener#onSkipInWrite(java.lang.Object, * java.lang.Throwable) */ + @Override public void onSkipInWrite(S item, Throwable t) { for (Iterator> iterator = listeners.iterator(); iterator.hasNext();) { SkipListener listener = iterator.next(); @@ -78,6 +80,7 @@ public class CompositeSkipListener implements SkipListener { * @see org.springframework.batch.core.SkipListener#onSkipInWrite(java.lang.Object, * java.lang.Throwable) */ + @Override public void onSkipInProcess(T item, Throwable t) { for (Iterator> iterator = listeners.iterator(); iterator.hasNext();) { SkipListener listener = iterator.next(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeStepExecutionListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeStepExecutionListener.java index 2c9dc6428..057295100 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeStepExecutionListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeStepExecutionListener.java @@ -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,9 +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 public ExitStatus afterStep(StepExecution stepExecution) { ExitStatus status = null; for (Iterator iterator = list.reverse(); iterator.hasNext();) { @@ -66,10 +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 public void beforeStep(StepExecution stepExecution) { for (Iterator iterator = list.iterator(); iterator.hasNext();) { StepExecutionListener listener = iterator.next(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ExecutionContextPromotionListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ExecutionContextPromotionListener.java index b5e322d91..0f55912ae 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ExecutionContextPromotionListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ExecutionContextPromotionListener.java @@ -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,6 +46,7 @@ public class ExecutionContextPromotionListener extends StepExecutionListenerSupp private boolean strict = false; + @Override public ExitStatus afterStep(StepExecution stepExecution) { ExecutionContext stepContext = stepExecution.getExecutionContext(); ExecutionContext jobContext = stepExecution.getJobExecution().getExecutionContext(); @@ -59,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; @@ -69,6 +70,7 @@ public class ExecutionContextPromotionListener extends StepExecutionListenerSupp return null; } + @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"); @@ -96,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) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ItemListenerSupport.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ItemListenerSupport.java index 5402580ed..4b305a5b5 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ItemListenerSupport.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ItemListenerSupport.java @@ -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,84 +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 implements ItemReadListener, ItemProcessListener, ItemWriteListener { /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.ItemReadListener#afterRead(java.lang.Object) */ + @Override public void afterRead(I item) { } /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.ItemReadListener#beforeRead() */ + @Override public void beforeRead() { } /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.ItemReadListener#onReadError(java.lang.Exception) */ + @Override public void onReadError(Exception ex) { } /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.ItemProcessListener#afterProcess(java.lang.Object, * java.lang.Object) */ + @Override public void afterProcess(I item, O result) { } /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.ItemProcessListener#beforeProcess(java.lang.Object) */ + @Override public void beforeProcess(I item) { } /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.ItemProcessListener#onProcessError(java.lang.Object, * java.lang.Exception) */ + @Override public void onProcessError(I item, Exception e) { } /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.ItemWriteListener#afterWrite() */ + @Override public void afterWrite(List item) { } /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.ItemWriteListener#beforeWrite(java.lang.Object) */ + @Override public void beforeWrite(List item) { } /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.ItemWriteListener#onWriteError(java.lang.Exception, * java.lang.Object) */ + @Override public void onWriteError(Exception ex, List item) { } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobExecutionListenerSupport.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobExecutionListenerSupport.java index 9f793c5f2..94ea48984 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobExecutionListenerSupport.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobExecutionListenerSupport.java @@ -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,14 @@ public class JobExecutionListenerSupport implements JobExecutionListener { /* (non-Javadoc) * @see org.springframework.batch.core.domain.JobListener#afterJob() */ + @Override public void afterJob(JobExecution jobExecution) { } /* (non-Javadoc) * @see org.springframework.batch.core.domain.JobListener#beforeJob(org.springframework.batch.core.domain.JobExecution) */ + @Override public void beforeJob(JobExecution jobExecution) { } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobListenerFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobListenerFactoryBean.java index 1294477f7..bb39640fc 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobListenerFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobListenerFactoryBean.java @@ -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,18 +29,22 @@ import org.springframework.batch.core.JobExecutionListener; */ public class JobListenerFactoryBean extends AbstractListenerFactoryBean { + @Override protected ListenerMetaData getMetaDataFromPropertyName(String propertyName) { return JobListenerMetaData.fromPropertyName(propertyName); } + @Override protected ListenerMetaData[] getMetaDataValues() { return JobListenerMetaData.values(); } + @Override protected Class getDefaultListenerClass() { return JobExecutionListener.class; } + @Override public Class getObjectType() { return JobExecutionListener.class; } @@ -48,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 */ @@ -61,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 diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobListenerMetaData.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobListenerMetaData.java index 078faccf1..14d0bd737 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobListenerMetaData.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobListenerMetaData.java @@ -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 annotation; private static final Map propertyMap; - + JobListenerMetaData(String methodName, String propertyName, Class annotation) { this.methodName = methodName; this.propertyName = propertyName; this.annotation = annotation; } - + static{ propertyMap = new HashMap(); for(JobListenerMetaData metaData : values()){ @@ -56,29 +56,34 @@ public enum JobListenerMetaData implements ListenerMetaData { } } + @Override public String getMethodName() { return methodName; } + @Override public Class getAnnotation() { return annotation; } + @Override public Class getListenerInterface() { return JobExecutionListener.class; } - + + @Override public String getPropertyName() { return propertyName; } - + + @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. */ diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MethodInvokerMethodInterceptor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MethodInvokerMethodInterceptor.java index 7d8d39b9d..ef2673730 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MethodInvokerMethodInterceptor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MethodInvokerMethodInterceptor.java @@ -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,6 +51,7 @@ public class MethodInvokerMethodInterceptor implements MethodInterceptor { this.invokerMap = invokerMap; } + @Override public Object invoke(MethodInvocation invocation) throws Throwable { String methodName = invocation.getMethod().getName(); @@ -91,7 +92,7 @@ public class MethodInvokerMethodInterceptor implements MethodInterceptor { MethodInvokerMethodInterceptor other = (MethodInvokerMethodInterceptor) obj; return invokerMap.equals(other.invokerMap); } - + /** * {@inheritDoc} */ diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MulticasterBatchListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MulticasterBatchListener.java index f77a2f0d2..83eb33171 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MulticasterBatchListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MulticasterBatchListener.java @@ -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 implements StepExecutionListener, ChunkListener, ItemReadListener, - ItemProcessListener, ItemWriteListener, SkipListener { +ItemProcessListener, ItemWriteListener, SkipListener { private CompositeStepExecutionListener stepListener = new CompositeStepExecutionListener(); @@ -106,6 +106,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @see org.springframework.batch.core.listener.CompositeItemProcessListener#afterProcess(java.lang.Object, * java.lang.Object) */ + @Override public void afterProcess(T item, S result) { try { itemProcessListener.afterProcess(item, result); @@ -119,6 +120,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @param item * @see org.springframework.batch.core.listener.CompositeItemProcessListener#beforeProcess(java.lang.Object) */ + @Override public void beforeProcess(T item) { try { itemProcessListener.beforeProcess(item); @@ -134,6 +136,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @see org.springframework.batch.core.listener.CompositeItemProcessListener#onProcessError(java.lang.Object, * java.lang.Exception) */ + @Override public void onProcessError(T item, Exception ex) { try { itemProcessListener.onProcessError(item, ex); @@ -146,6 +149,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch /** * @see org.springframework.batch.core.listener.CompositeStepExecutionListener#afterStep(StepExecution) */ + @Override public ExitStatus afterStep(StepExecution stepExecution) { try { return stepListener.afterStep(stepExecution); @@ -159,6 +163,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @param stepExecution * @see org.springframework.batch.core.listener.CompositeStepExecutionListener#beforeStep(org.springframework.batch.core.StepExecution) */ + @Override public void beforeStep(StepExecution stepExecution) { try { stepListener.beforeStep(stepExecution); @@ -172,6 +177,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * * @see org.springframework.batch.core.listener.CompositeChunkListener#afterChunk() */ + @Override public void afterChunk() { try { chunkListener.afterChunk(); @@ -185,6 +191,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * * @see org.springframework.batch.core.listener.CompositeChunkListener#beforeChunk() */ + @Override public void beforeChunk() { try { chunkListener.beforeChunk(); @@ -198,6 +205,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @param item * @see org.springframework.batch.core.listener.CompositeItemReadListener#afterRead(java.lang.Object) */ + @Override public void afterRead(T item) { try { itemReadListener.afterRead(item); @@ -211,6 +219,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * * @see org.springframework.batch.core.listener.CompositeItemReadListener#beforeRead() */ + @Override public void beforeRead() { try { itemReadListener.beforeRead(); @@ -224,6 +233,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @param ex * @see org.springframework.batch.core.listener.CompositeItemReadListener#onReadError(java.lang.Exception) */ + @Override public void onReadError(Exception ex) { try { itemReadListener.onReadError(ex); @@ -237,6 +247,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * * @see ItemWriteListener#afterWrite(List) */ + @Override public void afterWrite(List items) { try { itemWriteListener.afterWrite(items); @@ -250,6 +261,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @param items * @see ItemWriteListener#beforeWrite(List) */ + @Override public void beforeWrite(List items) { try { itemWriteListener.beforeWrite(items); @@ -264,6 +276,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @param items * @see ItemWriteListener#onWriteError(Exception, List) */ + @Override public void onWriteError(Exception ex, List items) { try { itemWriteListener.onWriteError(ex, items); @@ -277,6 +290,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @param t * @see org.springframework.batch.core.listener.CompositeSkipListener#onSkipInRead(java.lang.Throwable) */ + @Override public void onSkipInRead(Throwable t) { skipListener.onSkipInRead(t); } @@ -287,6 +301,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @see org.springframework.batch.core.listener.CompositeSkipListener#onSkipInWrite(java.lang.Object, * java.lang.Throwable) */ + @Override public void onSkipInWrite(S item, Throwable t) { skipListener.onSkipInWrite(item, t); } @@ -297,6 +312,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @see org.springframework.batch.core.listener.CompositeSkipListener#onSkipInProcess(Object, * Throwable) */ + @Override public void onSkipInProcess(T item, Throwable t) { skipListener.onSkipInProcess(item, t); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/SkipListenerSupport.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/SkipListenerSupport.java index 3ae689ee6..4afc57d9d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/SkipListenerSupport.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/SkipListenerSupport.java @@ -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,19 +28,22 @@ public class SkipListenerSupport implements SkipListener { /* (non-Javadoc) * @see org.springframework.batch.core.SkipListener#onSkipInRead(java.lang.Throwable) */ + @Override public void onSkipInRead(Throwable t) { } /* (non-Javadoc) * @see org.springframework.batch.core.SkipListener#onSkipInWrite(java.lang.Object, java.lang.Throwable) */ + @Override public void onSkipInWrite(S item, Throwable t) { } /* (non-Javadoc) * @see org.springframework.batch.core.SkipListener#onSkipInProcess(java.lang.Object, java.lang.Throwable) */ - public void onSkipInProcess(T item, Throwable t) { + @Override + public void onSkipInProcess(T item, Throwable t) { } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepExecutionListenerSupport.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepExecutionListenerSupport.java index 224dd7039..d87b01c12 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepExecutionListenerSupport.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepExecutionListenerSupport.java @@ -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,6 +28,7 @@ public class StepExecutionListenerSupport implements StepExecutionListener { /* (non-Javadoc) * @see org.springframework.batch.core.domain.StepListener#afterStep(StepExecution stepExecution) */ + @Override public ExitStatus afterStep(StepExecution stepExecution) { return null; } @@ -35,6 +36,7 @@ public class StepExecutionListenerSupport implements StepExecutionListener { /* (non-Javadoc) * @see org.springframework.batch.core.domain.StepListener#open(org.springframework.batch.item.ExecutionContext) */ + @Override public void beforeStep(StepExecution stepExecution) { } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerFactoryBean.java index 24500d6d3..e77ef8a60 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerFactoryBean.java @@ -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,18 +29,22 @@ import org.springframework.batch.core.StepListener; */ public class StepListenerFactoryBean extends AbstractListenerFactoryBean { + @Override protected ListenerMetaData getMetaDataFromPropertyName(String propertyName) { return StepListenerMetaData.fromPropertyName(propertyName); } + @Override protected ListenerMetaData[] getMetaDataValues() { return StepListenerMetaData.values(); } + @Override protected Class getDefaultListenerClass() { return StepListener.class; } + @Override @SuppressWarnings("rawtypes") public Class getObjectType() { return StepListener.class; @@ -49,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 */ @@ -62,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 diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerMetaData.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerMetaData.java index 753d7d21f..50a23c371 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerMetaData.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerMetaData.java @@ -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 annotation; private final Class listenerInterface; private final Class[] paramTypes; private static final Map propertyMap; - + StepListenerMetaData(String methodName, String propertyName, Class annotation, Class 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(); for(StepListenerMetaData metaData : values()){ @@ -94,36 +94,41 @@ public enum StepListenerMetaData implements ListenerMetaData { } } + @Override public String getMethodName() { return methodName; } + @Override public Class getAnnotation() { return annotation; } + @Override public Class getListenerInterface() { return listenerInterface; } + @Override public Class[] getParamTypes() { return paramTypes; } - + + @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}; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerSupport.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerSupport.java index 956c1a108..70d9d4028 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerSupport.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerSupport.java @@ -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,16 +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 implements StepExecutionListener, ChunkListener, - ItemReadListener, ItemProcessListener, ItemWriteListener, SkipListener { +ItemReadListener, ItemProcessListener, ItemWriteListener, SkipListener { /* (non-Javadoc) * @see org.springframework.batch.core.StepExecutionListener#afterStep(org.springframework.batch.core.StepExecution) */ + @Override public ExitStatus afterStep(StepExecution stepExecution) { return null; } @@ -46,90 +47,105 @@ public class StepListenerSupport implements StepExecutionListener, ChunkLis /* (non-Javadoc) * @see org.springframework.batch.core.StepExecutionListener#beforeStep(org.springframework.batch.core.StepExecution) */ + @Override public void beforeStep(StepExecution stepExecution) { } /* (non-Javadoc) * @see org.springframework.batch.core.domain.ChunkListener#afterChunk() */ + @Override public void afterChunk() { } /* (non-Javadoc) * @see org.springframework.batch.core.domain.ChunkListener#beforeChunk() */ + @Override public void beforeChunk() { } /* (non-Javadoc) * @see org.springframework.batch.core.domain.ItemReadListener#afterRead(java.lang.Object) */ + @Override public void afterRead(T item) { } /* (non-Javadoc) * @see org.springframework.batch.core.domain.ItemReadListener#beforeRead() */ + @Override public void beforeRead() { } /* (non-Javadoc) * @see org.springframework.batch.core.domain.ItemReadListener#onReadError(java.lang.Exception) */ + @Override public void onReadError(Exception ex) { } /* (non-Javadoc) * @see org.springframework.batch.core.ItemWriteListener#afterWrite(java.util.List) */ + @Override public void afterWrite(List items) { } /* (non-Javadoc) * @see org.springframework.batch.core.ItemWriteListener#beforeWrite(java.util.List) */ + @Override public void beforeWrite(List items) { } /* (non-Javadoc) * @see org.springframework.batch.core.ItemWriteListener#onWriteError(java.lang.Exception, java.util.List) */ + @Override public void onWriteError(Exception exception, List items) { } /* (non-Javadoc) * @see org.springframework.batch.core.ItemProcessListener#afterProcess(java.lang.Object, java.lang.Object) */ + @Override public void afterProcess(T item, S result) { } /* (non-Javadoc) * @see org.springframework.batch.core.ItemProcessListener#beforeProcess(java.lang.Object) */ + @Override public void beforeProcess(T item) { } /* (non-Javadoc) * @see org.springframework.batch.core.ItemProcessListener#onProcessError(java.lang.Object, java.lang.Exception) */ + @Override public void onProcessError(T item, Exception e) { } /* (non-Javadoc) * @see org.springframework.batch.core.SkipListener#onSkipInProcess(java.lang.Object, java.lang.Throwable) */ + @Override public void onSkipInProcess(T item, Throwable t) { } /* (non-Javadoc) * @see org.springframework.batch.core.SkipListener#onSkipInRead(java.lang.Throwable) */ + @Override public void onSkipInRead(Throwable t) { } /* (non-Javadoc) * @see org.springframework.batch.core.SkipListener#onSkipInWrite(java.lang.Object, java.lang.Throwable) */ + @Override public void onSkipInWrite(S item, Throwable t) { } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/AbstractPartitionHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/AbstractPartitionHandler.java index f745d6ea0..e75585efa 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/AbstractPartitionHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/AbstractPartitionHandler.java @@ -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,42 +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 doHandle(StepExecution masterStepExecution, - Set 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 doHandle(StepExecution masterStepExecution, + Set partitionStepExecutions) throws Exception; /** * @see PartitionHandler#handle(StepExecutionSplitter, StepExecution) */ - public Collection handle(final StepExecutionSplitter stepSplitter, - final StepExecution masterStepExecution) throws Exception { - final Set stepExecutions = stepSplitter.split(masterStepExecution, gridSize); + @Override + public Collection handle(final StepExecutionSplitter stepSplitter, + final StepExecution masterStepExecution) throws Exception { + final Set 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 @@ -78,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; + } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/DefaultStepExecutionAggregator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/DefaultStepExecutionAggregator.java index b03dcbc90..a293d4673 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/DefaultStepExecutionAggregator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/DefaultStepExecutionAggregator.java @@ -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,6 +43,7 @@ public class DefaultStepExecutionAggregator implements StepExecutionAggregator { * * @see StepExecutionAggregator #aggregate(StepExecution, Collection) */ + @Override public void aggregate(StepExecution result, Collection executions) { Assert.notNull(result, "To aggregate into a result it must be non-null."); if (executions == null) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/MultiResourcePartitioner.java b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/MultiResourcePartitioner.java index 244ad16c8..03f3eef09 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/MultiResourcePartitioner.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/MultiResourcePartitioner.java @@ -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 * {partition0, partition1, ..., partitionN}. The grid size is * ignored. - * + * * @author Dave Syer * @since 2.0 */ @@ -65,9 +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 public Map partition(int gridSize) { Map map = new HashMap(gridSize); int i = 0; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/PartitionStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/PartitionStep.java index 0e5105b3c..6eed9e759 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/PartitionStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/PartitionStep.java @@ -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,9 +75,10 @@ public class PartitionStep extends AbstractStep { /** * Assert that mandatory properties are set (stepExecutionSplitter, * partitionHandler) and delegate top superclass. - * + * * @see AbstractStep#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(stepExecutionSplitter, "StepExecutionSplitter must be provided"); Assert.notNull(partitionHandler, "PartitionHandler must be provided"); @@ -92,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 diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregator.java index 109a93acf..f49ddf4f5 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregator.java @@ -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,6 +72,7 @@ public class RemoteStepExecutionAggregator implements StepExecutionAggregator, I /** * @throws Exception if the job explorer is not provided */ + @Override public void afterPropertiesSet() throws Exception { Assert.state(jobExplorer != null, "A JobExplorer must be provided"); } @@ -80,9 +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 public void aggregate(StepExecution result, Collection executions) { Assert.notNull(result, "To aggregate into a result it must be non-null."); if (executions == null) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimplePartitioner.java b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimplePartitioner.java index 4f383902a..7b9c3848e 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimplePartitioner.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimplePartitioner.java @@ -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 * {partition0, partition1, ..., partitionN}, where N is the grid * size. - * + * * @author Dave Syer * @since 2.0 */ @@ -34,6 +34,7 @@ public class SimplePartitioner implements Partitioner { private static final String PARTITION_KEY = "partition"; + @Override public Map partition(int gridSize) { Map map = new HashMap(gridSize); for (int i = 0; i < gridSize; i++) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitter.java index e6848a28d..a6db0a6b8 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitter.java @@ -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. * {step1:partition0, step1:partition1, ...}. - * + * * @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,9 +105,10 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi /** * Check mandatory properties (step name, job repository and partitioner). - * + * * @see InitializingBean#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { Assert.state(jobRepository != null, "A JobRepository is required"); Assert.state(stepName != null, "A step name is required"); @@ -118,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) { @@ -130,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) { @@ -140,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) { @@ -150,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) { @@ -160,6 +161,7 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi /** * @see StepExecutionSplitter#getStepName() */ + @Override public String getStepName() { return this.stepName; } @@ -167,6 +169,7 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi /** * @see StepExecutionSplitter#split(StepExecution, int) */ + @Override public Set split(StepExecution stepExecution, int gridSize) throws JobExecutionException { JobExecution jobExecution = stepExecution.getJobExecution(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/TaskExecutorPartitionHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/TaskExecutorPartitionHandler.java index be486025e..083274862 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/TaskExecutorPartitionHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/TaskExecutorPartitionHandler.java @@ -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. @@ -53,6 +53,7 @@ public class TaskExecutorPartitionHandler extends AbstractPartitionHandler imple private Step step; + @Override public void afterPropertiesSet() throws Exception { } @@ -70,20 +71,21 @@ 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() */ + @Override public Step getStep() { return this.step; } @@ -132,6 +134,7 @@ public class TaskExecutorPartitionHandler extends AbstractPartitionHandler imple protected FutureTask createTask(final Step step, final StepExecution stepExecution) { return new FutureTask(new Callable() { + @Override public StepExecution call() throws Exception { step.execute(stepExecution); return stepExecution; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/AbstractJdbcBatchMetadataDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/AbstractJdbcBatchMetadataDao.java index 1fb8cf3ef..a6e393686 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/AbstractJdbcBatchMetadataDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/AbstractJdbcBatchMetadataDao.java @@ -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,6 +79,7 @@ public abstract class AbstractJdbcBatchMetadataDao implements InitializingBean { this.clobTypeToUse = clobTypeToUse; } + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(jdbcTemplate); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/DefaultExecutionContextSerializer.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/DefaultExecutionContextSerializer.java index 52c2eb9a7..93323eb8a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/DefaultExecutionContextSerializer.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/DefaultExecutionContextSerializer.java @@ -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,6 +47,7 @@ public class DefaultExecutionContextSerializer implements ExecutionContextSerial * @param context * @param out */ + @Override @SuppressWarnings("unchecked") public void serialize(Object context, OutputStream out) throws IOException { Assert.notNull(context); @@ -48,6 +62,7 @@ public class DefaultExecutionContextSerializer implements ExecutionContextSerial * @param inputStream * @return the object serialized in the provided {@link InputStream} */ + @Override public Object deserialize(InputStream inputStream) throws IOException { return deserializer.deserialize(inputStream); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcExecutionContextDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcExecutionContextDao.java index 85856462d..e6222595b 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcExecutionContextDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcExecutionContextDao.java @@ -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,6 +100,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem this.shortContextLength = shortContextLength; } + @Override public ExecutionContext getExecutionContext(JobExecution jobExecution) { Long executionId = jobExecution.getId(); Assert.notNull(executionId, "ExecutionId must not be null."); @@ -114,6 +115,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem } } + @Override public ExecutionContext getExecutionContext(StepExecution stepExecution) { Long executionId = stepExecution.getId(); Assert.notNull(executionId, "ExecutionId must not be null."); @@ -128,6 +130,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem } } + @Override public void updateExecutionContext(final JobExecution jobExecution) { Long executionId = jobExecution.getId(); ExecutionContext executionContext = jobExecution.getExecutionContext(); @@ -139,6 +142,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem persistSerializedContext(executionId, serializedContext, UPDATE_JOB_EXECUTION_CONTEXT); } + @Override public void updateExecutionContext(final StepExecution stepExecution) { Long executionId = stepExecution.getId(); @@ -151,6 +155,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem persistSerializedContext(executionId, serializedContext, UPDATE_STEP_EXECUTION_CONTEXT); } + @Override public void saveExecutionContext(JobExecution jobExecution) { Long executionId = jobExecution.getId(); @@ -163,6 +168,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem persistSerializedContext(executionId, serializedContext, INSERT_JOB_EXECUTION_CONTEXT); } + @Override public void saveExecutionContext(StepExecution stepExecution) { Long executionId = stepExecution.getId(); ExecutionContext executionContext = stepExecution.getExecutionContext(); @@ -204,6 +210,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem } getJdbcTemplate().update(getQuery(sql), new PreparedStatementSetter() { + @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, shortContext); if (longContext != null) { @@ -217,6 +224,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem }); } + @SuppressWarnings("unchecked") private String serializeContext(ExecutionContext ctx) { Map m = new HashMap(); for (Entry me : ctx.entrySet()) { @@ -240,6 +248,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem @SuppressWarnings("unchecked") private class ExecutionContextRowMapper implements ParameterizedRowMapper { + @Override public ExecutionContext mapRow(ResultSet rs, int i) throws SQLException { ExecutionContext executionContext = new ExecutionContext(); String serializedContext = rs.getString("SERIALIZED_CONTEXT"); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java index 31e7f68c2..83bf252c7 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java @@ -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,18 +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 public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.notNull(jobExecutionIncrementer, "The jobExecutionIncrementer must not be null."); } + @Override public List findJobExecutions(final JobInstance job) { Assert.notNull(job, "Job cannot be null."); @@ -116,15 +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 public void saveJobExecution(JobExecution jobExecution) { validateJobExecution(jobExecution); @@ -140,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 */ @@ -163,9 +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 public void updateJobExecution(JobExecution jobExecution) { validateJobExecution(jobExecution); @@ -202,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) { @@ -217,6 +221,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements } } + @Override public JobExecution getLastJobExecution(JobInstance jobInstance) { Long id = jobInstance.getId(); @@ -236,10 +241,11 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements /* * (non-Javadoc) - * + * * @seeorg.springframework.batch.core.repository.dao.JobExecutionDao# * getLastJobExecution(java.lang.String) */ + @Override public JobExecution getJobExecution(Long executionId) { try { JobExecution jobExecution = getJdbcTemplate().queryForObject(getQuery(GET_EXECUTION_BY_ID), @@ -253,14 +259,16 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements /* * (non-Javadoc) - * + * * @seeorg.springframework.batch.core.repository.dao.JobExecutionDao# * findRunningJobExecutions(java.lang.String) */ + @Override public Set findRunningJobExecutions(String jobName) { final Set result = new HashSet(); RowCallbackHandler handler = new RowCallbackHandler() { + @Override public void processRow(ResultSet rs) throws SQLException { JobExecutionRowMapper mapper = new JobExecutionRowMapper(); result.add(mapper.mapRow(rs, 0)); @@ -271,6 +279,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements return result; } + @Override public void synchronizeStatus(JobExecution jobExecution) { int currentVersion = getJdbcTemplate().queryForInt(getQuery(CURRENT_VERSION_JOB_EXECUTION), jobExecution.getId()); @@ -284,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 { @@ -299,6 +308,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements this.jobInstance = jobInstance; } + @Override public JobExecution mapRow(ResultSet rs, int rowNum) throws SQLException { Long id = rs.getLong(1); JobExecution jobExecution; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDao.java index 089bbf053..6bd2f6f9f 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDao.java @@ -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,11 +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 public JobInstance createJobInstance(String jobName, JobParameters jobParameters) { @@ -118,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); @@ -158,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) { @@ -201,11 +202,12 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements /** * The job table is queried for any 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 public JobInstance getJobInstance(final String jobName, final JobParameters jobParameters) { @@ -237,11 +239,12 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.repository.dao.JobInstanceDao#getJobInstance * (java.lang.Long) */ + @Override public JobInstance getJobInstance(Long instanceId) { try { @@ -260,6 +263,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements private JobParameters getJobParameters(Long instanceId) { final Map map = new HashMap(); RowCallbackHandler handler = new RowCallbackHandler() { + @Override public void processRow(ResultSet rs) throws SQLException { ParameterType type = ParameterType.valueOf(rs.getString(3)); JobParameter value = null; @@ -282,27 +286,31 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.repository.dao.JobInstanceDao#getJobNames * () */ + @Override public List getJobNames() { return getJdbcTemplate().query(getQuery(FIND_JOB_NAMES), new ParameterizedRowMapper() { - 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 + @SuppressWarnings("rawtypes") public List getJobInstances(String jobName, final int start, final int count) { @@ -310,8 +318,9 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements private List list = new ArrayList(); + @Override public Object extractData(ResultSet rs) throws SQLException, - DataAccessException { + DataAccessException { int rowNum = 0; while (rowNum < start && rs.next()) { rowNum++; @@ -328,18 +337,19 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements @SuppressWarnings("unchecked") List result = (List) 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 public JobInstance getJobInstance(JobExecution jobExecution) { try { @@ -354,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} */ @@ -362,6 +372,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements this.jobIncrementer = jobIncrementer; } + @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.notNull(jobIncrementer); @@ -369,10 +380,10 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements /** * @author Dave Syer - * + * */ private final class JobInstanceRowMapper implements - ParameterizedRowMapper { + ParameterizedRowMapper { private JobParameters jobParameters; @@ -383,6 +394,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements this.jobParameters = jobParameters; } + @Override public JobInstance mapRow(ResultSet rs, int rowNum) throws SQLException { Long id = rs.getLong(1); if (jobParameters == null) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java index 3f7275e4b..6a570c566 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java @@ -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}.
    - * + * JDBC implementation of {@link StepExecutionDao}.
    + * * Allows customization of the tables names used by Spring Batch for step meta * data via a prefix property.
    - * + * * 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.
    - * + * * @author Lucas Ward * @author Dave Syer * @author Robert Kasanicky - * + * * @see StepExecutionDao */ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implements StepExecutionDao, InitializingBean { @@ -91,6 +91,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement this.stepExecutionIncrementer = stepExecutionIncrementer; } + @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.notNull(stepExecutionIncrementer, "StepExecutionIncrementer cannot be null."); @@ -100,9 +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 public void saveStepExecution(StepExecution stepExecution) { Assert.isNull(stepExecution.getId(), @@ -127,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) { @@ -145,6 +147,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement Assert.notNull(stepExecution.getStatus(), "StepExecution status cannot be null."); } + @Override public void updateStepExecution(StepExecution stepExecution) { validateStepExecution(stepExecution); @@ -169,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) { @@ -206,6 +209,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement } } + @Override public StepExecution getStepExecution(JobExecution jobExecution, Long stepExecutionId) { List executions = getJdbcTemplate().query(getQuery(GET_STEP_EXECUTION), new StepExecutionRowMapper(jobExecution), jobExecution.getId(), stepExecutionId); @@ -220,6 +224,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement } } + @Override public void addStepExecutions(JobExecution jobExecution) { getJdbcTemplate().query(getQuery(GET_STEP_EXECUTIONS), new StepExecutionRowMapper(jobExecution), jobExecution.getId()); @@ -233,6 +238,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement this.jobExecution = jobExecution; } + @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)); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java index 880dd21cc..d70dd28aa 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java @@ -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 contexts = TransactionAwareProxyFactory @@ -44,29 +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 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); } @@ -74,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); } } @@ -85,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(); } @@ -93,10 +109,12 @@ public class MapExecutionContextDao implements ExecutionContextDao { return (ExecutionContext) SerializationUtils.deserialize(SerializationUtils.serialize(original)); } + @Override public ExecutionContext getExecutionContext(StepExecution stepExecution) { return copy(contexts.get(ContextKey.step(stepExecution.getId()))); } + @Override public void updateExecutionContext(StepExecution stepExecution) { ExecutionContext executionContext = stepExecution.getExecutionContext(); if (executionContext != null) { @@ -104,10 +122,12 @@ public class MapExecutionContextDao implements ExecutionContextDao { } } + @Override public ExecutionContext getExecutionContext(JobExecution jobExecution) { return copy(contexts.get(ContextKey.job(jobExecution.getId()))); } + @Override public void updateExecutionContext(JobExecution jobExecution) { ExecutionContext executionContext = jobExecution.getExecutionContext(); if (executionContext != null) { @@ -115,10 +135,12 @@ public class MapExecutionContextDao implements ExecutionContextDao { } } + @Override public void saveExecutionContext(JobExecution jobExecution) { updateExecutionContext(jobExecution); } + @Override public void saveExecutionContext(StepExecution stepExecution) { updateExecutionContext(stepExecution); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobExecutionDao.java index ca8da5215..7c30b8ac2 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobExecutionDao.java @@ -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,6 +51,7 @@ public class MapJobExecutionDao implements JobExecutionDao { return copy; } + @Override public void saveJobExecution(JobExecution jobExecution) { Assert.isTrue(jobExecution.getId() == null); Long newId = currentId.getAndIncrement(); @@ -61,6 +60,7 @@ public class MapJobExecutionDao implements JobExecutionDao { executionsById.put(newId, copy(jobExecution)); } + @Override public List findJobExecutions(JobInstance jobInstance) { List executions = new ArrayList(); for (JobExecution exec : executionsById.values()) { @@ -70,6 +70,7 @@ public class MapJobExecutionDao implements JobExecutionDao { } Collections.sort(executions, new Comparator() { + @Override public int compare(JobExecution e1, JobExecution e2) { long result = (e1.getId() - e2.getId()); if (result > 0) { @@ -86,6 +87,7 @@ public class MapJobExecutionDao implements JobExecutionDao { return executions; } + @Override public void updateJobExecution(JobExecution jobExecution) { Long id = jobExecution.getId(); Assert.notNull(id, "JobExecution is expected to have an id (should be saved already)"); @@ -103,6 +105,7 @@ public class MapJobExecutionDao implements JobExecutionDao { } } + @Override public JobExecution getLastJobExecution(JobInstance jobInstance) { JobExecution lastExec = null; for (JobExecution exec : executionsById.values()) { @@ -121,10 +124,11 @@ public class MapJobExecutionDao implements JobExecutionDao { /* * (non-Javadoc) - * + * * @seeorg.springframework.batch.core.repository.dao.JobExecutionDao# * findRunningJobExecutions(java.lang.String) */ + @Override public Set findRunningJobExecutions(String jobName) { Set result = new HashSet(); for (JobExecution exec : executionsById.values()) { @@ -138,15 +142,17 @@ public class MapJobExecutionDao implements JobExecutionDao { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.repository.dao.JobExecutionDao#getJobExecution * (java.lang.Long) */ + @Override public JobExecution getJobExecution(Long executionId) { return copy(executionsById.get(executionId)); } + @Override public void synchronizeStatus(JobExecution jobExecution) { JobExecution saved = getJobExecution(jobExecution.getId()); if (saved.getVersion().intValue() != jobExecution.getVersion().intValue()) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobInstanceDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobInstanceDao.java index 68ade2582..a0e23c953 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobInstanceDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobInstanceDao.java @@ -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,6 +43,7 @@ public class MapJobInstanceDao implements JobInstanceDao { jobInstances.clear(); } + @Override public JobInstance createJobInstance(String jobName, JobParameters jobParameters) { Assert.state(getJobInstance(jobName, jobParameters) == null, "JobInstance must not already exist"); @@ -56,6 +55,7 @@ public class MapJobInstanceDao implements JobInstanceDao { return jobInstance; } + @Override public JobInstance getJobInstance(String jobName, JobParameters jobParameters) { for (JobInstance instance : jobInstances) { @@ -67,6 +67,7 @@ public class MapJobInstanceDao implements JobInstanceDao { } + @Override public JobInstance getJobInstance(Long instanceId) { for (JobInstance instance : jobInstances) { if (instance.getId().equals(instanceId)) { @@ -76,6 +77,7 @@ public class MapJobInstanceDao implements JobInstanceDao { return null; } + @Override public List getJobNames() { List result = new ArrayList(); for (JobInstance instance : jobInstances) { @@ -85,6 +87,7 @@ public class MapJobInstanceDao implements JobInstanceDao { return result; } + @Override public List getJobInstances(String jobName, int start, int count) { List result = new ArrayList(); for (JobInstance instance : jobInstances) { @@ -94,6 +97,7 @@ public class MapJobInstanceDao implements JobInstanceDao { } Collections.sort(result, new Comparator() { // sort by ID descending + @Override public int compare(JobInstance o1, JobInstance o2) { return Long.signum(o2.getId() - o1.getId()); } @@ -104,6 +108,7 @@ public class MapJobInstanceDao implements JobInstanceDao { return result.subList(startIndex, endIndex); } + @Override public JobInstance getJobInstance(JobExecution jobExecution) { return jobExecution.getJobInstance(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java index 2752059d4..8a4d62146 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java @@ -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,6 +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 public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException { field.setAccessible(true); field.set(targetExecution, field.get(sourceExecution)); @@ -63,6 +64,7 @@ public class MapStepExecutionDao implements StepExecutionDao { }); } + @Override public void saveStepExecution(StepExecution stepExecution) { Assert.isTrue(stepExecution.getId() == null); @@ -83,6 +85,7 @@ public class MapStepExecutionDao implements StepExecutionDao { } + @Override public void updateStepExecution(StepExecution stepExecution) { Assert.notNull(stepExecution.getJobExecutionId()); @@ -108,10 +111,12 @@ public class MapStepExecutionDao implements StepExecutionDao { } } + @Override public StepExecution getStepExecution(JobExecution jobExecution, Long stepExecutionId) { return executionsByStepExecutionId.get(stepExecutionId); } + @Override public void addStepExecutions(JobExecution jobExecution) { Map executions = executionsByJobExecutionId.get(jobExecution.getId()); if (executions == null || executions.isEmpty()) { @@ -120,6 +125,7 @@ public class MapStepExecutionDao implements StepExecutionDao { List result = new ArrayList(executions.values()); Collections.sort(result, new Comparator() { + @Override public int compare(Entity o1, Entity o2) { return Long.signum(o2.getId() - o1.getId()); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/XStreamExecutionContextStringSerializer.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/XStreamExecutionContextStringSerializer.java index b0be6a559..4f050ebb6 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/XStreamExecutionContextStringSerializer.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/XStreamExecutionContextStringSerializer.java @@ -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,6 +57,7 @@ public class XStreamExecutionContextStringSerializer implements ExecutionContext this.hierarchicalStreamDriver = hierarchicalStreamDriver; } + @Override public void afterPropertiesSet() throws Exception { init(); } @@ -80,6 +81,7 @@ public class XStreamExecutionContextStringSerializer implements ExecutionContext * @param out * @see Serializer#serialize(Object, OutputStream) */ + @Override public void serialize(Object context, OutputStream out) throws IOException { Assert.notNull(context); Assert.notNull(out); @@ -94,7 +96,7 @@ public class XStreamExecutionContextStringSerializer implements ExecutionContext * @return a reconstructed execution context * @see Deserializer#deserialize(InputStream) */ - @SuppressWarnings("unchecked") + @Override public Object deserialize(InputStream in) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(in)); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/AbstractJobRepositoryFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/AbstractJobRepositoryFactoryBean.java index db4f6ead0..f6a10fb11 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/AbstractJobRepositoryFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/AbstractJobRepositoryFactoryBean.java @@ -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,14 +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 public Class getObjectType() { return JobRepository.class; } + @Override public boolean isSingleton() { return true; } @@ -100,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) { @@ -112,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) */ @@ -133,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() { @@ -159,6 +162,7 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I + isolationLevelForCreate + "\n*=PROPAGATION_REQUIRED")); if (validateTransactionState) { DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(new MethodInterceptor() { + @Override public Object invoke(MethodInvocation invocation) throws Throwable { if (TransactionSynchronizationManager.isActualTransactionActive()) { throw new IllegalStateException( @@ -180,6 +184,7 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I } } + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(transactionManager, "TransactionManager must not be null."); @@ -191,6 +196,7 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I createExecutionContextDao()); } + @Override public Object getObject() throws Exception { if (proxyFactory == null) { afterPropertiesSet(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java index 5aa9a9976..9518bfb6f 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java @@ -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; /** - * + * *

    * Implementation of {@link JobRepository} that stores JobInstances, * JobExecutions, and StepExecutions using the injected DAOs. *

    - * + * * @author Lucas Ward * @author Dave Syer * @author Robert Kasanicky - * + * * @see JobRepository * @see JobInstanceDao * @see JobExecutionDao * @see StepExecutionDao - * + * */ public class SimpleJobRepository implements JobRepository { @@ -83,10 +83,12 @@ public class SimpleJobRepository implements JobRepository { this.ecDao = ecDao; } + @Override public boolean isJobInstanceExists(String jobName, JobParameters jobParameters) { return jobInstanceDao.getJobInstance(jobName, jobParameters) != null; } + @Override public JobExecution createJobExecution(String jobName, JobParameters jobParameters) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException { @@ -95,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 @@ -116,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)); @@ -145,6 +147,7 @@ public class SimpleJobRepository implements JobRepository { } + @Override public void update(JobExecution jobExecution) { Assert.notNull(jobExecution, "JobExecution cannot be null."); @@ -155,6 +158,7 @@ public class SimpleJobRepository implements JobRepository { jobExecutionDao.updateJobExecution(jobExecution); } + @Override public void add(StepExecution stepExecution) { validateStepExecution(stepExecution); @@ -163,6 +167,7 @@ public class SimpleJobRepository implements JobRepository { ecDao.saveExecutionContext(stepExecution); } + @Override public void update(StepExecution stepExecution) { validateStepExecution(stepExecution); Assert.notNull(stepExecution.getId(), "StepExecution must already be saved (have an id assigned)"); @@ -178,16 +183,19 @@ public class SimpleJobRepository implements JobRepository { Assert.notNull(stepExecution.getJobExecutionId(), "StepExecution must belong to persisted JobExecution"); } + @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 public void updateExecutionContext(JobExecution jobExecution) { ecDao.updateExecutionContext(jobExecution); } + @Override public StepExecution getLastStepExecution(JobInstance jobInstance, String stepName) { List jobExecutions = jobExecutionDao.findJobExecutions(jobInstance); List stepExecutions = new ArrayList(jobExecutions.size()); @@ -218,6 +226,7 @@ public class SimpleJobRepository implements JobRepository { /** * @return number of executions of the step within given job instance */ + @Override public int getStepExecutionCount(JobInstance jobInstance, String stepName) { int count = 0; List jobExecutions = jobExecutionDao.findJobExecutions(jobInstance); @@ -237,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) { @@ -249,13 +258,14 @@ public class SimpleJobRepository implements JobRepository { } } + @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)); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/resource/ListPreparedStatementSetter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/resource/ListPreparedStatementSetter.java index 342bc6c0c..8b367bb54 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/resource/ListPreparedStatementSetter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/resource/ListPreparedStatementSetter.java @@ -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,20 +29,21 @@ import org.springframework.util.Assert; /** * Implementation of the {@link PreparedStatementSetter} interface that accepts * a list of values to be set on a PreparedStatement. This is usually used in - * conjunction with the {@link JdbcCursorItemReader} to allow for the replacement + * conjunction with the {@link JdbcCursorItemReader} to allow for the replacement * of bind variables when generating the cursor. The order of the list will be * used to determine the ordering of setting variables. For example, the first * item in the list will be the first bind variable set. (i.e. it will * correspond to the first '?' in the SQL statement) - * + * * @author Lucas Ward - * + * */ public class ListPreparedStatementSetter implements - PreparedStatementSetter, InitializingBean { +PreparedStatementSetter, InitializingBean { private List parameters; + @Override public void setValues(PreparedStatement ps) throws SQLException { for (int i = 0; i < parameters.size(); i++) { StatementCreatorUtils.setParameterValue(ps, i + 1, SqlTypeValue.TYPE_UNKNOWN, parameters.get(i)); @@ -58,6 +59,7 @@ public class ListPreparedStatementSetter implements this.parameters = parameters; } + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(parameters, "Parameters must be provided"); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicy.java b/spring-batch-core/src/main/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicy.java index 3ed303631..a61393888 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicy.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicy.java @@ -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. @@ -35,16 +35,16 @@ import org.springframework.util.Assert; * step. N.B. only after the step has started will the completion policy be * usable. *

    - * + * *

    * It is easier and probably preferable to simply declare the chunk with a * commit-interval that is a late-binding expression (e.g. * #{jobParameters['commit.interval']}). That feature is available * from of Spring Batch 2.1.7. *

    - * + * * @author Dave Syer - * + * * @see CompletionPolicy */ public class StepExecutionSimpleCompletionPolicy extends StepExecutionListenerSupport implements CompletionPolicy { @@ -68,9 +68,10 @@ public class StepExecutionSimpleCompletionPolicy extends StepExecutionListenerSu * the {@link JobParameters}. If there is a Long parameter with the given * key name, the intValue of this parameter is used. If not an exception * will be thrown. - * + * * @see org.springframework.batch.core.listener.StepExecutionListenerSupport#beforeStep(org.springframework.batch.core.StepExecution) */ + @Override public void beforeStep(StepExecution stepExecution) { JobParameters jobParameters = stepExecution.getJobParameters(); Assert.state(jobParameters.getParameters().containsKey(keyName), @@ -85,6 +86,7 @@ public class StepExecutionSimpleCompletionPolicy extends StepExecutionListenerSu * indicates completion * @see CompletionPolicy#isComplete(RepeatContext, RepeatStatus) */ + @Override public boolean isComplete(RepeatContext context, RepeatStatus result) { Assert.state(delegate != null, "The delegate resource has not been initialised. " + "Remember to register this object as a StepListener."); @@ -96,6 +98,7 @@ public class StepExecutionSimpleCompletionPolicy extends StepExecutionListenerSu * @return if the commit interval has been reached * @see org.springframework.batch.repeat.CompletionPolicy#isComplete(org.springframework.batch.repeat.RepeatContext) */ + @Override public boolean isComplete(RepeatContext context) { Assert.state(delegate != null, "The delegate resource has not been initialised. " + "Remember to register this object as a StepListener."); @@ -107,6 +110,7 @@ public class StepExecutionSimpleCompletionPolicy extends StepExecutionListenerSu * @return a new {@link RepeatContext} * @see org.springframework.batch.repeat.CompletionPolicy#start(org.springframework.batch.repeat.RepeatContext) */ + @Override public RepeatContext start(RepeatContext parent) { Assert.state(delegate != null, "The delegate resource has not been initialised. " + "Remember to register this object as a StepListener."); @@ -117,6 +121,7 @@ public class StepExecutionSimpleCompletionPolicy extends StepExecutionListenerSu * @param context * @see org.springframework.batch.repeat.CompletionPolicy#update(org.springframework.batch.repeat.RepeatContext) */ + @Override public void update(RepeatContext context) { Assert.state(delegate != null, "The delegate resource has not been initialised. " + "Remember to register this object as a StepListener."); @@ -127,6 +132,7 @@ public class StepExecutionSimpleCompletionPolicy extends StepExecutionListenerSu * Delegates to the wrapped {@link CompletionPolicy} if set, otherwise * returns the value of {@link #setKeyName(String)}. */ + @Override public String toString() { return (delegate == null) ? keyName : delegate.toString(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepScope.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepScope.java index 0b4cf7c55..f2e45ef8d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepScope.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepScope.java @@ -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. @@ -44,34 +44,34 @@ import org.springframework.util.StringValueResolver; * step. All objects in this scope are <aop:scoped-proxy/> (no need to * decorate the bean definitions).
    *
    - * + * * In addition, support is provided for late binding of references accessible * from the {@link StepContext} using #{..} placeholders. Using this feature, * bean properties can be pulled from the step or job execution context and the * job parameters. E.g. - * + * *
      * <bean id="..." class="..." scope="step">
      * 	<property name="parent" ref="#{stepExecutionContext[helper]}" />
      * </bean>
    - * 
    + *
      * <bean id="..." class="..." scope="step">
      * 	<property name="name" value="#{stepExecutionContext['input.name']}" />
      * </bean>
    - * 
    + *
      * <bean id="..." class="..." scope="step">
      * 	<property name="name" value="#{jobParameters[input]}" />
      * </bean>
    - * 
    + *
      * <bean id="..." class="..." scope="step">
      * 	<property name="name" value="#{jobExecutionContext['input.stem']}.txt" />
      * </bean>
      * 
    - * + * * The {@link StepContext} is referenced using standard bean property paths (as * per {@link BeanWrapper}). The examples above all show the use of the Map * accessors provided as a convenience for step and job attributes. - * + * * @author Dave Syer * @since 2.0 */ @@ -91,6 +91,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { this.order = order; } + @Override public int getOrder() { return order; } @@ -111,7 +112,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { /** * Flag to indicate that proxies should use dynamic subclassing. This allows * classes with no interface to be proxied. Defaults to false. - * + * * @param proxyTargetClass set to true to have proxies created using dynamic * subclasses */ @@ -124,6 +125,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { * step-scoped beans. This method is part of the Scope SPI in Spring 3.0, * but should just be ignored by earlier versions of Spring. */ + @Override public Object resolveContextualObject(String key) { StepContext context = getContext(); // TODO: support for attributes as well maybe (setters not exposed yet @@ -134,6 +136,8 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { /** * @see Scope#get(String, ObjectFactory) */ + @SuppressWarnings("rawtypes") + @Override public Object get(String name, ObjectFactory objectFactory) { StepContext context = getContext(); @@ -161,6 +165,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { /** * @see Scope#getConversationId() */ + @Override public String getConversationId() { StepContext context = getContext(); return context.getId(); @@ -169,6 +174,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { /** * @see Scope#registerDestructionCallback(String, Runnable) */ + @Override public void registerDestructionCallback(String name, Runnable callback) { StepContext context = getContext(); logger.debug(String.format("Registered destruction callback in scope=%s, name=%s", this.name, name)); @@ -178,6 +184,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { /** * @see Scope#remove(String) */ + @Override public Object remove(String name) { StepContext context = getContext(); logger.debug(String.format("Removing from scope=%s, name=%s", this.name, name)); @@ -187,7 +194,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { /** * Get an attribute accessor in the form of a {@link StepContext} that can * be used to store scoped bean instances. - * + * * @return the current step context which we can use as a scope storage * medium */ @@ -201,12 +208,13 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { /** * Register this scope with the enclosing BeanFactory. - * + * * @see BeanFactoryPostProcessor#postProcessBeanFactory(ConfigurableListableBeanFactory) - * + * * @param beanFactory the BeanFactory to register with * @throws BeansException if there is a problem. */ + @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { beanFactory.registerScope(name, this); @@ -244,7 +252,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { /** * Public setter for the name property. This can then be used as a bean * definition attribute, e.g. scope="step". Defaults to "step". - * + * * @param name the name to set for this scope. */ public void setName(String name) { @@ -257,7 +265,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { * <aop-auto-proxy/> to a step scoped bean. Also if Spring EL is not * available will enable a weak version of late binding as described in the * class-level docs. - * + * * @param beanName the bean name to replace * @param definition the bean definition to replace * @param registry the enclosing {@link BeanDefinitionRegistry} @@ -291,9 +299,9 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { /** * Helper class to scan a bean definition hierarchy and force the use of * auto-proxy for step scoped beans. - * + * * @author Dave Syer - * + * */ private static class Scopifier extends BeanDefinitionVisitor { @@ -307,6 +315,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { public Scopifier(BeanDefinitionRegistry registry, String scope, boolean proxyTargetClass, boolean scoped) { super(new StringValueResolver() { + @Override public String resolveStringValue(String value) { return value; } @@ -356,9 +365,9 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { /** * Helper class to scan a bean definition hierarchy and hide placeholders * from Spring EL. - * + * * @author Dave Syer - * + * */ private static class ExpressionHider extends BeanDefinitionVisitor { @@ -374,6 +383,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { private ExpressionHider(String scope, final boolean scoped) { super(new StringValueResolver() { + @Override public String resolveStringValue(String value) { if (scoped && value.contains(PLACEHOLDER_PREFIX) && value.contains(PLACEHOLDER_SUFFIX)) { value = value.replace(PLACEHOLDER_PREFIX, REPLACEMENT_PREFIX); @@ -400,7 +410,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { boolean scopeChange = !scope.equals(otherScope); if (scopeChange) { new ExpressionHider(otherScope == null ? scope : otherScope, !scoped) - .visitBeanDefinition(definition); + .visitBeanDefinition(definition); // Exit here so that nested inner bean definitions are not // analysed by both visitors return value; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepContextRepeatCallback.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepContextRepeatCallback.java index 558cc945e..b4a383e81 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepContextRepeatCallback.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepContextRepeatCallback.java @@ -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,14 +30,14 @@ import org.springframework.util.ObjectUtils; /** * Convenient base class for clients who need to do something in a repeat * callback inside a {@link Step}. - * + * * @author Dave Syer - * + * */ public abstract class StepContextRepeatCallback implements RepeatCallback { private final Queue attributeQueue = new LinkedBlockingQueue(); - + private final StepExecution stepExecution; private final Log logger = LogFactory.getLog(StepContextRepeatCallback.class); @@ -56,11 +56,12 @@ public abstract class StepContextRepeatCallback implements RepeatCallback { * if the callback is executed in a pooled thread. Handles the registration * and de-registration of the step context, so clients should not duplicate * those calls. - * + * * @see RepeatCallback#doInIteration(RepeatContext) */ + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { - + // The StepContext has to be the same for all chunks, // otherwise step-scoped beans will be re-initialised for each chunk. StepContext stepContext = StepSynchronizationManager.register(stepExecution); @@ -94,7 +95,7 @@ public abstract class StepContextRepeatCallback implements RepeatCallback { * that they are finished with a context by removing all the attributes they * have added. If a worker does not remove them another thread might see * stale state. - * + * * @param context the current {@link RepeatContext} * @param chunkContext the chunk context in which to carry out the work * @return the repeat status from the execution diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/PlaceholderProxyFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/PlaceholderProxyFactoryBean.java index c76821dd2..515469274 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/PlaceholderProxyFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/PlaceholderProxyFactoryBean.java @@ -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. @@ -41,10 +41,11 @@ import org.springframework.util.ClassUtils; * Factory bean for proxies that can replace placeholders in their target. Just * a specialisation of {@link ScopedProxyFactoryBean}, with a different target * source type. - * + * * @author Dave Syer - * + * */ +@SuppressWarnings({ "serial", "rawtypes" }) public class PlaceholderProxyFactoryBean extends ProxyConfig implements FactoryBean, BeanFactoryAware { /** The TargetSource that manages scoping */ @@ -74,6 +75,7 @@ public class PlaceholderProxyFactoryBean extends ProxyConfig implements FactoryB this.scopedTargetSource.setTargetBeanName(targetBeanName); } + @Override public void setBeanFactory(BeanFactory beanFactory) { if (!(beanFactory instanceof ConfigurableBeanFactory)) { throw new IllegalStateException("Not running in a ConfigurableBeanFactory: " + beanFactory); @@ -104,12 +106,13 @@ public class PlaceholderProxyFactoryBean extends ProxyConfig implements FactoryB // proxy itself is not subject to auto-proxying! Only its target bean // is. pf.addInterface(AopInfrastructureBean.class); - + this.scopedTargetSource.afterPropertiesSet(); this.proxy = pf.getProxy(cbf.getBeanClassLoader()); } + @Override public Object getObject() { if (this.proxy == null) { throw new FactoryBeanNotInitializedException(); @@ -117,6 +120,7 @@ public class PlaceholderProxyFactoryBean extends ProxyConfig implements FactoryB return this.proxy; } + @Override public Class getObjectType() { if (this.proxy != null) { return this.proxy.getClass(); @@ -127,6 +131,7 @@ public class PlaceholderProxyFactoryBean extends ProxyConfig implements FactoryB return null; } + @Override public boolean isSingleton() { return true; } @@ -135,7 +140,7 @@ public class PlaceholderProxyFactoryBean extends ProxyConfig implements FactoryB * Convenience method to create a {@link BeanDefinition} for a target * wrapped in a placeholder tarrget source, able to defer binding of * placeholders until the bean is used. - * + * * @param definition a target bean definition * @param registry a {@link BeanDefinitionRegistry} * @param proxyTargetClass true if we need to use CGlib to create the diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/StepContextFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/StepContextFactory.java index 664a9c6f3..19f1cc560 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/StepContextFactory.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/StepContextFactory.java @@ -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,16 +22,18 @@ import org.springframework.batch.core.scope.context.StepSynchronizationManager; /** * Implementation of {@link ContextFactory} that provides the current * {@link StepContext} as a context object. - * + * * @author Dave Syer - * + * */ public class StepContextFactory implements ContextFactory { + @Override public Object getContext() { return StepSynchronizationManager.getContext(); } + @Override public String getContextId() { StepContext context = StepSynchronizationManager.getContext(); return context!=null ? (String) context.getId() : "sysinit"; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java index 79e78e189..91bf92520 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java @@ -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. @@ -41,7 +41,7 @@ import org.springframework.util.ClassUtils; /** * A {@link Step} implementation that provides common behavior to subclasses, including registering and calling * listeners. - * + * * @author Dave Syer * @author Ben Hale * @author Robert Kasanicky @@ -67,18 +67,20 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw super(); } + @Override public void afterPropertiesSet() throws Exception { Assert.state(name != null, "A Step must have a name"); Assert.state(jobRepository != null, "JobRepository is mandatory"); } + @Override public String getName() { return this.name; } /** * 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) { @@ -89,28 +91,31 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw * Set the name property if it is not already set. Because of the order of the callbacks in a Spring container the * name property will be set first 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 public void setBeanName(String name) { if (this.name == null) { this.name = name; } } + @Override public int getStartLimit() { return this.startLimit; } /** * Public setter for the startLimit. - * + * * @param startLimit the startLimit to set */ public void setStartLimit(int startLimit) { this.startLimit = startLimit; } + @Override public boolean isAllowStartIfComplete() { return this.allowStartIfComplete; } @@ -118,7 +123,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw /** * Public setter for flag that determines whether the step should start again if it is already complete. Defaults to * false. - * + * * @param allowStartIfComplete the value of the flag to set */ public void setAllowStartIfComplete(boolean allowStartIfComplete) { @@ -127,7 +132,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw /** * Convenient constructor for setting only the name property. - * + * * @param name */ public AbstractStep(String name) { @@ -137,7 +142,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw /** * Extension point for subclasses to execute business logic. Subclasses should set the {@link ExitStatus} on the * {@link StepExecution} before returning. - * + * * @param stepExecution the current step context * @throws Exception */ @@ -146,7 +151,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw /** * Extension point for subclasses to provide callbacks to their collaborators at the beginning of a step, to open or * acquire resources. Does nothing by default. - * + * * @param ctx the {@link ExecutionContext} to use * @throws Exception */ @@ -156,7 +161,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw /** * Extension point for subclasses to provide callbacks to their collaborators at the end of a step (right at the end * of the finally block), to close or release resources. Does nothing by default. - * + * * @param ctx the {@link ExecutionContext} to use * @throws Exception */ @@ -168,8 +173,9 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw * {@link #open(ExecutionContext)}), execution logic ({@link #doExecute(StepExecution)}) and resource closing ( * {@link #close(ExecutionContext)}). */ + @Override public final void execute(StepExecution stepExecution) throws JobInterruptedException, - UnexpectedJobExecutionException { + UnexpectedJobExecutionException { logger.debug("Executing: id=" + stepExecution.getId()); stepExecution.setStartTime(new Date()); @@ -282,7 +288,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw /** * Register a step listener for callbacks at the appropriate stages in a step execution. - * + * * @param listener a {@link StepExecutionListener} */ public void registerStepExecutionListener(StepExecutionListener listener) { @@ -291,7 +297,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw /** * Register each of the objects as listeners. - * + * * @param listeners an array of listener objects of known types. */ public void setStepExecutionListeners(StepExecutionListener[] listeners) { @@ -309,7 +315,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw /** * Public setter for {@link JobRepository}. - * + * * @param jobRepository is a mandatory dependence (no default). */ public void setJobRepository(JobRepository jobRepository) { @@ -320,6 +326,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw return jobRepository; } + @Override public String toString() { return ClassUtils.getShortName(getClass()) + ": [name=" + name + "]"; } @@ -327,7 +334,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw /** * Default mapping from throwable to {@link ExitStatus}. Clients can modify the exit code using a * {@link StepExecutionListener}. - * + * * @param ex the cause of the failure * @return an {@link ExitStatus} */ @@ -346,4 +353,4 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw return exitStatus; } -} \ No newline at end of file +} diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/NoWorkFoundStepExecutionListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/NoWorkFoundStepExecutionListener.java index 9739b0884..8aced0999 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/NoWorkFoundStepExecutionListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/NoWorkFoundStepExecutionListener.java @@ -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. @@ -22,11 +22,12 @@ import org.springframework.batch.core.listener.StepExecutionListenerSupport; /** * Fails the step if no items have been processed ( item count is 0). - * + * * @author Robert Kasanicky */ public class NoWorkFoundStepExecutionListener extends StepExecutionListenerSupport { + @Override public ExitStatus afterStep(StepExecution stepExecution) { if (stepExecution.getReadCount() == 0) { return ExitStatus.FAILED; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/StepLocatorStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/StepLocatorStepFactoryBean.java index 6a45a323a..7345c6d54 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/StepLocatorStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/StepLocatorStepFactoryBean.java @@ -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.step; import org.springframework.batch.core.Job; @@ -8,9 +23,9 @@ import org.springframework.beans.factory.FactoryBean; * Convenience factory for {@link Step} instances given a {@link StepLocator}. * Most implementations of {@link Job} implement StepLocator, so that can be a * good starting point. - * + * * @author Dave Syer - * + * */ public class StepLocatorStepFactoryBean implements FactoryBean { @@ -33,27 +48,30 @@ public class StepLocatorStepFactoryBean implements FactoryBean { } /** - * + * * @see FactoryBean#getObject() */ + @Override public Step getObject() throws Exception { return stepLocator.getStep(stepName); } /** * Tell clients that we are a factory for {@link Step} instances. - * + * * @see FactoryBean#getObjectType() */ + @Override public Class getObjectType() { return Step.class; } /** * Always return true as optimization for bean factory. - * + * * @see FactoryBean#isSingleton() */ + @Override public boolean isSingleton() { return true; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/ThreadStepInterruptionPolicy.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/ThreadStepInterruptionPolicy.java index d551350de..daed5d7d1 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/ThreadStepInterruptionPolicy.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/ThreadStepInterruptionPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2012 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,10 +23,10 @@ import org.springframework.batch.core.StepExecution; /** * Policy that checks the current thread to see if it has been interrupted. - * + * * @author Lucas Ward * @author Dave Syer - * + * */ public class ThreadStepInterruptionPolicy implements StepInterruptionPolicy { @@ -36,6 +36,7 @@ public class ThreadStepInterruptionPolicy implements StepInterruptionPolicy { * Returns if the current job lifecycle has been interrupted by checking if * the current thread is interrupted. */ + @Override public void checkInterrupted(StepExecution stepExecution) throws JobInterruptedException { if (isInterrupted(stepExecution)) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java index b7b3f3d11..2e0dec69c 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java @@ -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. @@ -73,9 +73,9 @@ import org.springframework.util.Assert; /** * A step builder for fully fault tolerant chunk-oriented item processing steps. Extends {@link SimpleStepBuilder} with * additional properties for retry and skip of failed items. - * + * * @author Dave Syer - * + * * @since 2.2 */ public class FaultTolerantStepBuilder extends SimpleStepBuilder { @@ -116,7 +116,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Create a new builder initialized with any properties in the parent. The parent is copied, so it can be re-used. - * + * * @param parent a parent helper containing common step properties */ public FaultTolerantStepBuilder(StepBuilderHelper parent) { @@ -125,7 +125,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Create a new builder initialized with any properties in the parent. The parent is copied, so it can be re-used. - * + * * @param parent a parent helper containing common step properties */ protected FaultTolerantStepBuilder(SimpleStepBuilder parent) { @@ -134,7 +134,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Create a new chunk oriented tasklet with reader, writer and processor as provided. - * + * * @see org.springframework.batch.core.step.builder.SimpleStepBuilder#createTasklet() */ @Override @@ -152,7 +152,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Register a skip listener. - * + * * @param listener the listener to register * @return this for fluent chaining */ @@ -175,7 +175,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Register a retry listener. - * + * * @param listener the listener to register * @return this for fluent chaining */ @@ -190,7 +190,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { * own implementation to ensure that they can be identified. Often a key generator is not necessary as long as the * items have reliable hash code and equals implementations, or the reader is not transactional (the default) and * the item processor either is itself not transactional (not the default) or does not create new items. - * + * * @param keyGenerator a key generator for the stateful retry * @return this for fluent chaining */ @@ -202,7 +202,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * The maximum number of times to try a failed item. Zero and one both translate to try only once and do not retry. * Ignored if an explicit {@link #retryPolicy} is set. - * + * * @param retryLimit the retry limit (default 0) * @return this for fluent chaining */ @@ -214,7 +214,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Provide an explicit retry policy instead of using the {@link #retryLimit(int)} and retryable exceptions provided * elsewhere. Can be used to retry different exceptions a different number of times, for instance. - * + * * @param retryPolicy a retry policy * @return this for fluent chaining */ @@ -227,7 +227,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { * Provide a backoff policy to prevent items being retried immediately (e.g. in case the failure was caused by a * remote resource failure that might take some time to be resolved). Ignored if an explicit {@link #retryPolicy} is * set. - * + * * @param backOffPolicy the back off policy to use (default no backoff) * @return this for fluent chaining */ @@ -239,7 +239,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Provide an explicit retry context cache. Retry is stateful across transactions in the case of failures in item * processing or writing, so some information about the context for subsequent retries has to be stored. - * + * * @param retryContextCache cache for retry contexts in between transactions (default to standard in-memory * implementation) * @return this for fluent chaining @@ -252,7 +252,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Sets the maximium number of failed items to skip before the step fails. Ignored if an explicit * {@link #skipPolicy(SkipPolicy)} is provided. - * + * * @param skipLimit the skip limit to set * @return this for fluent chaining */ @@ -263,7 +263,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Explicitly prevent certain exceptions (and subclasses) from being skipped. - * + * * @param type the non-skippable exception * @return this for fluent chaining */ @@ -274,7 +274,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Explicitly request certain exceptions (and subclasses) to be skipped. - * + * * @param type * @return this for fluent chaining */ @@ -286,7 +286,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Provide an explicit policy for managing skips. A skip policy determines which exceptions are skippable and how * many times. - * + * * @param skipPolicy the skip policy * @return this for fluent chaining */ @@ -299,7 +299,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { * Mark this exception as ignorable during item read or processing operations. Processing continues with no * additional callbacks (use skips instead if you need to be notified). Ignored during write because there is no * guarantee of skip and retry without rollback. - * + * * @param type the exception to mark as no rollback * @return this for fluent chaining */ @@ -310,7 +310,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Explicitly ask for an exception (and subclasses) to be excluded from retry. - * + * * @param type the exception to exclude from retry * @return this for fluent chaining */ @@ -321,7 +321,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Explicitly ask for an exception (and subclasses) to be retried. - * + * * @param type the exception to retry * @return this for fluent chaining */ @@ -334,7 +334,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { * Mark the item processor as non-transactional (default is the opposite). If this flag is set the results of item * processing are cached across transactions in between retries and during skip processing, otherwise the processor * will be called in every transaction. - * + * * @return this for fluent chaining */ public FaultTolerantStepBuilder processorNonTransactional() { @@ -446,7 +446,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Convenience method to get an exception classifier based on the provided transaction attributes. - * + * * @return an exception classifier: maps to true if an exception should cause rollback */ private Classifier getRollbackClassifier() { @@ -466,6 +466,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { final Classifier panic = new BinaryExceptionClassifier(types, true); classifier = new Classifier() { + @Override public Boolean classify(Throwable classifiable) { // Rollback if either the user's list or our own applies return panic.classify(classifiable) || binary.classify(classifiable); @@ -478,6 +479,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { } + @SuppressWarnings("serial") private TransactionAttribute getTransactionAttribute(TransactionAttribute attribute) { final Classifier classifier = getRollbackClassifier(); @@ -583,7 +585,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Wrap a {@link SkipPolicy} and make it consistent with known fatal exceptions. - * + * * @param skipPolicy an existing skip policy * @return a skip policy that will not skip fatal exceptions */ @@ -626,16 +628,16 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { exceptions.add(fatal); } } - nonRetryableExceptionClasses = (List>) exceptions; + nonRetryableExceptionClasses = exceptions; } /** * ChunkListener that wraps exceptions thrown from the ChunkListener in {@link FatalStepExecutionException} to force * termination of StepExecution - * + * * ChunkListeners shoulnd't throw exceptions and expect continued processing, they must be handled in the * implementation or the step will terminate - * + * */ private class TerminateOnExceptionChunkListenerDelegate implements ChunkListener { @@ -645,6 +647,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { this.chunkListener = chunkListener; } + @Override public void beforeChunk() { try { chunkListener.beforeChunk(); @@ -654,6 +657,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { } } + @Override public void afterChunk() { try { chunkListener.afterChunk(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/FaultTolerantStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/FaultTolerantStepFactoryBean.java index 8cee29a06..566847214 100755 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/FaultTolerantStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/FaultTolerantStepFactoryBean.java @@ -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. @@ -35,20 +35,18 @@ import org.springframework.retry.policy.MapRetryContextCache; import org.springframework.retry.policy.RetryContextCache; /** - * Factory bean for step that provides options for configuring skip behaviour. User can set {@link #setSkipLimit(int)} - * to set how many exceptions of {@link #setSkippableExceptionClasses(Collection)} types are tolerated. - * {@link #setFatalExceptionClasses(Collection)} will cause immediate termination of job - they are treated as higher - * priority than {@link #setSkippableExceptionClasses(Collection)}, so the two lists don't need to be exclusive. - * + * Factory bean for step that provides options for configuring skip behavior. User can set {@link #setSkipLimit(int)} + * to set how many exceptions of {@link #setSkippableExceptionClasses(Map)} types are tolerated. + * * Skippable exceptions on write will by default cause transaction rollback - to avoid rollback for specific exception * class include it in the transaction attribute as "no rollback for". - * + * * @see SimpleStepFactoryBean - * + * * @author Dave Syer * @author Robert Kasanicky * @author Morten Andersen-Gott - * + * */ public class FaultTolerantStepFactoryBean extends SimpleStepFactoryBean { @@ -81,7 +79,7 @@ public class FaultTolerantStepFactoryBean extends SimpleStepFactoryBean extends SimpleStepFactoryBean extends SimpleStepFactoryBeanretryLimit == 1 by default. - * + * * @param retryLimit the retry limit to set, must be greater or equal to 1. */ public void setRetryLimit(int retryLimit) { @@ -112,13 +110,13 @@ public class FaultTolerantStepFactoryBean extends SimpleStepFactoryBean - * + * * 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}.
    - * + * * This property is ignored if the {@link #setRetryContextCache(RetryContextCache)} is set directly. - * + * * @param cacheCapacity the cache capacity to set (greater than 0 else ignored) */ public void setCacheCapacity(int cacheCapacity) { @@ -128,7 +126,7 @@ public class FaultTolerantStepFactoryBean extends SimpleStepFactoryBean extends SimpleStepFactoryBean, Boolean> retryableExceptionClasses) { @@ -146,7 +144,7 @@ public class FaultTolerantStepFactoryBean extends SimpleStepFactoryBean extends SimpleStepFactoryBean extends SimpleStepFactoryBean extends SimpleStepFactoryBean extends SimpleStepFactoryBean * Defaults to all no exception. - * + * * @param exceptionClasses defaults to Exception */ public void setSkippableExceptionClasses(Map, Boolean> exceptionClasses) { @@ -203,7 +201,7 @@ public class FaultTolerantStepFactoryBean extends SimpleStepFactoryBean * Defaults is empty. - * + * * @param noRollbackExceptionClasses the exception classes to set */ public void setNoRollbackExceptionClasses(Collection> noRollbackExceptionClasses) { @@ -217,6 +215,7 @@ public class FaultTolerantStepFactoryBean extends SimpleStepFactoryBean createBuilder(String name) { return new FaultTolerantStepBuilder(new StepBuilder(name)); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/SimpleStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/SimpleStepFactoryBean.java index a0a983799..f17e3dcf9 100755 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/SimpleStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/SimpleStepFactoryBean.java @@ -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. @@ -50,16 +50,17 @@ import org.springframework.transaction.interceptor.TransactionAttribute; /** * Most common configuration options for simple steps should be found here. Use this factory bean instead of creating a * {@link Step} implementation manually. - * + * * This factory does not support configuration of fault-tolerant behavior, use appropriate subclass of this factory bean * to configure skip or retry. - * + * * @see FaultTolerantStepFactoryBean - * + * * @author Dave Syer * @author Robert Kasanicky - * + * */ +@SuppressWarnings("rawtypes") public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { private String name; @@ -118,7 +119,7 @@ public class SimpleStepFactoryBean 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) { @@ -135,9 +136,10 @@ public class SimpleStepFactoryBean 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 public void setBeanName(String name) { this.name = name; } @@ -152,7 +154,7 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { /** * The timeout for an individual transaction in the step. - * + * * @param transactionTimeout the transaction timeout to set, defaults to infinite */ public void setTransactionTimeout(int transactionTimeout) { @@ -175,7 +177,7 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { /** * Public setter for the start limit for the step. - * + * * @param startLimit the startLimit to set */ public void setStartLimit(int startLimit) { @@ -185,7 +187,7 @@ public class SimpleStepFactoryBean 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) { @@ -216,7 +218,7 @@ public class SimpleStepFactoryBean 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) { @@ -226,7 +228,7 @@ public class SimpleStepFactoryBean 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) { @@ -267,7 +269,7 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { /** * Public setter for {@link JobRepository}. - * + * * @param jobRepository is a mandatory dependence (no default). */ public void setJobRepository(JobRepository jobRepository) { @@ -276,7 +278,7 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { /** * Public setter for the {@link PlatformTransactionManager}. - * + * * @param transactionManager the transaction manager to set */ public void setTransactionManager(PlatformTransactionManager transactionManager) { @@ -311,9 +313,10 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { /** * Create a {@link Step} from the configuration provided. - * + * * @see FactoryBean#getObject() */ + @Override public final Object getObject() throws Exception { SimpleStepBuilder builder = createBuilder(getName()); applyConfiguration(builder); @@ -325,6 +328,7 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { return new SimpleStepBuilder(new StepBuilder(name)); } + @Override public Class getObjectType() { return TaskletStep.class; } @@ -332,9 +336,10 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { /** * Returns true by default, but in most cases a {@link Step} should not be treated as thread safe. Clients are * recommended to create a new step for each job execution. - * + * * @see org.springframework.beans.factory.FactoryBean#isSingleton() */ + @Override public boolean isSingleton() { return this.singleton; } @@ -349,7 +354,7 @@ public class SimpleStepFactoryBean 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) { @@ -360,7 +365,7 @@ public class SimpleStepFactoryBean 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) { @@ -418,7 +423,7 @@ public class SimpleStepFactoryBean 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) { @@ -487,4 +492,4 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { } } -} \ No newline at end of file +} diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/BatchRetryTemplate.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/BatchRetryTemplate.java index 8e995f956..50b5c2f97 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/BatchRetryTemplate.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/BatchRetryTemplate.java @@ -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,9 +51,9 @@ import org.springframework.retry.support.RetryTemplate; * normal), but there may still be entries in the cache for the original failed * items. This might mean that an item that did not cause a failure is never * retried because other items in the same batch fail fatally first. - * + * * @author Dave Syer - * + * */ public class BatchRetryTemplate implements RetryOperations { @@ -68,6 +68,7 @@ public class BatchRetryTemplate implements RetryOperations { } + @SuppressWarnings("serial") private static class BatchRetryContext extends RetryContextSupport { private final Collection contexts; @@ -199,7 +200,7 @@ public class BatchRetryTemplate implements RetryOperations { private RetryPolicy retryPolicy; public T execute(RetryCallback retryCallback, Collection states) throws ExhaustedRetryException, - Exception { + Exception { RetryState batchState = new BatchRetryState(states); return delegate.execute(retryCallback, batchState); } @@ -209,21 +210,25 @@ public class BatchRetryTemplate implements RetryOperations { RetryState batchState = new BatchRetryState(states); return delegate.execute(retryCallback, recoveryCallback, batchState); } - + + @Override public final T execute(RetryCallback retryCallback, RecoveryCallback recoveryCallback, RetryState retryState) throws Exception, ExhaustedRetryException { return regular.execute(retryCallback, recoveryCallback, retryState); } + @Override public final T execute(RetryCallback retryCallback, RecoveryCallback recoveryCallback) throws Exception { return regular.execute(retryCallback, recoveryCallback); } + @Override public final T execute(RetryCallback retryCallback, RetryState retryState) throws Exception, - ExhaustedRetryException { + ExhaustedRetryException { return regular.execute(retryCallback, retryState); } + @Override public final T execute(RetryCallback retryCallback) throws Exception { return regular.execute(retryCallback); } @@ -269,7 +274,7 @@ public class BatchRetryTemplate implements RetryOperations { delegate.setRetryPolicy(retryPolicy); regular.setRetryPolicy(retryPolicy); } - + public boolean canRetry(RetryContext context) { return context==null ? true : retryPolicy.canRetry(context); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/Chunk.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/Chunk.java index 936807fc1..dfce3e0cd 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/Chunk.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/Chunk.java @@ -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 java.util.List; * over the chunk using the {@link #iterator()} method, and if there is a * failure call {@link org.springframework.batch.core.step.item.Chunk.ChunkIterator#remove()} on the iterator. * The skipped items are then available through the chunk. - * + * * @author Dave Syer * @since 2.0 */ @@ -105,7 +105,7 @@ public class Chunk implements Iterable { /** * Register an anonymous skip. To skip an individual item, use * {@link ChunkIterator#remove()}. - * + * * @param e the exception that caused the skip */ public void skip(Exception e) { @@ -123,6 +123,7 @@ public class Chunk implements Iterable { * Get an unmodifiable iterator for the underlying items. * @see java.lang.Iterable#iterator() */ + @Override public ChunkIterator iterator() { return new ChunkIterator(items); } @@ -136,7 +137,7 @@ public class Chunk implements Iterable { /** * Flag to indicate if the source data is exhausted. - * + * * @return true if there is no more data to process */ public boolean isEnd() { @@ -154,7 +155,7 @@ public class Chunk implements Iterable { /** * Query the chunk to see if anyone has registered an interest in keeping a * reference to it. - * + * * @return the busy flag */ public boolean isBusy() { @@ -164,7 +165,7 @@ public class Chunk implements Iterable { /** * Register an interest in the chunk to prevent it from being cleaned up * before the flag is reset to false. - * + * * @param busy the flag to set */ public void setBusy(boolean busy) { @@ -188,7 +189,7 @@ public class Chunk implements Iterable { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override @@ -197,11 +198,11 @@ public class Chunk implements Iterable { } /** - * Special iterator for a chunk providing the {@link #remove(Exception)} + * Special iterator for a chunk providing the {@link #remove(Throwable)} * method for dynamically removing an item and adding it to the skips. - * + * * @author Dave Syer - * + * */ public class ChunkIterator implements Iterator { @@ -213,10 +214,12 @@ public class Chunk implements Iterable { iterator = items.iterator(); } + @Override public boolean hasNext() { return iterator.hasNext(); } + @Override public W next() { next = iterator.next(); return next; @@ -227,6 +230,7 @@ public class Chunk implements Iterable { skips.add(new SkipWrapper(next, e)); } + @Override public void remove() { if (next == null) { if (iterator.hasNext()) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkMonitor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkMonitor.java index 684ab57b1..ae99ac162 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkMonitor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkMonitor.java @@ -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,14 +28,14 @@ import org.springframework.batch.item.support.CompositeItemStream; * an input chunk. Only works with single threaded steps because it has to use a * {@link ThreadLocal} to manage the state and co-ordinate between the caller * and the wrapped {@link ItemStream}. - * + * * @author Dave Syer * @since 2.0 */ public class ChunkMonitor implements ItemStream { - + private Log logger = LogFactory.getLog(getClass()); - + private boolean streamsRegistered = false; public static class ChunkMonitorData { @@ -93,6 +93,7 @@ public class ChunkMonitor implements ItemStream { resetOffset(); } + @Override public void close() throws ItemStreamException { holder.set(null); if (streamsRegistered) { @@ -100,6 +101,7 @@ public class ChunkMonitor implements ItemStream { } } + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { if (streamsRegistered) { stream.open(executionContext); @@ -120,6 +122,7 @@ public class ChunkMonitor implements ItemStream { } } + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { if (streamsRegistered) { ChunkMonitorData data = getData(); @@ -146,4 +149,4 @@ public class ChunkMonitor implements ItemStream { return data; } -} \ No newline at end of file +} diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkOrientedTasklet.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkOrientedTasklet.java index bf0ebbe14..1fd2bcf8b 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkOrientedTasklet.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkOrientedTasklet.java @@ -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. @@ -26,9 +26,9 @@ import org.springframework.batch.repeat.RepeatStatus; /** * A {@link Tasklet} implementing variations on read-process-write item * handling. - * + * * @author Dave Syer - * + * * @param input item type */ public class ChunkOrientedTasklet implements Tasklet { @@ -53,13 +53,14 @@ public class ChunkOrientedTasklet implements Tasklet { * true, which is appropriate for forward-only, non-transactional item * readers. Main (or only) use case for setting this flag to false is a * transactional JMS item reader. - * + * * @param buffering */ public void setBuffering(boolean buffering) { this.buffering = buffering; } + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { @SuppressWarnings("unchecked") diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessor.java index 608364cf5..664db55a9 100755 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessor.java @@ -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,8 +25,6 @@ import java.util.concurrent.atomic.AtomicReference; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.classify.BinaryExceptionClassifier; -import org.springframework.classify.Classifier; import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.step.skip.LimitCheckingItemSkipPolicy; import org.springframework.batch.core.step.skip.NonSkippableProcessException; @@ -35,6 +33,8 @@ import org.springframework.batch.core.step.skip.SkipListenerFailedException; import org.springframework.batch.core.step.skip.SkipPolicy; import org.springframework.batch.item.ItemProcessor; import org.springframework.batch.item.ItemWriter; +import org.springframework.classify.BinaryExceptionClassifier; +import org.springframework.classify.Classifier; import org.springframework.retry.ExhaustedRetryException; import org.springframework.retry.RecoveryCallback; import org.springframework.retry.RetryCallback; @@ -45,7 +45,7 @@ import org.springframework.retry.support.DefaultRetryState; /** * FaultTolerant implementation of the {@link ChunkProcessor} interface, that * allows for skipping or retry of items that cause exceptions during writing. - * + * */ public class FaultTolerantChunkProcessor extends SimpleChunkProcessor { @@ -71,7 +71,7 @@ public class FaultTolerantChunkProcessor extends SimpleChunkProcessor extends SimpleChunkProcessor rollbackClassifier) { @@ -114,7 +114,7 @@ public class FaultTolerantChunkProcessor extends SimpleChunkProcessor extends SimpleChunkProcessor extends SimpleChunkProcessor retryCallback = new RetryCallback() { + @Override public O doWithRetry(RetryContext context) throws Exception { O output = null; try { @@ -263,6 +264,7 @@ public class FaultTolerantChunkProcessor extends SimpleChunkProcessor recoveryCallback = new RecoveryCallback() { + @Override public O recover(RetryContext context) throws Exception { Throwable e = context.getLastThrowable(); if (shouldSkip(itemProcessSkipPolicy, e, contribution.getStepSkipCount())) { @@ -316,6 +318,7 @@ public class FaultTolerantChunkProcessor extends SimpleChunkProcessor contextHolder = new AtomicReference(); RetryCallback retryCallback = new RetryCallback() { + @Override public Object doWithRetry(RetryContext context) throws Exception { contextHolder.set(context); @@ -352,6 +355,7 @@ public class FaultTolerantChunkProcessor extends SimpleChunkProcessor batchRecoveryCallback = new RecoveryCallback() { + @Override public Object recover(RetryContext context) throws Exception { Throwable e = context.getLastThrowable(); @@ -389,6 +393,7 @@ public class FaultTolerantChunkProcessor extends SimpleChunkProcessor recoveryCallback = new RecoveryCallback() { + @Override public Object recover(RetryContext context) throws Exception { /* @@ -466,7 +471,7 @@ public class FaultTolerantChunkProcessor extends SimpleChunkProcessor extends SimpleChunkProcessor implements ChunkProcessor, InitializingBean { @@ -71,9 +71,10 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi /** * Check mandatory properties. - * + * * @see InitializingBean#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(itemWriter, "ItemWriter must be set"); Assert.notNull(itemProcessor, "ItemProcessor must be set"); @@ -82,7 +83,7 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi /** * Register some {@link StepListener}s with the handler. Each will get the * callbacks in the order specified at the correct stage. - * + * * @param listeners */ public void setListeners(List listeners) { @@ -93,7 +94,7 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi /** * Register a listener for callbacks at the appropriate stages in a process. - * + * * @param listener a {@link StepListener} */ public void registerListener(StepListener listener) { @@ -135,7 +136,7 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi /** * Surrounds the actual write call with listener callbacks. - * + * * @param items * @throws Exception */ @@ -159,7 +160,7 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi /** * Call the listener's after write method. - * + * * @param items */ protected final void doAfterWrite(List items) { @@ -175,6 +176,7 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi } } + @Override public final void process(StepContribution contribution, Chunk inputs) throws Exception { // Allow temporary state to be stored in the user data field @@ -206,7 +208,7 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi * {@link #isComplete(Chunk)}, {@link #getFilterCount(Chunk, Chunk)} and * {@link #getAdjustedOutputs(Chunk, Chunk)} might also need to be, to * ensure that the user data is handled consistently. - * + * * @param inputs the inputs for the process */ protected void initializeUserData(Chunk inputs) { @@ -216,12 +218,12 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi /** * Extension point for subclasses to calculate the filter count. Defaults to * the difference between input size and output size. - * + * * @param inputs the inputs after transformation * @param outputs the outputs after transformation - * + * * @return the difference in sizes - * + * * @see #initializeUserData(Chunk) */ protected int getFilterCount(Chunk inputs, Chunk outputs) { @@ -231,10 +233,10 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi /** * Extension point for subclasses that want to store additional data in the * inputs. Default just checks if inputs are empty. - * + * * @param inputs the input chunk * @return true if it is empty - * + * * @see #initializeUserData(Chunk) */ protected boolean isComplete(Chunk inputs) { @@ -245,11 +247,11 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi * Extension point for subclasses that want to adjust the outputs based on * additional saved data in the inputs. Default implementation just returns * the outputs unchanged. - * + * * @param inputs the inputs for the transformation * @param outputs the result of the transformation * @return the outputs unchanged - * + * * @see #initializeUserData(Chunk) */ protected Chunk getAdjustedOutputs(Chunk inputs, Chunk outputs) { @@ -261,7 +263,7 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi * increments the write count in the contribution. Subclasses can handle * more complicated scenarios, e.g.with fault tolerance. If output items are * skipped they should be removed from the inputs as well. - * + * * @param contribution the current step contribution * @param inputs the inputs that gave rise to the ouputs * @param outputs the outputs to write diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleChunkProvider.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleChunkProvider.java index decbd9c5b..0a18103d1 100755 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleChunkProvider.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleChunkProvider.java @@ -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. @@ -101,11 +101,13 @@ public class SimpleChunkProvider implements ChunkProvider { } } + @Override public Chunk provide(final StepContribution contribution) throws Exception { final Chunk inputs = new Chunk(); repeatOperations.iterate(new RepeatCallback() { + @Override public RepeatStatus doInIteration(final RepeatContext context) throws Exception { I item = null; try { @@ -131,6 +133,7 @@ public class SimpleChunkProvider implements ChunkProvider { } + @Override public void postProcess(StepContribution contribution, Chunk chunk) { // do nothing } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandler.java index 84cdd9b86..7aedd7999 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandler.java @@ -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,12 +17,12 @@ package org.springframework.batch.core.step.item; import java.util.Collection; -import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.Log; -import org.springframework.classify.BinaryExceptionClassifier; +import org.apache.commons.logging.LogFactory; import org.springframework.batch.repeat.RepeatContext; import org.springframework.batch.repeat.exception.ExceptionHandler; import org.springframework.batch.repeat.support.RepeatSynchronizationManager; +import org.springframework.classify.BinaryExceptionClassifier; import org.springframework.retry.RetryCallback; import org.springframework.retry.RetryContext; import org.springframework.retry.RetryPolicy; @@ -32,9 +32,9 @@ import org.springframework.retry.listener.RetryListenerSupport; * An {@link ExceptionHandler} that is aware of the retry context so that it can * distinguish between a fatal exception and one that can be retried. Delegates * the actual exception handling to another {@link ExceptionHandler}. - * + * * @author Dave Syer - * + * */ public class SimpleRetryExceptionHandler extends RetryListenerSupport implements ExceptionHandler { @@ -42,7 +42,7 @@ public class SimpleRetryExceptionHandler extends RetryListenerSupport implements * Attribute key, whose existence signals an exhausted retry. */ private static final String EXHAUSTED = SimpleRetryExceptionHandler.class.getName() + ".RETRY_EXHAUSTED"; - + private static final Log logger = LogFactory.getLog(SimpleRetryExceptionHandler.class); final private RetryPolicy retryPolicy; @@ -53,7 +53,7 @@ public class SimpleRetryExceptionHandler extends RetryListenerSupport implements /** * Create an exception handler from its mandatory properties. - * + * * @param retryPolicy the retry policy that will be under effect when an * exception is encountered * @param exceptionHandler the delegate to use if an exception actually @@ -70,10 +70,11 @@ public class SimpleRetryExceptionHandler extends RetryListenerSupport implements * Check if the exception is going to be retried, and veto the handling if * it is. If retry is exhausted or the exception is on the fatal list, then * handle using the delegate. - * + * * @see ExceptionHandler#handleException(org.springframework.batch.repeat.RepeatContext, * java.lang.Throwable) */ + @Override public void handleException(RepeatContext context, Throwable throwable) throws Throwable { // Only bother to check the delegate exception handler if we know that // retry is exhausted @@ -89,10 +90,11 @@ public class SimpleRetryExceptionHandler extends RetryListenerSupport implements /** * If retry is exhausted set up some state in the context that can be used * to signal that the exception should be handled. - * - * @see org.springframework.batch.retry.RetryListener#close(org.springframework.batch.retry.RetryContext, - * org.springframework.batch.retry.RetryCallback, java.lang.Throwable) + * + * @see org.springframework.retry.RetryListener#close(org.springframework.retry.RetryContext, + * org.springframework.retry.RetryCallback, java.lang.Throwable) */ + @Override public void close(RetryContext context, RetryCallback callback, Throwable throwable) { if (!retryPolicy.canRetry(context)) { logger.debug("Marking retry as exhausted: "+context); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/job/DefaultJobParametersExtractor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/job/DefaultJobParametersExtractor.java index 10ec4b4d4..8b778803a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/job/DefaultJobParametersExtractor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/job/DefaultJobParametersExtractor.java @@ -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. @@ -32,9 +32,9 @@ import org.springframework.batch.item.ExecutionContext; * Simple implementation of {@link JobParametersExtractor} which pulls * parameters with named keys out of the step execution context and the job * parameters of the surrounding job. - * + * * @author Dave Syer - * + * */ public class DefaultJobParametersExtractor implements JobParametersExtractor { @@ -52,7 +52,7 @@ public class DefaultJobParametersExtractor implements JobParametersExtractor { * values of the respective type and assigned to job parameters accordingly * (there will be an error if they are not of the right type). Without a * special suffix in that form a parameter is assumed to be of type String. - * + * * @param keys the keys to set */ public void setKeys(String[] keys) { @@ -60,8 +60,9 @@ public class DefaultJobParametersExtractor implements JobParametersExtractor { } /** - * @see JobParametersExtractor#getJobParameters(StepExecution) + * @see JobParametersExtractor#getJobParameters(Job, StepExecution) */ + @Override public JobParameters getJobParameters(Job job, StepExecution stepExecution) { JobParametersBuilder builder = new JobParametersBuilder(); Map jobParameters = stepExecution.getJobParameters().getParameters(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/AlwaysSkipItemSkipPolicy.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/AlwaysSkipItemSkipPolicy.java index f6883fd61..9668dc5c8 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/AlwaysSkipItemSkipPolicy.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/AlwaysSkipItemSkipPolicy.java @@ -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,12 +19,13 @@ package org.springframework.batch.core.step.skip; /** * Implementation of the {@link SkipPolicy} interface that * will always return that an item should be skipped. - * + * * @author Ben Hale * @author Lucas Ward */ public class AlwaysSkipItemSkipPolicy implements SkipPolicy { + @Override public boolean shouldSkip(Throwable t, int skipCount) { return true; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/CompositeSkipPolicy.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/CompositeSkipPolicy.java index 2e5ad9396..bb75f1508 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/CompositeSkipPolicy.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/CompositeSkipPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2011 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 @@ package org.springframework.batch.core.step.skip; public class CompositeSkipPolicy implements SkipPolicy { private SkipPolicy[] skipPolicies; - + public CompositeSkipPolicy() { this(new SkipPolicy[0]); } @@ -30,11 +30,12 @@ public class CompositeSkipPolicy implements SkipPolicy { public CompositeSkipPolicy(SkipPolicy[] skipPolicies) { this.skipPolicies = skipPolicies; } - + public void setSkipPolicies(SkipPolicy[] skipPolicies) { this.skipPolicies = skipPolicies; } + @Override public boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException { for (SkipPolicy policy : skipPolicies) { if (policy.shouldSkip(t, skipCount)) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/ExceptionClassifierSkipPolicy.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/ExceptionClassifierSkipPolicy.java index 600324486..a32be2db5 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/ExceptionClassifierSkipPolicy.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/ExceptionClassifierSkipPolicy.java @@ -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. @@ -23,9 +23,9 @@ import org.springframework.classify.SubclassClassifier; /** * A {@link SkipPolicy} that depends on an exception classifier to make its * decision, and then delegates to the classifier result. - * + * * @author Dave Syer - * + * * @see SubclassClassifier */ public class ExceptionClassifierSkipPolicy implements SkipPolicy { @@ -34,7 +34,7 @@ public class ExceptionClassifierSkipPolicy implements SkipPolicy { /** * The classifier that will be used to choose a delegate policy. - * + * * @param classifier the classifier to use to choose a delegate policy */ public void setExceptionClassifier(SubclassClassifier classifier) { @@ -46,7 +46,7 @@ public class ExceptionClassifierSkipPolicy implements SkipPolicy { * set it once, e.g. in configuration, and then don't change it during a * running application. Either this property or the exception classifier * directly should be set, but not both. - * + * * @param policyMap a map of String to {@link SkipPolicy} that will be used * to create a {@link Classifier} to locate a policy. */ @@ -59,12 +59,13 @@ public class ExceptionClassifierSkipPolicy implements SkipPolicy { /** * Consult the classifier and find a delegate policy, and then use that to * determine the outcome. - * + * * @param t the throwable to consider * @param skipCount the current skip count * @return true if the exception can be skipped * @throws SkipLimitExceededException if a limit is exceeded */ + @Override public boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException { return classifier.classify(t).shouldSkip(t, skipCount); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/LimitCheckingItemSkipPolicy.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/LimitCheckingItemSkipPolicy.java index ce1ab2d29..e2024f34f 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/LimitCheckingItemSkipPolicy.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/LimitCheckingItemSkipPolicy.java @@ -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,11 +19,11 @@ import java.io.FileNotFoundException; import java.util.Collections; import java.util.Map; -import org.springframework.classify.BinaryExceptionClassifier; -import org.springframework.classify.Classifier; import org.springframework.batch.core.Step; import org.springframework.batch.core.StepExecution; import org.springframework.batch.item.file.FlatFileParseException; +import org.springframework.classify.BinaryExceptionClassifier; +import org.springframework.classify.Classifier; /** *

    @@ -35,7 +35,7 @@ import org.springframework.batch.item.file.FlatFileParseException; * however, if the vast majority of records are causing exceptions, the file is * likely bad. *

    - * + * *

    * Furthermore, it is also likely that you only want to skip certain exceptions. * {@link FlatFileParseException} is a good example of an exception you will @@ -43,7 +43,7 @@ import org.springframework.batch.item.file.FlatFileParseException; * immediate termination of the {@link Step}. A {@link Classifier} is used to * determine whether a particular exception is skippable or not. *

    - * + * * @author Ben Hale * @author Lucas Ward * @author Robert Kasanicky @@ -87,7 +87,7 @@ public class LimitCheckingItemSkipPolicy implements SkipPolicy { /** * The absolute number of skips (of skippable exceptions) that can be * tolerated before a failure. - * + * * @param skipLimit the skip limit to set */ public void setSkipLimit(int skipLimit) { @@ -97,7 +97,7 @@ public class LimitCheckingItemSkipPolicy implements SkipPolicy { /** * The classifier that will be used to decide on skippability. If an * exception classifies as "true" then it is skippable, and otherwise not. - * + * * @param skippableExceptionClassifier the skippableExceptionClassifier to * set */ @@ -108,7 +108,7 @@ public class LimitCheckingItemSkipPolicy implements SkipPolicy { /** * Set up the classifier through a convenient map from throwable class to * boolean (true if skippable). - * + * * @param skippableExceptions the skippable exceptions to set */ public void setSkippableExceptionMap(Map, Boolean> skippableExceptions) { @@ -123,6 +123,7 @@ public class LimitCheckingItemSkipPolicy implements SkipPolicy { * skipCount is greater than the skipLimit, then a * {@link SkipLimitExceededException} will be thrown. */ + @Override public boolean shouldSkip(Throwable t, int skipCount) { if (skippableExceptionClassifier.classify(t)) { if (skipCount < skipLimit) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/NeverSkipItemSkipPolicy.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/NeverSkipItemSkipPolicy.java index a10bf906c..bf1ff0399 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/NeverSkipItemSkipPolicy.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/NeverSkipItemSkipPolicy.java @@ -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,11 +19,12 @@ package org.springframework.batch.core.step.skip; /** * {@link SkipPolicy} implementation that always returns false, * indicating that an item should not be skipped. - * + * * @author Lucas Ward */ public class NeverSkipItemSkipPolicy implements SkipPolicy{ + @Override public boolean shouldSkip(Throwable t, int skipCount) { return false; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapter.java index 5ee760332..906af7753 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapter.java @@ -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,9 +26,9 @@ import org.springframework.util.Assert; /** * Adapts a {@link Callable}<{@link RepeatStatus}> to the {@link Tasklet} * interface. - * + * * @author Dave Syer - * + * */ public class CallableTaskletAdapter implements Tasklet, InitializingBean { @@ -44,9 +44,10 @@ public class CallableTaskletAdapter implements Tasklet, InitializingBean { /** * Assert that the callable is set. - * + * * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(callable); } @@ -56,6 +57,7 @@ public class CallableTaskletAdapter implements Tasklet, InitializingBean { * the {@link StepContribution} and the attributes. * @see Tasklet#execute(StepContribution, ChunkContext) */ + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return callable.call(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/ConfigurableSystemProcessExitCodeMapper.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/ConfigurableSystemProcessExitCodeMapper.java index ee1e6ab0c..0f4dca290 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/ConfigurableSystemProcessExitCodeMapper.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/ConfigurableSystemProcessExitCodeMapper.java @@ -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,19 +22,20 @@ import org.springframework.batch.core.ExitStatus; import org.springframework.util.Assert; /** - * Maps exit codes to {@link org.springframework.batch.core.ExitStatus} - * according to injected map. The injected map is required to contain a value - * for 'else' key, this value will be returned if the injected map + * Maps exit codes to {@link org.springframework.batch.core.ExitStatus} + * according to injected map. The injected map is required to contain a value + * for 'else' key, this value will be returned if the injected map * does not contain value for the exit code returned by the system process. - * + * * @author Robert Kasanicky */ public class ConfigurableSystemProcessExitCodeMapper implements SystemProcessExitCodeMapper { - + public static final String ELSE_KEY = "else"; - + private Map mappings; + @Override public ExitStatus getExitStatus(int exitCode) { ExitStatus exitStatus = mappings.get(exitCode); if (exitStatus != null) { @@ -45,7 +46,7 @@ public class ConfigurableSystemProcessExitCodeMapper implements SystemProcessExi } /** - * @param mappings Integer exit code keys to + * @param mappings Integer exit code keys to * {@link org.springframework.batch.core.ExitStatus} values. */ public void setMappings(Map mappings) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/MethodInvokingTaskletAdapter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/MethodInvokingTaskletAdapter.java index 63f433908..c713f76f6 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/MethodInvokingTaskletAdapter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/MethodInvokingTaskletAdapter.java @@ -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,11 +27,11 @@ import org.springframework.batch.repeat.RepeatStatus; * an {@link ExitStatus}. The POJO method is usually going to have no arguments, * but a static argument or array of arguments can be used by setting the * arguments property. - * + * * @see AbstractMethodInvokingDelegator - * + * * @author Dave Syer - * + * */ public class MethodInvokingTaskletAdapter extends AbstractMethodInvokingDelegator implements Tasklet { @@ -39,9 +39,10 @@ public class MethodInvokingTaskletAdapter extends AbstractMethodInvokingDelegato * Delegate execution to the target object and translate the return value to * an {@link ExitStatus} by invoking a method in the delegate POJO. Ignores * the {@link StepContribution} and the attributes. - * + * * @see Tasklet#execute(StepContribution, ChunkContext) */ + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { contribution.setExitStatus(mapResult(invokeDelegateMethod())); return RepeatStatus.FINISHED; @@ -50,7 +51,7 @@ public class MethodInvokingTaskletAdapter extends AbstractMethodInvokingDelegato /** * If the result is an {@link ExitStatus} already just return that, * otherwise return {@link ExitStatus#COMPLETED}. - * + * * @param result the value returned by the delegate method * @return an {@link ExitStatus} consistent with the result */ diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SimpleSystemProcessExitCodeMapper.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SimpleSystemProcessExitCodeMapper.java index bf78b73e7..ba27551f9 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SimpleSystemProcessExitCodeMapper.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SimpleSystemProcessExitCodeMapper.java @@ -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,13 +20,14 @@ import org.springframework.batch.core.ExitStatus; /** * Simple {@link SystemProcessExitCodeMapper} implementation that performs following mapping: - * + * * 0 -> ExitStatus.FINISHED * else -> ExitStatus.FAILED - * + * * @author Robert Kasanicky */ public class SimpleSystemProcessExitCodeMapper implements SystemProcessExitCodeMapper { + @Override public ExitStatus getExitStatus(int exitCode) { if (exitCode == 0) { return ExitStatus.COMPLETED; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java index 46bf9a4da..397ef7578 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java @@ -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,23 +36,23 @@ import org.springframework.util.Assert; /** * {@link Tasklet} that executes a system command. - * + * * The system command is executed asynchronously using injected * {@link #setTaskExecutor(TaskExecutor)} - timeout value is required to be set, * so that the batch job does not hang forever if the external process hangs. - * + * * Tasklet periodically checks for termination status (i.e. * {@link #setCommand(String)} finished its execution or * {@link #setTimeout(long)} expired or job was interrupted). The check interval * is given by {@link #setTerminationCheckInterval(long)}. - * + * * When job interrupt is detected tasklet's execution is terminated immediately * by throwing {@link JobInterruptedException}. - * + * * {@link #setInterruptOnCancel(boolean)} specifies whether the tasklet should * attempt to interrupt the thread that executes the system command if it is * still running when tasklet exits (abnormally). - * + * * @author Robert Kasanicky */ public class SystemCommandTasklet extends StepExecutionListenerSupport implements Tasklet, InitializingBean { @@ -81,10 +81,12 @@ public class SystemCommandTasklet extends StepExecutionListenerSupport implement * Execute system command and map its exit code to {@link ExitStatus} using * {@link SystemProcessExitCodeMapper}. */ + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { FutureTask systemCommandTask = new FutureTask(new Callable() { + @Override public Integer call() throws Exception { Process process = Runtime.getRuntime().exec(command, environmentParams, workingDirectory); return process.waitFor(); @@ -144,6 +146,7 @@ public class SystemCommandTasklet extends StepExecutionListenerSupport implement } + @Override public void afterPropertiesSet() throws Exception { Assert.hasLength(command, "'command' property value is required"); Assert.notNull(systemProcessExitCodeMapper, "SystemProcessExitCodeMapper must be set"); @@ -172,7 +175,7 @@ public class SystemCommandTasklet extends StepExecutionListenerSupport implement /** * The time interval how often the tasklet will check for termination * status. - * + * * @param checkInterval time interval in milliseconds (1 second by default). */ public void setTerminationCheckInterval(long checkInterval) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java index 7e7677fec..552cded4d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java @@ -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. @@ -60,17 +60,18 @@ import org.springframework.util.Assert; * loop is controlled by the step operations ( * {@link #setStepOperations(RepeatOperations)}).
    *
    - * + * * Clients can use interceptors in the step operations to intercept or listen to * the iteration on a step-wide basis, for instance to get a callback when the * step is complete. Those that want callbacks at the level of an individual * tasks, can specify interceptors for the chunk operations. - * + * * @author Dave Syer * @author Lucas Ward * @author Ben Hale * @author Robert Kasanicky */ +@SuppressWarnings("serial") public class TaskletStep extends AbstractStep { private static final Log logger = LogFactory.getLog(TaskletStep.class); @@ -113,7 +114,7 @@ public class TaskletStep extends AbstractStep { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.step.AbstractStep#afterPropertiesSet() */ @@ -125,7 +126,7 @@ public class TaskletStep extends AbstractStep { /** * Public setter for the {@link PlatformTransactionManager}. - * + * * @param transactionManager the transaction manager to set */ public void setTransactionManager(PlatformTransactionManager transactionManager) { @@ -134,7 +135,7 @@ public class TaskletStep extends AbstractStep { /** * Public setter for the {@link TransactionAttribute}. - * + * * @param transactionAttribute the {@link TransactionAttribute} to set */ public void setTransactionAttribute(TransactionAttribute transactionAttribute) { @@ -143,7 +144,7 @@ public class TaskletStep extends AbstractStep { /** * Public setter for the {@link Tasklet}. - * + * * @param tasklet the {@link Tasklet} to set */ public void setTasklet(Tasklet tasklet) { @@ -156,7 +157,7 @@ public class TaskletStep extends AbstractStep { /** * Register a chunk listener for callbacks at the appropriate stages in a * step execution. - * + * * @param listener a {@link ChunkListener} */ public void registerChunkListener(ChunkListener listener) { @@ -165,7 +166,7 @@ public class TaskletStep extends AbstractStep { /** * Register each of the objects as listeners. - * + * * @param listeners an array of listener objects of known types. */ public void setChunkListeners(ChunkListener[] listeners) { @@ -182,7 +183,7 @@ public class TaskletStep extends AbstractStep { * so if you implement {@link ItemWriter} using delegation to another object * which itself is a {@link ItemStream}, you need to register the delegate * here. - * + * * @param streams an array of {@link ItemStream} objects. */ public void setStreams(ItemStream[] streams) { @@ -194,7 +195,7 @@ public class TaskletStep extends AbstractStep { /** * Register a single {@link ItemStream} for callbacks to the stream * interface. - * + * * @param stream */ public void registerStream(ItemStream stream) { @@ -205,7 +206,7 @@ public class TaskletStep extends AbstractStep { * The {@link RepeatOperations} to use for the outer loop of the batch * processing. Should be set up by the caller through a factory. Defaults to * a plain {@link RepeatTemplate}. - * + * * @param stepOperations a {@link RepeatOperations} instance. */ public void setStepOperations(RepeatOperations stepOperations) { @@ -216,7 +217,7 @@ public class TaskletStep extends AbstractStep { * Setter for the {@link StepInterruptionPolicy}. The policy is used to * check whether an external request has been made to interrupt the job * execution. - * + * * @param interruptionPolicy a {@link StepInterruptionPolicy} */ public void setInterruptionPolicy(StepInterruptionPolicy interruptionPolicy) { @@ -231,13 +232,14 @@ public class TaskletStep extends AbstractStep { * used to store the result. Various reporting information are also added to * the current context governing the step execution, which would normally be * available to the caller through the step's {@link ExecutionContext}.
    - * + * * @throws JobInterruptedException if the step or a chunk is interrupted * @throws RuntimeException if there is an exception during a chunk * execution - * + * */ @Override + @SuppressWarnings("unchecked") protected void doExecute(StepExecution stepExecution) throws Exception { stream.update(stepExecution.getExecutionContext()); @@ -262,7 +264,7 @@ public class TaskletStep extends AbstractStep { RepeatStatus result; try { result = (RepeatStatus) new TransactionTemplate(transactionManager, transactionAttribute) - .execute(new ChunkTransactionCallback(chunkContext, semaphore)); + .execute(new ChunkTransactionCallback(chunkContext, semaphore)); } catch (UncheckedTransactionException e) { // Allow checked exceptions to be thrown inside callback @@ -286,17 +288,19 @@ public class TaskletStep extends AbstractStep { /** * Extension point mainly for test purposes so that the behaviour of the * lock can be manipulated to simulate various pathologies. - * + * * @return a semaphore for locking access to the JobRepository */ protected Semaphore createSemaphore() { return new Semaphore(1); } + @Override protected void close(ExecutionContext ctx) throws Exception { stream.close(); } + @Override protected void open(ExecutionContext ctx) throws Exception { stream.open(ctx); } @@ -306,10 +310,11 @@ public class TaskletStep extends AbstractStep { * failures in the transaction commit and rollback, only panicking if the * transaction status is unknown (i.e. if a commit failure leads to a clean * rollback then we assume the state is consistent). - * + * * @author Dave Syer - * + * */ + @SuppressWarnings("rawtypes") private class ChunkTransactionCallback extends TransactionSynchronizationAdapter implements TransactionCallback { private final StepExecution stepExecution; @@ -364,6 +369,7 @@ public class TaskletStep extends AbstractStep { } } + @Override public Object doInTransaction(TransactionStatus status) { TransactionSynchronizationManager.registerSynchronization(this); @@ -483,9 +489,9 @@ public class TaskletStep extends AbstractStep { /** * Convenience wrapper for a checked exception so that it can cause a * rollback and be extracted afterwards. - * + * * @author Dave Syer - * + * */ private static class UncheckedTransactionException extends RuntimeException { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionExceptionTests.java index c296ac501..7596c3b6f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionExceptionTests.java @@ -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,6 +25,7 @@ public class JobExecutionExceptionTests extends AbstractExceptionTests { /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ + @Override public Exception getException(String msg) throws Exception { return new JobExecutionException(msg); } @@ -32,6 +33,7 @@ public class JobExecutionExceptionTests extends AbstractExceptionTests { /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable) */ + @Override public Exception getException(String msg, Throwable t) throws Exception { return new JobExecutionException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/JobInterruptedExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/JobInterruptedExceptionTests.java index 98654693a..12b540731 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/JobInterruptedExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/JobInterruptedExceptionTests.java @@ -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,6 +25,7 @@ public class JobInterruptedExceptionTests extends AbstractExceptionTests { /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ + @Override public Exception getException(String msg) throws Exception { return new JobInterruptedException(msg); } @@ -32,6 +33,7 @@ public class JobInterruptedExceptionTests extends AbstractExceptionTests { /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable) */ + @Override public Exception getException(String msg, Throwable t) throws Exception { return new RuntimeException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/DuplicateJobExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/DuplicateJobExceptionTests.java index ead268026..52a7a80a7 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/DuplicateJobExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/DuplicateJobExceptionTests.java @@ -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. @@ -16,11 +16,10 @@ package org.springframework.batch.core.configuration; import org.springframework.batch.core.AbstractExceptionTests; -import org.springframework.batch.core.configuration.DuplicateJobException; /** * @author Dave Syer - * + * */ public class DuplicateJobExceptionTests extends AbstractExceptionTests { @@ -28,6 +27,7 @@ public class DuplicateJobExceptionTests extends AbstractExceptionTests { * (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ + @Override public Exception getException(String msg) throws Exception { return new DuplicateJobException(msg); } @@ -37,6 +37,7 @@ public class DuplicateJobExceptionTests extends AbstractExceptionTests { * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, * java.lang.Throwable) */ + @Override public Exception getException(String msg, Throwable t) throws Exception { return new DuplicateJobException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/ApplicationContextJobFactoryTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/ApplicationContextJobFactoryTests.java index e6e0e1f8a..2b7b8960c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/ApplicationContextJobFactoryTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/ApplicationContextJobFactoryTests.java @@ -27,6 +27,7 @@ public class ApplicationContextJobFactoryTests { } private static class StubApplicationContextFactory implements ApplicationContextFactory { + @Override public ConfigurableApplicationContext createApplicationContext() { StaticApplicationContext context = new StaticApplicationContext(); context.registerSingleton("job", JobSupport.class); @@ -36,6 +37,7 @@ public class ApplicationContextJobFactoryTests { } private static class PostProcessingApplicationContextFactory implements ApplicationContextFactory { + @Override public ConfigurableApplicationContext createApplicationContext() { StaticApplicationContext context = new StaticApplicationContext(); context.registerSingleton("job", JobSupport.class); @@ -48,6 +50,7 @@ public class ApplicationContextJobFactoryTests { private static class TestBeanPostProcessor implements BeanPostProcessor { + @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof JobSupport) { ((JobSupport) bean).setName("bar"); @@ -55,6 +58,7 @@ public class ApplicationContextJobFactoryTests { return bean; } + @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { return bean; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/JobFactoryRegistrationListenerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/JobFactoryRegistrationListenerTests.java index 4a21cdac1..1f6590486 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/JobFactoryRegistrationListenerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/JobFactoryRegistrationListenerTests.java @@ -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,7 +15,7 @@ */ package org.springframework.batch.core.configuration.support; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; import org.junit.Test; import org.springframework.batch.core.Job; @@ -23,7 +23,7 @@ import org.springframework.batch.core.configuration.JobFactory; /** * @author Dave Syer - * + * */ public class JobFactoryRegistrationListenerTests { @@ -40,10 +40,12 @@ public class JobFactoryRegistrationListenerTests { public void testBind() throws Exception { listener.setJobRegistry(registry); listener.bind(new JobFactory() { + @Override public Job createJob() { return null; } + @Override public String getJobName() { return "foo"; } @@ -54,16 +56,18 @@ public class JobFactoryRegistrationListenerTests { /** * Test method for * {@link org.springframework.batch.core.configuration.support.JobFactoryRegistrationListener#unbind(org.springframework.batch.core.configuration.JobFactory, java.util.Map)}. - * @throws Exception + * @throws Exception */ @Test public void testUnbind() throws Exception { testBind(); listener.unbind(new JobFactory() { + @Override public Job createJob() { return null; } + @Override public String getJobName() { return "foo"; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DecisionJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DecisionJobParserTests.java index f1df01054..329b901e8 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DecisionJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DecisionJobParserTests.java @@ -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. @@ -35,7 +35,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Dave Syer - * + * */ @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) @@ -58,6 +58,7 @@ public class DecisionJobParserTests { } public static class TestDecider implements JobExecutionDecider { + @Override public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { return new FlowExecutionStatus("FOO"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyCompletionPolicy.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyCompletionPolicy.java index 299b18637..e27f05073 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyCompletionPolicy.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyCompletionPolicy.java @@ -10,18 +10,22 @@ import org.springframework.batch.repeat.RepeatStatus; */ public class DummyCompletionPolicy implements CompletionPolicy { + @Override public boolean isComplete(RepeatContext context, RepeatStatus result) { return false; } + @Override public boolean isComplete(RepeatContext context) { return false; } + @Override public RepeatContext start(RepeatContext parent) { return null; } + @Override public void update(RepeatContext context) { } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemProcessor.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemProcessor.java index 74e7b6ebe..c8fd3e1a8 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemProcessor.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemProcessor.java @@ -8,6 +8,7 @@ import org.springframework.batch.item.ItemProcessor; */ public class DummyItemProcessor implements ItemProcessor { + @Override public Object process(Object item) throws Exception { return item; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemReader.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemReader.java index 655ace386..8b6b580ef 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemReader.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemReader.java @@ -10,6 +10,7 @@ import org.springframework.batch.item.UnexpectedInputException; */ public class DummyItemReader implements ItemReader { + @Override public Object read() throws Exception, UnexpectedInputException, ParseException { return null; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemWriter.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemWriter.java index 7e3cf012f..7374d52ff 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemWriter.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemWriter.java @@ -10,6 +10,7 @@ import org.springframework.batch.item.ItemWriter; */ public class DummyItemWriter implements ItemWriter { + @Override public void write(List items) throws Exception { } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyJobRepository.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyJobRepository.java index 23b575be1..894a89b18 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyJobRepository.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyJobRepository.java @@ -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. @@ -37,43 +37,54 @@ public class DummyJobRepository implements JobRepository, BeanNameAware { return name; } + @Override public void setBeanName(String name) { this.name = name; } + @Override public void add(StepExecution stepExecution) { } + @Override public JobExecution createJobExecution(String jobName, JobParameters jobParameters) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException { return null; } + @Override public JobExecution getLastJobExecution(String jobName, JobParameters jobParameters) { return null; } + @Override public StepExecution getLastStepExecution(JobInstance jobInstance, String stepName) { return null; } + @Override public int getStepExecutionCount(JobInstance jobInstance, String stepName) { return 0; } + @Override public boolean isJobInstanceExists(String jobName, JobParameters jobParameters) { return false; } + @Override public void update(JobExecution jobExecution) { } + @Override public void update(StepExecution stepExecution) { } + @Override public void updateExecutionContext(StepExecution stepExecution) { } + @Override public void updateExecutionContext(JobExecution jobExecution) { } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyPlatformTransactionManager.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyPlatformTransactionManager.java index 9d8b33832..aeec5b5c2 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyPlatformTransactionManager.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyPlatformTransactionManager.java @@ -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,16 +33,20 @@ public class DummyPlatformTransactionManager implements PlatformTransactionManag return name; } + @Override public void setBeanName(String name) { this.name = name; } + @Override public void commit(TransactionStatus status) throws TransactionException { } + @Override public void rollback(TransactionStatus status) throws TransactionException { } + @Override public TransactionStatus getTransaction(TransactionDefinition definition) throws TransactionException { return null; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyRetryListener.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyRetryListener.java index 90f092a27..e4220e547 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyRetryListener.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyRetryListener.java @@ -10,14 +10,17 @@ import org.springframework.retry.RetryListener; */ public class DummyRetryListener implements RetryListener { + @Override public boolean open(RetryContext context, RetryCallback callback) { return false; } + @Override public void close(RetryContext context, RetryCallback callback, Throwable throwable) { } + @Override public void onError(RetryContext context, RetryCallback callback, Throwable throwable) { } -} \ No newline at end of file +} diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyStep.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyStep.java index b5c1f625b..95333c05c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyStep.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyStep.java @@ -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. @@ -28,22 +28,27 @@ public class DummyStep implements Step, BeanNameAware { private String name; + @Override public String getName() { return name; } + @Override public void setBeanName(String name) { this.name = name; } + @Override public void execute(StepExecution stepExecution) throws JobInterruptedException { System.out.println("EXECUTING " + getName()); } + @Override public int getStartLimit() { return 100; } + @Override public boolean isAllowStartIfComplete() { return false; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyTasklet.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyTasklet.java index 996ed41b5..232888dca 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyTasklet.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyTasklet.java @@ -11,6 +11,7 @@ import org.springframework.batch.repeat.RepeatStatus; */ public class DummyTasklet implements Tasklet { + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return null; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FailingTasklet.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FailingTasklet.java index 5d8fc00ec..dd3fbad06 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FailingTasklet.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FailingTasklet.java @@ -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,12 +23,13 @@ import org.springframework.batch.repeat.RepeatStatus; * This tasklet will call * {@link NameStoringTasklet#execute(StepContribution, ChunkContext)} and then * throw an exeception. - * + * * @author Dan Garrette * @since 2.0 */ public class FailingTasklet extends NameStoringTasklet { + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { super.execute(contribution, chunkContext); throw new RuntimeException(); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FlowStepParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FlowStepParserTests.java index 74998f1a8..d0f598895 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FlowStepParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FlowStepParserTests.java @@ -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,7 +40,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Dave Syer - * + * */ @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) @@ -137,6 +137,7 @@ public class FlowStepParserTests { int count = 0; + @Override public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { if (count++ < 2) { return new FlowExecutionStatus("OK"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/InterruptibleTasklet.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/InterruptibleTasklet.java index 65be1b903..444d7f865 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/InterruptibleTasklet.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/InterruptibleTasklet.java @@ -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,14 +23,15 @@ import org.springframework.batch.repeat.RepeatStatus; * This tasklet will call * {@link NameStoringTasklet#execute(StepContribution, ChunkContext)} and then * return CONTINUABLE, so it needs to be interrupted for it to stop. - * + * * @author Dave Syer * @since 2.0 */ public class InterruptibleTasklet extends NameStoringTasklet { - + private volatile boolean started = false; + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { if (!started) { super.execute(contribution, chunkContext); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/JobRegistryJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/JobRegistryJobParserTests.java index 3df954178..5be6ae14e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/JobRegistryJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/JobRegistryJobParserTests.java @@ -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,16 +36,17 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) public class JobRegistryJobParserTests implements ApplicationContextAware { - + @Autowired private ListableJobLocator jobRegistry; private ApplicationContext applicationContext; - + + @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } - + @Test public void testOneStep() throws Exception { assertEquals(2, applicationContext.getBeanNamesForType(Job.class).length); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/NameStoringTasklet.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/NameStoringTasklet.java index fa4c52c13..63861a7a3 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/NameStoringTasklet.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/NameStoringTasklet.java @@ -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.repeat.RepeatStatus; /** * This class will store the step name when it is executed. - * + * * @author Dan Garrette * @since 2.0 */ @@ -35,10 +35,12 @@ public class NameStoringTasklet extends StepExecutionListenerSupport implements private String stepName = null; private List stepNamesList = null; + @Override public void beforeStep(StepExecution stepExecution) { stepName = stepExecution.getStepName(); } + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { if (stepNamesList != null) { stepNamesList.add(stepName); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/PartitionStepParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/PartitionStepParserTests.java index 148ae8335..04a5da4ef 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/PartitionStepParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/PartitionStepParserTests.java @@ -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,11 @@ import java.util.List; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.batch.core.*; +import org.springframework.batch.core.BatchStatus; +import org.springframework.batch.core.Job; +import org.springframework.batch.core.JobExecution; +import org.springframework.batch.core.JobParameters; +import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.partition.PartitionHandler; import org.springframework.batch.core.partition.StepExecutionSplitter; import org.springframework.batch.core.partition.support.PartitionStep; @@ -88,6 +92,7 @@ public class PartitionStepParserTests implements ApplicationContextAware { private List savedStepNames = new ArrayList(); + @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } @@ -151,7 +156,7 @@ public class PartitionStepParserTests implements ApplicationContextAware { for (StepExecution se : jobExecution.getStepExecutions()) { String stepExecutionName = se.getStepName(); // the partitioned step - if (stepExecutionName.equalsIgnoreCase("j3s1")) { + if (stepExecutionName.equalsIgnoreCase("j3s1")) { PartitionStep partitionStep = (PartitionStep) this.applicationContext.getBean(stepExecutionName); // prove that the reference in the {@link // TaskExecutorPartitionHandler} is the step configured inline @@ -186,7 +191,7 @@ public class PartitionStepParserTests implements ApplicationContextAware { for (StepExecution se : jobExecution.getStepExecutions()) { String stepExecutionName = se.getStepName(); if (stepExecutionName.equalsIgnoreCase("j4s1")) { // the partitioned - // step + // step PartitionStep partitionStep = (PartitionStep) this.applicationContext.getBean(stepExecutionName); // prove that the reference in the {@link @@ -226,21 +231,23 @@ public class PartitionStepParserTests implements ApplicationContextAware { Collections.sort(list); return list; } - + public static class CustomPartitionHandler implements PartitionHandler { + @Override public Collection handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception { return Arrays.asList(stepExecution); } - + } public static class CustomStepExecutionAggregator implements StepExecutionAggregator { + @Override public void aggregate(StepExecution result, Collection executions) { result.getJobExecution().getExecutionContext().put("foo", "bar"); } - + } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/PartitionStepWithFlowParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/PartitionStepWithFlowParserTests.java index 9a078ecfd..4252c3e14 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/PartitionStepWithFlowParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/PartitionStepWithFlowParserTests.java @@ -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. @@ -73,7 +73,7 @@ public class PartitionStepWithFlowParserTests { public void testRepeatedFlowStep() throws Exception { assertNotNull(job1); JobExecution jobExecution = jobRepository.createJobExecution(job1.getName(), new JobParametersBuilder() - .addLong("gridSize", 1L).toJobParameters()); + .addLong("gridSize", 1L).toJobParameters()); job1.execute(jobExecution); assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus()); Collections.sort(savedStepNames); @@ -95,9 +95,10 @@ public class PartitionStepWithFlowParserTests { public static class Decider implements JobExecutionDecider { int count = 0; + @Override public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { if (count++<2) { - return new FlowExecutionStatus("OK"); + return new FlowExecutionStatus("OK"); } return new FlowExecutionStatus("END"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/SplitInterruptedJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/SplitInterruptedJobParserTests.java index 3cad4b06e..c185e8ee4 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/SplitInterruptedJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/SplitInterruptedJobParserTests.java @@ -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,11 +40,12 @@ public class SplitInterruptedJobParserTests extends AbstractJobParserTests { final JobExecution jobExecution = createJobExecution(); new Thread(new Runnable() { + @Override public void run() { job.execute(jobExecution); } }).start(); - + Thread.sleep(100L); jobExecution.setStatus(BatchStatus.STOPPING); Thread.sleep(200L); @@ -53,7 +54,7 @@ public class SplitInterruptedJobParserTests extends AbstractJobParserTests { Thread.sleep(200L); } assertTrue("Timed out waiting for job to stop: "+jobExecution, count<10); - + assertEquals(BatchStatus.STOPPED, jobExecution.getStatus()); assertEquals(ExitStatus.STOPPED.getExitCode(), jobExecution.getExitStatus().getExitCode()); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StopJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StopJobParserTests.java index bcbe30528..95cc8f239 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StopJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StopJobParserTests.java @@ -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.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Dave Syer - * + * */ @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) @@ -74,6 +74,7 @@ public class StopJobParserTests extends AbstractJobParserTests { } public static class TestDecider implements JobExecutionDecider { + @Override public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { return new FlowExecutionStatus("FOO"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestCustomStatusListener.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestCustomStatusListener.java index 0564cfd81..424814218 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestCustomStatusListener.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestCustomStatusListener.java @@ -6,12 +6,14 @@ import org.springframework.batch.core.StepExecutionListener; public class TestCustomStatusListener extends AbstractTestComponent implements StepExecutionListener { + @Override public ExitStatus afterStep(StepExecution stepExecution) { return new ExitStatus("FOO").and(stepExecution.getExitStatus()); } + @Override public void beforeStep(StepExecution stepExecution) { executed = true; } - + } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestIncrementer.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestIncrementer.java index 5363f60b4..1fea100df 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestIncrementer.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestIncrementer.java @@ -5,6 +5,7 @@ import org.springframework.batch.core.JobParametersIncrementer; public class TestIncrementer implements JobParametersIncrementer{ + @Override public JobParameters getNext(JobParameters parameters) { return null; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestListener.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestListener.java index 0b9277eac..ba24f7e67 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestListener.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestListener.java @@ -7,6 +7,7 @@ import org.springframework.batch.core.annotation.AfterRead; public class TestListener extends AbstractTestComponent implements StepExecutionListener { + @Override public ExitStatus afterStep(StepExecution stepExecution) { return null; } @@ -16,13 +17,14 @@ public class TestListener extends AbstractTestComponent implements StepExecution return stepExecution.getExitStatus(); } + @Override public void beforeStep(StepExecution stepExecution) { executed = true; } - + @AfterRead public void logItem(){ - + } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestProcessor.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestProcessor.java index 61f6ba641..731ec465d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestProcessor.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestProcessor.java @@ -4,6 +4,7 @@ import org.springframework.batch.item.ItemProcessor; public class TestProcessor extends AbstractTestComponent implements ItemProcessor{ + @Override public String process(String item) throws Exception { executed = true; return item; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestReader.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestReader.java index 60c80744d..15b9d8ae6 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestReader.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestReader.java @@ -32,6 +32,7 @@ public class TestReader extends AbstractTestComponent implements ItemReader void close(RetryContext context, RetryCallback callback, Throwable throwable) { } + @Override public void onError(RetryContext context, RetryCallback callback, Throwable throwable) { } + @Override public boolean open(RetryContext context, RetryCallback callback) { executed = true; return true; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestTasklet.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestTasklet.java index 72c23c65a..3e526e515 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestTasklet.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestTasklet.java @@ -8,17 +8,18 @@ import org.springframework.batch.repeat.RepeatStatus; public class TestTasklet extends AbstractTestComponent implements Tasklet { private String name; - + + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { executed = true; - return RepeatStatus.FINISHED; - } + return RepeatStatus.FINISHED; + } public String getName() { return name; } - + public void setName(String name) { this.name = name; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestWriter.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestWriter.java index 7c13f96db..b4e1ae90d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestWriter.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestWriter.java @@ -6,6 +6,7 @@ import org.springframework.batch.item.ItemWriter; public class TestWriter extends AbstractTestComponent implements ItemWriter { + @Override public void write(List items) throws Exception { executed = true; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/MapJobExplorerIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/MapJobExplorerIntegrationTests.java index f138edead..1f0987506 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/MapJobExplorerIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/MapJobExplorerIntegrationTests.java @@ -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,6 @@ import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParametersBuilder; import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.explore.JobExplorer; -import org.springframework.batch.core.explore.support.MapJobExplorerFactoryBean; import org.springframework.batch.core.job.SimpleJob; import org.springframework.batch.core.launch.support.SimpleJobLauncher; import org.springframework.batch.core.repository.JobRepository; @@ -37,7 +36,7 @@ import org.springframework.core.task.SimpleAsyncTaskExecutor; /** * @author Dave Syer - * + * */ public class MapJobExplorerIntegrationTests { @@ -57,6 +56,7 @@ public class MapJobExplorerIntegrationTests { SimpleJob job = new SimpleJob("job"); TaskletStep step = new TaskletStep("step"); step.setTasklet(new Tasklet() { + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { while (block) { Thread.sleep(100L); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java index 9a568e042..f046a2cdb 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java @@ -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. @@ -41,13 +41,13 @@ import org.springframework.batch.core.step.StepSupport; /** * @author Dave Syer - * + * */ public class ExtendedAbstractJobTests { private AbstractJob job; private JobRepository jobRepository; - + @Before public void setUp() throws Exception { MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); @@ -118,7 +118,7 @@ public class ExtendedAbstractJobTests { assertTrue(e.getMessage().contains("JobRepository")); } } - + @Test public void testValidatorWithNotNullParameters() throws Exception { JobExecution execution = jobRepository.createJobExecution("job", new JobParameters()); @@ -147,7 +147,7 @@ public class ExtendedAbstractJobTests { */ @Test public void testHandleStep() throws Exception { - + class StubStep extends StepSupport { static final String value = "message for next steps"; @@ -158,11 +158,12 @@ public class ExtendedAbstractJobTests { setName("StubStep"); } + @Override public void execute(StepExecution stepExecution) throws JobInterruptedException { stepExecution.getJobExecution().getExecutionContext().put(key, value); } } - + MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); factory.afterPropertiesSet(); JobRepository repository = (JobRepository) factory.getObject(); @@ -185,12 +186,12 @@ public class ExtendedAbstractJobTests { /** * @author Dave Syer - * + * */ private static class StubJob extends AbstractJob { /** * @param name - * @param jobRepository + * @param jobRepository */ private StubJob(String name, JobRepository jobRepository) { super(name); @@ -217,7 +218,7 @@ public class ExtendedAbstractJobTests { public Step getStep(String stepName) { return null; } - + @Override public Collection getStepNames() { return Collections. emptySet(); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/JobSupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/JobSupport.java index 9ece5b763..f7143557f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/JobSupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/JobSupport.java @@ -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. @@ -37,7 +37,7 @@ import org.springframework.util.ClassUtils; * representing the configuration of a job specified by a developer. It should * be noted that restart policy is applied to the job as a whole and not to a * step. - * + * * @author Lucas Ward * @author Dave Syer */ @@ -63,7 +63,7 @@ public class JobSupport implements BeanNameAware, Job, StepLocator { /** * Convenience constructor to immediately add name (which is mandatory but * not final). - * + * * @param name */ public JobSupport(String name) { @@ -77,9 +77,10 @@ public class JobSupport implements BeanNameAware, Job, StepLocator { * 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 public void setBeanName(String name) { if (this.name == null) { this.name = name; @@ -89,7 +90,7 @@ public class JobSupport implements BeanNameAware, Job, StepLocator { /** * 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) { @@ -98,13 +99,14 @@ public class JobSupport implements BeanNameAware, Job, StepLocator { /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.IJob#getName() */ + @Override public String getName() { return name; } - + /** * @param jobParametersValidator the jobParametersValidator to set */ @@ -114,9 +116,9 @@ public class JobSupport implements BeanNameAware, Job, StepLocator { public void setSteps(List steps) { this.steps.clear(); - for (Step step : steps) { - this.steps.put(step.getName(), step); - } + for (Step step : steps) { + this.steps.put(step.getName(), step); + } } public void addStep(Step step) { @@ -125,7 +127,7 @@ public class JobSupport implements BeanNameAware, Job, StepLocator { /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.IJob#getStartLimit() */ public int getStartLimit() { @@ -142,51 +144,58 @@ public class JobSupport implements BeanNameAware, Job, StepLocator { /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.IJob#isRestartable() */ + @Override public boolean isRestartable() { return restartable; } - + /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.domain.Job#run(org.springframework.batch * .core.domain.JobExecution) */ + @Override public void execute(JobExecution execution) throws UnexpectedJobExecutionException { throw new UnsupportedOperationException( "JobSupport does not provide an implementation of execute(). Use a smarter subclass."); } + @Override public String toString() { return ClassUtils.getShortName(getClass()) + ": [name=" + name + "]"; } /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.Job#getJobParametersIncrementer() */ + @Override public JobParametersIncrementer getJobParametersIncrementer() { return null; } - + + @Override public JobParametersValidator getJobParametersValidator() { return jobParametersValidator; } - public Collection getStepNames() { - return steps.keySet(); - } + @Override + public Collection getStepNames() { + return steps.keySet(); + } - public Step getStep(String stepName) throws NoSuchStepException { - final Step step = steps.get(stepName); - if (step == null) { - throw new NoSuchStepException("Step ["+stepName+"] does not exist for job with name ["+getName()+"]"); - } - return step; - } + @Override + public Step getStep(String stepName) throws NoSuchStepException { + final Step step = steps.get(stepName); + if (step == null) { + throw new NoSuchStepException("Step ["+stepName+"] does not exist for job with name ["+getName()+"]"); + } + return step; + } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleJobTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleJobTests.java index e745f1c01..7dc93f4e6 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleJobTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleJobTests.java @@ -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. @@ -64,7 +64,7 @@ import org.springframework.batch.item.ExecutionContext; /** * Tests for DefaultJobLifecycle. MapJobDao and MapStepExecutionDao are used * instead of a mock repository to test that status is being stored correctly. - * + * * @author Lucas Ward */ public class SimpleJobTests { @@ -110,12 +110,14 @@ public class SimpleJobTests { step1 = new StubStep("TestStep1", jobRepository); step1.setCallback(new Runnable() { + @Override public void run() { list.add("default"); } }); step2 = new StubStep("TestStep2", jobRepository); step2.setCallback(new Runnable() { + @Override public void run() { list.add("default"); } @@ -173,18 +175,22 @@ public class SimpleJobTests { Step testStep = new Step() { + @Override public void execute(StepExecution stepExecution) throws JobInterruptedException { stepExecution.setExitStatus(customStatus); } + @Override public String getName() { return "test"; } + @Override public int getStartLimit() { return 1; } + @Override public boolean isAllowStartIfComplete() { return false; } @@ -213,10 +219,12 @@ public class SimpleJobTests { @Test public void testRunNormallyWithListener() throws Exception { job.setJobExecutionListeners(new JobExecutionListenerSupport[] { new JobExecutionListenerSupport() { + @Override public void beforeJob(JobExecution jobExecution) { list.add("before"); } + @Override public void afterJob(JobExecution jobExecution) { list.add("after"); } @@ -291,6 +299,7 @@ public class SimpleJobTests { @Test public void testFailedWithListener() throws Exception { job.setJobExecutionListeners(new JobExecutionListenerSupport[] { new JobExecutionListenerSupport() { + @Override public void afterJob(JobExecution jobExecution) { list.add("afterJob"); } @@ -478,8 +487,9 @@ public class SimpleJobTests { step1 = new StubStep("interruptStep", jobRepository) { + @Override public void execute(StepExecution stepExecution) throws JobInterruptedException, - UnexpectedJobExecutionException { + UnexpectedJobExecutionException { stepExecution.getJobExecution().stop(); super.execute(stepExecution); } @@ -570,12 +580,13 @@ public class SimpleJobTests { /* * (non-Javadoc) - * + * * @seeorg.springframework.batch.core.step.StepSupport#execute(org. * springframework.batch.core.StepExecution) */ + @Override public void execute(StepExecution stepExecution) throws JobInterruptedException, - UnexpectedJobExecutionException { + UnexpectedJobExecutionException { passedInJobContext = new ExecutionContext(stepExecution.getJobExecution().getExecutionContext()); passedInStepContext = new ExecutionContext(stepExecution.getExecutionContext()); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleStepHandlerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleStepHandlerTests.java index f051544fe..2764c69a9 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleStepHandlerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleStepHandlerTests.java @@ -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,7 +32,7 @@ import org.springframework.batch.core.step.StepSupport; /** * @author Dave Syer - * + * */ public class SimpleStepHandlerTests { @@ -77,6 +77,7 @@ public class SimpleStepHandlerTests { super(name); } + @Override public void execute(StepExecution stepExecution) throws JobInterruptedException { stepExecution.setStatus(BatchStatus.COMPLETED); stepExecution.setExitStatus(ExitStatus.COMPLETED); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/builder/FlowJobBuilderTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/builder/FlowJobBuilderTests.java index 7462d1095..daead9e30 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/builder/FlowJobBuilderTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/builder/FlowJobBuilderTests.java @@ -48,7 +48,7 @@ public class FlowJobBuilderTests { private StepSupport step1 = new StepSupport("step1") { @Override public void execute(StepExecution stepExecution) throws JobInterruptedException, - UnexpectedJobExecutionException { + UnexpectedJobExecutionException { stepExecution.upgradeStatus(BatchStatus.COMPLETED); stepExecution.setExitStatus(ExitStatus.COMPLETED); jobRepository.update(stepExecution); @@ -58,7 +58,7 @@ public class FlowJobBuilderTests { private StepSupport fails = new StepSupport("fails") { @Override public void execute(StepExecution stepExecution) throws JobInterruptedException, - UnexpectedJobExecutionException { + UnexpectedJobExecutionException { stepExecution.upgradeStatus(BatchStatus.FAILED); stepExecution.setExitStatus(ExitStatus.FAILED); jobRepository.update(stepExecution); @@ -68,7 +68,7 @@ public class FlowJobBuilderTests { private StepSupport step2 = new StepSupport("step2") { @Override public void execute(StepExecution stepExecution) throws JobInterruptedException, - UnexpectedJobExecutionException { + UnexpectedJobExecutionException { stepExecution.upgradeStatus(BatchStatus.COMPLETED); stepExecution.setExitStatus(ExitStatus.COMPLETED); jobRepository.update(stepExecution); @@ -78,7 +78,7 @@ public class FlowJobBuilderTests { private StepSupport step3 = new StepSupport("step3") { @Override public void execute(StepExecution stepExecution) throws JobInterruptedException, - UnexpectedJobExecutionException { + UnexpectedJobExecutionException { stepExecution.upgradeStatus(BatchStatus.COMPLETED); stepExecution.setExitStatus(ExitStatus.COMPLETED); jobRepository.update(stepExecution); @@ -143,6 +143,7 @@ public class FlowJobBuilderTests { public void testBuildDecision() throws Exception { JobExecutionDecider decider = new JobExecutionDecider() { private int count = 0; + @Override public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { count++; return count<2 ? new FlowExecutionStatus("ONGOING") : FlowExecutionStatus.COMPLETED; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowJobTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowJobTests.java index 73d5aa402..e9a09856a 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowJobTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowJobTests.java @@ -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. @@ -49,7 +49,7 @@ import org.springframework.batch.core.step.StepSupport; /** * @author Dave Syer - * + * */ public class FlowJobTests { @@ -361,7 +361,7 @@ public class FlowJobTests { List transitions = new ArrayList(); transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step1")), "end")); transitions - .add(StateTransition.createStateTransition(new EndState(FlowExecutionStatus.FAILED, "end"), "step2")); + .add(StateTransition.createStateTransition(new EndState(FlowExecutionStatus.FAILED, "end"), "step2")); transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step2")), ExitStatus.FAILED .getExitCode(), "end0")); transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step2")), @@ -450,6 +450,7 @@ public class FlowJobTests { SimpleFlow flow = new SimpleFlow("job"); JobExecutionDecider decider = new JobExecutionDecider() { + @Override public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { assertNotNull(stepExecution); return new FlowExecutionStatus("SWITCH"); @@ -490,6 +491,7 @@ public class FlowJobTests { SimpleFlow flow = new SimpleFlow("job"); JobExecutionDecider decider = new JobExecutionDecider() { + @Override public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { assertNotNull(stepExecution); throw new RuntimeException("Foo"); @@ -667,7 +669,7 @@ public class FlowJobTests { /** /** * @author Dave Syer - * + * */ private class StubStep extends StepSupport { @@ -675,6 +677,7 @@ public class FlowJobTests { super(name); } + @Override public void execute(StepExecution stepExecution) throws JobInterruptedException { stepExecution.setStatus(BatchStatus.COMPLETED); stepExecution.setExitStatus(ExitStatus.COMPLETED); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowStepTests.java index e1f903947..a4c084114 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowStepTests.java @@ -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. @@ -43,7 +43,7 @@ import org.springframework.batch.core.step.StepSupport; * */ public class FlowStepTests { - + private JobRepository jobRepository; private JobExecution jobExecution; @@ -164,7 +164,7 @@ public class FlowStepTests { /** * @author Dave Syer - * + * */ private class StubStep extends StepSupport { @@ -179,6 +179,7 @@ public class FlowStepTests { this.fail = fail; } + @Override public void execute(StepExecution stepExecution) throws JobInterruptedException { BatchStatus status = BatchStatus.COMPLETED; ExitStatus exitStatus = ExitStatus.COMPLETED; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/StateSupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/StateSupport.java index 7727bed7b..317cf0d90 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/StateSupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/StateSupport.java @@ -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,14 +20,14 @@ import org.springframework.batch.core.job.flow.support.state.AbstractState; /** * Base class for {@link State} implementations in test cases. - * + * * @author Dave Syer * */ public class StateSupport extends AbstractState { private FlowExecutionStatus status; - + public StateSupport(String name) { this(name, FlowExecutionStatus.COMPLETED); } @@ -45,7 +45,8 @@ public class StateSupport extends AbstractState { } return this.status; } - + + @Override public boolean isEndState() { return false; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/support/JobFlowExecutorSupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/support/JobFlowExecutorSupport.java index 24658b2c7..c4be052e0 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/support/JobFlowExecutorSupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/support/JobFlowExecutorSupport.java @@ -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,36 +28,44 @@ import org.springframework.batch.core.repository.JobRestartException; /** * @author Dave Syer - * + * */ public class JobFlowExecutorSupport implements FlowExecutor { + @Override public String executeStep(Step step) throws JobInterruptedException, JobRestartException, - StartLimitExceededException { + StartLimitExceededException { return ExitStatus.COMPLETED.getExitCode(); } + @Override public JobExecution getJobExecution() { return null; } + @Override public StepExecution getStepExecution() { return null; } + @Override public void close(FlowExecution result) { } + @Override public void abandonStepExecution() { } - - public void updateJobExecutionStatus(FlowExecutionStatus status) { + + @Override + public void updateJobExecutionStatus(FlowExecutionStatus status) { } - + + @Override public boolean isRestart() { return false; } - + + @Override public void addExitStatus(String code) { } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/EmptyItemWriter.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/EmptyItemWriter.java index 7767681b3..3a49d2a60 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/EmptyItemWriter.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/EmptyItemWriter.java @@ -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,6 +39,7 @@ public class EmptyItemWriter implements ItemWriter, InitializingBean { List list; + @Override public void afterPropertiesSet() throws Exception { list = TransactionAwareProxyFactory.createTransactionalList(); } @@ -47,6 +48,7 @@ public class EmptyItemWriter implements ItemWriter, InitializingBean { this.failurePoint = failurePoint; } + @Override public void write(List items) { for (T data : items) { if (!failed && list.size() == failurePoint) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobExecutionNotFailedExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobExecutionNotFailedExceptionTests.java index a10abca34..7de6f10de 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobExecutionNotFailedExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobExecutionNotFailedExceptionTests.java @@ -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,6 +26,7 @@ public class JobExecutionNotFailedExceptionTests extends AbstractExceptionTests /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ + @Override public Exception getException(String msg) throws Exception { return new JobExecutionNotFailedException(msg); } @@ -33,6 +34,7 @@ public class JobExecutionNotFailedExceptionTests extends AbstractExceptionTests /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable) */ + @Override public Exception getException(String msg, Throwable t) throws Exception { return new JobExecutionNotFailedException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobInstanceAlreadyExistsExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobInstanceAlreadyExistsExceptionTests.java index c41fb89e4..3921e4d89 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobInstanceAlreadyExistsExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobInstanceAlreadyExistsExceptionTests.java @@ -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. @@ -16,7 +16,6 @@ package org.springframework.batch.core.launch; import org.springframework.batch.core.AbstractExceptionTests; -import org.springframework.batch.core.launch.JobInstanceAlreadyExistsException; /** * @author Dave Syer @@ -27,6 +26,7 @@ public class JobInstanceAlreadyExistsExceptionTests extends AbstractExceptionTes /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ + @Override public Exception getException(String msg) throws Exception { return new JobInstanceAlreadyExistsException(msg); } @@ -34,6 +34,7 @@ public class JobInstanceAlreadyExistsExceptionTests extends AbstractExceptionTes /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable) */ + @Override public Exception getException(String msg, Throwable t) throws Exception { return new JobInstanceAlreadyExistsException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobParametersNotFoundExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobParametersNotFoundExceptionTests.java index d6968f204..003e33e0b 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobParametersNotFoundExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobParametersNotFoundExceptionTests.java @@ -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,6 +26,7 @@ public class JobParametersNotFoundExceptionTests extends AbstractExceptionTests /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ + @Override public Exception getException(String msg) throws Exception { return new JobParametersNotFoundException(msg); } @@ -33,6 +34,7 @@ public class JobParametersNotFoundExceptionTests extends AbstractExceptionTests /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable) */ + @Override public Exception getException(String msg, Throwable t) throws Exception { return new JobParametersNotFoundException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/NoSuchJobExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/NoSuchJobExceptionTests.java index e0c0cb947..3ad7fec12 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/NoSuchJobExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/NoSuchJobExceptionTests.java @@ -28,6 +28,7 @@ public class NoSuchJobExceptionTests extends AbstractExceptionTests { * (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ + @Override public Exception getException(String msg) throws Exception { return new NoSuchJobException(msg); } @@ -37,6 +38,7 @@ public class NoSuchJobExceptionTests extends AbstractExceptionTests { * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, * java.lang.Throwable) */ + @Override public Exception getException(String msg, Throwable t) throws Exception { return new NoSuchJobException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/NoSuchJobExecutionExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/NoSuchJobExecutionExceptionTests.java index 13d4632eb..46fdab4d2 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/NoSuchJobExecutionExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/NoSuchJobExecutionExceptionTests.java @@ -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. @@ -16,7 +16,6 @@ package org.springframework.batch.core.launch; import org.springframework.batch.core.AbstractExceptionTests; -import org.springframework.batch.core.launch.NoSuchJobExecutionException; /** * @author Dave Syer @@ -27,6 +26,7 @@ public class NoSuchJobExecutionExceptionTests extends AbstractExceptionTests { /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ + @Override public Exception getException(String msg) throws Exception { return new NoSuchJobExecutionException(msg); } @@ -34,6 +34,7 @@ public class NoSuchJobExecutionExceptionTests extends AbstractExceptionTests { /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable) */ + @Override public Exception getException(String msg, Throwable t) throws Exception { return new NoSuchJobExecutionException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/NoSuchJobInstanceExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/NoSuchJobInstanceExceptionTests.java index 708fa313d..1a1a4e300 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/NoSuchJobInstanceExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/NoSuchJobInstanceExceptionTests.java @@ -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. @@ -16,7 +16,6 @@ package org.springframework.batch.core.launch; import org.springframework.batch.core.AbstractExceptionTests; -import org.springframework.batch.core.launch.NoSuchJobInstanceException; /** * @author Dave Syer @@ -27,6 +26,7 @@ public class NoSuchJobInstanceExceptionTests extends AbstractExceptionTests { /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ + @Override public Exception getException(String msg) throws Exception { return new NoSuchJobInstanceException(msg); } @@ -34,6 +34,7 @@ public class NoSuchJobInstanceExceptionTests extends AbstractExceptionTests { /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable) */ + @Override public Exception getException(String msg, Throwable t) throws Exception { return new NoSuchJobInstanceException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/SimpleJobLauncherTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/SimpleJobLauncherTests.java index 5e001042b..d53681e01 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/SimpleJobLauncherTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/SimpleJobLauncherTests.java @@ -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. @@ -47,7 +47,7 @@ import org.springframework.core.task.TaskRejectedException; /** * @author Lucas Ward - * + * */ public class SimpleJobLauncherTests { @@ -162,6 +162,7 @@ public class SimpleJobLauncherTests { public void testTaskExecutor() throws Exception { final List list = new ArrayList(); jobLauncher.setTaskExecutor(new TaskExecutor() { + @Override public void execute(Runnable task) { list.add("execute"); task.run(); @@ -176,6 +177,7 @@ public class SimpleJobLauncherTests { final List list = new ArrayList(); jobLauncher.setTaskExecutor(new TaskExecutor() { + @Override public void execute(Runnable task) { list.add("execute"); throw new TaskRejectedException("Planned failure"); @@ -207,6 +209,7 @@ public class SimpleJobLauncherTests { @Test public void testRunWithException() throws Exception { job = new JobSupport() { + @Override public void execute(JobExecution execution) { execution.setExitStatus(ExitStatus.FAILED); throw new RuntimeException("foo"); @@ -224,6 +227,7 @@ public class SimpleJobLauncherTests { @Test public void testRunWithError() throws Exception { job = new JobSupport() { + @Override public void execute(JobExecution execution) { execution.setExitStatus(ExitStatus.FAILED); throw new Error("foo"); @@ -278,4 +282,4 @@ public class SimpleJobLauncherTests { private boolean contains(String str, String searchStr) { return str.indexOf(searchStr) != -1; } -} \ No newline at end of file +} diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java index 88c6a451a..f9f328054 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java @@ -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. @@ -48,7 +48,7 @@ import org.springframework.util.ClassUtils; /** * @author Lucas Ward - * + * */ public class CommandLineJobRunnerTests { @@ -75,6 +75,7 @@ public class CommandLineJobRunnerTests { StubJobLauncher.jobExecution = jobExecution; stdin = System.in; System.setIn(new InputStream() { + @Override public int read() { return -1; } @@ -140,10 +141,12 @@ public class CommandLineJobRunnerTests { @Test public void testWithInvalidStdin() throws Throwable { System.setIn(new InputStream() { - public int available() throws IOException { - throw new IOException("Planned"); - } + @Override + public int available() throws IOException { + throw new IOException("Planned"); + } + @Override public int read() { return -1; } @@ -160,10 +163,12 @@ public class CommandLineJobRunnerTests { int index = 0; - public int available() { - return input.length - index; - } + @Override + public int available() { + return input.length - index; + } + @Override public int read() { return index findRunningJobExecutions(String jobName) { throw new UnsupportedOperationException(); } + @Override public JobExecution getJobExecution(Long executionId) { if (jobExecution != null) { return jobExecution; @@ -418,6 +429,7 @@ public class CommandLineJobRunnerTests { throw new UnsupportedOperationException(); } + @Override public List getJobExecutions(JobInstance jobInstance) { if (jobInstance.getId() == 0) { return Arrays.asList(createJobExecution(jobInstance, BatchStatus.FAILED)); @@ -451,10 +463,12 @@ public class CommandLineJobRunnerTests { return jobExecution; } + @Override public JobInstance getJobInstance(Long instanceId) { throw new UnsupportedOperationException(); } + @Override public List getJobInstances(String jobName, int start, int count) { if (jobInstances == null) { return new ArrayList(); @@ -464,10 +478,12 @@ public class CommandLineJobRunnerTests { return result; } + @Override public StepExecution getStepExecution(Long jobExecutionId, Long stepExecutionId) { throw new UnsupportedOperationException(); } + @Override public List getJobNames() { throw new UnsupportedOperationException(); } @@ -480,11 +496,13 @@ public class CommandLineJobRunnerTests { static boolean called = false; + @Override public JobParameters getJobParameters(Properties properties) { called = true; return delegate.getJobParameters(properties); } + @Override public Properties getProperties(JobParameters params) { throw new UnsupportedOperationException(); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/ScheduledJobParametersFactoryTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/ScheduledJobParametersFactoryTests.java index 08a8b9015..32521bd16 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/ScheduledJobParametersFactoryTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/ScheduledJobParametersFactoryTests.java @@ -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. @@ -24,12 +24,11 @@ import junit.framework.TestCase; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.JobParametersBuilder; -import org.springframework.batch.core.launch.support.ScheduledJobParametersFactory; import org.springframework.util.StringUtils; /** * @author Lucas Ward - * + * */ public class ScheduledJobParametersFactoryTests extends TestCase { @@ -37,6 +36,7 @@ public class ScheduledJobParametersFactoryTests extends TestCase { DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); + @Override protected void setUp() throws Exception { super.setUp(); @@ -62,7 +62,7 @@ public class ScheduledJobParametersFactoryTests extends TestCase { public void testGetProperties() throws Exception { JobParameters parameters = new JobParametersBuilder().addDate("schedule.date", dateFormat.parse("01/23/2008")) - .addString("job.key", "myKey").addString("vendor.id", "33243243").toJobParameters(); + .addString("job.key", "myKey").addString("vendor.id", "33243243").toJobParameters(); Properties props = factory.getProperties(parameters); assertNotNull(props); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJobOperatorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJobOperatorTests.java index 03d7b0d8f..114e87d24 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJobOperatorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJobOperatorTests.java @@ -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,7 +58,7 @@ import org.springframework.batch.support.PropertiesConverter; /** * @author Dave Syer - * + * */ public class SimpleJobOperatorTests { @@ -67,14 +67,14 @@ public class SimpleJobOperatorTests { protected Job job; private JobExplorer jobExplorer; - + private JobRepository jobRepository; private JobParameters jobParameters; /** * @throws Exception - * + * */ @Before public void setUp() throws Exception { @@ -83,6 +83,7 @@ public class SimpleJobOperatorTests { @Override public JobParametersIncrementer getJobParametersIncrementer() { return new JobParametersIncrementer() { + @Override public JobParameters getNext(JobParameters parameters) { return jobParameters; } @@ -93,6 +94,7 @@ public class SimpleJobOperatorTests { jobOperator = new SimpleJobOperator(); jobOperator.setJobRegistry(new MapJobRegistry() { + @Override public Job getJob(String name) throws NoSuchJobException { if (name.equals("foo")) { return job; @@ -100,6 +102,7 @@ public class SimpleJobOperatorTests { throw new NoSuchJobException("foo"); } + @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public Set getJobNames() { return new HashSet(Arrays.asList(new String[] { "foo", "bar" })); @@ -107,8 +110,9 @@ public class SimpleJobOperatorTests { }); jobOperator.setJobLauncher(new JobLauncher() { + @Override public JobExecution run(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException, - JobRestartException, JobInstanceAlreadyCompleteException { + JobRestartException, JobInstanceAlreadyCompleteException { return new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 999L); } }); @@ -116,7 +120,7 @@ public class SimpleJobOperatorTests { jobExplorer = EasyMock.createNiceMock(JobExplorer.class); jobOperator.setJobExplorer(jobExplorer); - + jobRepository = createMock(JobRepository.class); jobOperator.setJobRepository(jobRepository); @@ -198,7 +202,7 @@ public class SimpleJobOperatorTests { jobParameters = new JobParameters(); jobExplorer.getJobExecution(111L); EasyMock.expectLastCall() - .andReturn(new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 111L)); + .andReturn(new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 111L)); EasyMock.replay(jobExplorer); Long value = jobOperator.restart(111L); assertEquals(999, value.longValue()); @@ -294,7 +298,7 @@ public class SimpleJobOperatorTests { final JobParameters jobParameters = new JobParameters(); jobExplorer.getJobExecution(111L); EasyMock.expectLastCall() - .andReturn(new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 111L)); + .andReturn(new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 111L)); EasyMock.replay(jobExplorer); String value = jobOperator.getParameters(111L); assertEquals("a=b", value); @@ -378,7 +382,7 @@ public class SimpleJobOperatorTests { } EasyMock.verify(jobExplorer); } - + @Test public void testStop() throws Exception{ JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName()); @@ -394,29 +398,29 @@ public class SimpleJobOperatorTests { assertEquals(BatchStatus.STOPPING, jobExecution.getStatus()); } - @Test - public void testAbort() throws Exception { - JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName()); - JobExecution jobExecution = new JobExecution(jobInstance, 111L); - jobExecution.setStatus(BatchStatus.STOPPING); - jobExplorer.getJobExecution(123L); - expectLastCall().andReturn(jobExecution); - jobRepository.update(jobExecution); - replay(jobExplorer); - jobOperator.abandon(123L); - assertEquals(BatchStatus.ABANDONED, jobExecution.getStatus()); - assertNotNull(jobExecution.getEndTime()); - } + @Test + public void testAbort() throws Exception { + JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName()); + JobExecution jobExecution = new JobExecution(jobInstance, 111L); + jobExecution.setStatus(BatchStatus.STOPPING); + jobExplorer.getJobExecution(123L); + expectLastCall().andReturn(jobExecution); + jobRepository.update(jobExecution); + replay(jobExplorer); + jobOperator.abandon(123L); + assertEquals(BatchStatus.ABANDONED, jobExecution.getStatus()); + assertNotNull(jobExecution.getEndTime()); + } - @Test(expected = JobExecutionAlreadyRunningException.class) - public void testAbortNonStopping() throws Exception { - JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName()); - JobExecution jobExecution = new JobExecution(jobInstance, 111L); - jobExecution.setStatus(BatchStatus.STARTED); - jobExplorer.getJobExecution(123L); - expectLastCall().andReturn(jobExecution); - jobRepository.update(jobExecution); - replay(jobExplorer); - jobOperator.abandon(123L); - } + @Test(expected = JobExecutionAlreadyRunningException.class) + public void testAbortNonStopping() throws Exception { + JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName()); + JobExecution jobExecution = new JobExecution(jobInstance, 111L); + jobExecution.setStatus(BatchStatus.STARTED); + jobExplorer.getJobExecution(123L); + expectLastCall().andReturn(jobExecution); + jobRepository.update(jobExecution); + replay(jobExplorer); + jobOperator.abandon(123L); + } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapperTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapperTests.java index e65da7884..0546cbd98 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapperTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapperTests.java @@ -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,20 +22,19 @@ import java.util.Map; import junit.framework.TestCase; import org.springframework.batch.core.ExitStatus; -import org.springframework.batch.core.launch.support.ExitCodeMapper; -import org.springframework.batch.core.launch.support.SimpleJvmExitCodeMapper; public class SimpleJvmExitCodeMapperTests extends TestCase { private SimpleJvmExitCodeMapper ecm; private SimpleJvmExitCodeMapper ecm2; - + + @Override protected void setUp() throws Exception { ecm = new SimpleJvmExitCodeMapper(); Map ecmMap = new HashMap(); ecmMap.put("MY_CUSTOM_CODE", new Integer(3)); ecm.setMapping(ecmMap); - + ecm2 = new SimpleJvmExitCodeMapper(); Map ecm2Map = new HashMap(); ecm2Map.put(ExitStatus.COMPLETED.getExitCode(), new Integer(-1)); @@ -45,6 +44,7 @@ public class SimpleJvmExitCodeMapperTests extends TestCase { ecm2.setMapping(ecm2Map); } + @Override protected void tearDown() throws Exception { super.tearDown(); } @@ -58,12 +58,12 @@ public class SimpleJvmExitCodeMapperTests extends TestCase { ExitCodeMapper.JVM_EXITCODE_GENERIC_ERROR); assertEquals( ecm.intValue(ExitCodeMapper.JOB_NOT_PROVIDED), - ExitCodeMapper.JVM_EXITCODE_JOB_ERROR); + ExitCodeMapper.JVM_EXITCODE_JOB_ERROR); assertEquals( ecm.intValue(ExitCodeMapper.NO_SUCH_JOB), - ExitCodeMapper.JVM_EXITCODE_JOB_ERROR); + ExitCodeMapper.JVM_EXITCODE_JOB_ERROR); } - + public void testGetExitCodeWithPredefinedCodesOverridden() { System.out.println(ecm2.intValue(ExitStatus.COMPLETED.getExitCode())); assertEquals( @@ -71,20 +71,20 @@ public class SimpleJvmExitCodeMapperTests extends TestCase { assertEquals( ecm2.intValue(ExitStatus.FAILED.getExitCode()), -2); assertEquals( - ecm2.intValue(ExitCodeMapper.JOB_NOT_PROVIDED), -3); + ecm2.intValue(ExitCodeMapper.JOB_NOT_PROVIDED), -3); assertEquals( - ecm2.intValue(ExitCodeMapper.NO_SUCH_JOB), -3); + ecm2.intValue(ExitCodeMapper.NO_SUCH_JOB), -3); } public void testGetExitCodeWithCustomCode() { - assertEquals(ecm.intValue("MY_CUSTOM_CODE"),3); + assertEquals(ecm.intValue("MY_CUSTOM_CODE"),3); } public void testGetExitCodeWithDefaultCode() { assertEquals( ecm.intValue("UNDEFINED_CUSTOM_CODE"), - ExitCodeMapper.JVM_EXITCODE_GENERIC_ERROR); + ExitCodeMapper.JVM_EXITCODE_GENERIC_ERROR); } - - + + } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/StubJobLauncher.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/StubJobLauncher.java index eb537ebbb..a28fa153f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/StubJobLauncher.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/StubJobLauncher.java @@ -30,6 +30,7 @@ public class StubJobLauncher implements JobLauncher { return isRunning; } + @Override public JobExecution run(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException { lastRunCalled = RUN_JOB_IDENTIFIER; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/TestJobParametersIncrementer.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/TestJobParametersIncrementer.java index aadef74b6..bde47fef7 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/TestJobParametersIncrementer.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/TestJobParametersIncrementer.java @@ -6,6 +6,7 @@ import org.springframework.batch.core.JobParametersIncrementer; public class TestJobParametersIncrementer implements JobParametersIncrementer { + @Override public JobParameters getNext(JobParameters parameters) { return new JobParametersBuilder().addString("foo", "spam").toJobParameters(); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeJobExecutionListenerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeJobExecutionListenerTests.java index 307ecca96..98aa545ce 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeJobExecutionListenerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeJobExecutionListenerTests.java @@ -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.JobInstance; /** * @author Dave Syer - * + * */ public class CompositeJobExecutionListenerTests extends TestCase { @@ -40,10 +40,12 @@ public class CompositeJobExecutionListenerTests extends TestCase { */ public void testSetListeners() { listener.setListeners(Arrays.asList(new JobExecutionListenerSupport() { + @Override public void afterJob(JobExecution jobExecution) { list.add("fail"); } }, new JobExecutionListenerSupport() { + @Override public void afterJob(JobExecution jobExecution) { list.add("continue"); } @@ -59,6 +61,7 @@ public class CompositeJobExecutionListenerTests extends TestCase { */ public void testSetListener() { listener.register(new JobExecutionListenerSupport() { + @Override public void afterJob(JobExecution jobExecution) { list.add("fail"); } @@ -74,6 +77,7 @@ public class CompositeJobExecutionListenerTests extends TestCase { */ public void testOpen() { listener.register(new JobExecutionListenerSupport() { + @Override public void beforeJob(JobExecution stepExecution) { list.add("foo"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeStepExecutionListenerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeStepExecutionListenerTests.java index a6308c6cb..723d85bc3 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeStepExecutionListenerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeStepExecutionListenerTests.java @@ -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.StepExecutionListener; /** * @author Dave Syer - * + * */ public class CompositeStepExecutionListenerTests extends TestCase { @@ -41,11 +41,13 @@ public class CompositeStepExecutionListenerTests extends TestCase { */ public void testSetListeners() { listener.setListeners(new StepExecutionListener[] { new StepExecutionListenerSupport() { + @Override public ExitStatus afterStep(StepExecution stepExecution) { list.add("fail"); return ExitStatus.FAILED; } }, new StepExecutionListenerSupport() { + @Override public ExitStatus afterStep(StepExecution stepExecution) { list.add("continue"); return ExitStatus.EXECUTING; @@ -62,6 +64,7 @@ public class CompositeStepExecutionListenerTests extends TestCase { */ public void testSetListener() { listener.register(new StepExecutionListenerSupport() { + @Override public ExitStatus afterStep(StepExecution stepExecution) { list.add("fail"); return ExitStatus.FAILED; @@ -78,6 +81,7 @@ public class CompositeStepExecutionListenerTests extends TestCase { */ public void testOpen() { listener.register(new StepExecutionListenerSupport() { + @Override public void beforeStep(StepExecution stepExecution) { list.add("foo"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/JobListenerFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/JobListenerFactoryBeanTests.java index 6012e4426..d6323ac62 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/JobListenerFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/JobListenerFactoryBeanTests.java @@ -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. @@ -36,7 +36,7 @@ import org.springframework.core.Ordered; /** * @author Lucas Ward - * + * */ public class JobListenerFactoryBeanTests { @@ -105,7 +105,6 @@ public class JobListenerFactoryBeanTests { @Test public void testAnnotationsIsListener() throws Exception { assertTrue(JobListenerFactoryBean.isListener(new Object() { - @SuppressWarnings("unused") @BeforeJob public void foo(JobExecution execution) { } @@ -120,11 +119,11 @@ public class JobListenerFactoryBeanTests { @Test public void testAnnotationsWithOrdered() throws Exception { Object delegate = new Ordered() { - @SuppressWarnings("unused") @BeforeJob public void foo(JobExecution execution) { } + @Override public int getOrder() { return 3; } @@ -145,7 +144,6 @@ public class JobListenerFactoryBeanTests { @Test public void testEmptySignatureAnnotation() { AbstractTestComponent delegate = new AbstractTestComponent() { - @SuppressWarnings("unused") @AfterJob public void aMethod() { executed = true; @@ -160,7 +158,6 @@ public class JobListenerFactoryBeanTests { @Test public void testRightSignatureAnnotation() { AbstractTestComponent delegate = new AbstractTestComponent() { - @SuppressWarnings("unused") @AfterJob public void aMethod(JobExecution jobExecution) { executed = true; @@ -176,7 +173,6 @@ public class JobListenerFactoryBeanTests { @Test(expected = IllegalArgumentException.class) public void testWrongSignatureAnnotation() { AbstractTestComponent delegate = new AbstractTestComponent() { - @SuppressWarnings("unused") @AfterJob public void aMethod(Integer item) { executed = true; @@ -242,17 +238,18 @@ public class JobListenerFactoryBeanTests { boolean afterJobCalled = false; + @Override public void afterJob(JobExecution jobExecution) { afterJobCalled = true; } + @Override public void beforeJob(JobExecution jobExecution) { beforeJobCalled = true; } } - @SuppressWarnings("unused") private class AnnotatedTestClass { boolean beforeJobCalled = false; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/OrderedCompositeTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/OrderedCompositeTests.java index 705a8cfe9..99ef203ee 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/OrderedCompositeTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/OrderedCompositeTests.java @@ -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.core.annotation.Order; /** * @author Dave Syer - * + * */ public class OrderedCompositeTests { @@ -62,6 +62,7 @@ public class OrderedCompositeTests { public void testAddOrdered() { list.setItems(Arrays.asList((Object) "1")); list.add(new Ordered() { + @Override public int getOrder() { return 0; } @@ -75,11 +76,13 @@ public class OrderedCompositeTests { public void testAddMultipleOrdered() { list.setItems(Arrays.asList((Object) "1")); list.add(new Ordered() { + @Override public int getOrder() { return 1; } }); list.add(new Ordered() { + @Override public int getOrder() { return 0; } @@ -94,11 +97,13 @@ public class OrderedCompositeTests { public void testAddDuplicateOrdered() { list.setItems(Arrays.asList((Object) "1")); list.add(new Ordered() { + @Override public int getOrder() { return 1; } }); list.add(new Ordered() { + @Override public int getOrder() { return 1; } @@ -112,6 +117,7 @@ public class OrderedCompositeTests { @Test public void testAddAnnotationOrdered() { list.add(new Ordered() { + @Override public int getOrder() { return 1; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerFactoryBeanTests.java index a39e38df1..3288289ef 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerFactoryBeanTests.java @@ -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. @@ -63,7 +63,7 @@ import org.springframework.util.Assert; /** * @author Lucas Ward - * + * */ public class StepListenerFactoryBeanTests { @@ -186,11 +186,11 @@ public class StepListenerFactoryBeanTests { @Test public void testAnnotationsWithOrdered() throws Exception { Object delegate = new Ordered() { - @SuppressWarnings("unused") @BeforeStep public void foo(StepExecution execution) { } + @Override public int getOrder() { return 3; } @@ -203,11 +203,11 @@ public class StepListenerFactoryBeanTests { @Test public void testProxiedAnnotationsFactoryMethod() throws Exception { Object delegate = new InitializingBean() { - @SuppressWarnings("unused") @BeforeStep public void foo(StepExecution execution) { } + @Override public void afterPropertiesSet() throws Exception { } }; @@ -224,7 +224,6 @@ public class StepListenerFactoryBeanTests { @Test public void testAnnotationsIsListener() throws Exception { assertTrue(StepListenerFactoryBean.isListener(new Object() { - @SuppressWarnings("unused") @BeforeStep public void foo(StepExecution execution) { } @@ -236,6 +235,7 @@ public class StepListenerFactoryBeanTests { ProxyFactory factory = new ProxyFactory(); factory.addInterface(DataSource.class); factory.addAdvice(new MethodInterceptor() { + @Override public Object invoke(MethodInvocation invocation) throws Throwable { return null; } @@ -247,11 +247,11 @@ public class StepListenerFactoryBeanTests { @Test public void testProxiedAnnotationsIsListener() throws Exception { Object delegate = new InitializingBean() { - @SuppressWarnings("unused") @BeforeStep public void foo(StepExecution execution) { } + @Override public void afterPropertiesSet() throws Exception { } }; @@ -276,7 +276,6 @@ public class StepListenerFactoryBeanTests { @Test public void testEmptySignatureAnnotation() { AbstractTestComponent delegate = new AbstractTestComponent() { - @SuppressWarnings("unused") @AfterWrite public void aMethod() { executed = true; @@ -292,7 +291,6 @@ public class StepListenerFactoryBeanTests { @Test public void testRightSignatureAnnotation() { AbstractTestComponent delegate = new AbstractTestComponent() { - @SuppressWarnings("unused") @AfterWrite public void aMethod(List items) { executed = true; @@ -310,7 +308,6 @@ public class StepListenerFactoryBeanTests { @Test(expected = IllegalArgumentException.class) public void testWrongSignatureAnnotation() { AbstractTestComponent delegate = new AbstractTestComponent() { - @SuppressWarnings("unused") @AfterWrite public void aMethod(Integer item) { executed = true; @@ -377,6 +374,7 @@ public class StepListenerFactoryBeanTests { int callcount = 0; + @Override @AfterStep public ExitStatus afterStep(StepExecution stepExecution) { Assert.notNull(stepExecution); @@ -384,6 +382,7 @@ public class StepListenerFactoryBeanTests { return null; } + @Override public void beforeStep(StepExecution stepExecution) { callcount++; } @@ -395,12 +394,14 @@ public class StepListenerFactoryBeanTests { int callcount = 0; + @Override public ExitStatus afterStep(StepExecution stepExecution) { Assert.notNull(stepExecution); callcount++; return null; } + @Override public void beforeStep(StepExecution stepExecution) { callcount++; } @@ -515,14 +516,17 @@ public class StepListenerFactoryBeanTests { onWriteErrorCalled = true; } + @Override public void onSkipInProcess(String item, Throwable t) { onSkipInProcessCalled = true; } + @Override public void onSkipInRead(Throwable t) { onSkipInReadCalled = true; } + @Override public void onSkipInWrite(Integer item, Throwable t) { onSkipInWriteCalled = true; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerMethodInterceptorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerMethodInterceptorTests.java index e706ab63d..297c9cea0 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerMethodInterceptorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerMethodInterceptorTests.java @@ -21,15 +21,15 @@ public class StepListenerMethodInterceptorTests { MethodInvokerMethodInterceptor interceptor; TestClass testClass; - + @Before public void setUp(){ testClass = new TestClass(); } - + @Test public void testNormalCase() throws Throwable{ - + Map> invokerMap = new HashMap>(); for(Method method : TestClass.class.getMethods()){ invokerMap.put(method.getName(), asSet( new SimpleMethodInvoker(testClass, method))); @@ -40,10 +40,10 @@ public class StepListenerMethodInterceptorTests { interceptor.invoke(new StubMethodInvocation(TestClass.class.getMethod("method2"))); assertEquals(1, testClass.method2Count); } - + @Test public void testMultipleInvokersPerName() throws Throwable{ - + Map> invokerMap = new HashMap>(); Set invokers = asSet(MethodInvokerUtils.getMethodInvokerByName(testClass, "method1", false)); invokers.add(MethodInvokerUtils.getMethodInvokerByName(testClass, "method2", false)); @@ -54,7 +54,7 @@ public class StepListenerMethodInterceptorTests { interceptor.invoke(new StubMethodInvocation(TestClass.class.getMethod("method2"))); assertEquals(1, testClass.method2Count); } - + @Test public void testExitStatusReturn() throws Throwable{ Map> invokerMap = new HashMap>(); @@ -64,64 +64,69 @@ public class StepListenerMethodInterceptorTests { interceptor = new MethodInvokerMethodInterceptor(invokerMap); assertEquals(ExitStatus.COMPLETED, interceptor.invoke(new StubMethodInvocation(TestClass.class.getMethod("method3")))); } - + public Set asSet(MethodInvoker methodInvoker){ Set invokerSet = new HashSet(); invokerSet.add(methodInvoker); return invokerSet; } - + @SuppressWarnings("unused") private class TestClass{ - + int method1Count = 0; int method2Count = 0; int method3Count = 0; - + public void method1(){ method1Count++; } - + public void method2(){ method2Count++; } - + public ExitStatus method3(){ method3Count++; return ExitStatus.COMPLETED; } } - + @SuppressWarnings("unused") private class StubMethodInvocation implements MethodInvocation{ Method method; Object[] args; - + public StubMethodInvocation(Method method, Object... args) { this.method = method; this.args = args; } - + + @Override public Method getMethod() { return method; } + @Override public Object[] getArguments() { return null; } + @Override public AccessibleObject getStaticPart() { return null; } + @Override public Object getThis() { return null; } + @Override public Object proceed() throws Throwable { return null; } - + } -} \ No newline at end of file +} diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/ExampleItemReader.java b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/ExampleItemReader.java index bf11cb9da..6c17abb9e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/ExampleItemReader.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/ExampleItemReader.java @@ -41,6 +41,7 @@ public class ExampleItemReader implements ItemReader, ItemStream { /** * Reads next record from input */ + @Override public String read() throws Exception { if (index >= input.length || index >= max) { return null; @@ -61,13 +62,16 @@ public class ExampleItemReader implements ItemReader, ItemStream { return input[index++]; } + @Override public void close() throws ItemStreamException { } + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { index = (int) executionContext.getLong("POSITION", min); } + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { executionContext.putLong("POSITION", index); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/ExampleItemWriter.java b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/ExampleItemWriter.java index 7b3e626e7..9026a8e04 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/ExampleItemWriter.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/ExampleItemWriter.java @@ -13,9 +13,9 @@ import org.springframework.batch.item.ItemWriter; public class ExampleItemWriter implements ItemWriter { private static final Log log = LogFactory.getLog(ExampleItemWriter.class); - + private static List items = new ArrayList(); - + public static void clear() { items.clear(); } @@ -27,6 +27,7 @@ public class ExampleItemWriter implements ItemWriter { /** * @see ItemWriter#write(List) */ + @Override public void write(List data) throws Exception { log.info(data); items.addAll(data); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/MinMaxPartitioner.java b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/MinMaxPartitioner.java index a0d93de6b..c8c12aaa5 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/MinMaxPartitioner.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/MinMaxPartitioner.java @@ -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. @@ -27,16 +27,17 @@ import org.springframework.batch.item.ExecutionContext; */ public class MinMaxPartitioner extends SimplePartitioner { + @Override public Map partition(int gridSize) { Map partition = super.partition(gridSize); int total = 8; // The number of items in the ExampleItemReader int range = total/gridSize; int i = 0; for (ExecutionContext context : partition.values()) { - int min = (i++)*range; - int max = Math.min(total, (min+1)*range); - context.putInt("min", min); - context.putInt("max", max); + int min = (i++)*range; + int max = Math.min(total, (min+1)*range); + context.putInt("min", min); + context.putInt("max", max); } return partition; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/PartitionStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/PartitionStepTests.java index fe8250c9e..5e2118e15 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/PartitionStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/PartitionStepTests.java @@ -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. @@ -37,7 +37,7 @@ import org.springframework.batch.core.repository.support.MapJobRepositoryFactory /** * @author Dave Syer - * + * */ public class PartitionStepTests { @@ -57,6 +57,7 @@ public class PartitionStepTests { public void testVanillaStepExecution() throws Exception { step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner())); step.setPartitionHandler(new PartitionHandler() { + @Override public Collection handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception { Set executions = stepSplitter.split(stepExecution, 2); @@ -81,6 +82,7 @@ public class PartitionStepTests { public void testFailedStepExecution() throws Exception { step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner())); step.setPartitionHandler(new PartitionHandler() { + @Override public Collection handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception { Set executions = stepSplitter.split(stepExecution, 2); @@ -106,6 +108,7 @@ public class PartitionStepTests { final AtomicBoolean started = new AtomicBoolean(false); step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner())); step.setPartitionHandler(new PartitionHandler() { + @Override public Collection handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception { Set executions = stepSplitter.split(stepExecution, 2); @@ -152,6 +155,7 @@ public class PartitionStepTests { public void testStoppedStepExecution() throws Exception { step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner())); step.setPartitionHandler(new PartitionHandler() { + @Override public Collection handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception { Set executions = stepSplitter.split(stepExecution, 2); @@ -183,6 +187,7 @@ public class PartitionStepTests { }); step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner())); step.setPartitionHandler(new PartitionHandler() { + @Override public Collection handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception { return Arrays.asList(stepExecution); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitterTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitterTests.java index c306e3a56..2824334f9 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitterTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitterTests.java @@ -59,10 +59,11 @@ public class SimpleStepExecutionSplitterTests { final Map map = Collections.singletonMap("foo", new ExecutionContext()); SimpleStepExecutionSplitter splitter = new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new Partitioner() { - public Map partition(int gridSize) { - return map; - } - }); + @Override + public Map partition(int gridSize) { + return map; + } + }); assertEquals(1, splitter.split(stepExecution, 2).size()); } @@ -79,10 +80,12 @@ public class SimpleStepExecutionSplitterTests { @Test public void testRememberPartitionNames() throws Exception { class CustomPartitioner implements Partitioner, PartitionNameProvider { + @Override public Map partition(int gridSize) { return Collections.singletonMap("foo", new ExecutionContext()); } + @Override public Collection getPartitionNames(int gridSize) { return Arrays.asList("foo"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/TaskExecutorPartitionHandlerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/TaskExecutorPartitionHandlerTests.java index 859a50f2b..b6287cdd1 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/TaskExecutorPartitionHandlerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/TaskExecutorPartitionHandlerTests.java @@ -27,17 +27,19 @@ public class TaskExecutorPartitionHandlerTests { private TaskExecutorPartitionHandler handler = new TaskExecutorPartitionHandler(); private int count = 0; - + private Collection stepExecutions = new TreeSet(); private StepExecution stepExecution = new StepExecution("step", new JobExecution(1L)); private StepExecutionSplitter stepExecutionSplitter = new StepExecutionSplitter() { + @Override public String getStepName() { return stepExecution.getStepName(); } + @Override public Set split(StepExecution stepExecution, int gridSize) throws JobExecutionException { HashSet result = new HashSet(); for (int i = gridSize; i-- > 0;) { @@ -92,6 +94,7 @@ public class TaskExecutorPartitionHandlerTests { public void testTaskExecutorFailure() throws Exception { handler.setGridSize(2); handler.setTaskExecutor(new TaskExecutor() { + @Override public void execute(Runnable task) { if (count > 0) { throw new TaskRejectedException("foo"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobExecutionAlreadyRunningExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobExecutionAlreadyRunningExceptionTests.java index 3dfa323ce..ab2d70511 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobExecutionAlreadyRunningExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobExecutionAlreadyRunningExceptionTests.java @@ -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,6 +26,7 @@ public class JobExecutionAlreadyRunningExceptionTests extends AbstractExceptionT /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ + @Override public Exception getException(String msg) throws Exception { return new JobExecutionAlreadyRunningException(msg); } @@ -33,6 +34,7 @@ public class JobExecutionAlreadyRunningExceptionTests extends AbstractExceptionT /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable) */ + @Override public Exception getException(String msg, Throwable t) throws Exception { return new JobExecutionAlreadyRunningException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobInstanceAlreadyCompleteExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobInstanceAlreadyCompleteExceptionTests.java index 1d443372f..3d824c05a 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobInstanceAlreadyCompleteExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobInstanceAlreadyCompleteExceptionTests.java @@ -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,6 +26,7 @@ public class JobInstanceAlreadyCompleteExceptionTests extends AbstractExceptionT /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ + @Override public Exception getException(String msg) throws Exception { return new JobInstanceAlreadyCompleteException(msg); } @@ -33,6 +34,7 @@ public class JobInstanceAlreadyCompleteExceptionTests extends AbstractExceptionT /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable) */ + @Override public Exception getException(String msg, Throwable t) throws Exception { return new JobInstanceAlreadyCompleteException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobRestartExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobRestartExceptionTests.java index a07f0e719..20d7db314 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobRestartExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobRestartExceptionTests.java @@ -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,7 +19,7 @@ import org.springframework.batch.core.AbstractExceptionTests; /** * @author Dave Syer - * + * */ public class JobRestartExceptionTests extends AbstractExceptionTests { @@ -27,6 +27,7 @@ public class JobRestartExceptionTests extends AbstractExceptionTests { * (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ + @Override public Exception getException(String msg) throws Exception { return new JobRestartException(msg); } @@ -36,6 +37,7 @@ public class JobRestartExceptionTests extends AbstractExceptionTests { * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, * java.lang.Throwable) */ + @Override public Exception getException(String msg, Throwable t) throws Exception { return new JobRestartException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobDaoQueryTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobDaoQueryTests.java index 6bcf4f23c..6bdab8cbb 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobDaoQueryTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobDaoQueryTests.java @@ -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,7 +29,7 @@ import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer /** * @author Dave Syer - * + * */ public class JdbcJobDaoQueryTests extends TestCase { @@ -41,19 +41,23 @@ public class JdbcJobDaoQueryTests extends TestCase { * (non-Javadoc) * @see junit.framework.TestCase#setUp() */ + @Override protected void setUp() throws Exception { jobExecutionDao = new JdbcJobExecutionDao(); jobExecutionDao.setJobExecutionIncrementer(new DataFieldMaxValueIncrementer() { + @Override public int nextIntValue() throws DataAccessException { return 0; } + @Override public long nextLongValue() throws DataAccessException { return 0; } + @Override public String nextStringValue() throws DataAccessException { return "bar"; } @@ -64,6 +68,7 @@ public class JdbcJobDaoQueryTests extends TestCase { public void testTablePrefix() throws Exception { jobExecutionDao.setTablePrefix("FOO_"); jobExecutionDao.setJdbcTemplate(new JdbcTemplate() { + @Override public int update(String sql, Object[] args, int[] argTypes) throws DataAccessException { list.add(sql); return 1; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDaoTests.java index 93076d53e..59fcc7e0d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDaoTests.java @@ -13,11 +13,11 @@ import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobInstance; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.support.JdbcTestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.batch.support.JdbcTestUtils; import org.springframework.transaction.annotation.Transactional; @RunWith(SpringJUnit4ClassRunner.class) @@ -25,22 +25,23 @@ import org.springframework.transaction.annotation.Transactional; public class JdbcJobInstanceDaoTests extends AbstractJobInstanceDaoTests { private JdbcTemplate jdbcTemplate; - + @Autowired public void setDataSource(DataSource dataSource) { this.jdbcTemplate = new JdbcTemplate(dataSource); } - + @Autowired private JobInstanceDao jobInstanceDao; @Autowired private JobExecutionDao jobExecutionDao; + @Override protected JobInstanceDao getJobInstanceDao() { JdbcTestUtils.deleteFromTables(jdbcTemplate, "BATCH_JOB_EXECUTION_CONTEXT", - "BATCH_STEP_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION", - "BATCH_JOB_EXECUTION", "BATCH_JOB_PARAMS", "BATCH_JOB_INSTANCE"); + "BATCH_STEP_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION", + "BATCH_JOB_EXECUTION", "BATCH_JOB_PARAMS", "BATCH_JOB_INSTANCE"); return jobInstanceDao; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDaoTests.java index fa0d0f77b..e5dabff17 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDaoTests.java @@ -15,10 +15,12 @@ import org.springframework.transaction.annotation.Transactional; @ContextConfiguration(locations = "sql-dao-test.xml") public class JdbcStepExecutionDaoTests extends AbstractStepExecutionDaoTests { + @Override protected StepExecutionDao getStepExecutionDao() { return (StepExecutionDao) applicationContext.getBean("stepExecutionDao"); } + @Override protected JobRepository getJobRepository() { deleteFromTables("BATCH_JOB_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION", "BATCH_JOB_EXECUTION", "BATCH_JOB_PARAMS", "BATCH_JOB_INSTANCE"); @@ -30,15 +32,15 @@ public class JdbcStepExecutionDaoTests extends AbstractStepExecutionDaoTests { */ @Transactional @Test public void testTruncateExitDescription() { - + StringBuffer sb = new StringBuffer(); for (int i = 0; i < 100; i++) { sb.append("too long exit description"); } String longDescription = sb.toString(); - + ExitStatus exitStatus = ExitStatus.FAILED.addExitDescription(longDescription); - + stepExecution.setExitStatus(exitStatus); ((JdbcStepExecutionDao) dao).setExitMessageLength(250); @@ -56,5 +58,5 @@ public class JdbcStepExecutionDaoTests extends AbstractStepExecutionDaoTests { assertTrue("Exit description should be truncated", retrievedAfterUpdate.getExitStatus().getExitDescription() .length() < stepExecution.getExitStatus().getExitDescription().length()); } - + } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobExecutionDaoTests.java index 7f9e127f0..507ce01bd 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobExecutionDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobExecutionDaoTests.java @@ -1,12 +1,13 @@ package org.springframework.batch.core.repository.dao; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + import java.util.Collections; import java.util.Date; import java.util.SortedSet; import java.util.TreeSet; - import java.util.concurrent.CountDownLatch; - import java.util.concurrent.atomic.AtomicReference; import org.junit.Test; @@ -16,8 +17,6 @@ import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobInstance; import org.springframework.batch.core.JobParameters; -import static org.junit.Assert.*; - @RunWith(JUnit4.class) public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests { @@ -25,7 +24,7 @@ public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests { protected JobExecutionDao getJobExecutionDao() { return new MapJobExecutionDao(); } - + @Override protected JobInstanceDao getJobInstanceDao() { return new MapJobInstanceDao(); @@ -38,23 +37,23 @@ public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests { public void testPersistentCopy() { JobExecutionDao tested = new MapJobExecutionDao(); JobExecution jobExecution = new JobExecution(new JobInstance((long) 1, new JobParameters(), "mapJob")); - + assertNull(jobExecution.getStartTime()); tested.saveJobExecution(jobExecution); jobExecution.setStartTime(new Date()); - + JobExecution retrieved = tested.getJobExecution(jobExecution.getId()); assertNull(retrieved.getStartTime()); - + tested.updateJobExecution(jobExecution); jobExecution.setEndTime(new Date()); assertNull(retrieved.getEndTime()); - + } /** - * Verify that the ids are properly generated even under heavy concurrent load - */ + * Verify that the ids are properly generated even under heavy concurrent load + */ @Test public void testConcurrentSaveJobExecution() throws Exception { final int iterations = 100; @@ -69,6 +68,7 @@ public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests { // Implementation of the high-concurrency code final Runnable codeUnderTest = new Runnable() { + @Override public void run() { try { JobExecution jobExecution = new JobExecution(new JobInstance((long) -1, new JobParameters(), "mapJob")); @@ -97,11 +97,13 @@ public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests { for(Thread t : threads) { t.join(); } // Ensure no general exceptions arose - if(exception.get() != null) throw new RuntimeException("Excepion occurred under high concurrency usage", exception.get()); + if(exception.get() != null) { + throw new RuntimeException("Excepion occurred under high concurrency usage", exception.get()); + } // Validate the ids: we'd expect one of these three things to fail if(ids.size() < iterations) { - fail("Duplicate id generated during high concurrency usage"); + fail("Duplicate id generated during high concurrency usage"); } if(ids.first() < 0) { fail("Generated an id less than zero during high concurrency usage: " + ids.first()); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobInstanceDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobInstanceDaoTests.java index 23f9101b1..4314df6ec 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobInstanceDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobInstanceDaoTests.java @@ -6,6 +6,7 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public class MapJobInstanceDaoTests extends AbstractJobInstanceDaoTests { + @Override protected JobInstanceDao getJobInstanceDao() { return new MapJobInstanceDao(); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapStepExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapStepExecutionDaoTests.java index 204808d27..5f2d8422c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapStepExecutionDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapStepExecutionDaoTests.java @@ -7,8 +7,8 @@ import static org.junit.Assert.assertNull; import java.util.Date; import org.junit.Test; -import org.junit.runners.JUnit4; import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.springframework.batch.core.BatchStatus; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.StepExecution; @@ -18,15 +18,17 @@ import org.springframework.batch.core.repository.support.SimpleJobRepository; @RunWith(JUnit4.class) public class MapStepExecutionDaoTests extends AbstractStepExecutionDaoTests { + @Override protected StepExecutionDao getStepExecutionDao() { return new MapStepExecutionDao(); } + @Override protected JobRepository getJobRepository() { return new SimpleJobRepository(new MapJobInstanceDao(), new MapJobExecutionDao(), new MapStepExecutionDao(), new MapExecutionContextDao()); } - + /** * Modifications to saved entity do not affect the persisted object. */ @@ -35,18 +37,18 @@ public class MapStepExecutionDaoTests extends AbstractStepExecutionDaoTests { StepExecutionDao tested = new MapStepExecutionDao(); JobExecution jobExecution = new JobExecution(77L); StepExecution stepExecution = new StepExecution("stepName", jobExecution); - + assertNull(stepExecution.getEndTime()); tested.saveStepExecution(stepExecution); stepExecution.setEndTime(new Date()); - + StepExecution retrieved = tested.getStepExecution(jobExecution, stepExecution.getId()); assertNull(retrieved.getEndTime()); - + stepExecution.setEndTime(null); tested.updateStepExecution(stepExecution); stepExecution.setEndTime(new Date()); - + StepExecution stored = tested.getStepExecution(jobExecution, stepExecution.getId()); assertNull(stored.getEndTime()); } @@ -54,50 +56,50 @@ public class MapStepExecutionDaoTests extends AbstractStepExecutionDaoTests { @Test public void testAddStepExecutions() { StepExecutionDao tested = new MapStepExecutionDao(); - + JobExecution jobExecution = new JobExecution(88L); - + // Create step execution with status STARTED - StepExecution stepExecution = new StepExecution("Step one", jobExecution); + StepExecution stepExecution = new StepExecution("Step one", jobExecution); stepExecution.setStatus(BatchStatus.STARTED); - + // Save and check id tested.saveStepExecution(stepExecution); assertNotNull(stepExecution.getId()); - - // Job execution instance doesn't contain step execution instances + + // Job execution instance doesn't contain step execution instances assertEquals(0, jobExecution.getStepExecutions().size()); - + // Load all execution steps and check tested.addStepExecutions(jobExecution); assertEquals(1, jobExecution.getStepExecutions().size()); - - // Check the first (and only) step execution instance of the job instance + + // Check the first (and only) step execution instance of the job instance StepExecution jobStepExecution = jobExecution.getStepExecutions().iterator().next(); assertEquals(BatchStatus.STARTED, jobStepExecution.getStatus()); assertEquals(stepExecution.getId(), jobStepExecution.getId()); - - // Load the step execution instance from the repository and check is it the same + + // Load the step execution instance from the repository and check is it the same StepExecution repoStepExecution = tested.getStepExecution(jobExecution, stepExecution.getId()); assertEquals(stepExecution.getId(), repoStepExecution.getId()); assertEquals(BatchStatus.STARTED, repoStepExecution.getStatus()); - + // Update the step execution instance repoStepExecution.setStatus(BatchStatus.COMPLETED); - + // Update the step execution in the repository and check tested.updateStepExecution(repoStepExecution); StepExecution updatedStepExecution = tested.getStepExecution(jobExecution, stepExecution.getId()); assertEquals(stepExecution.getId(), updatedStepExecution.getId()); assertEquals(BatchStatus.COMPLETED, updatedStepExecution.getStatus()); - + // Now, add step executions from the repository and check tested.addStepExecutions(jobExecution); - + jobStepExecution = jobExecution.getStepExecutions().iterator().next(); assertEquals(1, jobExecution.getStepExecutions().size()); assertEquals(stepExecution.getId(), jobStepExecution.getId()); - assertEquals(BatchStatus.COMPLETED, jobStepExecution.getStatus()); + assertEquals(BatchStatus.COMPLETED, jobStepExecution.getStatus()); } - + } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/TablePrefixTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/TablePrefixTests.java index 72f5b476e..4e896ae9c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/TablePrefixTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/TablePrefixTests.java @@ -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. @@ -30,11 +30,11 @@ import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.batch.support.JdbcTestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.batch.support.JdbcTestUtils; @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) @@ -62,6 +62,7 @@ public class TablePrefixTests { public static class TestTasklet implements Tasklet { + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return RepeatStatus.FINISHED; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/JobRepositoryFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/JobRepositoryFactoryBeanTests.java index e83b459cc..68037d135 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/JobRepositoryFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/JobRepositoryFactoryBeanTests.java @@ -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. @@ -332,14 +332,17 @@ public class JobRepositoryFactoryBeanTests { private static class StubIncrementer implements DataFieldMaxValueIncrementer { + @Override public int nextIntValue() throws DataAccessException { return 0; } + @Override public long nextLongValue() throws DataAccessException { return 0; } + @Override public String nextStringValue() throws DataAccessException { return null; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryProxyTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryProxyTests.java index ad0acb504..94ce39d5d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryProxyTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryProxyTests.java @@ -20,7 +20,7 @@ import org.springframework.transaction.annotation.Transactional; /** * Repository tests using JDBC DAOs (rather than mocks). - * + * * @author Robert Kasanicky */ @RunWith(SpringJUnit4ClassRunner.class) @@ -58,10 +58,11 @@ public class SimpleJobRepositoryProxyTests { private boolean invoked; + @Override public Object invoke(MethodInvocation invocation) throws Throwable { invoked = true; return invocation.proceed(); } } -} \ No newline at end of file +} diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/Foo.java b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/Foo.java index 072530a86..6f6efec71 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/Foo.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/Foo.java @@ -5,19 +5,19 @@ package org.springframework.batch.core.resource; * Simple domain object for testing purposes. */ public class Foo { - + private int id; private String name; private int value; - + public Foo(){} - + public Foo(int id, String name, int value) { this.id = id; this.name = name; this.value = value; } - + public String getName() { return name; } @@ -36,7 +36,8 @@ public class Foo { public void setId(int id) { this.id = id; } - + + @Override public String toString() { return "Foo[id=" +id +",name=" + name + ",value=" + value + "]"; } @@ -53,24 +54,31 @@ public class Foo { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Foo other = (Foo) obj; - if (id != other.id) - return false; - if (name == null) { - if (other.name != null) - return false; } - else if (!name.equals(other.name)) + if (obj == null) { return false; - if (value != other.value) + } + if (getClass() != obj.getClass()) { return false; + } + Foo other = (Foo) obj; + if (id != other.id) { + return false; + } + if (name == null) { + if (other.name != null) { + return false; + } + } + else if (!name.equals(other.name)) { + return false; + } + if (value != other.value) { + return false; + } return true; } - + } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/FooRowMapper.java b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/FooRowMapper.java index 117e376cf..983f22135 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/FooRowMapper.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/FooRowMapper.java @@ -6,15 +6,17 @@ import java.sql.SQLException; import org.springframework.jdbc.core.RowMapper; +@SuppressWarnings("rawtypes") public class FooRowMapper implements RowMapper { - public Object mapRow(ResultSet rs, int rowNum) throws SQLException { + @Override + public Object mapRow(ResultSet rs, int rowNum) throws SQLException { - Foo foo = new Foo(); - foo.setId(rs.getInt(1)); - foo.setName(rs.getString(2)); - foo.setValue(rs.getInt(3)); - - return foo; - } + Foo foo = new Foo(); + foo.setId(rs.getInt(1)); + foo.setName(rs.getString(2)); + foo.setValue(rs.getInt(3)); + + return foo; + } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/ListPreparedStatementSetterTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/ListPreparedStatementSetterTests.java index 53ee8cd58..cbca871e8 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/ListPreparedStatementSetterTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/ListPreparedStatementSetterTests.java @@ -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. @@ -35,20 +35,20 @@ import org.springframework.batch.core.job.AbstractJob; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.RowCallbackHandler; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowCallbackHandler; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.annotation.Transactional; /** * @author Lucas Ward - * + * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/org/springframework/batch/core/resource/ListPreparedStatementSetterTests-context.xml", - "/org/springframework/batch/core/repository/dao/data-source-context.xml" }) +"/org/springframework/batch/core/repository/dao/data-source-context.xml" }) public class ListPreparedStatementSetterTests { ListPreparedStatementSetter pss; @@ -88,10 +88,11 @@ public class ListPreparedStatementSetterTests { final List results = new ArrayList(); jdbcTemplate.query("SELECT NAME from T_FOOS where ID > ? and ID < ?", pss, new RowCallbackHandler() { - public void processRow(ResultSet rs) throws SQLException { - results.add(rs.getString(1)); - } - }); + @Override + public void processRow(ResultSet rs) throws SQLException { + results.add(rs.getString(1)); + } + }); assertEquals(2, results.size()); assertEquals("bar2", results.get(0)); @@ -133,6 +134,7 @@ public class ListPreparedStatementSetterTests { public static class FooStoringItemWriter implements ItemWriter { private List foos = new ArrayList(); + @Override public void write(List items) throws Exception { foos.addAll(items); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicyTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicyTests.java index 400ae22b8..27a1de1ac 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicyTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicyTests.java @@ -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.batch.repeat.RepeatContext; /** * Unit tests for {@link StepExecutionSimpleCompletionPolicy} - * + * * @author Dave Syer */ public class StepExecutionSimpleCompletionPolicyTests extends TestCase { @@ -49,6 +49,7 @@ public class StepExecutionSimpleCompletionPolicyTests extends TestCase { * mock step context */ + @Override protected void setUp() throws Exception { JobParameters jobParameters = new JobParametersBuilder().addLong("commit.interval", 2L).toJobParameters(); @@ -59,7 +60,7 @@ public class StepExecutionSimpleCompletionPolicyTests extends TestCase { policy.beforeStep(stepExecution); } - + public void testToString() throws Exception { String msg = policy.toString(); assertTrue("String does not contain chunk size", msg.indexOf("chunkSize=2")>=0); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/AsyncStepScopeIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/AsyncStepScopeIntegrationTests.java index 3e4cc6abb..2fa1ca891 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/AsyncStepScopeIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/AsyncStepScopeIntegrationTests.java @@ -45,6 +45,7 @@ public class AsyncStepScopeIntegrationTests implements BeanFactoryAware { private int beanCount; + @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = (ListableBeanFactory) beanFactory; } @@ -80,6 +81,7 @@ public class AsyncStepScopeIntegrationTests implements BeanFactoryAware { final String value = "foo" + i; final Long id = 123L + i; FutureTask task = new FutureTask(new Callable() { + @Override public String call() throws Exception { StepExecution stepExecution = new StepExecution(value, new JobExecution(0L), id); ExecutionContext executionContext = stepExecution.getExecutionContext(); @@ -119,6 +121,7 @@ public class AsyncStepScopeIntegrationTests implements BeanFactoryAware { for (int i = 0; i < 12; i++) { final String value = "foo" + i; FutureTask task = new FutureTask(new Callable() { + @Override public String call() throws Exception { ExecutionContext executionContext = stepExecution.getExecutionContext(); executionContext.put("foo", value); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/JobStartupRunner.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/JobStartupRunner.java index 4911c83d5..d67b72a15 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/JobStartupRunner.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/JobStartupRunner.java @@ -8,11 +8,12 @@ import org.springframework.beans.factory.InitializingBean; public class JobStartupRunner implements InitializingBean { private Step step; - + public void setStep(Step step) { this.step = step; } - + + @Override public void afterPropertiesSet() throws Exception { StepExecution stepExecution = new StepExecution("step", new JobExecution(1L), 0L); step.execute(stepExecution); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeClassIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeClassIntegrationTests.java index 4647953a9..a007ae5a1 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeClassIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeClassIntegrationTests.java @@ -40,6 +40,7 @@ public class StepScopeClassIntegrationTests implements BeanFactoryAware { private int beanCount; + @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = (ListableBeanFactory) beanFactory; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopePerformanceTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopePerformanceTests.java index 52baeb436..e24b20453 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopePerformanceTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopePerformanceTests.java @@ -21,11 +21,12 @@ import org.springframework.util.StopWatch; @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) public class StepScopePerformanceTests implements ApplicationContextAware { - + private Log logger = LogFactory.getLog(getClass()); private ApplicationContext applicationContext; + @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopePlaceholderIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopePlaceholderIntegrationTests.java index 21e216fbd..79a919ff8 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopePlaceholderIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopePlaceholderIntegrationTests.java @@ -61,6 +61,7 @@ public class StepScopePlaceholderIntegrationTests implements BeanFactoryAware { private int beanCount; + @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = (ListableBeanFactory) beanFactory; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeProxyTargetClassIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeProxyTargetClassIntegrationTests.java index 8c1432819..a3e0944fb 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeProxyTargetClassIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeProxyTargetClassIntegrationTests.java @@ -33,6 +33,7 @@ public class StepScopeProxyTargetClassIntegrationTests implements BeanFactoryAwa private int beanCount; + @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = (ListableBeanFactory) beanFactory; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeTests.java index 59030d17c..b46166cd0 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeTests.java @@ -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,8 +38,9 @@ import org.springframework.context.support.StaticApplicationContext; /** * @author Dave Syer - * + * */ +@SuppressWarnings("rawtypes") public class StepScopeTests { private StepScope scope = new StepScope(); @@ -64,6 +65,7 @@ public class StepScopeTests { StepSynchronizationManager.close(); try { scope.get("foo", new ObjectFactory() { + @Override public Object getObject() throws BeansException { return foo; } @@ -80,6 +82,7 @@ public class StepScopeTests { public void testGetWithNothingAlreadyThere() { final String foo = "bar"; Object value = scope.get("foo", new ObjectFactory() { + @Override public Object getObject() throws BeansException { return foo; } @@ -92,6 +95,7 @@ public class StepScopeTests { public void testGetWithSomethingAlreadyThere() { context.setAttribute("foo", "bar"); Object value = scope.get("foo", new ObjectFactory() { + @Override public Object getObject() throws BeansException { return null; } @@ -105,6 +109,7 @@ public class StepScopeTests { context.setAttribute("foo", "bar"); StepContext context = StepSynchronizationManager.register(new StepExecution("bar", new JobExecution(0L))); Object value = scope.get("foo", new ObjectFactory() { + @Override public Object getObject() throws BeansException { return "spam"; } @@ -133,6 +138,7 @@ public class StepScopeTests { final List list = new ArrayList(); context.setAttribute("foo", "bar"); scope.registerDestructionCallback("foo", new Runnable() { + @Override public void run() { list.add("foo"); } @@ -149,11 +155,13 @@ public class StepScopeTests { final List list = new ArrayList(); context.setAttribute("foo", "bar"); scope.registerDestructionCallback("foo", new Runnable() { + @Override public void run() { list.add("foo"); } }); scope.registerDestructionCallback("foo", new Runnable() { + @Override public void run() { list.add("bar"); } @@ -179,6 +187,7 @@ public class StepScopeTests { assertEquals(11, scope.getOrder()); } + @SuppressWarnings("resource") @Test public void testName() throws Exception { scope.setName("foo"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestCollaborator.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestCollaborator.java index bb21208cf..3cf7c5759 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestCollaborator.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestCollaborator.java @@ -4,14 +4,16 @@ import java.io.Serializable; import java.util.List; +@SuppressWarnings("serial") public class TestCollaborator implements Collaborator, Serializable { private String name; - + private Collaborator parent; - + private List list; + @Override public List getList() { return list; } @@ -20,6 +22,7 @@ public class TestCollaborator implements Collaborator, Serializable { this.list = list; } + @Override public Collaborator getParent() { return parent; } @@ -28,6 +31,7 @@ public class TestCollaborator implements Collaborator, Serializable { this.parent = parent; } + @Override public String getName() { return name; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestDisposableCollaborator.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestDisposableCollaborator.java index 7277647da..b801e1337 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestDisposableCollaborator.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestDisposableCollaborator.java @@ -2,10 +2,12 @@ package org.springframework.batch.core.scope; import org.springframework.beans.factory.DisposableBean; +@SuppressWarnings("serial") public class TestDisposableCollaborator extends TestCollaborator implements DisposableBean { public static volatile String message = "none"; + @Override public void destroy() throws Exception { message = (message.equals("none") ? "" : message + ",") + getName() + ":destroyed"; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestStep.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestStep.java index a9bb84ebf..0062d8828 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestStep.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestStep.java @@ -24,6 +24,7 @@ public class TestStep implements Step { context = null; } + @Override public void execute(StepExecution stepExecution) throws JobInterruptedException { context = StepSynchronizationManager.getContext(); setContextFromCollaborator(); @@ -42,14 +43,17 @@ public class TestStep implements Step { } } + @Override public String getName() { return "foo"; } + @Override public int getStartLimit() { return Integer.MAX_VALUE; } + @Override public boolean isAllowStartIfComplete() { return false; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextTests.java index caf755340..0a9e523c7 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextTests.java @@ -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,12 +30,11 @@ import org.springframework.batch.core.JobInstance; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.JobParametersBuilder; import org.springframework.batch.core.StepExecution; -import org.springframework.batch.core.scope.context.StepContext; import org.springframework.batch.item.ExecutionContext; /** * @author Dave Syer - * + * */ public class StepContextTests { @@ -81,6 +80,7 @@ public class StepContextTests { public void testDestructionCallbackSunnyDay() throws Exception { context.setAttribute("foo", "FOO"); context.registerDestructionCallback("foo", new Runnable() { + @Override public void run() { list.add("bar"); } @@ -93,6 +93,7 @@ public class StepContextTests { @Test public void testDestructionCallbackMissingAttribute() throws Exception { context.registerDestructionCallback("foo", new Runnable() { + @Override public void run() { list.add("bar"); } @@ -108,12 +109,14 @@ public class StepContextTests { context.setAttribute("foo", "FOO"); context.setAttribute("bar", "BAR"); context.registerDestructionCallback("bar", new Runnable() { + @Override public void run() { list.add("spam"); throw new RuntimeException("fail!"); } }); context.registerDestructionCallback("foo", new Runnable() { + @Override public void run() { list.add("bar"); throw new RuntimeException("fail!"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepSynchronizationManagerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepSynchronizationManagerTests.java index b1ee1f02b..188c40e3b 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepSynchronizationManagerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepSynchronizationManagerTests.java @@ -45,6 +45,7 @@ public class StepSynchronizationManagerTests { final List list = new ArrayList(); StepContext context = StepSynchronizationManager.register(stepExecution); context.registerDestructionCallback("foo", new Runnable() { + @Override public void run() { list.add("foo"); } @@ -69,6 +70,7 @@ public class StepSynchronizationManagerTests { StepContext context = StepSynchronizationManager.register(stepExecution); ExecutorService executorService = Executors.newFixedThreadPool(2); FutureTask task = new FutureTask(new Callable() { + @Override public StepContext call() throws Exception { try { StepSynchronizationManager.register(stepExecution); @@ -93,6 +95,7 @@ public class StepSynchronizationManagerTests { StepContext context = StepSynchronizationManager.register(stepExecution); final List list = new ArrayList(); context.registerDestructionCallback("foo", new Runnable() { + @Override public void run() { list.add("foo"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/AsyncPlaceholderTargetSourceTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/AsyncPlaceholderTargetSourceTests.java index 3d21c1a2d..7ec92fa59 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/AsyncPlaceholderTargetSourceTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/AsyncPlaceholderTargetSourceTests.java @@ -47,6 +47,7 @@ public class AsyncPlaceholderTargetSourceTests implements BeanFactoryAware { private int beanCount; + @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = (ListableBeanFactory) beanFactory; } @@ -79,6 +80,7 @@ public class AsyncPlaceholderTargetSourceTests implements BeanFactoryAware { for (int i = 0; i < 12; i++) { final String value = "foo" + i; FutureTask task = new FutureTask(new Callable() { + @Override public String call() throws Exception { attributes.set(Collections.singletonMap("foo", value)); try { @@ -105,6 +107,7 @@ public class AsyncPlaceholderTargetSourceTests implements BeanFactoryAware { private Object root; + @Override public Object getContext() { return root; } @@ -129,6 +132,7 @@ public class AsyncPlaceholderTargetSourceTests implements BeanFactoryAware { private Log logger = LogFactory.getLog(getClass()); + @Override public String getName() { return name; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/ContextFactorySupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/ContextFactorySupport.java index 24c428c01..d50da3cc0 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/ContextFactorySupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/ContextFactorySupport.java @@ -6,18 +6,20 @@ public class ContextFactorySupport implements ContextFactory { /** * Returns this. Override for more sensible behaviour. - * + * * @see org.springframework.batch.core.scope.util.ContextFactory#getContext() */ + @Override public Object getContext() { return this; } /** * Returns the context plus a counter, so each call is unique. - * + * * @see org.springframework.batch.core.scope.util.ContextFactory#getContextId() */ + @Override public String getContextId() { return getContext()+"#"+(count ++); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests.java index 0bc9d18ee..47fd03bd0 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests.java @@ -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.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Dave Syer - * + * */ @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) @@ -165,13 +165,13 @@ public class MultipleContextPlaceholderTargetSourceTests { public static class TestBean { private String name; - + private TestBean parent; private List names = new ArrayList(); private Map map = new HashMap(); - + public TestBean getParent() { return parent; } @@ -203,13 +203,14 @@ public class MultipleContextPlaceholderTargetSourceTests { public void setMap(Map map) { this.map.putAll(map); } - + } public static class SimpleContextFactory extends ContextFactorySupport { private Object root; + @Override public Object getContext() { return root; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceCustomEditorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceCustomEditorTests.java index 65c350ca5..3a8c0dd1f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceCustomEditorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceCustomEditorTests.java @@ -22,6 +22,7 @@ public class PlaceholderTargetSourceCustomEditorTests extends ContextFactorySupp private Date date = new Date(1L); + @Override public Object getContext() { return this; } @@ -48,6 +49,7 @@ public class PlaceholderTargetSourceCustomEditorTests extends ContextFactorySupp public Foo() { } + @Override public String getName() { return name; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceErrorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceErrorTests.java index b5864c963..2a9718c5f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceErrorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceErrorTests.java @@ -23,6 +23,7 @@ public class PlaceholderTargetSourceErrorTests extends ContextFactorySupport { private Date date = new Date(1L); + @Override public Object getContext() { return this; } @@ -57,7 +58,7 @@ public class PlaceholderTargetSourceErrorTests extends ContextFactorySupport { private PlaceholderTargetSource createValue(String name, String value) throws Exception { String input = IOUtils.toString(new ClassPathResource(getClass().getSimpleName() + "-context.xml", getClass()) - .getInputStream()); + .getInputStream()); input = input.replace("", String.format("", name, value)); Resource resource = new ByteArrayResource(input.getBytes()); GenericApplicationContext context = new GenericApplicationContext(); @@ -107,8 +108,8 @@ public class PlaceholderTargetSourceErrorTests extends ContextFactorySupport { @Test public void testPartialReplaceIntegerToString() throws Exception { - Node target = (Node) createValue("name", "foo-%{integer}").getTarget(); - assertEquals("foo-4321", target.getName()); + Node target = (Node) createValue("name", "foo-%{integer}").getTarget(); + assertEquals("foo-4321", target.getName()); } @Test @@ -159,6 +160,7 @@ public class PlaceholderTargetSourceErrorTests extends ContextFactorySupport { public Foo() { } + @Override public long getValue() { return value; } @@ -171,10 +173,12 @@ public class PlaceholderTargetSourceErrorTests extends ContextFactorySupport { this.name = name; } + @Override public String getName() { return name; } + @Override public Date getDate() { return date; } @@ -187,6 +191,7 @@ public class PlaceholderTargetSourceErrorTests extends ContextFactorySupport { this.name = name; } + @Override public Node getParent() { return parent; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceTests.java index 1bf7ae3c7..a34f7519c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceTests.java @@ -80,6 +80,7 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport { private Date date = new Date(1L); + @Override public Object getContext() { return this; } @@ -222,9 +223,9 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport { Date getDate(); Node getParent(); - + List getList(); - + Map getMap(); } @@ -235,7 +236,7 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport { private Date date; private Node parent; - + private List list; private Map map; @@ -247,10 +248,12 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport { this.name = name; } + @Override public String getName() { return name; } + @Override public Date getDate() { return date; } @@ -263,6 +266,7 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport { this.name = name; } + @Override public Node getParent() { return parent; } @@ -275,10 +279,12 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport { this.list = list; } + @Override public List getList() { return list; } + @Override public Map getMap() { return map; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/SimplePlaceholderTargetSourceTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/SimplePlaceholderTargetSourceTests.java index faa133a15..720bd7eaa 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/SimplePlaceholderTargetSourceTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/SimplePlaceholderTargetSourceTests.java @@ -12,25 +12,26 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) public class SimplePlaceholderTargetSourceTests { - + @Autowired @Qualifier("simple") private Node simple; - + @Autowired private SimpleContextFactory contextFactory; - + @Test public void testGetSimple() { contextFactory.set("bar"); assertEquals("bar", simple.getName()); contextFactory.clear(); } - + public static class SimpleContextFactory extends ContextFactorySupport { private ThreadLocal fooHolder = new ThreadLocal(); - + + @Override public Object getContext() { return this; } @@ -46,17 +47,18 @@ public class SimplePlaceholderTargetSourceTests { public String getFoo() { return fooHolder.get(); } - + } public static interface Node { String getName(); } - + public static class Foo implements Node { private String name; - + + @Override public String getName() { return name; } @@ -64,7 +66,7 @@ public class SimplePlaceholderTargetSourceTests { public void setName(String name) { this.name = name; } - + } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/JobRepositorySupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/JobRepositorySupport.java index 5fccc9f81..37fdee424 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/JobRepositorySupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/JobRepositorySupport.java @@ -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,6 +30,7 @@ public class JobRepositorySupport implements JobRepository { /* (non-Javadoc) * @see org.springframework.batch.container.common.repository.JobRepository#findOrCreateJob(org.springframework.batch.container.common.domain.JobConfiguration) */ + @Override public JobExecution createJobExecution(String jobName, JobParameters jobParameters) { JobInstance jobInstance = new JobInstance(0L, jobParameters, jobName); return new JobExecution(jobInstance, 11L); @@ -38,6 +39,7 @@ public class JobRepositorySupport implements JobRepository { /* (non-Javadoc) * @see org.springframework.batch.container.common.repository.JobRepository#saveOrUpdate(org.springframework.batch.container.common.domain.JobExecution) */ + @Override public void update(JobExecution jobExecution) { } @@ -47,10 +49,12 @@ public class JobRepositorySupport implements JobRepository { public void update(JobInstance job) { } + @Override public StepExecution getLastStepExecution(JobInstance jobInstance, String stepName) { return null; } + @Override public int getStepExecutionCount(JobInstance jobInstance, String stepName) { return 0; } @@ -63,26 +67,32 @@ public class JobRepositorySupport implements JobRepository { return null; } + @Override public void add(StepExecution stepExecution) { } + @Override public void update(StepExecution stepExecution) { } + @Override public void updateExecutionContext(StepExecution stepExecution) { } /* (non-Javadoc) * @see org.springframework.batch.core.repository.JobRepository#isJobInstanceExists(java.lang.String, org.springframework.batch.core.JobParameters) */ + @Override public boolean isJobInstanceExists(String jobName, JobParameters jobParameters) { return false; } + @Override public JobExecution getLastJobExecution(String jobName, JobParameters jobParameters) { return null; } + @Override public void updateExecutionContext(JobExecution jobExecution) { } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/NonAbstractStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/NonAbstractStepTests.java index 9929618cc..87001db72 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/NonAbstractStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/NonAbstractStepTests.java @@ -4,7 +4,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import java.util.ArrayList; import java.util.List; @@ -51,6 +50,7 @@ public class NonAbstractStepTests { setBeanName("eventTrackingStep"); } + @Override protected void open(ExecutionContext ctx) throws Exception { events.add("open"); } @@ -62,6 +62,7 @@ public class NonAbstractStepTests { context.setExitStatus(ExitStatus.COMPLETED); } + @Override protected void close(ExecutionContext ctx) throws Exception { events.add("close"); } @@ -82,6 +83,7 @@ public class NonAbstractStepTests { return name + "#" + event; } + @Override public ExitStatus afterStep(StepExecution stepExecution) { assertSame(execution, stepExecution); events.add(getEvent("afterStep(" + stepExecution.getExitStatus().getExitCode() + ")")); @@ -89,6 +91,7 @@ public class NonAbstractStepTests { return stepExecution.getExitStatus(); } + @Override public void beforeStep(StepExecution stepExecution) { assertSame(execution, stepExecution); events.add(getEvent("beforeStep")); @@ -106,6 +109,7 @@ public class NonAbstractStepTests { static long counter = 0; + @Override public void updateExecutionContext(StepExecution stepExecution) { Assert.state(stepExecution.getId() != null, "StepExecution must already be saved"); saved = stepExecution.getExecutionContext(); @@ -286,6 +290,7 @@ public class NonAbstractStepTests { } }; repository = new JobRepositoryStub() { + @Override public void updateExecutionContext(StepExecution stepExecution) { throw new RuntimeException("Bad context!"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/StepLocatorStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/StepLocatorStepFactoryBeanTests.java index 8d61ec18f..0e5b74734 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/StepLocatorStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/StepLocatorStepFactoryBeanTests.java @@ -1,60 +1,64 @@ package org.springframework.batch.core.step; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.springframework.batch.core.JobInterruptedException; import org.springframework.batch.core.Step; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.job.SimpleJob; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - /** * Tests for StepLocatorStepFactoryBean. - * + * * @author tvaughan */ public class StepLocatorStepFactoryBeanTests { - - @Test - public void testFoo() throws Exception { - Step testStep1 = buildTestStep("foo"); - Step testStep2 = buildTestStep("bar"); - Step testStep3 = buildTestStep("baz"); - - SimpleJob simpleJob = new SimpleJob(); // is a StepLocator - simpleJob.addStep(testStep1); - simpleJob.addStep(testStep2); - simpleJob.addStep(testStep3); - - StepLocatorStepFactoryBean stepLocatorStepFactoryBean = new StepLocatorStepFactoryBean(); - stepLocatorStepFactoryBean.setStepLocator(simpleJob); - stepLocatorStepFactoryBean.setStepName("bar"); - assertEquals(testStep2, stepLocatorStepFactoryBean.getObject()); - } - - private Step buildTestStep(final String stepName) { - return new Step() { - public String getName() { - return stepName; - } - public boolean isAllowStartIfComplete() { - throw new UnsupportedOperationException("Not supported yet."); - } + @Test + public void testFoo() throws Exception { + Step testStep1 = buildTestStep("foo"); + Step testStep2 = buildTestStep("bar"); + Step testStep3 = buildTestStep("baz"); - public int getStartLimit() { - throw new UnsupportedOperationException("Not supported yet."); - } + SimpleJob simpleJob = new SimpleJob(); // is a StepLocator + simpleJob.addStep(testStep1); + simpleJob.addStep(testStep2); + simpleJob.addStep(testStep3); - public void execute(StepExecution stepExecution) throws JobInterruptedException { - throw new UnsupportedOperationException("Not supported yet."); - } - }; - } - - @Test - public void testGetObjectType() { - assertTrue((new StepLocatorStepFactoryBean()).getObjectType().isAssignableFrom(Step.class)); - } + StepLocatorStepFactoryBean stepLocatorStepFactoryBean = new StepLocatorStepFactoryBean(); + stepLocatorStepFactoryBean.setStepLocator(simpleJob); + stepLocatorStepFactoryBean.setStepName("bar"); + assertEquals(testStep2, stepLocatorStepFactoryBean.getObject()); + } + + private Step buildTestStep(final String stepName) { + return new Step() { + @Override + public String getName() { + return stepName; + } + + @Override + public boolean isAllowStartIfComplete() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getStartLimit() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void execute(StepExecution stepExecution) throws JobInterruptedException { + throw new UnsupportedOperationException("Not supported yet."); + } + }; + } + + @Test + public void testGetObjectType() { + assertTrue((new StepLocatorStepFactoryBean()).getObjectType().isAssignableFrom(Step.class)); + } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/StepSupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/StepSupport.java index 2838b6845..f36816aeb 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/StepSupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/StepSupport.java @@ -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,18 +15,18 @@ */ package org.springframework.batch.core.step; -import org.springframework.batch.core.UnexpectedJobExecutionException; import org.springframework.batch.core.JobInterruptedException; import org.springframework.batch.core.Step; import org.springframework.batch.core.StepExecution; +import org.springframework.batch.core.UnexpectedJobExecutionException; import org.springframework.beans.factory.BeanNameAware; /** * Basic no-op support implementation for use as base class for {@link Step}. Implements {@link BeanNameAware} so that * if no name is provided explicitly it will be inferred from the bean definition in Spring configuration. - * + * * @author Dave Syer - * + * */ public class StepSupport implements Step, BeanNameAware { @@ -51,6 +51,7 @@ public class StepSupport implements Step, BeanNameAware { this.name = string; } + @Override public String getName() { return this.name; } @@ -59,9 +60,10 @@ public class StepSupport implements Step, BeanNameAware { * Set the name property if it is not already set. Because of the order of the callbacks in a Spring container the * name property will be set first 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 public void setBeanName(String name) { if (this.name == null) { this.name = name; @@ -70,33 +72,35 @@ public class StepSupport implements Step, 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) { this.name = name; } + @Override public int getStartLimit() { return this.startLimit; } /** * Public setter for the startLimit. - * + * * @param startLimit the startLimit to set */ public void setStartLimit(int startLimit) { this.startLimit = startLimit; } + @Override public boolean isAllowStartIfComplete() { return this.allowStartIfComplete; } /** * Public setter for the shouldAllowStartIfComplete. - * + * * @param allowStartIfComplete the shouldAllowStartIfComplete to set */ public void setAllowStartIfComplete(boolean allowStartIfComplete) { @@ -105,13 +109,14 @@ public class StepSupport implements Step, BeanNameAware { /** * Not supported but provided so that tests can easily create a step. - * + * * @throws UnsupportedOperationException always - * + * * @see org.springframework.batch.core.Step#execute(org.springframework.batch.core.StepExecution) */ + @Override public void execute(StepExecution stepExecution) throws JobInterruptedException, UnexpectedJobExecutionException { throw new UnsupportedOperationException( - "Cannot process a StepExecution. Use a smarter subclass of StepSupport."); + "Cannot process a StepExecution. Use a smarter subclass of StepSupport."); } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/builder/StepBuilderTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/builder/StepBuilderTests.java index 4c8e5699f..a5ebfca8a 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/builder/StepBuilderTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/builder/StepBuilderTests.java @@ -29,7 +29,7 @@ import org.springframework.transaction.PlatformTransactionManager; /** * @author Dave Syer - * + * */ public class StepBuilderTests { @@ -42,6 +42,7 @@ public class StepBuilderTests { PlatformTransactionManager transactionManager = new ResourcelessTransactionManager(); TaskletStepBuilder builder = new StepBuilder("step").repository(jobRepository) .transactionManager(transactionManager).tasklet(new Tasklet() { + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return null; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/BatchRetryTemplateTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/BatchRetryTemplateTests.java index 360b4e939..31a8e34d6 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/BatchRetryTemplateTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/BatchRetryTemplateTests.java @@ -20,6 +20,7 @@ import org.springframework.retry.support.DefaultRetryState; public class BatchRetryTemplateTests { + @SuppressWarnings("serial") private static class RecoverableException extends Exception { public RecoverableException(String message) { @@ -38,6 +39,7 @@ public class BatchRetryTemplateTests { BatchRetryTemplate template = new BatchRetryTemplate(); String result = template.execute(new RetryCallback() { + @Override public String doWithRetry(RetryContext context) throws Exception { assertTrue("Wrong context type: " + context.getClass().getSimpleName(), context.getClass() .getSimpleName().contains("Batch")); @@ -55,6 +57,7 @@ public class BatchRetryTemplateTests { BatchRetryTemplate template = new BatchRetryTemplate(); RetryCallback retryCallback = new RetryCallback() { + @Override public String[] doWithRetry(RetryContext context) throws Exception { assertEquals(count, context.getRetryCount()); if (count++ == 0) { @@ -86,6 +89,7 @@ public class BatchRetryTemplateTests { ., Boolean> singletonMap(Exception.class, true))); RetryCallback retryCallback = new RetryCallback() { + @Override public String[] doWithRetry(RetryContext context) throws Exception { if (count++ < 2) { throw new RecoverableException("Recoverable"); @@ -115,6 +119,7 @@ public class BatchRetryTemplateTests { ., Boolean> singletonMap(Exception.class, true))); RetryCallback retryCallback = new RetryCallback() { + @Override public String[] doWithRetry(RetryContext context) throws Exception { if (count++ < 1) { throw new RecoverableException("Recoverable"); @@ -169,6 +174,7 @@ public class BatchRetryTemplateTests { ., Boolean> singletonMap(Exception.class, true))); RetryCallback retryCallback = new RetryCallback() { + @Override public String[] doWithRetry(RetryContext context) throws Exception { if (count++ < 2) { throw new RecoverableException("Recoverable"); @@ -178,6 +184,7 @@ public class BatchRetryTemplateTests { }; RecoveryCallback recoveryCallback = new RecoveryCallback() { + @Override public String[] recover(RetryContext context) throws Exception { List recovered = new ArrayList(); for (String item : outputs) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkMonitorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkMonitorTests.java index 63c37e93d..13fd1c23a 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkMonitorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkMonitorTests.java @@ -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.batch.item.UnexpectedInputException; /** * @author Dave Syer - * + * */ public class ChunkMonitorTests { /** - * + * */ private static final int CHUNK_SIZE = 5; @@ -47,6 +47,7 @@ public class ChunkMonitorTests { @Before public void setUp() { monitor.setItemReader(new ItemReader() { + @Override public String read() throws Exception, UnexpectedInputException, ParseException { return "" + (count++); } @@ -109,6 +110,7 @@ public class ChunkMonitorTests { @Test(expected = ItemStreamException.class) public void testOpenWithErrorInReader() { monitor.setItemReader(new ItemReader() { + @Override public String read() throws Exception, UnexpectedInputException, ParseException { throw new IllegalStateException("Expected"); } @@ -138,6 +140,7 @@ public class ChunkMonitorTests { public void testUpdateWithNoStream() throws Exception { monitor = new ChunkMonitor(); monitor.setItemReader(new ItemReader() { + @Override public String read() throws Exception, UnexpectedInputException, ParseException { return "" + (count++); } @@ -146,6 +149,6 @@ public class ChunkMonitorTests { monitor.incrementOffset(); ExecutionContext executionContext = new ExecutionContext(); monitor.update(executionContext); - assertEquals(0, executionContext.size()); + assertEquals(0, executionContext.size()); } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkOrientedTaskletTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkOrientedTaskletTests.java index 135067a2e..348234a0f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkOrientedTaskletTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkOrientedTaskletTests.java @@ -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. @@ -29,7 +29,7 @@ import org.springframework.batch.core.scope.context.ChunkContext; /** * @author Dave Syer - * + * */ public class ChunkOrientedTaskletTests { @@ -38,14 +38,17 @@ public class ChunkOrientedTaskletTests { @Test public void testHandle() throws Exception { ChunkOrientedTasklet handler = new ChunkOrientedTasklet(new ChunkProvider() { + @Override public Chunk provide(StepContribution contribution) throws Exception { contribution.incrementReadCount(); Chunk chunk = new Chunk(); chunk.add("foo"); return chunk; } + @Override public void postProcess(StepContribution contribution, Chunk chunk) {}; }, new ChunkProcessor() { + @Override public void process(StepContribution contribution, Chunk chunk) { contribution.incrementWriteCount(1); } @@ -61,11 +64,14 @@ public class ChunkOrientedTaskletTests { @Test public void testFail() throws Exception { ChunkOrientedTasklet handler = new ChunkOrientedTasklet(new ChunkProvider() { + @Override public Chunk provide(StepContribution contribution) throws Exception { throw new RuntimeException("Foo!"); } + @Override public void postProcess(StepContribution contribution, Chunk chunk) {}; }, new ChunkProcessor() { + @Override public void process(StepContribution contribution, Chunk chunk) { fail("Not expecting to get this far"); } @@ -85,6 +91,7 @@ public class ChunkOrientedTaskletTests { @Test public void testExitCode() throws Exception { ChunkOrientedTasklet handler = new ChunkOrientedTasklet(new ChunkProvider() { + @Override public Chunk provide(StepContribution contribution) throws Exception { contribution.incrementReadCount(); Chunk chunk = new Chunk(); @@ -92,8 +99,10 @@ public class ChunkOrientedTaskletTests { chunk.setEnd(); return chunk; } + @Override public void postProcess(StepContribution contribution, Chunk chunk) {}; }, new ChunkProcessor() { + @Override public void process(StepContribution contribution, Chunk chunk) { contribution.incrementWriteCount(1); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ExceptionThrowingTaskletStub.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ExceptionThrowingTaskletStub.java index ed9df6d32..c0fc4550a 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ExceptionThrowingTaskletStub.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ExceptionThrowingTaskletStub.java @@ -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. @@ -31,7 +31,7 @@ import org.springframework.batch.support.transaction.TransactionAwareProxyFactor * @since 2.0.2 */ public class ExceptionThrowingTaskletStub implements Tasklet { - + private int maxTries = 4; protected Log logger = LogFactory.getLog(getClass()); @@ -56,6 +56,7 @@ public class ExceptionThrowingTaskletStub implements Tasklet { committed.clear(); } + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { committed.add(1); if (committed.size()>=maxTries) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessorTests.java index a08506083..e94bcbf72 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessorTests.java @@ -47,6 +47,7 @@ public class FaultTolerantChunkProcessorTests { processor = new FaultTolerantChunkProcessor( new PassThroughItemProcessor(), new ItemWriter() { + @Override public void write(List items) throws Exception { if (items.contains("fail")) { @@ -68,6 +69,7 @@ public class FaultTolerantChunkProcessorTests { @Test public void testTransform() throws Exception { processor.setItemProcessor(new ItemProcessor() { + @Override public String process(String item) throws Exception { return item.equals("1") ? null : item; } @@ -82,6 +84,7 @@ public class FaultTolerantChunkProcessorTests { public void testFilterCountOnSkip() throws Exception { processor.setProcessSkipPolicy(new AlwaysSkipItemSkipPolicy()); processor.setItemProcessor(new ItemProcessor() { + @Override public String process(String item) throws Exception { if (item.equals("1")) { throw new RuntimeException("Skippable"); @@ -107,13 +110,14 @@ public class FaultTolerantChunkProcessorTests { /** * An Error can be retried or skipped but by default it is just propagated - * + * * @throws Exception */ @Test public void testWriteSkipOnError() throws Exception { processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy()); processor.setItemWriter(new ItemWriter() { + @Override public void write(List items) throws Exception { if (items.contains("fail")) { assertFalse("Expected Error!", true); @@ -135,6 +139,7 @@ public class FaultTolerantChunkProcessorTests { public void testWriteSkipOnException() throws Exception { processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy()); processor.setItemWriter(new ItemWriter() { + @Override public void write(List items) throws Exception { if (items.contains("fail")) { throw new RuntimeException("Expected Exception!"); @@ -165,6 +170,7 @@ public class FaultTolerantChunkProcessorTests { public void testWriteSkipOnExceptionWithTrivialChunk() throws Exception { processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy()); processor.setItemWriter(new ItemWriter() { + @Override public void write(List items) throws Exception { if (items.contains("fail")) { throw new RuntimeException("Expected Exception!"); @@ -195,18 +201,20 @@ public class FaultTolerantChunkProcessorTests { @Test public void testTransformWithExceptionAndNoRollback() throws Exception { processor.setItemProcessor(new ItemProcessor() { + @Override public String process(String item) throws Exception { - if (item.equals("1")) + if (item.equals("1")) { throw new DataIntegrityViolationException("Planned"); + } return item; } }); processor.setProcessSkipPolicy(new AlwaysSkipItemSkipPolicy()); processor - .setRollbackClassifier(new BinaryExceptionClassifier( - Collections - .> singleton(DataIntegrityViolationException.class), - false)); + .setRollbackClassifier(new BinaryExceptionClassifier( + Collections + .> singleton(DataIntegrityViolationException.class), + false)); Chunk inputs = new Chunk(Arrays.asList("1", "2")); processor.process(contribution, inputs); assertEquals(1, list.size()); @@ -245,6 +253,7 @@ public class FaultTolerantChunkProcessorTests { processor = new FaultTolerantChunkProcessor( new PassThroughItemProcessor(), new ItemWriter() { + @Override public void write(List items) throws Exception { // Fail if there is more than one item @@ -298,6 +307,7 @@ public class FaultTolerantChunkProcessorTests { processor = new FaultTolerantChunkProcessor( new PassThroughItemProcessor(), new ItemWriter() { + @Override public void write(List items) throws Exception { // Always fail in writer @@ -328,6 +338,7 @@ public class FaultTolerantChunkProcessorTests { batchRetryTemplate.setRetryPolicy(retryPolicy); processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy()); processor.setItemWriter(new ItemWriter() { + @Override public void write(List items) throws Exception { if (items.contains("fail")) { throw new IllegalArgumentException("Expected Exception!"); @@ -372,6 +383,7 @@ public class FaultTolerantChunkProcessorTests { batchRetryTemplate.setRetryPolicy(retryPolicy); processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy()); processor.setItemWriter(new ItemWriter() { + @Override public void write(List items) throws Exception { if (items.contains("fail")) { throw new IllegalArgumentException("Expected Exception!"); @@ -426,6 +438,7 @@ public class FaultTolerantChunkProcessorTests { Collections., Boolean> singletonMap( IllegalArgumentException.class, true))); processor.setItemWriter(new ItemWriter() { + @Override public void write(List items) throws Exception { if (items.contains("fail")) { throw new IllegalArgumentException("Expected Exception!"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProviderTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProviderTests.java index 5c2f30e47..372dd1e46 100755 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProviderTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProviderTests.java @@ -38,6 +38,7 @@ public class FaultTolerantChunkProviderTests { @Test public void testProvideWithOverflow() throws Exception { provider = new FaultTolerantChunkProvider(new ItemReader() { + @Override public String read() throws Exception, UnexpectedInputException, ParseException { throw new RuntimeException("Planned"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantExceptionClassesTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantExceptionClassesTests.java index 82495f47f..12760b2be 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantExceptionClassesTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantExceptionClassesTests.java @@ -51,6 +51,7 @@ public class FaultTolerantExceptionClassesTests implements ApplicationContextAwa private ApplicationContext applicationContext; + @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } @@ -291,9 +292,9 @@ public class FaultTolerantExceptionClassesTests implements ApplicationContextAwa writer.setExceptionType(FatalRuntimeException.class); StepExecution stepExecution = launchStep("noRollbackFatal"); assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus()); - // BATCH-1331: + // BATCH-1331: assertEquals("[1, 2, 3, 1, 2, 3, 4]", writer.getWritten().toString()); - // BATCH-1331: + // BATCH-1331: assertEquals("[1, 2, 3, 4]", writer.getCommitted().toString()); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanNonBufferingTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanNonBufferingTests.java index 6a6d327ca..d6d97e0ea 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanNonBufferingTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanNonBufferingTests.java @@ -133,6 +133,7 @@ public class FaultTolerantStepFactoryBeanNonBufferingTests { this.failures = failures; } + @Override public void write(List items) throws Exception { logger.debug("Writing: " + items); for (String item : items) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java index baa9498ec..d8c163123 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java @@ -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. @@ -62,7 +62,7 @@ import org.springframework.util.StringUtils; /** * @author Dave Syer - * + * */ public class FaultTolerantStepFactoryBeanRetryTests { @@ -90,6 +90,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { JobExecution jobExecution; private ItemWriter writer = new ItemWriter() { + @Override public void write(List data) throws Exception { processed.addAll(data); } @@ -140,6 +141,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { factory.setJobRepository(repository); factory.setTransactionManager(new ResourcelessTransactionManager()); ItemWriter failingWriter = new ItemWriter() { + @Override public void write(List data) throws Exception { int count = 0; for (Integer item : data) { @@ -152,6 +154,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { }; ItemProcessor processor = new ItemProcessor() { + @Override public Integer process(String item) throws Exception { processed.add(item); return Integer.parseInt(item); @@ -175,11 +178,11 @@ public class FaultTolerantStepFactoryBeanRetryTests { jobExecution); repository.add(stepExecution); step.execute(stepExecution); -// System.out.println(stepExecution.getWriteCount()); -// System.out.println(stepExecution.getSkipCount()); -// System.out.println(processed.size()); -// System.out.println(processed); -// System.out.println(written); + // System.out.println(stepExecution.getWriteCount()); + // System.out.println(stepExecution.getSkipCount()); + // System.out.println(processed.size()); + // System.out.println(processed); + // System.out.println(written); /* * Each chunk tried up to RETRY_LIMIT, then the scan processes each item * once, identfiying the skip as it goes @@ -192,6 +195,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { final int RETRY_LIMIT = 3; final List ITEM_LIST = Arrays.asList("a", "b", "c"); ItemWriter failingWriter = new ItemWriter() { + @Override public void write(List data) throws Exception { int count = 0; for (String item : data) { @@ -204,6 +208,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { }; ItemProcessor processor = new ItemProcessor() { + @Override public String process(String item) throws Exception { processed.add(item); return item; @@ -239,6 +244,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { public void testNoItemsReprocessedWhenErrorInWriterAndProcessorNotTransactional() throws Exception { ItemWriter failingWriter = new ItemWriter() { + @Override public void write(List data) throws Exception { int count = 0; for (String item : data) { @@ -251,6 +257,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { }; ItemProcessor processor = new ItemProcessor() { + @Override public String process(String item) throws Exception { processed.add(item); return item; @@ -283,7 +290,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { * failures, but it does test that read errors are re-presented for another * try when the retryLimit is high enough (it is used to build an exception * handler). - * + * * @throws Exception */ @SuppressWarnings("unchecked") @@ -291,6 +298,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { public void testSuccessfulRetryWithReadFailure() throws Exception { ItemReader provider = new ListItemReader(Arrays.asList( "a", "b", "c")) { + @Override public String read() { String item = super.read(); provided.add(item); @@ -355,6 +363,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { factory.setItemReader(reader); factory.setStreams(new ItemStream[] { reader }); factory.setItemWriter(new ItemWriter() { + @Override public void write(List items) throws Exception { if (fail && items.contains("e")) { throw new RuntimeException("Planned failure"); @@ -393,6 +402,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { factory.setSkipLimit(2); ItemReader provider = new ListItemReader(Arrays.asList( "a", "b", "c", "d", "e", "f")) { + @Override public String read() { String item = super.read(); count++; @@ -423,6 +433,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { public void testSkipAndRetryWithWriteFailure() throws Exception { factory.setListeners(new StepListener[] { new SkipListenerSupport() { + @Override public void onSkipInWrite(String item, Throwable t) { recovered.add(item); assertTrue(TransactionSynchronizationManager @@ -432,6 +443,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { factory.setSkipLimit(2); ItemReader provider = new ListItemReader(Arrays.asList( "a", "b", "c", "d", "e", "f")) { + @Override public String read() { String item = super.read(); logger.debug("Read Called! Item: [" + item + "]"); @@ -442,6 +454,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { }; ItemWriter itemWriter = new ItemWriter() { + @Override public void write(List item) throws Exception { logger.debug("Write Called! Item: [" + item + "]"); processed.addAll(item); @@ -484,6 +497,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { factory.setCommitInterval(3); factory.setListeners(new StepListener[] { new SkipListenerSupport() { + @Override public void onSkipInWrite(String item, Throwable t) { recovered.add(item); assertTrue(TransactionSynchronizationManager @@ -493,6 +507,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { factory.setSkipLimit(2); ItemReader provider = new ListItemReader(Arrays.asList( "a", "b", "c", "d", "e", "f")) { + @Override public String read() { String item = super.read(); logger.debug("Read Called! Item: [" + item + "]"); @@ -503,6 +518,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { }; ItemWriter itemWriter = new ItemWriter() { + @Override public void write(List item) throws Exception { logger.debug("Write Called! Item: [" + item + "]"); processed.addAll(item); @@ -549,6 +565,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { factory.setSkipLimit(0); ItemReader provider = new ListItemReader( Arrays.asList("b")) { + @Override public String read() { String item = super.read(); provided.add(item); @@ -557,6 +574,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { } }; ItemWriter itemWriter = new ItemWriter() { + @Override public void write(List item) throws Exception { processed.addAll(item); written.addAll(item); @@ -602,6 +620,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { factory.setSkipLimit(1); ItemReader provider = new ListItemReader( Arrays.asList("b")) { + @Override public String read() { String item = super.read(); provided.add(item); @@ -610,6 +629,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { } }; ItemWriter itemWriter = new ItemWriter() { + @Override public void write(List item) throws Exception { processed.addAll(item); written.addAll(item); @@ -653,6 +673,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { factory.setSkipLimit(0); ItemReader provider = new ListItemReader( Arrays.asList("b")) { + @Override public String read() { String item = super.read(); provided.add(item); @@ -661,6 +682,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { } }; ItemWriter itemWriter = new ItemWriter() { + @Override public void write(List item) throws Exception { processed.addAll(item); written.addAll(item); @@ -701,6 +723,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { // set the cache limit stupidly low factory.setRetryContextCache(new MapRetryContextCache(0)); ItemReader provider = new ItemReader() { + @Override public String read() { String item = "" + count; provided.add(item); @@ -713,6 +736,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { } }; ItemWriter itemWriter = new ItemWriter() { + @Override public void write(List item) throws Exception { processed.addAll(item); logger.debug("Write Called! Item: [" + item + "]"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRollbackTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRollbackTests.java index 2799fcea0..bf646e3fb 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRollbackTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRollbackTests.java @@ -107,32 +107,32 @@ public class FaultTolerantStepFactoryBeanRollbackTests { writer = null; factory = null; } - + @Test public void testBeforeChunkListenerException() throws Exception{ factory.setListeners(new StepListener []{new ExceptionThrowingChunkListener(true)}); Step step = (Step) factory.getObject(); step.execute(stepExecution); assertEquals(FAILED, stepExecution.getStatus()); - assertEquals(FAILED.toString(), stepExecution.getExitStatus().getExitCode()); + assertEquals(FAILED.toString(), stepExecution.getExitStatus().getExitCode()); assertTrue(stepExecution.getCommitCount() == 0);//Make sure exception was thrown in after, not before Throwable e = stepExecution.getFailureExceptions().get(0); assertThat(e, instanceOf(FatalStepExecutionException.class)); assertThat(e.getCause(), instanceOf(IllegalArgumentException.class)); } - + @Test public void testAfterChunkListenerException() throws Exception{ factory.setListeners(new StepListener []{new ExceptionThrowingChunkListener(false)}); Step step = (Step) factory.getObject(); step.execute(stepExecution); assertEquals(FAILED, stepExecution.getStatus()); - assertEquals(FAILED.toString(), stepExecution.getExitStatus().getExitCode()); + assertEquals(FAILED.toString(), stepExecution.getExitStatus().getExitCode()); assertTrue(stepExecution.getCommitCount() > 0);//Make sure exception was thrown in after, not before Throwable e = stepExecution.getFailureExceptions().get(0); assertThat(e, instanceOf(FatalStepExecutionException.class)); assertThat(e.getCause(), instanceOf(IllegalArgumentException.class)); - } + } @Test public void testOverrideWithoutChangingRollbackRules() throws Exception { @@ -587,7 +587,7 @@ public class FaultTolerantStepFactoryBeanRollbackTests { } return map; } - + class ExceptionThrowingChunkListener implements ChunkListener{ private boolean throwBefore = true; @@ -595,16 +595,18 @@ public class FaultTolerantStepFactoryBeanRollbackTests { public ExceptionThrowingChunkListener(boolean throwBefore) { this.throwBefore = throwBefore; } - + + @Override public void beforeChunk() { if(throwBefore){ throw new IllegalArgumentException("Planned exception"); } } + @Override public void afterChunk() { throw new IllegalArgumentException("Planned exception"); - + } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java index ee7ce37bd..84c4c0a02 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java @@ -105,7 +105,7 @@ public class FaultTolerantStepFactoryBeanTests { factory.setSkipLimit(2); factory - .setSkippableExceptionClasses(getExceptionMap(SkippableException.class, SkippableRuntimeException.class)); + .setSkippableExceptionClasses(getExceptionMap(SkippableException.class, SkippableRuntimeException.class)); MapJobRepositoryFactoryBean repositoryFactory = new MapJobRepositoryFactoryBean(); repositoryFactory.afterPropertiesSet(); @@ -119,7 +119,7 @@ public class FaultTolerantStepFactoryBeanTests { /** * Non-skippable (and non-fatal) exception causes failure immediately. - * + * * @throws Exception */ @SuppressWarnings("unchecked") @@ -214,6 +214,7 @@ public class FaultTolerantStepFactoryBeanTests { factory.setSkipLimit(0); factory.setSkipPolicy(new SkipPolicy() { + @Override public boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException { throw new RuntimeException("Planned exception in SkipPolicy"); } @@ -224,7 +225,7 @@ public class FaultTolerantStepFactoryBeanTests { Step step = (Step) factory.getObject(); step.execute(stepExecution); - + assertEquals(BatchStatus.FAILED, stepExecution.getStatus()); assertEquals(0, stepExecution.getReadSkipCount()); assertEquals(1, stepExecution.getReadCount()); @@ -241,6 +242,7 @@ public class FaultTolerantStepFactoryBeanTests { factory.setSkipLimit(0); factory.setSkipPolicy(new SkipPolicy() { + @Override public boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException { throw new RuntimeException("Planned exception in SkipPolicy"); } @@ -251,7 +253,7 @@ public class FaultTolerantStepFactoryBeanTests { Step step = (Step) factory.getObject(); step.execute(stepExecution); - + assertEquals(BatchStatus.FAILED, stepExecution.getStatus()); assertEquals(0, stepExecution.getWriteSkipCount()); assertEquals(2, stepExecution.getReadCount()); @@ -420,6 +422,7 @@ public class FaultTolerantStepFactoryBeanTests { map.put(FatalRuntimeException.class, false); factory.setSkippableExceptionClasses(map); factory.setItemWriter(new ItemWriter() { + @Override public void write(List items) { throw new FatalRuntimeException("Ouch!"); } @@ -732,58 +735,73 @@ public class FaultTolerantStepFactoryBeanTests { final List listenerCalls = new ArrayList(); class TestItemListenerWriter implements ItemWriter, ItemReadListener, - ItemWriteListener, ItemProcessListener, SkipListener, - ChunkListener { + ItemWriteListener, ItemProcessListener, SkipListener, + ChunkListener { + @Override public void write(List items) throws Exception { if (items.contains("4")) { throw new SkippableException("skippable"); } } + @Override public void afterRead(String item) { listenerCalls.add(1); } + @Override public void beforeRead() { } + @Override public void onReadError(Exception ex) { } + @Override public void afterWrite(List items) { listenerCalls.add(2); } + @Override public void beforeWrite(List items) { } + @Override public void onWriteError(Exception exception, List items) { } + @Override public void afterProcess(String item, String result) { listenerCalls.add(3); } + @Override public void beforeProcess(String item) { } + @Override public void onProcessError(String item, Exception e) { } + @Override public void afterChunk() { listenerCalls.add(4); } + @Override public void beforeChunk() { } + @Override public void onSkipInProcess(String item, Throwable t) { } + @Override public void onSkipInRead(Throwable t) { listenerCalls.add(6); } + @Override public void onSkipInWrite(String item, Throwable t) { listenerCalls.add(5); } @@ -809,17 +827,21 @@ public class FaultTolerantStepFactoryBeanTests { writer.setFailures("4"); ItemStreamReader reader = new ItemStreamReader() { + @Override public void close() throws ItemStreamException { closed = true; } + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { opened = true; } + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { } + @Override public String read() throws Exception, UnexpectedInputException, ParseException { return null; } @@ -845,32 +867,40 @@ public class FaultTolerantStepFactoryBeanTests { writer.setFailures("4"); ItemStreamReader reader = new ItemStreamReader() { + @Override public void close() throws ItemStreamException { } + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { } + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { } + @Override public String read() throws Exception, UnexpectedInputException, ParseException { return null; } }; ItemStreamReader stream = new ItemStreamReader() { + @Override public void close() throws ItemStreamException { closed = true; } + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { opened = true; } + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { } + @Override public String read() throws Exception, UnexpectedInputException, ParseException { return null; } @@ -897,17 +927,21 @@ public class FaultTolerantStepFactoryBeanTests { writer.setFailures("4"); ItemStreamReader reader = new ItemStreamReader() { + @Override public void close() throws ItemStreamException { closed = true; } + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { opened = true; } + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { } + @Override public String read() throws Exception, UnexpectedInputException, ParseException { return null; } @@ -917,6 +951,7 @@ public class FaultTolerantStepFactoryBeanTests { proxy.setTarget(reader); proxy.setInterfaces(new Class[] { ItemReader.class, ItemStream.class }); proxy.addAdvice(new MethodInterceptor() { + @Override public Object invoke(MethodInvocation invocation) throws Throwable { return invocation.proceed(); } @@ -939,16 +974,19 @@ public class FaultTolerantStepFactoryBeanTests { private boolean filterEncountered = false; + @Override public void afterProcess(T item, S result) { if (result == null) { filterEncountered = true; } } + @Override public void beforeProcess(T item) { } + @Override public void onProcessError(T item, Exception e) { } @@ -979,7 +1017,7 @@ public class FaultTolerantStepFactoryBeanTests { /** * condition: skippable < fatal; exception is unclassified - * + * * expected: false; default classification */ @Test @@ -989,7 +1027,7 @@ public class FaultTolerantStepFactoryBeanTests { /** * condition: skippable < fatal; exception is skippable - * + * * expected: true */ @Test @@ -999,7 +1037,7 @@ public class FaultTolerantStepFactoryBeanTests { /** * condition: skippable < fatal; exception is fatal - * + * * expected: false */ @Test @@ -1009,7 +1047,7 @@ public class FaultTolerantStepFactoryBeanTests { /** * condition: fatal < skippable; exception is unclassified - * + * * expected: false; default classification */ @Test @@ -1019,7 +1057,7 @@ public class FaultTolerantStepFactoryBeanTests { /** * condition: fatal < skippable; exception is skippable - * + * * expected: true */ @Test @@ -1029,7 +1067,7 @@ public class FaultTolerantStepFactoryBeanTests { /** * condition: fatal < skippable; exception is fatal - * + * * expected: false */ @Test @@ -1053,6 +1091,7 @@ public class FaultTolerantStepFactoryBeanTests { return getSkipPolicy(factory); } + @SuppressWarnings("rawtypes") private SkipPolicy getSkipPolicy(FactoryBean factory) throws Exception { Object step = factory.getObject(); Object tasklet = ReflectionTestUtils.getField(step, "tasklet"); @@ -1067,9 +1106,10 @@ public class FaultTolerantStepFactoryBeanTests { } return map; } - + + @SuppressWarnings("serial") public static class NonExistentException extends Exception { - + } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanUnexpectedRollbackTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanUnexpectedRollbackTests.java index 1bb17378d..7aed2fe90 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanUnexpectedRollbackTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanUnexpectedRollbackTests.java @@ -36,7 +36,7 @@ import org.springframework.transaction.support.DefaultTransactionStatus; public class FaultTolerantStepFactoryBeanUnexpectedRollbackTests { protected final Log logger = LogFactory.getLog(getClass()); - + @Autowired private DataSource dataSource; @@ -47,8 +47,10 @@ public class FaultTolerantStepFactoryBeanUnexpectedRollbackTests { FaultTolerantStepFactoryBean factory = new FaultTolerantStepFactoryBean(); factory.setItemWriter(writer); + @SuppressWarnings("serial") DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource) { private boolean failed = false; + @Override protected void doCommit(DefaultTransactionStatus status) throws TransactionException { if (writer.getWritten().isEmpty() || failed || !isExistingTransaction(status.getTransaction())) { super.doCommit(status); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBeanTests.java index b65728232..1bf9b97b7 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBeanTests.java @@ -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.batch.support.transaction.ResourcelessTransactionMana /** * @author Dave Syer - * + * */ public class RepeatOperationsStepFactoryBeanTests extends TestCase { @@ -46,6 +46,7 @@ public class RepeatOperationsStepFactoryBeanTests extends TestCase { private JobExecution jobExecution = new JobExecution(new JobInstance(0L, new JobParameters(), "job")); + @Override protected void setUp() throws Exception { factory.setBeanName("RepeatOperationsStep"); factory.setItemReader(new ListItemReader(new ArrayList())); @@ -71,6 +72,7 @@ public class RepeatOperationsStepFactoryBeanTests extends TestCase { factory.setStepOperations(new RepeatOperations() { + @Override public RepeatStatus iterate(RepeatCallback callback) { list = new ArrayList(); list.add("foo"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleChunkProcessorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleChunkProcessorTests.java index e9f68b294..545936915 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleChunkProcessorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleChunkProcessorTests.java @@ -20,6 +20,7 @@ public class SimpleChunkProcessorTests { private SimpleChunkProcessor processor = new SimpleChunkProcessor( new ItemProcessor() { + @Override public String process(String item) throws Exception { if (item.equals("err")) { return null; @@ -27,6 +28,7 @@ public class SimpleChunkProcessorTests { return item; } }, new ItemWriter() { + @Override public void write(List items) throws Exception { if (items.contains("fail")) { throw new RuntimeException("Planned failure!"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandlerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandlerTests.java index 75991dfac..b4e3df0ec 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandlerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandlerTests.java @@ -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.retry.policy.NeverRetryPolicy; /** * @author Dave Syer - * + * */ public class SimpleRetryExceptionHandlerTests extends TestCase { @@ -39,18 +39,20 @@ public class SimpleRetryExceptionHandlerTests extends TestCase { /* * (non-Javadoc) - * + * * @see junit.framework.TestCase#setUp() */ + @Override protected void setUp() throws Exception { RepeatSynchronizationManager.register(context); } /* * (non-Javadoc) - * + * * @see junit.framework.TestCase#tearDown() */ + @Override protected void tearDown() throws Exception { RepeatSynchronizationManager.clear(); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java index 428b02853..d362bff4f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java @@ -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. @@ -70,6 +70,7 @@ public class SimpleStepFactoryBeanTests { private List written = new ArrayList(); private ItemWriter writer = new ItemWriter() { + @Override public void write(List data) throws Exception { written.addAll(data); } @@ -134,6 +135,7 @@ public class SimpleStepFactoryBeanTests { SimpleStepFactoryBean factory = getStepFactory(new String[] { "foo", "bar", "spam" }); factory.setItemWriter(new ItemWriter() { + @Override public void write(List data) throws Exception { throw new RuntimeException("Error!"); } @@ -171,6 +173,7 @@ public class SimpleStepFactoryBeanTests { SimpleStepFactoryBean factory = getStepFactory(new String[] { "foo", "bar", "spam" }); factory.setBeanName("exceptionStep"); factory.setItemWriter(new ItemWriter() { + @Override public void write(List data) throws Exception { throw new RuntimeException("Foo"); } @@ -195,6 +198,7 @@ public class SimpleStepFactoryBeanTests { factory.setItemWriter(new ItemWriter() { int count = 0; + @Override public void write(List data) throws Exception { if (count++ == 0) { throw new RuntimeException("Foo"); @@ -244,11 +248,13 @@ public class SimpleStepFactoryBeanTests { this.writeListener = writeListener; } + @Override public void afterChunk() { writeListener.trail = writeListener.trail + "4"; afterCount++; } + @Override public void beforeChunk() { writeListener.trail = writeListener.trail + "1"; beforeCount++; @@ -328,48 +334,61 @@ public class SimpleStepFactoryBeanTests { final List listenerCalls = new ArrayList(); class TestItemListenerWriter implements ItemWriter, ItemProcessor, - ItemReadListener, ItemWriteListener, ItemProcessListener, ChunkListener { + ItemReadListener, ItemWriteListener, ItemProcessListener, ChunkListener { + @Override public void write(List items) throws Exception { } + @Override public String process(String item) throws Exception { return item; } + @Override public void afterRead(String item) { listenerCalls.add("read"); } + @Override public void beforeRead() { } + @Override public void onReadError(Exception ex) { } + @Override public void afterWrite(List items) { listenerCalls.add("write"); } + @Override public void beforeWrite(List items) { } + @Override public void onWriteError(Exception exception, List items) { } + @Override public void afterProcess(String item, String result) { listenerCalls.add("process"); } + @Override public void beforeProcess(String item) { } + @Override public void onProcessError(String item, Exception e) { } + @Override public void afterChunk() { listenerCalls.add("chunk"); } + @Override public void beforeChunk() { } @@ -401,16 +420,20 @@ public class SimpleStepFactoryBeanTests { final List listenerCalls = new ArrayList(); class TestItemListenerWriter implements ItemWriter, ItemWriteListener { + @Override public void write(List items) throws Exception { } + @Override public void afterWrite(List items) { listenerCalls.add("write"); } + @Override public void beforeWrite(List items) { } + @Override public void onWriteError(Exception exception, List items) { } @@ -439,6 +462,7 @@ public class SimpleStepFactoryBeanTests { SimpleStepFactoryBean factory = getStepFactory(new String[] { "foo", "bar", "spam" }); factory.setItemWriter(null); factory.setItemProcessor(new ItemProcessor() { + @Override public String process(String item) throws Exception { written.add(item); return null; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipProcessorStub.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipProcessorStub.java index 613624de6..195d4de09 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipProcessorStub.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipProcessorStub.java @@ -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. @@ -55,6 +55,7 @@ public class SkipProcessorStub extends AbstractExceptionThrowingItemHandlerSt filter = false; } + @Override public T process(T item) throws Exception { processed.add(item); committed.add(item); @@ -71,4 +72,4 @@ public class SkipProcessorStub extends AbstractExceptionThrowingItemHandlerSt } return item; } -} \ No newline at end of file +} diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipReaderStub.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipReaderStub.java index 9c3bf9257..3e510bb75 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipReaderStub.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipReaderStub.java @@ -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. @@ -58,6 +58,7 @@ public class SkipReaderStub extends AbstractExceptionThrowingItemHandlerStub< read.clear(); } + @Override public T read() throws Exception, UnexpectedInputException, ParseException { counter++; if (counter >= items.length) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipWriterStub.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipWriterStub.java index 103eef785..048f85fbb 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipWriterStub.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipWriterStub.java @@ -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. @@ -48,6 +48,7 @@ public class SkipWriterStub extends AbstractExceptionThrowingItemHandlerStub< committed.clear(); } + @Override public void write(List items) throws Exception { logger.debug("Writing: " + items); for (T item : items) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/TaskletStepExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/TaskletStepExceptionTests.java index e57f4c371..35fee14ec 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/TaskletStepExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/TaskletStepExceptionTests.java @@ -1,5 +1,5 @@ /** - * + * */ package org.springframework.batch.core.step.item; @@ -42,10 +42,10 @@ import org.springframework.transaction.support.TransactionSynchronizationManager /** * Tests for the behavior of TaskletStep in a failure scenario. - * + * * @author Lucas Ward * @author Dave Syer - * + * */ public class TaskletStepExceptionTests { @@ -90,6 +90,7 @@ public class TaskletStepExceptionTests { @Test public void testInterruptedWithCustomStatus() throws Exception { taskletStep.setTasklet(new Tasklet() { + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { contribution.setExitStatus(new ExitStatus("FUNNY")); throw new JobInterruptedException("Planned"); @@ -144,6 +145,7 @@ public class TaskletStepExceptionTests { } }); taskletStep.setTasklet(new Tasklet() { + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; } @@ -193,6 +195,7 @@ public class TaskletStepExceptionTests { assertEquals(2, jobRepository.getUpdateCount()); } + @SuppressWarnings("serial") @Test public void testCommitError() throws Exception { @@ -210,6 +213,7 @@ public class TaskletStepExceptionTests { taskletStep.setTasklet(new Tasklet() { + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { attributes.getStepContext().getStepExecution().getExecutionContext().putString("foo", "bar"); return RepeatStatus.FINISHED; @@ -223,11 +227,12 @@ public class TaskletStepExceptionTests { assertEquals("foo", e.getMessage()); assertEquals(0, stepExecution.getCommitCount()); assertEquals(1, stepExecution.getRollbackCount()); // Failed transaction - // counts as - // rollback + // counts as + // rollback assertEquals(0, stepExecution.getExecutionContext().size()); } + @SuppressWarnings("serial") @Test public void testUnexpectedRollback() throws Exception { @@ -241,6 +246,7 @@ public class TaskletStepExceptionTests { taskletStep.setTasklet(new Tasklet() { + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { attributes.getStepContext().getStepExecution().getExecutionContext().putString("foo", "bar"); return RepeatStatus.FINISHED; @@ -254,8 +260,8 @@ public class TaskletStepExceptionTests { assertEquals("bar", e.getMessage()); assertEquals(0, stepExecution.getCommitCount()); assertEquals(1, stepExecution.getRollbackCount()); // Failed transaction - // counts as - // rollback + // counts as + // rollback assertEquals(0, stepExecution.getExecutionContext().size()); } @@ -264,6 +270,7 @@ public class TaskletStepExceptionTests { taskletStep.setTasklet(new Tasklet() { + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; } @@ -283,6 +290,7 @@ public class TaskletStepExceptionTests { taskletStep.setTasklet(new Tasklet() { + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; } @@ -303,6 +311,7 @@ public class TaskletStepExceptionTests { taskletStep.setTasklet(new Tasklet() { + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; } @@ -322,6 +331,7 @@ public class TaskletStepExceptionTests { taskletStep.setTasklet(new Tasklet() { + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { throw new RuntimeException("Tasklet exception"); } @@ -361,6 +371,7 @@ public class TaskletStepExceptionTests { private static class ExceptionTasklet implements Tasklet { + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { throw taskletException; } @@ -396,29 +407,36 @@ public class TaskletStepExceptionTests { this.failInTransaction = failInTransaction; } + @Override public void add(StepExecution stepExecution) { } + @Override public JobExecution createJobExecution(String jobName, JobParameters jobParameters) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException { return null; } + @Override public StepExecution getLastStepExecution(JobInstance jobInstance, String stepName) { return null; } + @Override public int getStepExecutionCount(JobInstance jobInstance, String stepName) { return 0; } + @Override public boolean isJobInstanceExists(String jobName, JobParameters jobParameters) { return false; } + @Override public void update(JobExecution jobExecution) { } + @Override public void update(StepExecution stepExecution) { if (updateCount == failOnUpdateExecution) { throw new RuntimeException("Expected exception in step execution persistence"); @@ -426,6 +444,7 @@ public class TaskletStepExceptionTests { updateCount++; } + @Override public void updateExecutionContext(StepExecution stepExecution) { if (failOnUpdateContext) { if (!failInTransaction @@ -439,10 +458,12 @@ public class TaskletStepExceptionTests { return updateCount; } + @Override public JobExecution getLastJobExecution(String jobName, JobParameters jobParameters) { return null; } + @Override public void updateExecutionContext(JobExecution jobExecution) { } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncChunkOrientedStepIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncChunkOrientedStepIntegrationTests.java index 517fb99b4..7600d86a7 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncChunkOrientedStepIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncChunkOrientedStepIntegrationTests.java @@ -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. @@ -50,7 +50,7 @@ import org.springframework.transaction.PlatformTransactionManager; /** * @author Dave Syer - * + * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "/org/springframework/batch/core/repository/dao/sql-dao-test.xml") @@ -80,17 +80,17 @@ public class AsyncChunkOrientedStepIntegrationTests { private ItemReader getReader(String[] args) { return new ListItemReader(Arrays.asList(args)); } - + @After public void reset() { // Reset concurrency settings to something reasonable dataSource.setMaxActive(maxActive); - dataSource.setMaxIdle(maxIdle); + dataSource.setMaxIdle(maxIdle); } @Before public void init() throws Exception { - + maxActive = dataSource.getMaxActive(); maxIdle = dataSource.getMaxIdle(); @@ -121,6 +121,7 @@ public class AsyncChunkOrientedStepIntegrationTests { step.setTasklet(new TestingChunkOrientedTasklet(getReader(new String[] { "a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c" }), new ItemWriter() { + @Override public void write(List data) throws Exception { written.addAll(data); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncTaskletStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncTaskletStepTests.java index 972a8b08a..ec89ec172 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncTaskletStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncTaskletStepTests.java @@ -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. @@ -57,6 +57,7 @@ public class AsyncTaskletStepTests { private int throttleLimit = 20; ItemWriter itemWriter = new ItemWriter() { + @Override public void write(List data) throws Exception { // Thread.sleep(100L); logger.info("Items: " + data); @@ -171,6 +172,7 @@ public class AsyncTaskletStepTests { concurrencyLimit = 1; items = Arrays.asList("one", "barf", "three", "four"); itemProcessor = new ItemProcessor() { + @Override public String process(String item) throws Exception { logger.info("Item: "+item); processed.add(item); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapterTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapterTests.java index 070be37e1..5254de2fe 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapterTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapterTests.java @@ -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.junit.Test; import org.springframework.batch.repeat.RepeatStatus; public class CallableTaskletAdapterTests { - + private CallableTaskletAdapter adapter = new CallableTaskletAdapter(); @Test public void testHandle() throws Exception { adapter.setCallable(new Callable() { + @Override public RepeatStatus call() throws Exception { return RepeatStatus.FINISHED; } @@ -47,5 +48,5 @@ public class CallableTaskletAdapterTests { // expected } } - + } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/ChunkOrientedStepIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/ChunkOrientedStepIntegrationTests.java index ee6eb8548..864ebc288 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/ChunkOrientedStepIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/ChunkOrientedStepIntegrationTests.java @@ -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. @@ -48,7 +48,7 @@ import org.springframework.transaction.support.TransactionSynchronizationManager /** * @author Dave Syer - * + * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "/org/springframework/batch/core/repository/dao/sql-dao-test.xml") @@ -87,20 +87,23 @@ public class ChunkOrientedStepIntegrationTests { } + @SuppressWarnings("serial") @Test public void testStatusForCommitFailedException() throws Exception { step.setTasklet(new TestingChunkOrientedTasklet(getReader(new String[] { "a", "b", "c" }), new ItemWriter() { - public void write(List data) throws Exception { - TransactionSynchronizationManager - .registerSynchronization(new TransactionSynchronizationAdapter() { - public void beforeCommit(boolean readOnly) { - throw new RuntimeException("Simulate commit failure"); - } - }); + @Override + public void write(List data) throws Exception { + TransactionSynchronizationManager + .registerSynchronization(new TransactionSynchronizationAdapter() { + @Override + public void beforeCommit(boolean readOnly) { + throw new RuntimeException("Simulate commit failure"); } - }, chunkOperations)); + }); + } + }, chunkOperations)); JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters(Collections .singletonMap("run.id", new JobParameter(getClass().getName() + ".1")))); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java index 9254b449b..0b20c1be0 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java @@ -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. @@ -65,7 +65,7 @@ public class StepExecutorInterruptionTests { } private void configureStep(TaskletStep step) throws JobExecutionAlreadyRunningException, JobRestartException, - JobInstanceAlreadyCompleteException { + JobInstanceAlreadyCompleteException { this.step = step; JobSupport job = new JobSupport(); @@ -75,6 +75,7 @@ public class StepExecutorInterruptionTests { step.setJobRepository(jobRepository); step.setTransactionManager(new ResourcelessTransactionManager()); itemWriter = new ItemWriter() { + @Override public void write(List item) throws Exception { } }; @@ -92,6 +93,7 @@ public class StepExecutorInterruptionTests { // N.B, If we don't set the completion policy it might run forever template.setCompletionPolicy(new SimpleCompletionPolicy(2)); step.setTasklet(new TestingChunkOrientedTasklet(new ItemReader() { + @Override public Object read() throws Exception { // do something non-trivial (and not Thread.sleep()) double foo = 1; @@ -132,6 +134,7 @@ public class StepExecutorInterruptionTests { // is taken. configureStep(new TaskletStep("step") { + @SuppressWarnings("serial") @Override protected Semaphore createSemaphore() { return new Semaphore(1) { @@ -152,6 +155,7 @@ public class StepExecutorInterruptionTests { Thread processingThread = createThread(stepExecution); step.setTasklet(new TestingChunkOrientedTasklet(new ItemReader() { + @Override public Object read() throws Exception { return null; } @@ -176,6 +180,7 @@ public class StepExecutorInterruptionTests { public void testLockNotReleasedIfChunkFails() throws Exception { configureStep(new TaskletStep("step") { + @SuppressWarnings("serial") @Override protected Semaphore createSemaphore() { return new Semaphore(1) { @@ -195,6 +200,7 @@ public class StepExecutorInterruptionTests { }); step.setTasklet(new TestingChunkOrientedTasklet(new ItemReader() { + @Override public Object read() throws Exception { throw new RuntimeException("Planned!"); } @@ -212,6 +218,7 @@ public class StepExecutorInterruptionTests { */ private Thread createThread(final StepExecution stepExecution) { Thread processingThread = new Thread() { + @Override public void run() { try { jobRepository.add(stepExecution); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandTaskletIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandTaskletIntegrationTests.java index 37f36a512..89711b90f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandTaskletIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandTaskletIntegrationTests.java @@ -223,6 +223,7 @@ public class SystemCommandTaskletIntegrationTests { */ private static class TestExitCodeMapper implements SystemProcessExitCodeMapper { + @Override public ExitStatus getExitStatus(int exitCode) { if (exitCode == 0) { return ExitStatus.COMPLETED; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java index 04576898f..847fcf0bf 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java @@ -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. @@ -73,6 +73,7 @@ public class TaskletStepTests { private List list = new ArrayList(); ItemWriter itemWriter = new ItemWriter() { + @Override public void write(List data) throws Exception { processed.addAll(data); } @@ -86,6 +87,7 @@ public class TaskletStepTests { private ResourcelessTransactionManager transactionManager; + @SuppressWarnings("serial") private ExecutionContext foobarEc = new ExecutionContext() { { put("foo", "bar"); @@ -99,7 +101,7 @@ public class TaskletStepTests { private TaskletStep getStep(String[] strings) throws Exception { return getStep(strings, 1); } - + private TaskletStep getStep(String[] strings, int commitInterval) throws Exception { TaskletStep step = new TaskletStep("stepName"); // Only process one item: @@ -240,6 +242,7 @@ public class TaskletStepTests { ItemReader itemReader = new ItemReader() { + @Override public String read() throws Exception { throw new RuntimeException(); } @@ -264,6 +267,7 @@ public class TaskletStepTests { ItemReader itemReader = new ItemReader() { + @Override public String read() throws Exception { throw new RuntimeException(); @@ -289,6 +293,7 @@ public class TaskletStepTests { ItemReader itemReader = new ItemReader() { + @Override public String read() throws Exception { throw new RuntimeException(); @@ -340,6 +345,7 @@ public class TaskletStepTests { final JobExecution jobExecution = new JobExecution(jobInstance); final StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); step.setJobRepository(new JobRepositorySupport() { + @Override public void updateExecutionContext(StepExecution stepExecution) { list.add(stepExecution); } @@ -359,9 +365,11 @@ public class TaskletStepTests { private int counter = 0; // initial save before item processing succeeds, later calls fail + @Override public void updateExecutionContext(StepExecution stepExecution) { - if (counter > 0) + if (counter > 0) { throw new RuntimeException("foo"); + } counter++; } }); @@ -402,6 +410,7 @@ public class TaskletStepTests { @Test public void testRestartJobOnNonRestartableTasklet() throws Exception { step.setTasklet(new TestingChunkOrientedTasklet(new ItemReader() { + @Override public String read() throws Exception { return "foo"; } @@ -415,10 +424,12 @@ public class TaskletStepTests { @Test public void testStreamManager() throws Exception { MockRestartableItemReader reader = new MockRestartableItemReader() { + @Override public String read() throws Exception { return "foo"; } + @Override public void update(ExecutionContext executionContext) { executionContext.putString("foo", "bar"); } @@ -440,6 +451,7 @@ public class TaskletStepTests { @Test public void testDirectlyInjectedItemStream() throws Exception { step.setStreams(new ItemStream[] { new ItemStreamSupport() { + @Override public void update(ExecutionContext executionContext) { executionContext.putString("foo", "bar"); } @@ -457,10 +469,12 @@ public class TaskletStepTests { @Test public void testDirectlyInjectedListener() throws Exception { step.registerStepExecutionListener(new StepExecutionListenerSupport() { + @Override public void beforeStep(StepExecution stepExecution) { list.add("foo"); } + @Override public ExitStatus afterStep(StepExecution stepExecution) { list.add("bar"); return null; @@ -475,10 +489,12 @@ public class TaskletStepTests { @Test public void testListenerCalledBeforeStreamOpened() throws Exception { MockRestartableItemReader reader = new MockRestartableItemReader() { + @Override public void beforeStep(StepExecution stepExecution) { list.add("foo"); } + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { assertEquals(1, list.size()); } @@ -496,6 +512,7 @@ public class TaskletStepTests { final ExitStatus customStatus = new ExitStatus("COMPLETED_CUSTOM"); step.setStepExecutionListeners(new StepExecutionListener[] { new StepExecutionListenerSupport() { + @Override public ExitStatus afterStep(StepExecution stepExecution) { list.add("afterStepCalled"); return customStatus; @@ -518,12 +535,14 @@ public class TaskletStepTests { @Test public void testDirectlyInjectedListenerOnError() throws Exception { step.registerStepExecutionListener(new StepExecutionListenerSupport() { + @Override public ExitStatus afterStep(StepExecution stepExecution) { list.add("exception"); return null; } }); step.setTasklet(new TestingChunkOrientedTasklet(new MockRestartableItemReader() { + @Override public String read() throws Exception { throw new RuntimeException("FOO"); } @@ -538,10 +557,12 @@ public class TaskletStepTests { @Test public void testDirectlyInjectedStreamWhichIsAlsoReader() throws Exception { MockRestartableItemReader reader = new MockRestartableItemReader() { + @Override public String read() throws Exception { return "foo"; } + @Override public void update(ExecutionContext executionContext) { executionContext.putString("foo", "bar"); } @@ -565,6 +586,7 @@ public class TaskletStepTests { StepInterruptionPolicy interruptionPolicy = new StepInterruptionPolicy() { + @Override public void checkInterrupted(StepExecution stepExecution) throws JobInterruptedException { throw new JobInterruptedException("interrupted"); } @@ -574,6 +596,7 @@ public class TaskletStepTests { ItemReader itemReader = new ItemReader() { + @Override public String read() throws Exception { throw new RuntimeException(); @@ -599,6 +622,7 @@ public class TaskletStepTests { public void testStatusForNormalFailure() throws Exception { ItemReader itemReader = new ItemReader() { + @Override public String read() throws Exception { // Trigger a rollback throw new RuntimeException("Foo"); @@ -622,6 +646,7 @@ public class TaskletStepTests { public void testStatusForErrorFailure() throws Exception { ItemReader itemReader = new ItemReader() { + @Override public String read() throws Exception { // Trigger a rollback throw new Error("Foo"); @@ -641,10 +666,12 @@ public class TaskletStepTests { assertEquals("Foo", stepExecution.getFailureExceptions().get(0).getMessage()); } + @SuppressWarnings("serial") @Test public void testStatusForResetFailedException() throws Exception { ItemReader itemReader = new ItemReader() { + @Override public String read() throws Exception { // Trigger a rollback throw new RuntimeException("Foo"); @@ -652,6 +679,7 @@ public class TaskletStepTests { }; step.setTasklet(new TestingChunkOrientedTasklet(itemReader, itemWriter)); step.setTransactionManager(new ResourcelessTransactionManager() { + @Override protected void doRollback(DefaultTransactionStatus status) throws TransactionException { // Simulate failure on rollback when stream resets throw new RuntimeException("Bar"); @@ -672,10 +700,12 @@ public class TaskletStepTests { assertEquals("Bar", stepExecution.getFailureExceptions().get(0).getMessage()); } + @SuppressWarnings("serial") @Test public void testStatusForCommitFailedException() throws Exception { step.setTransactionManager(new ResourcelessTransactionManager() { + @Override protected void doCommit(DefaultTransactionStatus status) throws TransactionException { // Simulate failure on commit throw new RuntimeException("Foo"); @@ -704,6 +734,7 @@ public class TaskletStepTests { step.setJobRepository(new JobRepositorySupport()); step.setStreams(new ItemStream[] { new ItemStreamSupport() { + @Override public void close() throws ItemStreamException { throw new RuntimeException("Bar"); } @@ -727,6 +758,7 @@ public class TaskletStepTests { public void testStatusForCloseFailedException() throws Exception { MockRestartableItemReader itemReader = new MockRestartableItemReader() { + @Override public void close() throws ItemStreamException { super.close(); // Simulate failure on rollback when stream resets @@ -760,6 +792,7 @@ public class TaskletStepTests { @Test public void testRestartAfterFailureInFirstChunk() throws Exception { MockRestartableItemReader reader = new MockRestartableItemReader() { + @Override public String read() throws Exception { // fail on the very first item throw new RuntimeException("CRASH!"); @@ -796,13 +829,14 @@ public class TaskletStepTests { } /** - * Exception in {@link StepExecutionListener#afterStep(StepExecution)} + * Exception in {@link StepExecutionListener#afterStep(StepExecution)} * doesn't cause step failure. * @throws JobInterruptedException */ @Test public void testStepFailureInAfterStepCallback() throws JobInterruptedException { StepExecutionListener listener = new StepExecutionListenerSupport() { + @Override public ExitStatus afterStep(StepExecution stepExecution) { throw new RuntimeException("exception thrown in afterStep to signal failure"); } @@ -819,6 +853,7 @@ public class TaskletStepTests { public void testNoRollbackFor() throws Exception { step.setTasklet(new Tasklet() { + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { throw new RuntimeException("Bar"); } @@ -827,8 +862,9 @@ public class TaskletStepTests { JobExecution jobExecutionContext = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); + @SuppressWarnings("serial") DefaultTransactionAttribute transactionAttribute = new DefaultTransactionAttribute() { - @Override + @Override public boolean rollbackOn(Throwable ex) { return false; } @@ -842,6 +878,7 @@ public class TaskletStepTests { @Test public void testTaskletExecuteReturnNull() throws Exception { step.setTasklet(new Tasklet() { + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return null; } @@ -851,7 +888,7 @@ public class TaskletStepTests { step.execute(stepExecution); assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus()); } - + private static class JobRepositoryStub extends JobRepositorySupport { private int updateCount = 0; @@ -870,6 +907,7 @@ public class TaskletStepTests { private int called = 0; + @Override public void update(StepExecution stepExecution) { called++; if (called == 3) { @@ -879,16 +917,18 @@ public class TaskletStepTests { } private class MockRestartableItemReader extends ItemStreamSupport implements ItemReader, - StepExecutionListener { + StepExecutionListener { private boolean getExecutionAttributesCalled = false; private boolean restoreFromCalled = false; + @Override public String read() throws Exception { return "item"; } + @Override public void update(ExecutionContext executionContext) { getExecutionAttributesCalled = true; executionContext.putString("spam", "bucket"); @@ -902,10 +942,12 @@ public class TaskletStepTests { return restoreFromCalled; } + @Override public ExitStatus afterStep(StepExecution stepExecution) { return null; } + @Override public void beforeStep(StepExecution stepExecution) { } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/test/namespace/config/DummyNamespaceHandler.java b/spring-batch-core/src/test/java/org/springframework/batch/test/namespace/config/DummyNamespaceHandler.java index 8a605d5b7..b82c45f4b 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/test/namespace/config/DummyNamespaceHandler.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/test/namespace/config/DummyNamespaceHandler.java @@ -1,12 +1,12 @@ /* - * 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. * 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. @@ -29,20 +29,23 @@ import org.w3c.dom.Node; /** * Empty implementation used for testing only. - * + * * @author Costin Leau */ public class DummyNamespaceHandler implements NamespaceHandler { public static String LABEL = new Random().toString(); + @Override public BeanDefinitionHolder decorate(Node source, BeanDefinitionHolder definition, ParserContext parserContext) { return null; } + @Override public void init() { } + @Override public BeanDefinition parse(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(TestTasklet.class); builder.addPropertyValue("name", LABEL); diff --git a/spring-batch-core/src/test/java/test/jdbc/datasource/DataSourceInitializer.java b/spring-batch-core/src/test/java/test/jdbc/datasource/DataSourceInitializer.java index 2b9031f62..c7d04860b 100644 --- a/spring-batch-core/src/test/java/test/jdbc/datasource/DataSourceInitializer.java +++ b/spring-batch-core/src/test/java/test/jdbc/datasource/DataSourceInitializer.java @@ -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. @@ -41,15 +41,15 @@ import org.springframework.util.StringUtils; /** * Wrapper for a {@link DataSource} that can run scripts on start up and shut * down. Us as a bean definition

    - * + * * Run this class to initialize a database in a running server process. * Make sure the server is running first by launching the "hsql-server" from the * hsql.server project. Then you can right click in Eclipse and * Run As -> Java Application. Do the same any time you want to wipe the * database and start again. - * + * * @author Dave Syer - * + * */ public class DataSourceInitializer implements InitializingBean { @@ -65,14 +65,16 @@ public class DataSourceInitializer implements InitializingBean { /** * Main method as convenient entry point. - * + * * @param args */ + @SuppressWarnings("resource") public static void main(String... args) { new ClassPathXmlApplicationContext(ClassUtils.addResourcePathToPackagePath(DataSourceInitializer.class, DataSourceInitializer.class.getSimpleName() + "-context.xml")); } + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(dataSource); initialize(); @@ -90,15 +92,16 @@ public class DataSourceInitializer implements InitializingBean { } } + @SuppressWarnings({ "unchecked", "rawtypes" }) private void doExecuteScript(final Resource scriptResource) { - if (scriptResource == null || !scriptResource.exists()) { - throw new IllegalArgumentException("Script resource is null or does not exist"); - } + if (scriptResource == null || !scriptResource.exists()) { + throw new IllegalArgumentException("Script resource is null or does not exist"); + } TransactionTemplate transactionTemplate = new TransactionTemplate(new DataSourceTransactionManager(dataSource)); transactionTemplate.execute(new TransactionCallback() { - @SuppressWarnings("unchecked") + @Override public Object doInTransaction(TransactionStatus status) { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); String[] scripts; diff --git a/spring-batch-infrastructure-tests/pom.xml b/spring-batch-infrastructure-tests/pom.xml index c2ebfadd3..8cc88bb3c 100644 --- a/spring-batch-infrastructure-tests/pom.xml +++ b/spring-batch-infrastructure-tests/pom.xml @@ -15,33 +15,6 @@ hsql - - tiger - - 1.5 - - - - javax.xml.bind - jaxb-api - provided - true - 2.1 - - - javax.xml.stream - stax-api - - - - - com.sun.xml.bind - jaxb-impl - 2.1.5 - provided - - - default diff --git a/spring-batch-infrastructure/pom.xml b/spring-batch-infrastructure/pom.xml index e429bcf43..62c1f348f 100644 --- a/spring-batch-infrastructure/pom.xml +++ b/spring-batch-infrastructure/pom.xml @@ -15,24 +15,6 @@ 2.2.0.BUILD-SNAPSHOT ../spring-batch-parent - - - tiger - - 1.5 - - - - stax - stax - - - javax.annotation - jsr250-api - - - - diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionContext.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionContext.java index 03723f869..3b40126f8 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionContext.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionContext.java @@ -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. @@ -18,8 +18,8 @@ package org.springframework.batch.item; import java.io.Serializable; import java.util.Map; -import java.util.Set; import java.util.Map.Entry; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.springframework.util.Assert; @@ -28,13 +28,14 @@ import org.springframework.util.Assert; * Object representing a context for an {@link ItemStream}. It is a thin wrapper * for a map that allows optionally for type safety on reads. It also allows for * dirty checking by setting a 'dirty' flag whenever any put is called. - * + * * Note that putting null value is equivalent to removing the entry * for the given key. - * + * * @author Lucas Ward * @author Douglas Kaminsky */ +@SuppressWarnings("serial") public class ExecutionContext implements Serializable { private volatile boolean dirty = false; @@ -51,7 +52,7 @@ public class ExecutionContext implements Serializable { /** * Initializes a new execution context with the contents of another map. - * + * * @param map Initial contents of context. */ public ExecutionContext(Map map) { @@ -73,7 +74,7 @@ public class ExecutionContext implements Serializable { /** * Adds a String value to the context. - * + * * @param key Key to add to context * @param value Value to associate with key */ @@ -85,7 +86,7 @@ public class ExecutionContext implements Serializable { /** * Adds a Long value to the context. - * + * * @param key Key to add to context * @param value Value to associate with key */ @@ -96,7 +97,7 @@ public class ExecutionContext implements Serializable { /** * Adds an Integer value to the context. - * + * * @param key Key to add to context * @param value Value to associate with key */ @@ -106,7 +107,7 @@ public class ExecutionContext implements Serializable { /** * Add a Double value to the context. - * + * * @param key Key to add to context * @param value Value to associate with key */ @@ -118,7 +119,7 @@ public class ExecutionContext implements Serializable { /** * Add an Object value to the context (must be Serializable). Putting * null value for a given key removes the key. - * + * * @param key Key to add to context * @param value Value to associate with key */ @@ -138,7 +139,7 @@ public class ExecutionContext implements Serializable { * Indicates if context has been changed with a "put" operation since the * dirty flag was last cleared. Note that the last time the flag was cleared * might correspond to creation of the context. - * + * * @return True if "put" operation has occurred since flag was last cleared */ public boolean isDirty() { @@ -147,7 +148,7 @@ public class ExecutionContext implements Serializable { /** * Typesafe Getter for the String represented by the provided key. - * + * * @param key The key to get a value for * @return The String value */ @@ -159,7 +160,7 @@ public class ExecutionContext implements Serializable { /** * Typesafe Getter for the String represented by the provided key with * default value to return if key is not represented. - * + * * @param key The key to get a value for * @param defaultString Default to return if key is not represented * @return The String value if key is repreesnted, specified @@ -175,7 +176,7 @@ public class ExecutionContext implements Serializable { /** * Typesafe Getter for the Long represented by the provided key. - * + * * @param key The key to get a value for * @return The Long value */ @@ -187,7 +188,7 @@ public class ExecutionContext implements Serializable { /** * Typesafe Getter for the Long represented by the provided key with default * value to return if key is not represented. - * + * * @param key The key to get a value for * @param defaultLong Default to return if key is not represented * @return The long value if key is represented, specified @@ -203,7 +204,7 @@ public class ExecutionContext implements Serializable { /** * Typesafe Getter for the Integer represented by the provided key. - * + * * @param key The key to get a value for * @return The Integer value */ @@ -215,7 +216,7 @@ public class ExecutionContext implements Serializable { /** * Typesafe Getter for the Integer represented by the provided key with * default value to return if key is not represented. - * + * * @param key The key to get a value for * @param defaultInt Default to return if key is not represented * @return The int value if key is represented, specified @@ -231,7 +232,7 @@ public class ExecutionContext implements Serializable { /** * Typesafe Getter for the Double represented by the provided key. - * + * * @param key The key to get a value for * @return The Double value */ @@ -242,7 +243,7 @@ public class ExecutionContext implements Serializable { /** * Typesafe Getter for the Double represented by the provided key with * default value to return if key is not represented. - * + * * @param key The key to get a value for * @param defaultDouble Default to return if key is not represented * @return The double value if key is represented, specified @@ -258,7 +259,7 @@ public class ExecutionContext implements Serializable { /** * Getter for the value represented by the provided key. - * + * * @param key The key to get a value for * @return The value represented by the given key */ @@ -269,7 +270,7 @@ public class ExecutionContext implements Serializable { /** * Utility method that attempts to take a value represented by a given key * and validate it as a member of the specified type. - * + * * @param key The key to validate a value for * @param type Class against which value should be validated * @return Value typed to the specified Class @@ -288,7 +289,7 @@ public class ExecutionContext implements Serializable { /** * Indicates whether or not the context is empty. - * + * * @return True if the context has no entries, false otherwise. * @see java.util.Map#isEmpty() */ @@ -305,7 +306,7 @@ public class ExecutionContext implements Serializable { /** * Returns the entry set containing the contents of this context. - * + * * @return A set representing the contents of the context * @see java.util.Map#entrySet() */ @@ -315,7 +316,7 @@ public class ExecutionContext implements Serializable { /** * Indicates whether or not a key is represented in this context. - * + * * @param key Key to check existence for * @return True if key is represented in context, false otherwise * @see java.util.Map#containsKey(Object) @@ -326,7 +327,7 @@ public class ExecutionContext implements Serializable { /** * Removes the mapping for a key from this context if it is present. - * + * * @see java.util.Map#remove(Object) */ public Object remove(String key) { @@ -335,7 +336,7 @@ public class ExecutionContext implements Serializable { /** * Indicates whether or not a value is represented in this context. - * + * * @param value Value to check existence for * @return True if value is represented in context, false otherwise * @see java.util.Map#containsValue(Object) @@ -346,9 +347,10 @@ public class ExecutionContext implements Serializable { /* * (non-Javadoc) - * + * * @see java.lang.Object#equals(java.lang.Object) */ + @Override public boolean equals(Object obj) { if (obj instanceof ExecutionContext == false) { return false; @@ -362,25 +364,27 @@ public class ExecutionContext implements Serializable { /* * (non-Javadoc) - * + * * @see java.lang.Object#hashCode() */ + @Override public int hashCode() { return map.hashCode(); } /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ + @Override public String toString() { return map.toString(); } /** * Returns number of entries in the context - * + * * @return Number of entries in the context * @see java.util.Map#size() */ diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ItemStreamSupport.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ItemStreamSupport.java index 623d6a44f..cebf23566 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ItemStreamSupport.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ItemStreamSupport.java @@ -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. @@ -18,7 +18,7 @@ package org.springframework.batch.item; /** * Empty method implementation of {@link ItemStream}. - * + * * @author Dave Syer * */ @@ -28,6 +28,7 @@ public abstract class ItemStreamSupport implements ItemStream { * No-op. * @see org.springframework.batch.item.ItemStream#close() */ + @Override public void close() throws ItemStreamException { } @@ -35,6 +36,7 @@ public abstract class ItemStreamSupport implements ItemStream { * No-op. * @see org.springframework.batch.item.ItemStream#open(ExecutionContext) */ + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { } @@ -42,6 +44,7 @@ public abstract class ItemStreamSupport implements ItemStream { * Return empty {@link ExecutionContext}. * @see org.springframework.batch.item.ItemStream#update(ExecutionContext) */ + @Override public void update(ExecutionContext executionContext) { } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/AbstractMethodInvokingDelegator.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/AbstractMethodInvokingDelegator.java index 326df0daa..516d70e65 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/AbstractMethodInvokingDelegator.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/AbstractMethodInvokingDelegator.java @@ -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,12 +30,12 @@ import org.springframework.util.MethodInvoker; * Superclass for delegating classes which dynamically call a custom method of * injected object. Provides convenient API for dynamic method invocation * shielding subclasses from low-level details and exception handling. - * + * * {@link Exception}s thrown by a successfully invoked delegate method are * re-thrown without wrapping. In case the delegate method throws a * {@link Throwable} that doesn't subclass {@link Exception} it will be wrapped * by {@link InvocationTargetThrowableWrapper}. - * + * * @author Robert Kasanicky */ public abstract class AbstractMethodInvokingDelegator implements InitializingBean { @@ -129,6 +129,7 @@ public abstract class AbstractMethodInvokingDelegator implements Initializing } } + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(targetObject); Assert.hasLength(targetMethod); @@ -170,8 +171,9 @@ public abstract class AbstractMethodInvokingDelegator implements Initializing argumentsMatchParameters = false; } } - if (argumentsMatchParameters) + if (argumentsMatchParameters) { return true; + } } } } @@ -200,7 +202,7 @@ public abstract class AbstractMethodInvokingDelegator implements Initializing * {@link #setTargetMethod(String)}. These will be used only when the * subclass tries to invoke the target method without providing explicit * argument values. - * + * * If arguments are set to not-null value {@link #afterPropertiesSet()} will * check the values are compatible with target method's signature. In case * arguments are null (not set) method signature will not be checked and it @@ -213,7 +215,7 @@ public abstract class AbstractMethodInvokingDelegator implements Initializing /** * Used to wrap a {@link Throwable} (not an {@link Exception}) thrown by a * reflectively-invoked delegate. - * + * * @author Robert Kasanicky */ public static class InvocationTargetThrowableWrapper extends RuntimeException { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemProcessorAdapter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemProcessorAdapter.java index aa58f456e..c95dfaf1a 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemProcessorAdapter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemProcessorAdapter.java @@ -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,16 +21,17 @@ import org.springframework.batch.item.ItemProcessor; /** * Invokes a custom method on a delegate plain old Java object which itself * processes an item. - * + * * @author Dave Syer */ public class ItemProcessorAdapter extends AbstractMethodInvokingDelegator implements ItemProcessor { /** * Invoke the delegate method and return the result. - * + * * @see ItemProcessor#process(Object) */ + @Override public O process(I item) throws Exception { return invokeDelegateMethodWithArgument(item); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemReaderAdapter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemReaderAdapter.java index 3f8031ac8..f7b3730d6 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemReaderAdapter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemReaderAdapter.java @@ -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,7 +21,7 @@ import org.springframework.batch.item.ItemReader; /** * Invokes a custom method on a delegate plain old Java object which itself * provides an item. - * + * * @author Robert Kasanicky */ public class ItemReaderAdapter extends AbstractMethodInvokingDelegator implements ItemReader { @@ -29,6 +29,7 @@ public class ItemReaderAdapter extends AbstractMethodInvokingDelegator imp /** * @return return value of the target method. */ + @Override public T read() throws Exception { return invokeDelegateMethod(); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemWriterAdapter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemWriterAdapter.java index 57b5d6b9c..0088e03ba 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemWriterAdapter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemWriterAdapter.java @@ -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,20 +22,21 @@ import org.springframework.batch.item.ItemWriter; /** - * Delegates item processing to a custom method - + * Delegates item processing to a custom method - * passes the item as an argument for the delegate method. - * + * * @see PropertyExtractingDelegatingItemWriter - * + * * @author Robert Kasanicky */ public class ItemWriterAdapter extends AbstractMethodInvokingDelegator implements ItemWriter { - - public void write(List items) throws Exception { - for (T item : items) { - invokeDelegateMethodWithArgument(item); + + @Override + public void write(List items) throws Exception { + for (T item : items) { + invokeDelegateMethodWithArgument(item); } - } - + } + } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/PropertyExtractingDelegatingItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/PropertyExtractingDelegatingItemWriter.java index ce094a44b..f7d997983 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/PropertyExtractingDelegatingItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/PropertyExtractingDelegatingItemWriter.java @@ -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,13 @@ import org.springframework.util.Assert; /** * Delegates processing to a custom method - extracts property values from item * object and uses them as arguments for the delegate method. - * + * * @see ItemWriterAdapter - * + * * @author Robert Kasanicky */ public class PropertyExtractingDelegatingItemWriter extends AbstractMethodInvokingDelegator implements - ItemWriter { +ItemWriter { private String[] fieldsUsedAsTargetMethodArguments; @@ -42,6 +42,7 @@ public class PropertyExtractingDelegatingItemWriter extends AbstractMethodInv * fieldsUsedAsTargetMethodArguments and passes them as arguments to the * delegate method. */ + @Override public void write(List items) throws Exception { for (T item : items) { @@ -58,6 +59,7 @@ public class PropertyExtractingDelegatingItemWriter extends AbstractMethodInv } } + @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.notEmpty(fieldsUsedAsTargetMethodArguments); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/amqp/AmqpItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/amqp/AmqpItemReader.java index 40b7c6a19..ee4d10cd3 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/amqp/AmqpItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/amqp/AmqpItemReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 the original author or authors. + * 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. @@ -30,33 +30,34 @@ import org.springframework.util.Assert; * @author Chris Schaefer */ public class AmqpItemReader implements ItemReader { - private final AmqpTemplate amqpTemplate; - private Class itemType; + private final AmqpTemplate amqpTemplate; + private Class itemType; - public AmqpItemReader(final AmqpTemplate amqpTemplate) { - Assert.notNull(amqpTemplate, "AmpqTemplate must not be null"); + public AmqpItemReader(final AmqpTemplate amqpTemplate) { + Assert.notNull(amqpTemplate, "AmpqTemplate must not be null"); - this.amqpTemplate = amqpTemplate; - } + this.amqpTemplate = amqpTemplate; + } - @SuppressWarnings("unchecked") - public T read() { - if (itemType != null && itemType.isAssignableFrom(Message.class)) { - return (T) amqpTemplate.receive(); - } + @Override + @SuppressWarnings("unchecked") + public T read() { + if (itemType != null && itemType.isAssignableFrom(Message.class)) { + return (T) amqpTemplate.receive(); + } - Object result = amqpTemplate.receiveAndConvert(); + Object result = amqpTemplate.receiveAndConvert(); - if (itemType != null && result != null) { - Assert.state(itemType.isAssignableFrom(result.getClass()), - "Received message payload of wrong type: expected [" + itemType + "]"); - } + if (itemType != null && result != null) { + Assert.state(itemType.isAssignableFrom(result.getClass()), + "Received message payload of wrong type: expected [" + itemType + "]"); + } - return (T) result; - } + return (T) result; + } - public void setItemType(Class itemType) { - Assert.notNull(itemType, "Item type cannot be null"); - this.itemType = itemType; - } + public void setItemType(Class itemType) { + Assert.notNull(itemType, "Item type cannot be null"); + this.itemType = itemType; + } } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/amqp/AmqpItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/amqp/AmqpItemWriter.java index 49913d6ac..ecc42c813 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/amqp/AmqpItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/amqp/AmqpItemWriter.java @@ -43,6 +43,7 @@ public class AmqpItemWriter implements ItemWriter { this.amqpTemplate = amqpTemplate; } + @Override public void write(final List items) throws Exception { if (log.isDebugEnabled()) { log.debug("Writing to AMQP with " + items.size() + " items."); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractCursorItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractCursorItemReader.java index 3da1779b7..24eaa9e49 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractCursorItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractCursorItemReader.java @@ -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. @@ -45,27 +45,27 @@ import org.springframework.util.Assert; /** *

    - * Abstract base class for any simple item reader that opens a database cursor and continually retrieves - * the next row in the ResultSet. + * Abstract base class for any simple item reader that opens a database cursor and continually retrieves + * the next row in the ResultSet. *

    - * + * *

    * By default the cursor will be opened using a separate connection. The ResultSet for the cursor - * is held open regardless of commits or roll backs in a surrounding transaction. Clients of this + * is held open regardless of commits or roll backs in a surrounding transaction. Clients of this * reader are responsible for buffering the items in the case that they need to be re-presented on a * rollback. This buffering is handled by the step implementations provided and is only a concern for * anyone writing their own step implementations. *

    - * + * *

    - * There is an option ({@link #setUseSharedExtendedConnection(boolean)} that will share the connection - * used for the cursor with the rest of the step processing. If you set this flag to true - * then you must wrap the DataSource in a {@link ExtendedConnectionDataSourceProxy} to prevent the - * connection from being closed and released after each commit performed as part of the step processing. - * You must also use a JDBC driver supporting JDBC 3.0 or later since the cursor will be opened with the - * additional option of 'HOLD_CUSORS_OVER_COMMIT' enabled. + * There is an option ({@link #setUseSharedExtendedConnection(boolean)} that will share the connection + * used for the cursor with the rest of the step processing. If you set this flag to true + * then you must wrap the DataSource in a {@link ExtendedConnectionDataSourceProxy} to prevent the + * connection from being closed and released after each commit performed as part of the step processing. + * You must also use a JDBC driver supporting JDBC 3.0 or later since the cursor will be opened with the + * additional option of 'HOLD_CUSORS_OVER_COMMIT' enabled. *

    - * + * *

    * Each call to {@link #read()} will attempt to map the row at the current position in the * ResultSet. There is currently no wrapping of the ResultSet to suppress calls @@ -76,7 +76,7 @@ import org.springframework.util.Assert; * restartability. This ensures that each call to {@link #read()} returns the * ResultSet at the correct row, regardless of rollbacks or restarts. *

    - * + * *

    * {@link ExecutionContext}: The current row is returned as restart data, and * when restored from that same data, the cursor is opened and the current row @@ -84,56 +84,56 @@ import org.springframework.util.Assert; * {@link #setDriverSupportsAbsolute(boolean)} for improving restart * performance. *

    - * + * *

    * Calling close on this {@link ItemStream} will cause all resources it is * currently using to be freed. (Connection, ResultSet, etc). It is then illegal * to call {@link #read()} again until it has been re-opened. *

    - * + * *

    * Known limitation: when used with Derby * {@link #setVerifyCursorPosition(boolean)} needs to be false * because {@link ResultSet#getRow()} call used for cursor position verification * is not available for 'TYPE_FORWARD_ONLY' result sets. *

    - * + * * @author Lucas Ward * @author Peter Zozom * @author Robert Kasanicky * @author Thomas Risberg */ public abstract class AbstractCursorItemReader extends AbstractItemCountingItemStreamItemReader - implements InitializingBean { +implements InitializingBean { /** Logger available to subclasses */ protected final Log log = LogFactory.getLog(getClass()); public static final int VALUE_NOT_SET = -1; private Connection con; - + protected ResultSet rs; - + private DataSource dataSource; - + private int fetchSize = VALUE_NOT_SET; - + private int maxRows = VALUE_NOT_SET; - + private int queryTimeout = VALUE_NOT_SET; - + private boolean ignoreWarnings = true; - + private boolean verifyCursorPosition = true; - + private SQLExceptionTranslator exceptionTranslator; - + private boolean initialized = false; - + private boolean driverSupportsAbsolute = false; - + private boolean useSharedExtendedConnection = false; - + public AbstractCursorItemReader() { super(); @@ -141,17 +141,18 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt /** * Assert that mandatory properties are set. - * + * * @throws IllegalArgumentException if either data source or sql properties * not set. */ + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(dataSource, "DataSource must be provided"); } /** * Public setter for the data source for injection purposes. - * + * * @param dataSource */ public void setDataSource(DataSource dataSource) { @@ -160,7 +161,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt /** * Public getter for the data source. - * + * * @return the dataSource */ public DataSource getDataSource() { @@ -172,7 +173,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt * CallableStatement), applying statement settings such as fetch size, max * rows, and query timeout. @param stmt the JDBC Statement to prepare * @throws SQLException - * + * * @see #setFetchSize * @see #setMaxRows * @see #setQueryTimeout @@ -192,7 +193,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt /** * Return the exception translator for this instance. - * + * * Creates a default SQLErrorCodeSQLExceptionTranslator for the specified * DataSource if none is set. */ @@ -213,31 +214,31 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt /** * Throw a SQLWarningException if we're not ignoring warnings, else log the * warnings (at debug level). - * + * * @param statement the current statement to obtain the warnings from, if there are any. * @throws SQLException - * + * * @see org.springframework.jdbc.SQLWarningException */ protected void handleWarnings(Statement statement) throws SQLWarningException, - SQLException { - if (ignoreWarnings) { - if (log.isDebugEnabled()) { - SQLWarning warningToLog = statement.getWarnings(); - while (warningToLog != null) { - log.debug("SQLWarning ignored: SQL state '" + warningToLog.getSQLState() + "', error code '" - + warningToLog.getErrorCode() + "', message [" + warningToLog.getMessage() + "]"); - warningToLog = warningToLog.getNextWarning(); - } - } - } - else { - SQLWarning warnings = statement.getWarnings(); - if (warnings != null) { - throw new SQLWarningException("Warning not ignored", warnings); - } + SQLException { + if (ignoreWarnings) { + if (log.isDebugEnabled()) { + SQLWarning warningToLog = statement.getWarnings(); + while (warningToLog != null) { + log.debug("SQLWarning ignored: SQL state '" + warningToLog.getSQLState() + "', error code '" + + warningToLog.getErrorCode() + "', message [" + warningToLog.getMessage() + "]"); + warningToLog = warningToLog.getNextWarning(); } } + } + else { + SQLWarning warnings = statement.getWarnings(); + if (warnings != null) { + throw new SQLWarningException("Warning not ignored", warnings); + } + } + } /** * Moves the cursor in the ResultSet to the position specified by the row @@ -261,7 +262,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt * fetched from the database when more rows are needed for this * ResultSet object. If the fetch size specified is zero, the * JDBC driver ignores the value. - * + * * @param fetchSize the number of rows to fetch * @see ResultSet#setFetchSize(int) */ @@ -272,7 +273,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt /** * Sets the limit for the maximum number of rows that any * ResultSet object can contain to the given number. - * + * * @param maxRows the new max rows limit; zero means there is no limit * @see Statement#setMaxRows(int) */ @@ -284,7 +285,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt * Sets the number of seconds the driver will wait for a * Statement object to execute to the given number of seconds. * If the limit is exceeded, an SQLException is thrown. - * + * * @param queryTimeout seconds the new query timeout limit in seconds; zero * means there is no limit * @see Statement#setQueryTimeout(int) @@ -296,7 +297,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt /** * Set whether SQLWarnings should be ignored (only logged) or exception * should be thrown. - * + * * @param ignoreWarnings if TRUE, warnings are ignored */ public void setIgnoreWarnings(boolean ignoreWarnings) { @@ -306,7 +307,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt /** * Allow verification of cursor position after current row is processed by * RowMapper or RowCallbackHandler. Default value is TRUE. - * + * * @param verifyCursorPosition if true, cursor position is verified */ public void setVerifyCursorPosition(boolean verifyCursorPosition) { @@ -319,9 +320,9 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt * true for JDBC drivers that supports ResultSet.absolute() as * it may improve performance, especially if a step fails while working with * a large data set. - * + * * @see ResultSet#absolute(int) - * + * * @param driverSupportsAbsolute false by default */ public void setDriverSupportsAbsolute(boolean driverSupportsAbsolute) { @@ -330,16 +331,16 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt /** * Indicate whether the connection used for the cursor should be used by all other processing - * thus sharing the same transaction. If this is set to false, which is the default, then the + * thus sharing the same transaction. If this is set to false, which is the default, then the * cursor will be opened using in its connection and will not participate in any transactions - * started for the rest of the step processing. If you set this flag to true then you must + * started for the rest of the step processing. If you set this flag to true then you must * wrap the DataSource in a {@link ExtendedConnectionDataSourceProxy} to prevent the * connection from being closed and released after each commit. - * - * When you set this option to true then the statement used to open the cursor - * will be created with both 'READ_ONLY' and 'HOLD_CUSORS_OVER_COMMIT' options. This allows - * holding the cursor open over transaction start and commits performed in the step processing. - * To use this feature you need a database that supports this and a JDBC driver supporting + * + * When you set this option to true then the statement used to open the cursor + * will be created with both 'READ_ONLY' and 'HOLD_CUSORS_OVER_COMMIT' options. This allows + * holding the cursor open over transaction start and commits performed in the step processing. + * To use this feature you need a database that supports this and a JDBC driver supporting * JDBC 3.0 or later. * * @param useSharedExtendedConnection false by default @@ -353,7 +354,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt } public abstract String getSql(); - + /** * Check the result set is in synch with the currentRow attribute. This is * important to ensure that the user hasn't modified the current row. @@ -367,9 +368,10 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt } /** - * Close the cursor and database connection. Make call to cleanupOnClose so sub classes can cleanup + * Close the cursor and database connection. Make call to cleanupOnClose so sub classes can cleanup * any resources they have allocated. */ + @Override protected void doClose() throws Exception { initialized = false; JdbcUtils.closeResultSet(this.rs); @@ -385,7 +387,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt JdbcUtils.closeConnection(this.con); } } - + protected abstract void cleanupOnClose() throws Exception; /** @@ -400,12 +402,12 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt initializeConnection(); openCursor(con); initialized = true; - + } protected void initializeConnection() { Assert.state(getDataSource() != null, "DataSource must not be null."); - + try { if (useSharedExtendedConnection) { if (!(getDataSource() instanceof ExtendedConnectionDataSourceProxy)) { @@ -425,18 +427,19 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt throw getExceptionTranslator().translate("Executing query", getSql(), se); } } - + protected abstract void openCursor(Connection con); - + /** * Read next row and map it to item, verify cursor position if * {@link #setVerifyCursorPosition(boolean)} is true. */ + @Override protected T doRead() throws Exception { if (rs == null) { throw new ReaderNotOpenException("Reader must be open before it can be read."); } - + try { if (!rs.next()) { return null; @@ -450,11 +453,11 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt throw getExceptionTranslator().translate("Attempt to process next row failed", getSql(), se); } } - + /** - * Read the cursor and map to the type of object this reader should return. This method must be + * Read the cursor and map to the type of object this reader should return. This method must be * overriden by subclasses. - * + * * @param rs The current result set * @param currentRow Current position of the result set * @return the mapped object at the cursor position @@ -466,6 +469,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt * Use {@link ResultSet#absolute(int)} if possible, otherwise scroll by * calling {@link ResultSet#next()}. */ + @Override protected void jumpToItem(int itemIndex) throws Exception { if (driverSupportsAbsolute) { try { @@ -476,7 +480,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt // traversing ResultSet log.warn("The JDBC driver does not appear to support ResultSet.absolute(). Consider" + " reverting to the default behavior setting the driverSupportsAbsolute to false", e); - + moveCursorToRow(itemIndex); } } @@ -485,4 +489,4 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt } } -} \ No newline at end of file +} diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractPagingItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractPagingItemReader.java index f21e9ab20..81dd39a35 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractPagingItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractPagingItemReader.java @@ -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. @@ -27,20 +27,20 @@ import org.springframework.util.ClassUtils; /** * Abstract {@link org.springframework.batch.item.ItemReader} for to extend when * reading database records in a paging fashion. - * + * *

    * Implementations should execute queries using paged requests of a size * specified in {@link #setPageSize(int)}. Additional pages are requested when * needed as {@link #read()} method is called, returning an object corresponding * to current position. *

    - * + * * @author Thomas Risberg * @author Dave Syer * @since 2.0 */ public abstract class AbstractPagingItemReader extends AbstractItemCountingItemStreamItemReader implements - InitializingBean { +InitializingBean { protected Log logger = LogFactory.getLog(getClass()); @@ -78,7 +78,7 @@ public abstract class AbstractPagingItemReader extends AbstractItemCountingIt /** * The number of rows to retrieve at a time. - * + * * @param pageSize the number of rows to fetch per page */ public void setPageSize(int pageSize) { @@ -89,6 +89,7 @@ public abstract class AbstractPagingItemReader extends AbstractItemCountingIt * Check mandatory properties. * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { Assert.isTrue(pageSize > 0, "pageSize must be greater than zero"); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/BeanPropertyItemSqlParameterSourceProvider.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/BeanPropertyItemSqlParameterSourceProvider.java index 3710b4182..68c23f3e5 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/BeanPropertyItemSqlParameterSourceProvider.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/BeanPropertyItemSqlParameterSourceProvider.java @@ -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. @@ -21,17 +21,18 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource; /** * A convenient implementation for providing BeanPropertySqlParameterSource when the item has JavaBean properties * that correspond to names used for parameters in the SQL statement. - * + * * @author Thomas Risberg * @since 2.0 */ public class BeanPropertyItemSqlParameterSourceProvider implements ItemSqlParameterSourceProvider { /** - * Provide parameter values in an {@link BeanPropertySqlParameterSource} based on values from + * Provide parameter values in an {@link BeanPropertySqlParameterSource} based on values from * the provided item. * @param item the item to use for parameter values */ + @Override public SqlParameterSource createSqlParameterSource(T item) { return new BeanPropertySqlParameterSource(item); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/ExtendedConnectionDataSourceProxy.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/ExtendedConnectionDataSourceProxy.java index b6cabd21c..0b6f1d155 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/ExtendedConnectionDataSourceProxy.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/ExtendedConnectionDataSourceProxy.java @@ -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. @@ -38,19 +38,19 @@ import org.springframework.util.Assert; * Implementation of {@link SmartDataSource} that is capable of keeping a single * JDBC Connection which is NOT closed after each use even if * {@link Connection#close()} is called. - * + * * The connection can be kept open over multiple transactions when used together * with any of Spring's * {@link org.springframework.transaction.PlatformTransactionManager} * implementations. - * + * *

    * Loosely based on the SingleConnectionDataSource implementation in Spring * Core. Intended to be used with the {@link JdbcCursorItemReader} to provide a * connection that remains open across transaction boundaries, It remains open * for the life of the cursor, and can be shared with the main transaction of * the rest of the step processing. - * + * *

    * Once close suppression has been turned on for a connection, it will be * returned for the first {@link #getConnection()} call. Any subsequent calls to @@ -64,16 +64,16 @@ import org.springframework.util.Assert; * {@link Connection} to be the main {@link Connection} for an extended data * access process. The close suppression is turned off by calling * {@link #stopCloseSuppression(Connection)}. - * + * *

    * This class is not multi-threading capable. - * + * *

    * The connection returned will be a close-suppressing proxy instead of the * physical {@link Connection}. Be aware that you will not be able to cast this * to a native OracleConnection or the like anymore; you need to * use a {@link org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor}. - * + * * @author Thomas Risberg * @see #getConnection() * @see java.sql.Connection#close() @@ -111,7 +111,7 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi /** * Setter for the {&link DataSource} that is to be wrapped. - * + * * @param dataSource the DataSource */ public void setDataSource(DataSource dataSource) { @@ -121,6 +121,7 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi /** * @see SmartDataSource */ + @Override public boolean shouldClose(Connection connection) { boolean shouldClose = !isCloseSuppressionActive(connection); if (borrowedConnection && closeSuppressedConnection.equals(connection)) { @@ -132,7 +133,7 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi /** * Return the status of close suppression being activated for a given * {@link Connection} - * + * * @param connection the {@link Connection} that the close suppression * status is requested for * @return true or false @@ -145,7 +146,7 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi } /** - * + * * @param connection the {@link Connection} that close suppression is * requested for */ @@ -159,7 +160,7 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi } /** - * + * * @param connection the {@link Connection} that close suppression should be * turned off for */ @@ -170,12 +171,14 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi } } + @Override public Connection getConnection() throws SQLException { synchronized (this.connectionMonitor) { return initConnection(null, null); } } + @Override public Connection getConnection(String username, String password) throws SQLException { synchronized (this.connectionMonitor) { return initConnection(username, password); @@ -207,18 +210,22 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi return connection; } + @Override public PrintWriter getLogWriter() throws SQLException { return dataSource.getLogWriter(); } + @Override public int getLoginTimeout() throws SQLException { return dataSource.getLoginTimeout(); } + @Override public void setLogWriter(PrintWriter out) throws SQLException { dataSource.setLogWriter(out); } + @Override public void setLoginTimeout(int seconds) throws SQLException { dataSource.setLoginTimeout(seconds); } @@ -250,6 +257,7 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi this.target = target; } + @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { // Invocation on ConnectionProxy interface coming in... @@ -292,6 +300,7 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi * Performs only a 'shallow' non-recursive check of self's and delegate's * class to retain Java 5 compatibility. */ + @Override public boolean isWrapperFor(Class iface) throws SQLException { if (iface.isAssignableFrom(SmartDataSource.class) || iface.isAssignableFrom(dataSource.getClass())) { return true; @@ -304,6 +313,7 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi * cast to supplied parameter class. Does *not* support recursive unwrapping * of the delegate to retain Java 5 compatibility. */ + @Override public T unwrap(Class iface) throws SQLException { if (iface.isAssignableFrom(SmartDataSource.class)) { @SuppressWarnings("unchecked") @@ -318,6 +328,7 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi throw new SQLException("Unsupported class " + iface.getSimpleName()); } + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(dataSource); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateCursorItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateCursorItemReader.java index d7bb24124..9d0b8bfca 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateCursorItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateCursorItemReader.java @@ -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,8 +39,8 @@ import org.springframework.util.ClassUtils; * {@link #setQueryString(String)}, a named query can be used by * {@link #setQueryName(String)}, or a query provider strategy can be supplied * via {@link #setQueryProvider(HibernateQueryProvider)}. - * - * + * + * *

    * The reader can be configured to use either {@link StatelessSession} * sufficient for simple mappings without the need to cascade to associated @@ -49,14 +49,14 @@ import org.springframework.util.ClassUtils; * the {@link #update(ExecutionContext)} method without being flushed (no data * modifications are expected). *

    - * + * * The implementation is not thread-safe. - * + * * @author Robert Kasanicky * @author Dave Syer */ public class HibernateCursorItemReader extends AbstractItemCountingItemStreamItemReader implements ItemStream, - InitializingBean { +InitializingBean { private HibernateItemReaderHelper helper = new HibernateItemReaderHelper(); @@ -72,6 +72,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream private Map parameterValues; + @Override public void afterPropertiesSet() throws Exception { Assert.state(fetchSize >= 0, "fetchSize must not be negative"); helper.afterPropertiesSet(); @@ -79,7 +80,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream /** * The parameter values to apply to a query (map of name:value). - * + * * @param parameterValues the parameter values to set */ public void setParameterValues(Map parameterValues) { @@ -91,7 +92,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream * {@link #setQueryString(String) query string} or the { * {@link #setQueryProvider(HibernateQueryProvider) query provider} should * be set. - * + * * @param queryName name of a hibernate named query */ public void setQueryName(String queryName) { @@ -101,7 +102,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream /** * Fetch size used internally by Hibernate to limit amount of data fetched * from database per round trip. - * + * * @param fetchSize the fetch size to pass down to Hibernate */ public void setFetchSize(int fetchSize) { @@ -112,7 +113,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream * A query provider. Either this or the {{@link #setQueryString(String) * query string} or the {{@link #setQueryName(String) query name} should be * set. - * + * * @param queryProvider Hibernate query provider */ public void setQueryProvider(HibernateQueryProvider queryProvider) { @@ -123,7 +124,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream * A query string in HQL. Either this or the { * {@link #setQueryProvider(HibernateQueryProvider) query provider} or the { * {@link #setQueryName(String) query name} should be set. - * + * * @param queryString HQL query string */ public void setQueryString(String queryString) { @@ -132,7 +133,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream /** * The Hibernate SessionFactory to use the create a session. - * + * * @param sessionFactory the {@link SessionFactory} to set */ public void setSessionFactory(SessionFactory sessionFactory) { @@ -141,7 +142,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream /** * Can be set only in uninitialized state. - * + * * @param useStatelessSession true to use * {@link StatelessSession} false to use standard hibernate * {@link Session} @@ -150,6 +151,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream helper.setUseStatelessSession(useStatelessSession); } + @Override protected T doRead() throws Exception { if (cursor.next()) { Object[] data = cursor.get(); @@ -178,6 +180,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream /** * Open hibernate session and create a forward-only cursor for the query. */ + @Override protected void doOpen() throws Exception { Assert.state(!initialized, "Cannot open an already opened ItemReader, call close first"); cursor = helper.getForwardOnlyCursor(fetchSize, parameterValues); @@ -186,7 +189,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream /** * Update the context and clear the session if stateful. - * + * * @param executionContext the current {@link ExecutionContext} * @throws ItemStreamException if there is a problem */ @@ -201,7 +204,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream * the session every now and then (if stateful) to avoid memory problems. * The frequency of session clearing is the larger of the fetch size (if * set) and 100. - * + * * @param itemIndex the first item to read * @throws Exception if there is a problem * @see AbstractItemCountingItemStreamItemReader#jumpToItem(int) @@ -215,6 +218,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream /** * Close the cursor and hibernate session. */ + @Override protected void doClose() throws Exception { initialized = false; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemReaderHelper.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemReaderHelper.java index 71c6a924b..a769f1ea6 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemReaderHelper.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemReaderHelper.java @@ -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. @@ -33,9 +33,9 @@ import org.springframework.util.StringUtils; /** * Internal shared state helper for hibernate readers managing sessions and * queries. - * + * * @author Dave Syer - * + * */ public class HibernateItemReaderHelper implements InitializingBean { @@ -76,7 +76,7 @@ public class HibernateItemReaderHelper implements InitializingBean { /** * Can be set only in uninitialized state. - * + * * @param useStatelessSession true to use * {@link StatelessSession} false to use standard hibernate * {@link Session} @@ -94,6 +94,7 @@ public class HibernateItemReaderHelper implements InitializingBean { this.sessionFactory = sessionFactory; } + @Override public void afterPropertiesSet() throws Exception { Assert.state(sessionFactory != null, "A SessionFactory must be provided"); @@ -112,10 +113,10 @@ public class HibernateItemReaderHelper implements InitializingBean { /** * Get a cursor over all of the results, with the forward-only flag set. - * + * * @param fetchSize the fetch size to use retrieving the results * @param parameterValues the parameter values to use (or null if none). - * + * * @return a forward-only {@link ScrollableResults} */ public ScrollableResults getForwardOnlyCursor(int fetchSize, Map parameterValues) { @@ -171,7 +172,7 @@ public class HibernateItemReaderHelper implements InitializingBean { /** * Scroll through the results up to the item specified. - * + * * @param cursor the results to scroll over */ public void jumpToItem(ScrollableResults cursor, int itemIndex, int flushInterval) { @@ -200,7 +201,7 @@ public class HibernateItemReaderHelper implements InitializingBean { /** * Read a page of data, clearing the existing session (if necessary) first, * and creating a new session before executing the query. - * + * * @param page the page to read (starting at 0) * @param pageSize the size of the page or maximum number of items to read * @param fetchSize the fetch size to use diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemWriter.java index fcf74d1f9..228567b1c 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemWriter.java @@ -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. @@ -33,13 +33,13 @@ import org.springframework.util.Assert; * TaskletStep). It will also clear the session on write * default (see {@link #setClearSession(boolean) clearSession} property).
    *
    - * + * * The writer is thread safe after its properties are set (normal singleton * behavior), so it can be used to write in multiple concurrent transactions. - * + * * @author Dave Syer * @author Thomas Risberg - * + * */ public class HibernateItemWriter implements ItemWriter, InitializingBean { @@ -53,7 +53,7 @@ public class HibernateItemWriter implements ItemWriter, InitializingBean { /** * Flag to indicate that the session should be cleared and flushed at the * end of the write (default true). - * + * * @param clearSession * the flag value to set */ @@ -63,7 +63,7 @@ public class HibernateItemWriter implements ItemWriter, InitializingBean { /** * Public setter for the {@link HibernateOperations} property. - * + * * @param hibernateTemplate * the hibernateTemplate to set */ @@ -74,7 +74,7 @@ public class HibernateItemWriter implements ItemWriter, InitializingBean { /** * Set the Hibernate SessionFactory to be used internally. Will * automatically create a HibernateTemplate for the given SessionFactory. - * + * * @see #setHibernateTemplate */ public final void setSessionFactory(SessionFactory sessionFactory) { @@ -84,6 +84,7 @@ public class HibernateItemWriter implements ItemWriter, InitializingBean { /** * Check mandatory properties - there must be a hibernateTemplate. */ + @Override public void afterPropertiesSet() { Assert.notNull(hibernateTemplate, "HibernateItemWriter requires a HibernateOperations"); @@ -92,9 +93,10 @@ public class HibernateItemWriter implements ItemWriter, InitializingBean { /** * Save or update any entities not in the current hibernate session and then * flush the hibernate session. - * + * * @see org.springframework.batch.item.ItemWriter#write(java.util.List) */ + @Override public final void write(List items) { doWrite(hibernateTemplate, items); hibernateTemplate.flush(); @@ -106,7 +108,7 @@ public class HibernateItemWriter implements ItemWriter, InitializingBean { /** * Do perform the actual write operation. This can be overridden in a * subclass if necessary. - * + * * @param hibernateTemplate * the HibernateTemplate to use for the operation * @param items diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernatePagingItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernatePagingItemReader.java index 4e23457d7..b4c650008 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernatePagingItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernatePagingItemReader.java @@ -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. @@ -37,7 +37,7 @@ import org.springframework.util.ClassUtils; * query can be used by {@link #setQueryName(String)}, or a query provider * strategy can be supplied via * {@link #setQueryProvider(HibernateQueryProvider)}. - * + * *

    * The reader can be configured to use either {@link StatelessSession} * sufficient for simple mappings without the need to cascade to associated @@ -46,16 +46,16 @@ import org.springframework.util.ClassUtils; * the {@link #update(ExecutionContext)} method without being flushed (no data * modifications are expected). *

    - * + * *

    * The implementation is thread-safe in between calls to * {@link #open(ExecutionContext)}, but remember to use * saveState=false if used in a multi-threaded client (no restart * available). *

    - * + * * @author Dave Syer - * + * * @since 2.1 */ public class HibernatePagingItemReader extends AbstractPagingItemReader implements ItemStream, InitializingBean { @@ -72,7 +72,7 @@ public class HibernatePagingItemReader extends AbstractPagingItemReader im /** * The parameter values to apply to a query (map of name:value). - * + * * @param parameterValues the parameter values to set */ public void setParameterValues(Map parameterValues) { @@ -84,7 +84,7 @@ public class HibernatePagingItemReader extends AbstractPagingItemReader im * {@link #setQueryString(String) query string} or the { * {@link #setQueryProvider(HibernateQueryProvider) query provider} should * be set. - * + * * @param queryName name of a hibernate named query */ public void setQueryName(String queryName) { @@ -94,7 +94,7 @@ public class HibernatePagingItemReader extends AbstractPagingItemReader im /** * Fetch size used internally by Hibernate to limit amount of data fetched * from database per round trip. - * + * * @param fetchSize the fetch size to pass down to Hibernate */ public void setFetchSize(int fetchSize) { @@ -105,7 +105,7 @@ public class HibernatePagingItemReader extends AbstractPagingItemReader im * A query provider. Either this or the {{@link #setQueryString(String) * query string} or the {{@link #setQueryName(String) query name} should be * set. - * + * * @param queryProvider Hibernate query provider */ public void setQueryProvider(HibernateQueryProvider queryProvider) { @@ -116,7 +116,7 @@ public class HibernatePagingItemReader extends AbstractPagingItemReader im * A query string in HQL. Either this or the { * {@link #setQueryProvider(HibernateQueryProvider) query provider} or the { * {@link #setQueryName(String) query name} should be set. - * + * * @param queryString HQL query string */ public void setQueryString(String queryString) { @@ -125,7 +125,7 @@ public class HibernatePagingItemReader extends AbstractPagingItemReader im /** * The Hibernate SessionFactory to use the create a session. - * + * * @param sessionFactory the {@link SessionFactory} to set */ public void setSessionFactory(SessionFactory sessionFactory) { @@ -134,7 +134,7 @@ public class HibernatePagingItemReader extends AbstractPagingItemReader im /** * Can be set only in uninitialized state. - * + * * @param useStatelessSession true to use * {@link StatelessSession} false to use standard hibernate * {@link Session} @@ -143,6 +143,7 @@ public class HibernatePagingItemReader extends AbstractPagingItemReader im helper.setUseStatelessSession(useStatelessSession); } + @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.state(fetchSize >= 0, "fetchSize must not be negative"); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisBatchItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisBatchItemWriter.java index 597494767..cf168b991 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisBatchItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisBatchItemWriter.java @@ -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. @@ -34,18 +34,18 @@ import com.ibatis.sqlmap.engine.execution.BatchException; import com.ibatis.sqlmap.engine.execution.BatchResult; /** - * {@link ItemWriter} that uses the batching features from - * {@link SqlMapClientTemplate} to execute a batch of statements for all items + * {@link ItemWriter} that uses the batching features from + * {@link SqlMapClientTemplate} to execute a batch of statements for all items * provided.
    - * + * * The user must provide an iBATIS statement id that points to the SQL statement defined * in the iBATIS SqlMap configuration.
    - * + * * It is expected that {@link #write(List)} is called inside a transaction.
    - * + * * The writer is thread safe after its properties are set (normal singleton * behavior), so it can be used to write in multiple concurrent transactions. - * + * * @author Thomas Risberg * @since 2.0 */ @@ -62,7 +62,7 @@ public class IbatisBatchItemWriter implements ItemWriter, InitializingBean /** * Public setter for the flag that determines whether an assertion is made * that all items cause at least one row to be updated. - * + * * @param assertUpdates the flag to set. Defaults to true; */ public void setAssertUpdates(boolean assertUpdates) { @@ -71,7 +71,7 @@ public class IbatisBatchItemWriter implements ItemWriter, InitializingBean /** * Public setter for {@link SqlMapClient} for injection purposes. - * + * * @param sqlMapClient the SqlMapClient */ public void setSqlMapClient(SqlMapClient sqlMapClient) { @@ -82,7 +82,7 @@ public class IbatisBatchItemWriter implements ItemWriter, InitializingBean /** * Public setter for the {@link SqlMapClientTemplate}. - * + * * @param sqlMapClientTemplate the SqlMapClientTemplate */ public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) { @@ -90,9 +90,9 @@ public class IbatisBatchItemWriter implements ItemWriter, InitializingBean } /** - * Public setter for the statement id identifying the statement in the SqlMap + * Public setter for the statement id identifying the statement in the SqlMap * configuration file. - * + * * @param statementId the id for the statement */ public void setStatementId(String statementId) { @@ -102,14 +102,16 @@ public class IbatisBatchItemWriter implements ItemWriter, InitializingBean /** * Check mandatory properties - there must be an SqlMapClient and a statementId. */ + @Override public void afterPropertiesSet() { Assert.notNull(sqlMapClientTemplate, "A SqlMapClient or a SqlMapClientTemplate is required."); Assert.notNull(statementId, "A statementId is required."); } - + /* (non-Javadoc) * @see org.springframework.batch.item.ItemWriter#write(java.util.List) */ + @Override public void write(final List items) { if (!items.isEmpty()) { @@ -117,10 +119,11 @@ public class IbatisBatchItemWriter implements ItemWriter, InitializingBean if (logger.isDebugEnabled()) { logger.debug("Executing batch with " + items.size() + " items."); } - + @SuppressWarnings("unchecked") List results = (List) sqlMapClientTemplate.execute( new SqlMapClientCallback() { + @Override public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException { executor.startBatch(); @@ -134,14 +137,14 @@ public class IbatisBatchItemWriter implements ItemWriter, InitializingBean } } }); - + if (assertUpdates) { if (results.size() != 1) { throw new InvalidDataAccessResourceUsageException("Batch execution returned invalid results. " + "Expected 1 but number of BatchResult objects returned was " + results.size()); } - - int[] updateCounts = results.get(0).getUpdateCounts(); + + int[] updateCounts = results.get(0).getUpdateCounts(); for (int i = 0; i < updateCounts.length; i++) { int value = updateCounts[i]; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisPagingItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisPagingItemReader.java index bd25a122f..afbf25dfe 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisPagingItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisPagingItemReader.java @@ -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. @@ -16,14 +16,14 @@ package org.springframework.batch.item.database; -import org.springframework.util.ClassUtils; -import org.springframework.util.Assert; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CopyOnWriteArrayList; + import org.springframework.batch.item.ExecutionContext; import org.springframework.orm.ibatis.SqlMapClientTemplate; - -import java.util.Map; -import java.util.HashMap; -import java.util.concurrent.CopyOnWriteArrayList; +import org.springframework.util.Assert; +import org.springframework.util.ClassUtils; import com.ibatis.sqlmap.client.SqlMapClient; @@ -32,7 +32,7 @@ import com.ibatis.sqlmap.client.SqlMapClient; * {@link org.springframework.batch.item.ItemReader} for reading database * records using iBATIS in a paging fashion. *

    - * + * *

    * It executes the query specified as the {@link #setQueryId(String)} to * retrieve requested data. The query is executed using paged requests of a size @@ -53,20 +53,20 @@ import com.ibatis.sqlmap.client.SqlMapClient; * infinite loop in the reader because it keeps asking for the next page and * gets the same result set over and over. *

    - * + * *

    * The performance of the paging depends on the iBATIS implementation. * Setting a fairly large page size and using a commit interval that matches the * page size should provide better performance. *

    - * + * *

    * The implementation is thread-safe in between calls to * {@link #open(ExecutionContext)}, but remember to use * saveState=false if used in a multi-threaded client (no restart * available). *

    - * + * * @author Thomas Risberg * @author Dave Syer * @since 2.0 @@ -95,7 +95,7 @@ public class IbatisPagingItemReader extends AbstractPagingItemReader { /** * The parameter values to be used for the query execution. - * + * * @param parameterValues the values keyed by the parameter named used in * the query string. */ @@ -107,6 +107,7 @@ public class IbatisPagingItemReader extends AbstractPagingItemReader { * Check mandatory properties. * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.notNull(sqlMapClient); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcBatchItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcBatchItemWriter.java index 90d7205ef..b9dcfc2ec 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcBatchItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcBatchItemWriter.java @@ -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. @@ -30,29 +30,29 @@ import org.springframework.dao.DataAccessException; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.jdbc.core.PreparedStatementCallback; -import org.springframework.jdbc.core.namedparam.SqlParameterSource; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; +import org.springframework.jdbc.core.namedparam.SqlParameterSource; import org.springframework.util.Assert; /** - *

    {@link ItemWriter} that uses the batching features from + *

    {@link ItemWriter} that uses the batching features from * {@link NamedParameterJdbcTemplate} to execute a batch of statements for all items * provided.

    - * - * The user must provide an SQL query and a special callback in the for of either + * + * The user must provide an SQL query and a special callback in the for of either * {@link ItemPreparedStatementSetter}, or a {@link ItemSqlParameterSourceProvider}. - * You can use either named parameters or the traditional '?' placeholders. If you use the - * named parameter support then you should provide a {@link ItemSqlParameterSourceProvider}, + * You can use either named parameters or the traditional '?' placeholders. If you use the + * named parameter support then you should provide a {@link ItemSqlParameterSourceProvider}, * otherwise you should provide a {@link ItemPreparedStatementSetter}. - * This callback would be responsible for mapping the item to the parameters needed to + * This callback would be responsible for mapping the item to the parameters needed to * execute the SQL statement.
    - * + * * It is expected that {@link #write(List)} is called inside a transaction.
    - * + * * The writer is thread safe after its properties are set (normal singleton * behavior), so it can be used to write in multiple concurrent transactions. - * + * * @author Dave Syer * @author Thomas Risberg * @since 2.0 @@ -114,7 +114,7 @@ public class JdbcBatchItemWriter implements ItemWriter, InitializingBean { /** * Public setter for the data source for injection purposes. - * + * * @param dataSource */ public void setDataSource(DataSource dataSource) { @@ -132,9 +132,10 @@ public class JdbcBatchItemWriter implements ItemWriter, InitializingBean { } /** - * Check mandatory properties - there must be a SimpleJdbcTemplate and an SQL statement plus a + * Check mandatory properties - there must be a SimpleJdbcTemplate and an SQL statement plus a * parameter source. */ + @Override public void afterPropertiesSet() { Assert.notNull(namedParameterJdbcTemplate, "A DataSource or a NamedParameterJdbcTemplate is required."); Assert.notNull(sql, "An SQL statement is required."); @@ -153,10 +154,11 @@ public class JdbcBatchItemWriter implements ItemWriter, InitializingBean { Assert.notNull(itemPreparedStatementSetter, "Using SQL statement with '?' placeholders requires an ItemPreparedStatementSetter"); } } - + /* (non-Javadoc) * @see org.springframework.batch.item.ItemWriter#write(java.util.List) */ + @Override public void write(final List items) throws Exception { if (!items.isEmpty()) { @@ -166,7 +168,7 @@ public class JdbcBatchItemWriter implements ItemWriter, InitializingBean { } int[] updateCounts = null; - + if (usingNamedParameters) { SqlParameterSource[] batchArgs = new SqlParameterSource[items.size()]; int i = 0; @@ -177,6 +179,7 @@ public class JdbcBatchItemWriter implements ItemWriter, InitializingBean { } else { updateCounts = (int[]) namedParameterJdbcTemplate.getJdbcOperations().execute(sql, new PreparedStatementCallback() { + @Override public Object doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException { for (T item : items) { itemPreparedStatementSetter.setValues(item, ps); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcCursorItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcCursorItemReader.java index 3236f2aee..1404bdd78 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcCursorItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcCursorItemReader.java @@ -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. @@ -21,7 +21,6 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; - import org.springframework.jdbc.core.PreparedStatementSetter; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.support.JdbcUtils; @@ -31,26 +30,27 @@ import org.springframework.util.ClassUtils; /** *

    * Simple item reader implementation that opens a JDBC cursor and continually retrieves the - * next row in the ResultSet. + * next row in the ResultSet. *

    - * + * *

    - * The statement used to open the cursor is created with the 'READ_ONLY' option since a non read-only - * cursor may unnecessarily lock tables or rows. It is also opened with 'TYPE_FORWARD_ONLY' option. - * By default the cursor will be opened using a separate connection which means that it will not participate + * The statement used to open the cursor is created with the 'READ_ONLY' option since a non read-only + * cursor may unnecessarily lock tables or rows. It is also opened with 'TYPE_FORWARD_ONLY' option. + * By default the cursor will be opened using a separate connection which means that it will not participate * in any transactions created as part of the step processing. *

    - * + * *

    * Each call to {@link #read()} will call the provided RowMapper, passing in the - * ResultSet. + * ResultSet. *

    - * + * * @author Lucas Ward * @author Peter Zozom * @author Robert Kasanicky * @author Thomas Risberg */ +@SuppressWarnings("rawtypes") public class JdbcCursorItemReader extends AbstractCursorItemReader { PreparedStatement preparedStatement; @@ -68,7 +68,7 @@ public class JdbcCursorItemReader extends AbstractCursorItemReader { /** * Set the RowMapper to be used for all calls to read(). - * + * * @param rowMapper */ public void setRowMapper(RowMapper rowMapper) { @@ -79,7 +79,7 @@ public class JdbcCursorItemReader extends AbstractCursorItemReader { * Set the SQL statement to be used when creating the cursor. This statement * should be a complete and valid SQL statement, as it will be run directly * without any modification. - * + * * @param sql */ public void setSql(String sql) { @@ -89,7 +89,7 @@ public class JdbcCursorItemReader extends AbstractCursorItemReader { /** * Set the PreparedStatementSetter to use if any parameter values that need * to be set in the supplied query. - * + * * @param preparedStatementSetter */ public void setPreparedStatementSetter(PreparedStatementSetter preparedStatementSetter) { @@ -98,10 +98,11 @@ public class JdbcCursorItemReader extends AbstractCursorItemReader { /** * Assert that mandatory properties are set. - * + * * @throws IllegalArgumentException if either data source or sql properties * not set. */ + @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.notNull(sql, "The SQL query must be provided"); @@ -109,7 +110,8 @@ public class JdbcCursorItemReader extends AbstractCursorItemReader { } - protected void openCursor(Connection con) { + @Override + protected void openCursor(Connection con) { try { if (isUseSharedExtendedConnection()) { preparedStatement = con.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, @@ -129,18 +131,20 @@ public class JdbcCursorItemReader extends AbstractCursorItemReader { close(); throw getExceptionTranslator().translate("Executing query", getSql(), se); } - + } + @Override @SuppressWarnings("unchecked") protected T readCursor(ResultSet rs, int currentRow) throws SQLException { return (T) rowMapper.mapRow(rs, currentRow); } - + /** * Close the cursor and database connection. */ + @Override protected void cleanupOnClose() throws Exception { JdbcUtils.closeStatement(this.preparedStatement); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcPagingItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcPagingItemReader.java index 7f8c13775..126867192 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcPagingItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcPagingItemReader.java @@ -266,6 +266,7 @@ public class JdbcPagingItemReader extends AbstractPagingItemReader impleme } RowMapper startMapper = new RowMapper() { + @Override public Object mapRow(ResultSet rs, int i) throws SQLException { return rs.getObject(1); } @@ -324,6 +325,7 @@ public class JdbcPagingItemReader extends AbstractPagingItemReader impleme @SuppressWarnings("rawtypes") private class PagingRowMapper implements RowMapper { + @Override public Object mapRow(ResultSet rs, int rowNum) throws SQLException { startAfterValues = new LinkedHashMap(); for (Map.Entry sortKey : queryProvider.getSortKeys().entrySet()) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JpaItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JpaItemWriter.java index e3e72afeb..803a24809 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JpaItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JpaItemWriter.java @@ -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. @@ -33,18 +33,18 @@ import org.springframework.util.Assert; * {@link org.springframework.batch.item.ItemWriter} that is using a JPA * EntityManagerFactory to merge any Entities that aren't part of the * persistence context. - * + * * It is required that {@link #write(List)} is called inside a transaction.
    - * + * * The reader must be configured with an * {@link javax.persistence.EntityManagerFactory} that is capable of * participating in Spring managed transactions. - * + * * The writer is thread safe after its properties are set (normal singleton * behaviour), so it can be used to write in multiple concurrent transactions. - * + * * @author Thomas Risberg - * + * */ public class JpaItemWriter implements ItemWriter, InitializingBean { @@ -54,7 +54,7 @@ public class JpaItemWriter implements ItemWriter, InitializingBean { /** * Set the EntityManager to be used internally. - * + * * @param entityManagerFactory the entityManagerFactory to set */ public void setEntityManagerFactory(EntityManagerFactory entityManagerFactory) { @@ -64,6 +64,7 @@ public class JpaItemWriter implements ItemWriter, InitializingBean { /** * Check mandatory properties - there must be an entityManagerFactory. */ + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(entityManagerFactory, "An EntityManagerFactory is required"); } @@ -71,9 +72,10 @@ public class JpaItemWriter implements ItemWriter, InitializingBean { /** * Merge all provided items that aren't already in the persistence context * and then flush the entity manager. - * + * * @see org.springframework.batch.item.ItemWriter#write(java.util.List) */ + @Override public final void write(List items) { EntityManager entityManager = EntityManagerFactoryUtils.getTransactionalEntityManager(entityManagerFactory); if (entityManager == null) { @@ -86,7 +88,7 @@ public class JpaItemWriter implements ItemWriter, InitializingBean { /** * Do perform the actual write operation. This can be overridden in a * subclass if necessary. - * + * * @param entityManager the EntityManager to use for the operation * @param items the list of items to use for the write */ diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JpaPagingItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JpaPagingItemReader.java index dc9940235..fd8c002fd 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JpaPagingItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JpaPagingItemReader.java @@ -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. @@ -36,7 +36,7 @@ import org.springframework.util.ClassUtils; * {@link org.springframework.batch.item.ItemReader} for reading database * records built on top of JPA. *

    - * + * *

    * It executes the JPQL {@link #setQueryString(String)} to retrieve requested * data. The query is executed using paged requests of a size specified in @@ -44,39 +44,39 @@ import org.springframework.util.ClassUtils; * {@link #read()} method is called, returning an object corresponding to * current position. *

    - * + * *

    * The performance of the paging depends on the JPA implementation and its use * of database specific features to limit the number of returned rows. *

    - * + * *

    * Setting a fairly large page size and using a commit interval that matches the * page size should provide better performance. *

    - * + * *

    * In order to reduce the memory usage for large results the persistence context * is flushed and cleared after each page is read. This causes any entities read * to be detached. If you make changes to the entities and want the changes * persisted then you must explicitly merge the entities. *

    - * + * *

    * The reader must be configured with an * {@link javax.persistence.EntityManagerFactory}. All entity access is * performed within a new transaction, independent of any existing Spring * managed transactions. *

    - * + * *

    * The implementation is thread-safe in between calls to * {@link #open(ExecutionContext)}, but remember to use * saveState=false if used in a multi-threaded client (no restart * available). *

    - * - * + * + * * @author Thomas Risberg * @author Dave Syer * @since 2.0 @@ -118,7 +118,7 @@ public class JpaPagingItemReader extends AbstractPagingItemReader { /** * The parameter values to be used for the query execution. - * + * * @param parameterValues the values keyed by the parameter named used in * the query string. */ @@ -126,6 +126,7 @@ public class JpaPagingItemReader extends AbstractPagingItemReader { this.parameterValues = parameterValues; } + @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/StoredProcedureItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/StoredProcedureItemReader.java index 8488585dd..e63387c64 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/StoredProcedureItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/StoredProcedureItemReader.java @@ -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,27 +34,28 @@ import org.springframework.util.ClassUtils; /** *

    - * Item reader implementation that executes a stored procedure and then reads the returned cursor - * and continually retrieves the next row in the ResultSet. + * Item reader implementation that executes a stored procedure and then reads the returned cursor + * and continually retrieves the next row in the ResultSet. *

    - * + * *

    - * The callable statement used to open the cursor is created with the 'READ_ONLY' option as well as with the - * 'TYPE_FORWARD_ONLY' option. By default the cursor will be opened using a separate connection which means + * The callable statement used to open the cursor is created with the 'READ_ONLY' option as well as with the + * 'TYPE_FORWARD_ONLY' option. By default the cursor will be opened using a separate connection which means * that it will not participate in any transactions created as part of the step processing. *

    - * + * *

    * Each call to {@link #read()} will call the provided RowMapper, passing in the - * ResultSet. + * ResultSet. *

    - * + * *

    - * This class is modeled after the similar JdbcCursorItemReader class. + * This class is modeled after the similar JdbcCursorItemReader class. *

    - * + * * @author Thomas Risberg */ +@SuppressWarnings("rawtypes") public class StoredProcedureItemReader extends AbstractCursorItemReader { private CallableStatement callableStatement; @@ -62,15 +63,15 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { private PreparedStatementSetter preparedStatementSetter; private String procedureName; - + private String callString; private RowMapper rowMapper; private SqlParameter[] parameters = new SqlParameter[0]; - + private boolean function = false; - + private int refCursorPosition = 0; public StoredProcedureItemReader() { @@ -80,7 +81,7 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { /** * Set the RowMapper to be used for all calls to read(). - * + * * @param rowMapper */ public void setRowMapper(RowMapper rowMapper) { @@ -91,7 +92,7 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { * Set the SQL statement to be used when creating the cursor. This statement * should be a complete and valid SQL statement, as it will be run directly * without any modification. - * + * * @param sprocedureName */ public void setProcedureName(String sprocedureName) { @@ -101,7 +102,7 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { /** * Set the PreparedStatementSetter to use if any parameter values that need * to be set in the supplied query. - * + * * @param preparedStatementSetter */ public void setPreparedStatementSetter(PreparedStatementSetter preparedStatementSetter) { @@ -109,15 +110,15 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { } /** - * Add one or more declared parameters. Used for configuring this operation when used in a - * bean factory. Each parameter will specify SQL type and (optionally) the parameter's name. - * + * Add one or more declared parameters. Used for configuring this operation when used in a + * bean factory. Each parameter will specify SQL type and (optionally) the parameter's name. + * * @param parameters Array containing the declared SqlParameter objects */ public void setParameters(SqlParameter[] parameters) { this.parameters = parameters; } - + /** * Set whether this stored procedure is a function. */ @@ -127,9 +128,9 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { /** * Set the parameter position of the REF CURSOR. Only used for Oracle and - * PostgreSQL that use REF CURSORs. For any other database this should be + * PostgreSQL that use REF CURSORs. For any other database this should be * kept as 0 which is the default. - * + * * @param refCursorPosition The parameter position of the REF CURSOR */ public void setRefCursorPosition(int refCursorPosition) { @@ -138,25 +139,27 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { /** * Assert that mandatory properties are set. - * + * * @throws IllegalArgumentException if either data source or sql properties * not set. */ + @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.notNull(procedureName, "The name of the stored procedure must be provided"); Assert.notNull(rowMapper, "RowMapper must be provided"); } - protected void openCursor(Connection con) { + @Override + protected void openCursor(Connection con) { Assert.state(procedureName != null, "Procedure Name must not be null."); - Assert.state(refCursorPosition >= 0, + Assert.state(refCursorPosition >= 0, "invalid refCursorPosition specified as " + refCursorPosition + "; it can't be " + "specified as a negative number."); - Assert.state(refCursorPosition == 0 || refCursorPosition > 0, - "invalid refCursorPosition specified as " + refCursorPosition + "; there are " + - parameters.length + " parameters defined."); + Assert.state(refCursorPosition == 0 || refCursorPosition > 0, + "invalid refCursorPosition specified as " + refCursorPosition + "; there are " + + parameters.length + " parameters defined."); CallMetaDataContext callContext = new CallMetaDataContext(); callContext.setAccessCallParameterMetaData(false); @@ -168,7 +171,7 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { this.callString = callContext.createCallString(); log.debug("Call string is: " + callString); - + int cursorSqlType = Types.OTHER; if (function) { if (cursorParameter instanceof SqlOutParameter) { @@ -180,7 +183,7 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { cursorSqlType = parameters[refCursorPosition - 1].getSqlType(); } } - + try { if (isUseSharedExtendedConnection()) { callableStatement = con.prepareCall(callString, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, @@ -193,7 +196,7 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { if (this.preparedStatementSetter != null) { preparedStatementSetter.setValues(callableStatement); } - + if (function) { callableStatement.registerOutParameter(1, cursorSqlType); } @@ -223,6 +226,7 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { } + @Override @SuppressWarnings("unchecked") protected T readCursor(ResultSet rs, int currentRow) throws SQLException { return (T) rowMapper.mapRow(rs, currentRow); @@ -231,6 +235,7 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { /** * Close the cursor and database connection. */ + @Override protected void cleanupOnClose() throws Exception { JdbcUtils.closeStatement(this.callableStatement); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/AbstractHibernateQueryProvider.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/AbstractHibernateQueryProvider.java index 3fd0be922..f2e744037 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/AbstractHibernateQueryProvider.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/AbstractHibernateQueryProvider.java @@ -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. @@ -21,42 +21,44 @@ import org.hibernate.Session; import org.hibernate.StatelessSession; /** - *

    Abstract Hibernate Query Provider to serve as a base class for all + *

    Abstract Hibernate Query Provider to serve as a base class for all * Hibernate {@link Query} providers.

    - * - *

    The implementing provider can be configured to use either - * {@link StatelessSession} sufficient for simple mappings without the need - * to cascade to associated objects or standard Hibernate {@link Session} + * + *

    The implementing provider can be configured to use either + * {@link StatelessSession} sufficient for simple mappings without the need + * to cascade to associated objects or standard Hibernate {@link Session} * for more advanced mappings or when caching is desired.

    - * + * * @author Anatoly Polinsky * @author Dave Syer - * + * * @since 2.1 * */ public abstract class AbstractHibernateQueryProvider implements HibernateQueryProvider { - - private StatelessSession statelessSession; - private Session statefulSession; - - public void setStatelessSession(StatelessSession statelessSession) { + + private StatelessSession statelessSession; + private Session statefulSession; + + @Override + public void setStatelessSession(StatelessSession statelessSession) { this.statelessSession = statelessSession; } + @Override public void setSession(Session statefulSession) { this.statefulSession = statefulSession; } public boolean isStatelessSession() { - return this.statefulSession==null && this.statelessSession!=null; - } - - protected StatelessSession getStatelessSession() { - return statelessSession; + return this.statefulSession==null && this.statelessSession!=null; } - protected Session getStatefulSession() { - return statefulSession; - } + protected StatelessSession getStatelessSession() { + return statelessSession; + } + + protected Session getStatefulSession() { + return statefulSession; + } } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/AbstractJpaQueryProvider.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/AbstractJpaQueryProvider.java index aef4e9a6a..118dc34bb 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/AbstractJpaQueryProvider.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/AbstractJpaQueryProvider.java @@ -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,10 +26,10 @@ import org.springframework.beans.factory.InitializingBean; * Abstract JPA Query Provider to serve as a base class for all JPA * {@link Query} providers. *

    - * + * * @author Anatoly Polinsky * @author Dave Syer - * + * * @since 2.1 */ public abstract class AbstractJpaQueryProvider implements JpaQueryProvider, InitializingBean { @@ -42,9 +42,10 @@ public abstract class AbstractJpaQueryProvider implements JpaQueryProvider, Init * {@link HibernateQueryProvider}. This is currently needed to allow * {@link HibernateQueryProvider} to participate in a user's managed transaction. *

    - * + * * @param entityManager */ + @Override public void setEntityManager(EntityManager entityManager) { this.entityManager = entityManager; } @@ -53,7 +54,7 @@ public abstract class AbstractJpaQueryProvider implements JpaQueryProvider, Init *

    * Getter for {@link EntityManager} *

    - * + * * @return entityManager the injected {@link EntityManager} */ protected EntityManager getEntityManager() { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/HibernateNativeQueryProvider.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/HibernateNativeQueryProvider.java index 8ea2e4f39..ffacfdd32 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/HibernateNativeQueryProvider.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/HibernateNativeQueryProvider.java @@ -44,6 +44,7 @@ public class HibernateNativeQueryProvider extends AbstractHibernateQueryProvi * stateless if both are available). *

    */ + @Override public SQLQuery createQuery() { if (isStatelessSession()) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/JpaNativeQueryProvider.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/JpaNativeQueryProvider.java index 80d69579b..6a9be866b 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/JpaNativeQueryProvider.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/JpaNativeQueryProvider.java @@ -38,6 +38,7 @@ public class JpaNativeQueryProvider extends AbstractJpaQueryProvider { private String sqlQuery; + @Override public Query createQuery() { return getEntityManager().createNativeQuery(sqlQuery, entityClass); } @@ -50,6 +51,7 @@ public class JpaNativeQueryProvider extends AbstractJpaQueryProvider { this.entityClass = entityClazz; } + @Override public void afterPropertiesSet() throws Exception { Assert.isTrue(StringUtils.hasText(sqlQuery), "Native SQL query cannot be empty"); Assert.notNull(entityClass, "Entity class cannot be NULL"); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/AbstractSqlPagingQueryProvider.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/AbstractSqlPagingQueryProvider.java index 5123bb34c..c1b89b1d2 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/AbstractSqlPagingQueryProvider.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/AbstractSqlPagingQueryProvider.java @@ -151,14 +151,17 @@ public abstract class AbstractSqlPagingQueryProvider implements PagingQueryProvi * * @return sortKey key to use to sort and limit page content */ + @Override public Map getSortKeys() { return sortKeys; } + @Override public int getParameterCount() { return parameterCount; } + @Override public boolean isUsingNamedParameters() { return usingNamedParameters; } @@ -169,6 +172,7 @@ public abstract class AbstractSqlPagingQueryProvider implements PagingQueryProvi * * @return place holder for sortKey. */ + @Override public String getSortKeyPlaceHolder(String keyName) { return usingNamedParameters ? ":_" + keyName : "?"; } @@ -177,6 +181,7 @@ public abstract class AbstractSqlPagingQueryProvider implements PagingQueryProvi * Check mandatory properties. * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ + @Override public void init(DataSource dataSource) throws Exception { Assert.notNull(dataSource); Assert.hasLength(selectClause, "selectClause must be specified"); @@ -209,6 +214,7 @@ public abstract class AbstractSqlPagingQueryProvider implements PagingQueryProvi * @param pageSize number of rows to read per page * @return query string */ + @Override public abstract String generateFirstPageQuery(int pageSize); /** @@ -218,6 +224,7 @@ public abstract class AbstractSqlPagingQueryProvider implements PagingQueryProvi * @param pageSize number of rows to read per page * @return query string */ + @Override public abstract String generateRemainingPagesQuery(int pageSize); /** @@ -228,6 +235,7 @@ public abstract class AbstractSqlPagingQueryProvider implements PagingQueryProvi * @param pageSize number of rows to read per page * @return query string */ + @Override public abstract String generateJumpToItemQuery(int itemIndex, int pageSize); private String removeKeyWord(String keyWord, String clause) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/ColumnMapItemPreparedStatementSetter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/ColumnMapItemPreparedStatementSetter.java index b4e7148ee..6cb7d9815 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/ColumnMapItemPreparedStatementSetter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/ColumnMapItemPreparedStatementSetter.java @@ -39,6 +39,7 @@ import org.springframework.util.Assert; */ public class ColumnMapItemPreparedStatementSetter implements ItemPreparedStatementSetter> { + @Override public void setValues(Map item, PreparedStatement ps) throws SQLException { Assert.isInstanceOf(Map.class, item, "Input to map PreparedStatement parameters must be of type Map."); int counter = 1; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactory.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactory.java index 92d046a25..83ff2f506 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactory.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactory.java @@ -73,6 +73,7 @@ public class DefaultDataFieldMaxValueIncrementerFactory implements DataFieldMaxV this.dataSource = dataSource; } + @Override public DataFieldMaxValueIncrementer getIncrementer(String incrementerType, String incrementerName) { DatabaseType databaseType = DatabaseType.valueOf(incrementerType.toUpperCase()); @@ -110,6 +111,7 @@ public class DefaultDataFieldMaxValueIncrementerFactory implements DataFieldMaxV } + @Override public boolean isSupportedIncrementerType(String incrementerType) { for (DatabaseType type : DatabaseType.values()) { if (type.name().equals(incrementerType.toUpperCase())) { @@ -120,6 +122,7 @@ public class DefaultDataFieldMaxValueIncrementerFactory implements DataFieldMaxV return false; } + @Override public String[] getSupportedIncrementerTypes() { List types = new ArrayList(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/DerbyPagingQueryProvider.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/DerbyPagingQueryProvider.java index b3e783dc5..97f6fe5a2 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/DerbyPagingQueryProvider.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/DerbyPagingQueryProvider.java @@ -57,10 +57,12 @@ public class DerbyPagingQueryProvider extends SqlWindowingPagingQueryProvider { return ""; } + @Override protected String getOverSubstituteClauseStart() { return " FROM (SELECT " + getSelectClause(); } + @Override protected String getOverSubstituteClauseEnd() { return " ) AS " + getOrderedQueryAlias(); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/SqlPagingQueryProviderFactoryBean.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/SqlPagingQueryProviderFactoryBean.java index 35f7743f0..592e96114 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/SqlPagingQueryProviderFactoryBean.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/SqlPagingQueryProviderFactoryBean.java @@ -145,6 +145,7 @@ public class SqlPagingQueryProviderFactoryBean implements FactoryBean { * * @see FactoryBean#getObject() */ + @Override public Object getObject() throws Exception { DatabaseType type; @@ -181,6 +182,7 @@ public class SqlPagingQueryProviderFactoryBean implements FactoryBean { * * @see FactoryBean#getObjectType() */ + @Override public Class getObjectType() { return PagingQueryProvider.class; } @@ -189,6 +191,7 @@ public class SqlPagingQueryProviderFactoryBean implements FactoryBean { * Always returns true. * @see FactoryBean#isSingleton() */ + @Override public boolean isSingleton() { return true; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/DefaultBufferedReaderFactory.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/DefaultBufferedReaderFactory.java index 91d8f7fde..f32940121 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/DefaultBufferedReaderFactory.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/DefaultBufferedReaderFactory.java @@ -29,6 +29,7 @@ import org.springframework.core.io.Resource; */ public class DefaultBufferedReaderFactory implements BufferedReaderFactory { + @Override public BufferedReader create(Resource resource, String encoding) throws UnsupportedEncodingException, IOException { return new BufferedReader(new InputStreamReader(resource.getInputStream(), encoding)); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/FlatFileItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/FlatFileItemReader.java index bee3d0d8b..cb3308cf5 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/FlatFileItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/FlatFileItemReader.java @@ -145,6 +145,7 @@ public class FlatFileItemReader extends AbstractItemCountingItemStreamItemRea /** * Public setter for the input resource. */ + @Override public void setResource(Resource resource) { this.resource = resource; } @@ -272,6 +273,7 @@ public class FlatFileItemReader extends AbstractItemCountingItemStreamItemRea noInput = false; } + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(lineMapper, "LineMapper is required"); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/FlatFileItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/FlatFileItemWriter.java index e09ff0f22..13ad811d5 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/FlatFileItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/FlatFileItemWriter.java @@ -105,6 +105,7 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implement * * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(lineAggregator, "A LineAggregator must be provided."); if (append) { @@ -149,6 +150,7 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implement * * @param resource */ + @Override public void setResource(Resource resource) { this.resource = resource; } @@ -246,6 +248,7 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implement * @throws Exception if the transformer or file output fail, * WriterNotOpenException if the writer has not been initialized. */ + @Override public void write(List items) throws Exception { if (!getOutputState().isInitialized()) { @@ -276,6 +279,7 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implement /** * @see ItemStream#close() */ + @Override public void close() { if (state != null) { try { @@ -308,6 +312,7 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implement * * @see ItemStream#open(ExecutionContext) */ + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { Assert.notNull(resource, "The resource must be set"); @@ -344,6 +349,7 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implement /** * @see ItemStream#update(ExecutionContext) */ + @Override public void update(ExecutionContext executionContext) { if (state == null) { throw new ItemStreamException("ItemStream not open or already closed."); @@ -581,6 +587,7 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implement final FileChannel channel = fileChannel; if (transactional) { TransactionAwareBufferedWriter writer = new TransactionAwareBufferedWriter(channel, new Runnable() { + @Override public void run() { closeStream(); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/MultiResourceItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/MultiResourceItemReader.java index 4254a7566..5de23a0fe 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/MultiResourceItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/MultiResourceItemReader.java @@ -73,6 +73,7 @@ public class MultiResourceItemReader implements ItemReader, ItemStream { /** * Compares resource filenames. */ + @Override public int compare(Resource r1, Resource r2) { return r1.getFilename().compareTo(r2.getFilename()); } @@ -86,6 +87,7 @@ public class MultiResourceItemReader implements ItemReader, ItemStream { /** * Reads the next item, jumping to next resource if necessary. */ + @Override public T read() throws Exception, UnexpectedInputException, ParseException { if (noInput) { @@ -142,6 +144,7 @@ public class MultiResourceItemReader implements ItemReader, ItemStream { /** * Close the {@link #setDelegate(ResourceAwareItemReaderItemStream)} reader and reset instance variable values. */ + @Override public void close() throws ItemStreamException { delegate.close(); noInput = false; @@ -151,6 +154,7 @@ public class MultiResourceItemReader implements ItemReader, ItemStream { * Figure out which resource to start with in case of restart, open the delegate and restore delegate's position in * the resource. */ + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { Assert.notNull(resources, "Resources must be set"); @@ -189,6 +193,7 @@ public class MultiResourceItemReader implements ItemReader, ItemStream { /** * Store the current resource index and position in the resource. */ + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { if (saveState) { executionContext.putInt(executionContextUserSupport.getKey(RESOURCE_KEY), currentResource); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/MultiResourceItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/MultiResourceItemWriter.java index 018e831df..45b535cf0 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/MultiResourceItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/MultiResourceItemWriter.java @@ -70,6 +70,7 @@ public class MultiResourceItemWriter extends ExecutionContextUserSupport impl setName(ClassUtils.getShortName(MultiResourceItemWriter.class)); } + @Override public void write(List items) throws Exception { if (!opened) { File file = setResourceToDelegate(); @@ -127,6 +128,7 @@ public class MultiResourceItemWriter extends ExecutionContextUserSupport impl this.saveState = saveState; } + @Override public void close() throws ItemStreamException { resourceIndex = 1; currentResourceItemCount = 0; @@ -135,6 +137,7 @@ public class MultiResourceItemWriter extends ExecutionContextUserSupport impl } } + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { resourceIndex = executionContext.getInt(getKey(RESOURCE_INDEX_KEY), 1); currentResourceItemCount = executionContext.getInt(getKey(CURRENT_RESOURCE_ITEM_COUNT), 0); @@ -155,6 +158,7 @@ public class MultiResourceItemWriter extends ExecutionContextUserSupport impl } } + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { if (saveState) { if (opened) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/ResourcesItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/ResourcesItemReader.java index 5d1140c2d..ee1402009 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/ResourcesItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/ResourcesItemReader.java @@ -56,6 +56,7 @@ public class ResourcesItemReader extends ExecutionContextUserSupport implements * Increments a counter and returns the next {@link Resource} instance from * the input, or null if none remain. */ + @Override public synchronized Resource read() throws Exception { int index = counter.incrementAndGet() - 1; if (index >= resources.length) { @@ -64,13 +65,16 @@ public class ResourcesItemReader extends ExecutionContextUserSupport implements return resources[index]; } + @Override public void close() throws ItemStreamException { } + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { counter.set(executionContext.getInt(getKey("COUNT"), 0)); } + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { executionContext.putInt(getKey("COUNT"), counter.get()); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/SimpleBinaryBufferedReaderFactory.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/SimpleBinaryBufferedReaderFactory.java index 87d2af66e..1f1b5b1dc 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/SimpleBinaryBufferedReaderFactory.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/SimpleBinaryBufferedReaderFactory.java @@ -50,6 +50,7 @@ public class SimpleBinaryBufferedReaderFactory implements BufferedReaderFactory this.lineEnding = lineEnding; } + @Override public BufferedReader create(Resource resource, String encoding) throws UnsupportedEncodingException, IOException { return new BinaryBufferedReader(new InputStreamReader(resource.getInputStream(), encoding), lineEnding); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/SimpleResourceSuffixCreator.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/SimpleResourceSuffixCreator.java index aeb58d1d1..01fe937b1 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/SimpleResourceSuffixCreator.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/SimpleResourceSuffixCreator.java @@ -24,6 +24,7 @@ package org.springframework.batch.item.file; */ public class SimpleResourceSuffixCreator implements ResourceSuffixCreator { + @Override public String getSuffix(int index) { return "." + index; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/ArrayFieldSetMapper.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/ArrayFieldSetMapper.java index 2151b4779..b089b0c0f 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/ArrayFieldSetMapper.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/ArrayFieldSetMapper.java @@ -27,6 +27,7 @@ import org.springframework.validation.BindException; */ public class ArrayFieldSetMapper implements FieldSetMapper { + @Override public String[] mapFieldSet(FieldSet fieldSet) throws BindException { return fieldSet.getValues(); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/BeanWrapperFieldSetMapper.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/BeanWrapperFieldSetMapper.java index e33c405eb..0525cd392 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/BeanWrapperFieldSetMapper.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/BeanWrapperFieldSetMapper.java @@ -109,6 +109,7 @@ public class BeanWrapperFieldSetMapper extends DefaultPropertyEditorRegistrar * org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org * .springframework.beans.factory.BeanFactory) */ + @Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; } @@ -161,6 +162,7 @@ public class BeanWrapperFieldSetMapper extends DefaultPropertyEditorRegistrar * * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { Assert.state(name != null || type != null, "Either name or type must be provided."); Assert.state(name == null || type == null, "Both name and type cannot be specified together."); @@ -178,6 +180,7 @@ public class BeanWrapperFieldSetMapper extends DefaultPropertyEditorRegistrar * field that cannot be mapped to a bean property. * @see org.springframework.batch.item.file.mapping.FieldSetMapper#mapFieldSet(FieldSet) */ + @Override public T mapFieldSet(FieldSet fs) throws BindException { T copy = getBean(); DataBinder binder = createBinder(copy); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/DefaultLineMapper.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/DefaultLineMapper.java index 4a21f1d86..27aac6d5b 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/DefaultLineMapper.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/DefaultLineMapper.java @@ -38,6 +38,7 @@ public class DefaultLineMapper implements LineMapper, InitializingBean { private FieldSetMapper fieldSetMapper; + @Override public T mapLine(String line, int lineNumber) throws Exception { return fieldSetMapper.mapFieldSet(tokenizer.tokenize(line)); } @@ -50,6 +51,7 @@ public class DefaultLineMapper implements LineMapper, InitializingBean { this.fieldSetMapper = fieldSetMapper; } + @Override public void afterPropertiesSet() { Assert.notNull(tokenizer, "The LineTokenizer must be set"); Assert.notNull(fieldSetMapper, "The FieldSetMapper must be set"); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/JsonLineMapper.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/JsonLineMapper.java index 41b0f4d8f..05d427a01 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/JsonLineMapper.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/JsonLineMapper.java @@ -33,6 +33,7 @@ public class JsonLineMapper implements LineMapper> { * * @see LineMapper#mapLine(String, int) */ + @Override public Map mapLine(String line, int lineNumber) throws Exception { Map result; JsonParser parser = factory.createJsonParser(line); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/PassThroughFieldSetMapper.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/PassThroughFieldSetMapper.java index b91dcfa97..e90d1b918 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/PassThroughFieldSetMapper.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/PassThroughFieldSetMapper.java @@ -33,6 +33,7 @@ public class PassThroughFieldSetMapper implements FieldSetMapper
    { * org.springframework.batch.item.file.FieldSetMapper#mapLine(org.springframework * .batch.io.file.FieldSet) */ + @Override public FieldSet mapFieldSet(FieldSet fs) { return fs; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/PassThroughLineMapper.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/PassThroughLineMapper.java index 494ae1c4b..be7f2e71e 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/PassThroughLineMapper.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/PassThroughLineMapper.java @@ -25,6 +25,7 @@ import org.springframework.batch.item.file.LineMapper; */ public class PassThroughLineMapper implements LineMapper{ + @Override public String mapLine(String line, int lineNumber) throws Exception { return line; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/PatternMatchingCompositeLineMapper.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/PatternMatchingCompositeLineMapper.java index cd49bcb07..428ba622d 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/PatternMatchingCompositeLineMapper.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/mapping/PatternMatchingCompositeLineMapper.java @@ -57,6 +57,7 @@ public class PatternMatchingCompositeLineMapper implements LineMapper, Ini * org.springframework.batch.item.file.mapping.LineMapper#mapLine(java.lang * .String, int) */ + @Override public T mapLine(String line, int lineNumber) throws Exception { return patternMatcher.match(line).mapFieldSet(this.tokenizer.tokenize(line)); } @@ -67,6 +68,7 @@ public class PatternMatchingCompositeLineMapper implements LineMapper, Ini * @see * org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { this.tokenizer.afterPropertiesSet(); Assert.isTrue(this.patternMatcher != null, "The 'fieldSetMappers' property must be non-empty"); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/separator/DefaultRecordSeparatorPolicy.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/separator/DefaultRecordSeparatorPolicy.java index e535777d2..92d6b0745 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/separator/DefaultRecordSeparatorPolicy.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/separator/DefaultRecordSeparatorPolicy.java @@ -85,6 +85,7 @@ public class DefaultRecordSeparatorPolicy extends SimpleRecordSeparatorPolicy { * * @see org.springframework.batch.item.file.separator.RecordSeparatorPolicy#isEndOfRecord(java.lang.String) */ + @Override public boolean isEndOfRecord(String line) { return !isQuoteUnterminated(line) && !isContinued(line); } @@ -96,6 +97,7 @@ public class DefaultRecordSeparatorPolicy extends SimpleRecordSeparatorPolicy { * * @see org.springframework.batch.item.file.separator.SimpleRecordSeparatorPolicy#preProcess(java.lang.String) */ + @Override public String preProcess(String line) { if (isQuoteUnterminated(line)) { return line + "\n"; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/separator/JsonRecordSeparatorPolicy.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/separator/JsonRecordSeparatorPolicy.java index e64aa3064..def28d8ed 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/separator/JsonRecordSeparatorPolicy.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/separator/JsonRecordSeparatorPolicy.java @@ -41,6 +41,7 @@ public class JsonRecordSeparatorPolicy extends SimpleRecordSeparatorPolicy { * * @see RecordSeparatorPolicy#isEndOfRecord(String) */ + @Override public boolean isEndOfRecord(String line) { return StringUtils.countOccurrencesOf(line, "{") == StringUtils.countOccurrencesOf(line, "}") && line.trim().endsWith("}"); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/separator/SimpleRecordSeparatorPolicy.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/separator/SimpleRecordSeparatorPolicy.java index 4751dd8c2..d00674abd 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/separator/SimpleRecordSeparatorPolicy.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/separator/SimpleRecordSeparatorPolicy.java @@ -31,6 +31,7 @@ public class SimpleRecordSeparatorPolicy implements RecordSeparatorPolicy { * * @see org.springframework.batch.item.file.separator.RecordSeparatorPolicy#isEndOfRecord(java.lang.String) */ + @Override public boolean isEndOfRecord(String line) { return true; } @@ -39,6 +40,7 @@ public class SimpleRecordSeparatorPolicy implements RecordSeparatorPolicy { * Pass the record through. Do nothing. * @see org.springframework.batch.item.file.separator.RecordSeparatorPolicy#postProcess(java.lang.String) */ + @Override public String postProcess(String record) { return record; } @@ -47,6 +49,7 @@ public class SimpleRecordSeparatorPolicy implements RecordSeparatorPolicy { * Pass the line through. Do nothing. * @see org.springframework.batch.item.file.separator.RecordSeparatorPolicy#preProcess(java.lang.String) */ + @Override public String preProcess(String line) { return line; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/separator/SuffixRecordSeparatorPolicy.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/separator/SuffixRecordSeparatorPolicy.java index b8147b4c4..b04b400c4 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/separator/SuffixRecordSeparatorPolicy.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/separator/SuffixRecordSeparatorPolicy.java @@ -61,6 +61,7 @@ public class SuffixRecordSeparatorPolicy extends DefaultRecordSeparatorPolicy { * * @see org.springframework.batch.item.file.separator.RecordSeparatorPolicy#isEndOfRecord(java.lang.String) */ + @Override public boolean isEndOfRecord(String line) { if (line == null) { return true; @@ -74,6 +75,7 @@ public class SuffixRecordSeparatorPolicy extends DefaultRecordSeparatorPolicy { * * @see org.springframework.batch.item.file.separator.SimpleRecordSeparatorPolicy#postProcess(java.lang.String) */ + @Override public String postProcess(String record) { if (record==null) { return null; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/AbstractLineTokenizer.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/AbstractLineTokenizer.java index d7e1ca6e8..5f58642c7 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/AbstractLineTokenizer.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/AbstractLineTokenizer.java @@ -101,6 +101,7 @@ public abstract class AbstractLineTokenizer implements LineTokenizer { * * @return the resulting tokens */ + @Override public FieldSet tokenize(String line) { if (line == null) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/BeanWrapperFieldExtractor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/BeanWrapperFieldExtractor.java index 66ece9e6d..9151a5b5b 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/BeanWrapperFieldExtractor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/BeanWrapperFieldExtractor.java @@ -48,6 +48,7 @@ public class BeanWrapperFieldExtractor implements FieldExtractor, Initiali /** * @see org.springframework.batch.item.file.transform.FieldExtractor#extract(java.lang.Object) */ + @Override public Object[] extract(T item) { List values = new ArrayList(); @@ -58,6 +59,7 @@ public class BeanWrapperFieldExtractor implements FieldExtractor, Initiali return values.toArray(); } + @Override public void afterPropertiesSet() { Assert.notNull(names, "The 'names' property must be set."); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/DefaultFieldSet.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/DefaultFieldSet.java index 2bef134a8..d6d1af5ea 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/DefaultFieldSet.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/DefaultFieldSet.java @@ -118,6 +118,7 @@ public class DefaultFieldSet implements FieldSet { * * @see org.springframework.batch.item.file.mapping.IFieldSet#getNames() */ + @Override public String[] getNames() { if (names == null) { throw new IllegalStateException("Field names are not known"); @@ -130,6 +131,7 @@ public class DefaultFieldSet implements FieldSet { * * @see org.springframework.batch.item.file.mapping.FieldSet#hasNames() */ + @Override public boolean hasNames() { return names != null; } @@ -139,6 +141,7 @@ public class DefaultFieldSet implements FieldSet { * * @see org.springframework.batch.item.file.mapping.IFieldSet#getValues() */ + @Override public String[] getValues() { return tokens.clone(); } @@ -149,6 +152,7 @@ public class DefaultFieldSet implements FieldSet { * @see * org.springframework.batch.item.file.mapping.IFieldSet#readString(int) */ + @Override public String readString(int index) { return readAndTrim(index); } @@ -160,6 +164,7 @@ public class DefaultFieldSet implements FieldSet { * org.springframework.batch.item.file.mapping.IFieldSet#readString(java * .lang.String) */ + @Override public String readString(String name) { return readString(indexOf(name)); } @@ -170,6 +175,7 @@ public class DefaultFieldSet implements FieldSet { * @see * org.springframework.batch.item.file.mapping.IFieldSet#readRawString(int) */ + @Override public String readRawString(int index) { return tokens[index]; } @@ -181,6 +187,7 @@ public class DefaultFieldSet implements FieldSet { * org.springframework.batch.item.file.mapping.IFieldSet#readRawString(java * .lang.String) */ + @Override public String readRawString(String name) { return readRawString(indexOf(name)); } @@ -191,6 +198,7 @@ public class DefaultFieldSet implements FieldSet { * @see * org.springframework.batch.item.file.mapping.IFieldSet#readBoolean(int) */ + @Override public boolean readBoolean(int index) { return readBoolean(index, "true"); } @@ -202,6 +210,7 @@ public class DefaultFieldSet implements FieldSet { * org.springframework.batch.item.file.mapping.IFieldSet#readBoolean(java * .lang.String) */ + @Override public boolean readBoolean(String name) { return readBoolean(indexOf(name)); } @@ -213,6 +222,7 @@ public class DefaultFieldSet implements FieldSet { * org.springframework.batch.item.file.mapping.IFieldSet#readBoolean(int, * java.lang.String) */ + @Override public boolean readBoolean(int index, String trueValue) { Assert.notNull(trueValue, "'trueValue' cannot be null."); @@ -228,6 +238,7 @@ public class DefaultFieldSet implements FieldSet { * org.springframework.batch.item.file.mapping.IFieldSet#readBoolean(java * .lang.String, java.lang.String) */ + @Override public boolean readBoolean(String name, String trueValue) { return readBoolean(indexOf(name), trueValue); } @@ -237,6 +248,7 @@ public class DefaultFieldSet implements FieldSet { * * @see org.springframework.batch.item.file.mapping.IFieldSet#readChar(int) */ + @Override public char readChar(int index) { String value = readAndTrim(index); @@ -252,6 +264,7 @@ public class DefaultFieldSet implements FieldSet { * org.springframework.batch.item.file.mapping.IFieldSet#readChar(java.lang * .String) */ + @Override public char readChar(String name) { return readChar(indexOf(name)); } @@ -261,6 +274,7 @@ public class DefaultFieldSet implements FieldSet { * * @see org.springframework.batch.item.file.mapping.IFieldSet#readByte(int) */ + @Override public byte readByte(int index) { return Byte.parseByte(readAndTrim(index)); } @@ -272,6 +286,7 @@ public class DefaultFieldSet implements FieldSet { * org.springframework.batch.item.file.mapping.IFieldSet#readByte(java.lang * .String) */ + @Override public byte readByte(String name) { return readByte(indexOf(name)); } @@ -281,6 +296,7 @@ public class DefaultFieldSet implements FieldSet { * * @see org.springframework.batch.item.file.mapping.IFieldSet#readShort(int) */ + @Override public short readShort(int index) { return Short.parseShort(readAndTrim(index)); } @@ -292,6 +308,7 @@ public class DefaultFieldSet implements FieldSet { * org.springframework.batch.item.file.mapping.IFieldSet#readShort(java. * lang.String) */ + @Override public short readShort(String name) { return readShort(indexOf(name)); } @@ -301,6 +318,7 @@ public class DefaultFieldSet implements FieldSet { * * @see org.springframework.batch.item.file.mapping.IFieldSet#readInt(int) */ + @Override public int readInt(int index) { return parseNumber(readAndTrim(index)).intValue(); } @@ -312,6 +330,7 @@ public class DefaultFieldSet implements FieldSet { * org.springframework.batch.item.file.mapping.IFieldSet#readInt(java.lang * .String) */ + @Override public int readInt(String name) { return readInt(indexOf(name)); } @@ -322,6 +341,7 @@ public class DefaultFieldSet implements FieldSet { * @see org.springframework.batch.item.file.mapping.IFieldSet#readInt(int, * int) */ + @Override public int readInt(int index, int defaultValue) { String value = readAndTrim(index); @@ -335,6 +355,7 @@ public class DefaultFieldSet implements FieldSet { * org.springframework.batch.item.file.mapping.IFieldSet#readInt(java.lang * .String, int) */ + @Override public int readInt(String name, int defaultValue) { return readInt(indexOf(name), defaultValue); } @@ -344,6 +365,7 @@ public class DefaultFieldSet implements FieldSet { * * @see org.springframework.batch.item.file.mapping.IFieldSet#readLong(int) */ + @Override public long readLong(int index) { return parseNumber(readAndTrim(index)).longValue(); } @@ -355,6 +377,7 @@ public class DefaultFieldSet implements FieldSet { * org.springframework.batch.item.file.mapping.IFieldSet#readLong(java.lang * .String) */ + @Override public long readLong(String name) { return readLong(indexOf(name)); } @@ -365,6 +388,7 @@ public class DefaultFieldSet implements FieldSet { * @see org.springframework.batch.item.file.mapping.IFieldSet#readLong(int, * long) */ + @Override public long readLong(int index, long defaultValue) { String value = readAndTrim(index); @@ -378,6 +402,7 @@ public class DefaultFieldSet implements FieldSet { * org.springframework.batch.item.file.mapping.IFieldSet#readLong(java.lang * .String, long) */ + @Override public long readLong(String name, long defaultValue) { return readLong(indexOf(name), defaultValue); } @@ -387,6 +412,7 @@ public class DefaultFieldSet implements FieldSet { * * @see org.springframework.batch.item.file.mapping.IFieldSet#readFloat(int) */ + @Override public float readFloat(int index) { return parseNumber(readAndTrim(index)).floatValue(); } @@ -398,6 +424,7 @@ public class DefaultFieldSet implements FieldSet { * org.springframework.batch.item.file.mapping.IFieldSet#readFloat(java. * lang.String) */ + @Override public float readFloat(String name) { return readFloat(indexOf(name)); } @@ -408,6 +435,7 @@ public class DefaultFieldSet implements FieldSet { * @see * org.springframework.batch.item.file.mapping.IFieldSet#readDouble(int) */ + @Override public double readDouble(int index) { return (Double) parseNumber(readAndTrim(index)).doubleValue(); } @@ -419,6 +447,7 @@ public class DefaultFieldSet implements FieldSet { * org.springframework.batch.item.file.mapping.IFieldSet#readDouble(java * .lang.String) */ + @Override public double readDouble(String name) { return readDouble(indexOf(name)); } @@ -429,6 +458,7 @@ public class DefaultFieldSet implements FieldSet { * @see * org.springframework.batch.item.file.mapping.IFieldSet#readBigDecimal(int) */ + @Override public BigDecimal readBigDecimal(int index) { return readBigDecimal(index, null); } @@ -440,6 +470,7 @@ public class DefaultFieldSet implements FieldSet { * org.springframework.batch.item.file.mapping.IFieldSet#readBigDecimal( * java.lang.String) */ + @Override public BigDecimal readBigDecimal(String name) { return readBigDecimal(name, null); } @@ -451,6 +482,7 @@ public class DefaultFieldSet implements FieldSet { * org.springframework.batch.item.file.mapping.IFieldSet#readBigDecimal(int, * java.math.BigDecimal) */ + @Override public BigDecimal readBigDecimal(int index, BigDecimal defaultValue) { String candidate = readAndTrim(index); @@ -478,6 +510,7 @@ public class DefaultFieldSet implements FieldSet { * org.springframework.batch.item.file.mapping.IFieldSet#readBigDecimal( * java.lang.String, java.math.BigDecimal) */ + @Override public BigDecimal readBigDecimal(String name, BigDecimal defaultValue) { try { return readBigDecimal(indexOf(name), defaultValue); @@ -495,6 +528,7 @@ public class DefaultFieldSet implements FieldSet { * * @see org.springframework.batch.item.file.mapping.IFieldSet#readDate(int) */ + @Override public Date readDate(int index) { return parseDate(readAndTrim(index), dateFormat); } @@ -505,6 +539,7 @@ public class DefaultFieldSet implements FieldSet { * @see org.springframework.batch.item.file.transform.FieldSet#readDate(int, * java.util.Date) */ + @Override public Date readDate(int index, Date defaultValue) { try { return readDate(index); @@ -521,6 +556,7 @@ public class DefaultFieldSet implements FieldSet { * org.springframework.batch.item.file.mapping.IFieldSet#readDate(java.lang * .String) */ + @Override public Date readDate(String name) { try { return readDate(indexOf(name)); @@ -536,6 +572,7 @@ public class DefaultFieldSet implements FieldSet { * @see org.springframework.batch.item.file.transform.FieldSet#readDate(int, * java.util.Date) */ + @Override public Date readDate(String name, Date defaultValue) { try { return readDate(name); @@ -551,6 +588,7 @@ public class DefaultFieldSet implements FieldSet { * @see org.springframework.batch.item.file.mapping.IFieldSet#readDate(int, * java.lang.String) */ + @Override public Date readDate(int index, String pattern) { SimpleDateFormat sdf = new SimpleDateFormat(pattern); sdf.setLenient(false); @@ -563,6 +601,7 @@ public class DefaultFieldSet implements FieldSet { * @see org.springframework.batch.item.file.mapping.IFieldSet#readDate(int, * java.lang.String) */ + @Override public Date readDate(int index, String pattern, Date defaultValue) { try { return readDate(index, pattern); @@ -579,6 +618,7 @@ public class DefaultFieldSet implements FieldSet { * org.springframework.batch.item.file.mapping.IFieldSet#readDate(java.lang * .String, java.lang.String) */ + @Override public Date readDate(String name, String pattern) { try { return readDate(indexOf(name), pattern); @@ -594,6 +634,7 @@ public class DefaultFieldSet implements FieldSet { * @see org.springframework.batch.item.file.mapping.IFieldSet#readDate(int, * java.lang.String) */ + @Override public Date readDate(String name, String pattern, Date defaultValue) { try { return readDate(name, pattern); @@ -609,6 +650,7 @@ public class DefaultFieldSet implements FieldSet { * @see * org.springframework.batch.item.file.mapping.IFieldSet#getFieldCount() */ + @Override public int getFieldCount() { return tokens.length; } @@ -647,6 +689,7 @@ public class DefaultFieldSet implements FieldSet { throw new IllegalArgumentException("Cannot access column [" + name + "] from " + names); } + @Override public String toString() { if (names != null) { return getProperties().toString(); @@ -658,6 +701,7 @@ public class DefaultFieldSet implements FieldSet { /** * @see java.lang.Object#equals(java.lang.Object) */ + @Override public boolean equals(Object object) { if (object instanceof DefaultFieldSet) { DefaultFieldSet fs = (DefaultFieldSet) object; @@ -673,6 +717,7 @@ public class DefaultFieldSet implements FieldSet { return false; } + @Override public int hashCode() { // this algorithm was taken from java 1.5 jdk Arrays.hashCode(Object[]) if (tokens == null) { @@ -694,6 +739,7 @@ public class DefaultFieldSet implements FieldSet { * @see * org.springframework.batch.item.file.mapping.IFieldSet#getProperties() */ + @Override public Properties getProperties() { if (names == null) { throw new IllegalStateException("Cannot create properties without meta data"); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/DefaultFieldSetFactory.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/DefaultFieldSetFactory.java index 02b0c30ef..d1a01cea5 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/DefaultFieldSetFactory.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/DefaultFieldSetFactory.java @@ -38,6 +38,7 @@ public class DefaultFieldSetFactory implements FieldSetFactory { /** * {@inheritDoc} */ + @Override public FieldSet create(String[] values, String[] names) { DefaultFieldSet fieldSet = new DefaultFieldSet(values, names); return enhance(fieldSet); @@ -46,6 +47,7 @@ public class DefaultFieldSetFactory implements FieldSetFactory { /** * {@inheritDoc} */ + @Override public FieldSet create(String[] values) { DefaultFieldSet fieldSet = new DefaultFieldSet(values); return enhance(fieldSet); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/ExtractorLineAggregator.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/ExtractorLineAggregator.java index a2277def7..48838e5bb 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/ExtractorLineAggregator.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/ExtractorLineAggregator.java @@ -48,6 +48,7 @@ public abstract class ExtractorLineAggregator implements LineAggregator { * * @see org.springframework.batch.item.file.transform.LineAggregator#aggregate(java.lang.Object) */ + @Override public String aggregate(T item) { Assert.notNull(item); Object[] fields = this.fieldExtractor.extract(item); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/FixedLengthTokenizer.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/FixedLengthTokenizer.java index 8124d5e4f..4da782ee4 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/FixedLengthTokenizer.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/FixedLengthTokenizer.java @@ -96,6 +96,7 @@ public class FixedLengthTokenizer extends AbstractLineTokenizer { * @throws IncorrectLineLengthException if line length is greater than or * less than the max range set. */ + @Override protected List doTokenize(String line) { List tokens = new ArrayList(ranges.length); int lineLength; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/PassThroughFieldExtractor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/PassThroughFieldExtractor.java index 345fdc59b..1ce70368f 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/PassThroughFieldExtractor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/PassThroughFieldExtractor.java @@ -46,6 +46,7 @@ public class PassThroughFieldExtractor implements FieldExtractor { * @param item the object to convert * @return an array of objects as close as possible to the original item */ + @Override public Object[] extract(T item) { if (item.getClass().isArray()) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/PassThroughLineAggregator.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/PassThroughLineAggregator.java index cd3bbbb60..df698a365 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/PassThroughLineAggregator.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/PassThroughLineAggregator.java @@ -28,6 +28,7 @@ public class PassThroughLineAggregator implements LineAggregator { * * @see org.springframework.batch.item.file.transform.LineAggregator#aggregate(java.lang.Object) */ + @Override public String aggregate(T item) { return item.toString(); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/PatternMatchingCompositeLineTokenizer.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/PatternMatchingCompositeLineTokenizer.java index 63cd00d59..e12fac113 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/PatternMatchingCompositeLineTokenizer.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/PatternMatchingCompositeLineTokenizer.java @@ -45,6 +45,7 @@ public class PatternMatchingCompositeLineTokenizer implements LineTokenizer, Ini * org.springframework.batch.item.file.transform.LineTokenizer#tokenize( * java.lang.String) */ + @Override public FieldSet tokenize(String line) { return tokenizers.match(line).tokenize(line); } @@ -55,6 +56,7 @@ public class PatternMatchingCompositeLineTokenizer implements LineTokenizer, Ini * @see * org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { Assert.isTrue(this.tokenizers != null, "The 'tokenizers' property must be non-empty"); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/Range.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/Range.java index 3f53d47f4..94ac6a079 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/Range.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/Range.java @@ -55,6 +55,7 @@ public class Range { return max != UPPER_BORDER_NOT_DEFINED; } + @Override public String toString() { return hasMaxValue() ? min + "-" + max : String.valueOf(min); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/RangeArrayPropertyEditor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/RangeArrayPropertyEditor.java index 30a0b51ee..0398b47ab 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/RangeArrayPropertyEditor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/RangeArrayPropertyEditor.java @@ -61,6 +61,7 @@ public class RangeArrayPropertyEditor extends PropertyEditorSupport { this.forceDisjointRanges = forceDisjointRanges; } + @Override public void setAsText(String text) throws IllegalArgumentException { //split text into ranges @@ -93,6 +94,7 @@ public class RangeArrayPropertyEditor extends PropertyEditorSupport { setValue(ranges); } + @Override public String getAsText() { Range[] ranges = (Range[])getValue(); @@ -117,6 +119,7 @@ public class RangeArrayPropertyEditor extends PropertyEditorSupport { //sort array of Ranges Arrays.sort(c, new Comparator() { + @Override public int compare(Integer r1, Integer r2) { return ranges[r1].getMin()-ranges[r2].getMin(); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/RecursiveCollectionLineAggregator.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/RecursiveCollectionLineAggregator.java index 6a5e7760d..4b75752e9 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/RecursiveCollectionLineAggregator.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/RecursiveCollectionLineAggregator.java @@ -47,6 +47,7 @@ public class RecursiveCollectionLineAggregator implements LineAggregator items) { StringBuilder builder = new StringBuilder(); for (T value : items) { @@ -55,4 +56,4 @@ public class RecursiveCollectionLineAggregator implements LineAggregator implements ItemReader, InitializingBean { this.itemType = itemType; } + @Override @SuppressWarnings("unchecked") public T read() { if (itemType != null && itemType.isAssignableFrom(Message.class)) { @@ -89,6 +90,7 @@ public class JmsItemReader implements ItemReader, InitializingBean { return (T) result; } + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(this.jmsTemplate, "The 'jmsTemplate' is required."); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsItemWriter.java index 588186f62..db3308d60 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsItemWriter.java @@ -65,6 +65,7 @@ public class JmsItemWriter implements ItemWriter { * * @see org.springframework.batch.item.ItemWriter#write(java.util.List) */ + @Override public void write(List items) throws Exception { if (logger.isDebugEnabled()) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsMethodArgumentsKeyGenerator.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsMethodArgumentsKeyGenerator.java index b7c099d55..28916c93c 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsMethodArgumentsKeyGenerator.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsMethodArgumentsKeyGenerator.java @@ -40,6 +40,7 @@ public class JmsMethodArgumentsKeyGenerator implements MethodArgumentsKeyGenerat * a JMS Message * @throws IllegalArgumentException if the arguments are empty */ + @Override public Object getKey(Object[] items) { for (Object item : items) { if (item instanceof Message) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsMethodInvocationRecoverer.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsMethodInvocationRecoverer.java index 03c087d0b..5b6be5418 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsMethodInvocationRecoverer.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsMethodInvocationRecoverer.java @@ -47,6 +47,7 @@ public class JmsMethodInvocationRecoverer implements MethodInvocationRecovere * @see org.springframework.retry.interceptor.MethodInvocationRecoverer#recover(Object[], * Throwable) */ + @Override public T recover(Object[] items, Throwable cause) { try { for (Object item : items) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsNewMethodArgumentsIdentifier.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsNewMethodArgumentsIdentifier.java index 2cfb61a87..1600654b9 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsNewMethodArgumentsIdentifier.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsNewMethodArgumentsIdentifier.java @@ -37,6 +37,7 @@ public class JmsNewMethodArgumentsIdentifier implements NewMethodArgumentsIde * * @see org.springframework.retry.interceptor.NewMethodArgumentsIdentifier#isNew(java.lang.Object[]) */ + @Override public boolean isNew(Object[] args) { for (Object item : args) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/mail/DefaultMailErrorHandler.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/mail/DefaultMailErrorHandler.java index d90d2ea7d..11a09063d 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/mail/DefaultMailErrorHandler.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/mail/DefaultMailErrorHandler.java @@ -53,6 +53,7 @@ public class DefaultMailErrorHandler implements MailErrorHandler { * @throws MailException a translation of the Exception * @see MailErrorHandler#handle(MailMessage, Exception) */ + @Override public void handle(MailMessage message, Exception exception) throws MailException { String msg = message.toString(); throw new MailSendException("Mail server send failed: " diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/mail/SimpleMailMessageItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/mail/SimpleMailMessageItemWriter.java index 0421d10e3..0aa0d08a8 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/mail/SimpleMailMessageItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/mail/SimpleMailMessageItemWriter.java @@ -86,6 +86,7 @@ public class SimpleMailMessageItemWriter implements ItemWriter items) throws MailException { try { mailSender.send(items.toArray(new SimpleMailMessage[items.size()])); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/mail/javamail/MimeMessageItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/mail/javamail/MimeMessageItemWriter.java index ec2019e48..6c8b72e72 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/mail/javamail/MimeMessageItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/mail/javamail/MimeMessageItemWriter.java @@ -99,6 +99,7 @@ public class MimeMessageItemWriter implements ItemWriter { * @param items the items to send * @see ItemWriter#write(List) */ + @Override public void write(List items) throws MailException { try { mailSender.send(items.toArray(new MimeMessage[items.size()])); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/AbstractItemCountingItemStreamItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/AbstractItemCountingItemStreamItemReader.java index 72a7bcddd..7fb019bf6 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/AbstractItemCountingItemStreamItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/AbstractItemCountingItemStreamItemReader.java @@ -77,6 +77,7 @@ public abstract class AbstractItemCountingItemStreamItemReader implements Ite } } + @Override public final T read() throws Exception, UnexpectedInputException, ParseException { if (currentItemCount >= maxItemCount) { return null; @@ -118,6 +119,7 @@ public abstract class AbstractItemCountingItemStreamItemReader implements Ite this.maxItemCount = count; } + @Override public void close() throws ItemStreamException { currentItemCount = 0; try { @@ -128,6 +130,7 @@ public abstract class AbstractItemCountingItemStreamItemReader implements Ite } } + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { try { @@ -161,6 +164,7 @@ public abstract class AbstractItemCountingItemStreamItemReader implements Ite } + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { if (saveState) { Assert.notNull(executionContext, "ExecutionContext must not be null"); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ClassifierCompositeItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ClassifierCompositeItemWriter.java index a3fa648c7..b8ab7e146 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ClassifierCompositeItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ClassifierCompositeItemWriter.java @@ -49,6 +49,7 @@ public class ClassifierCompositeItemWriter implements ItemWriter { * Delegates to injected {@link ItemWriter} instances according to their * classification by the {@link Classifier}. */ + @Override public void write(List items) throws Exception { Map, List> map = new HashMap, List>(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemProcessor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemProcessor.java index 921bad3fc..29e552525 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemProcessor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemProcessor.java @@ -37,6 +37,7 @@ public class CompositeItemProcessor implements ItemProcessor, Initia private List> delegates; + @Override @SuppressWarnings("unchecked") public O process(I item) throws Exception { Object result = item; @@ -50,6 +51,7 @@ public class CompositeItemProcessor implements ItemProcessor, Initia return (O) result; } + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(delegates, "The 'delgates' may not be null"); Assert.notEmpty(delegates, "The 'delgates' may not be empty"); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemStream.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemStream.java index 3db7ce1db..e56dfbb97 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemStream.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemStream.java @@ -68,6 +68,7 @@ public class CompositeItemStream implements ItemStream { * * @see org.springframework.batch.item.ItemStream#update(ExecutionContext) */ + @Override public void update(ExecutionContext executionContext) { for (ItemStream itemStream : streams) { itemStream.update(executionContext); @@ -78,6 +79,7 @@ public class CompositeItemStream implements ItemStream { * Broadcast the call to close. * @throws ItemStreamException */ + @Override public void close() throws ItemStreamException { for (ItemStream itemStream : streams) { itemStream.close(); @@ -88,6 +90,7 @@ public class CompositeItemStream implements ItemStream { * Broadcast the call to open. * @throws ItemStreamException */ + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { for (ItemStream itemStream : streams) { itemStream.open(executionContext); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemWriter.java index f511b63e7..1faa720ea 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemWriter.java @@ -45,12 +45,14 @@ public class CompositeItemWriter implements ItemStreamWriter, Initializing this.ignoreItemStream = ignoreItemStream; } + @Override public void write(List item) throws Exception { for (ItemWriter writer : delegates) { writer.write(item); } } + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(delegates, "The 'delgates' may not be null"); Assert.notEmpty(delegates, "The 'delgates' may not be empty"); @@ -60,6 +62,7 @@ public class CompositeItemWriter implements ItemStreamWriter, Initializing this.delegates = delegates; } + @Override public void close() throws ItemStreamException { for (ItemWriter writer : delegates) { if (!ignoreItemStream && (writer instanceof ItemStream)) { @@ -68,6 +71,7 @@ public class CompositeItemWriter implements ItemStreamWriter, Initializing } } + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { for (ItemWriter writer : delegates) { if (!ignoreItemStream && (writer instanceof ItemStream)) { @@ -76,6 +80,7 @@ public class CompositeItemWriter implements ItemStreamWriter, Initializing } } + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { for (ItemWriter writer : delegates) { if (!ignoreItemStream && (writer instanceof ItemStream)) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/IteratorItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/IteratorItemReader.java index 958bfbd44..9cbcbc159 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/IteratorItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/IteratorItemReader.java @@ -63,6 +63,7 @@ public class IteratorItemReader implements ItemReader { * Implementation of {@link ItemReader#read()} that just iterates over the * iterator provided. */ + @Override public T read() throws Exception, UnexpectedInputException, ParseException { if (iterator.hasNext()) return iterator.next(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ListItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ListItemReader.java index 50361271b..108ff8ab8 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ListItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ListItemReader.java @@ -43,6 +43,7 @@ public class ListItemReader implements ItemReader { } } + @Override public T read() { if (!list.isEmpty()) { return list.remove(0); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/PassThroughItemProcessor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/PassThroughItemProcessor.java index d0ba048c0..e5825cbf1 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/PassThroughItemProcessor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/PassThroughItemProcessor.java @@ -35,8 +35,9 @@ public class PassThroughItemProcessor implements ItemProcessor { * @return the item * @see ItemProcessor#process(Object) */ + @Override public T process(T item) throws Exception { return item; } -} \ No newline at end of file +} diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/SingleItemPeekableItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/SingleItemPeekableItemReader.java index 75cbc1477..c01e1933b 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/SingleItemPeekableItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/SingleItemPeekableItemReader.java @@ -66,6 +66,7 @@ public class SingleItemPeekableItemReader implements ItemStreamReader, Pee * * @see ItemReader#read() */ + @Override public T read() throws Exception, UnexpectedInputException, ParseException { if (next != null) { T item = next; @@ -85,6 +86,7 @@ public class SingleItemPeekableItemReader implements ItemStreamReader, Pee * * @see PeekableItemReader#peek() */ + @Override public T peek() throws Exception, UnexpectedInputException, ParseException { if (next == null) { updateDelegate(executionContext); @@ -100,6 +102,7 @@ public class SingleItemPeekableItemReader implements ItemStreamReader, Pee * @throws ItemStreamException if there is a problem * @see ItemStream#close() */ + @Override public void close() throws ItemStreamException { next = null; if (delegate instanceof ItemStream) { @@ -116,6 +119,7 @@ public class SingleItemPeekableItemReader implements ItemStreamReader, Pee * @throws ItemStreamException if there is a problem * @see ItemStream#open(ExecutionContext) */ + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { next = null; if (delegate instanceof ItemStream) { @@ -133,6 +137,7 @@ public class SingleItemPeekableItemReader implements ItemStreamReader, Pee * @throws ItemStreamException if there is a problem * @see ItemStream#update(ExecutionContext) */ + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { if (next != null) { // Get the last state from the delegate instead of using diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/validator/SpringValidator.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/validator/SpringValidator.java index cdf4583eb..888098014 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/validator/SpringValidator.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/validator/SpringValidator.java @@ -38,6 +38,7 @@ public class SpringValidator implements Validator, InitializingBean { /** * @see Validator#validate(Object) */ + @Override public void validate(T item) throws ValidationException { if (!validator.supports(item.getClass())) { @@ -81,6 +82,7 @@ public class SpringValidator implements Validator, InitializingBean { this.validator = validator; } + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(validator, "validator must be set"); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/validator/ValidatingItemProcessor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/validator/ValidatingItemProcessor.java index a54d6b8a0..f419295ac 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/validator/ValidatingItemProcessor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/validator/ValidatingItemProcessor.java @@ -72,6 +72,7 @@ public class ValidatingItemProcessor implements ItemProcessor, Initiali * @return the input item * @throws ValidationException if validation fails */ + @Override public T process(T item) throws ValidationException { try { validator.validate(item); @@ -87,6 +88,7 @@ public class ValidatingItemProcessor implements ItemProcessor, Initiali return item; } + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(validator, "Validator must not be null."); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemReader.java index 94e9e8eb9..5a24cebe6 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemReader.java @@ -86,6 +86,7 @@ public class StaxEventItemReader extends AbstractItemCountingItemStreamItemRe this.strict = strict; } + @Override public void setResource(Resource resource) { this.resource = resource; } @@ -112,6 +113,7 @@ public class StaxEventItemReader extends AbstractItemCountingItemStreamItemRe * the root element is empty. * @throws IllegalStateException if the Resource does not exist. */ + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(unmarshaller, "The Unmarshaller must not be null."); Assert.hasLength(fragmentRootElementName, "The FragmentRootElementName must not be null"); @@ -157,6 +159,7 @@ public class StaxEventItemReader extends AbstractItemCountingItemStreamItemRe } } + @Override protected void doClose() throws Exception { try { if (fragmentReader != null) { @@ -173,6 +176,7 @@ public class StaxEventItemReader extends AbstractItemCountingItemStreamItemRe } + @Override protected void doOpen() throws Exception { Assert.notNull(resource, "The Resource must not be null."); @@ -202,6 +206,7 @@ public class StaxEventItemReader extends AbstractItemCountingItemStreamItemRe /** * Move to next fragment and map it to item. */ + @Override protected T doRead() throws Exception { if (noInput) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemWriter.java index e427c94c0..9ada94cb1 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemWriter.java @@ -151,6 +151,7 @@ public class StaxEventItemWriter extends ExecutionContextUserSupport implemen * * @param resource the output file */ + @Override public void setResource(Resource resource) { this.resource = resource; } @@ -322,6 +323,7 @@ public class StaxEventItemWriter extends ExecutionContextUserSupport implemen * @throws Exception * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(marshaller); if (rootTagName.contains("{")) { @@ -339,6 +341,7 @@ public class StaxEventItemWriter extends ExecutionContextUserSupport implemen * * @see org.springframework.batch.item.ItemStream#open(ExecutionContext) */ + @Override public void open(ExecutionContext executionContext) { Assert.notNull(resource, "The resource must be set"); @@ -411,6 +414,7 @@ public class StaxEventItemWriter extends ExecutionContextUserSupport implemen final FileChannel channel = fileChannel; if (transactional) { TransactionAwareBufferedWriter writer = new TransactionAwareBufferedWriter(channel, new Runnable() { + @Override public void run() { closeStream(); } @@ -570,6 +574,7 @@ public class StaxEventItemWriter extends ExecutionContextUserSupport implemen * * @see org.springframework.batch.item.ItemStream#close() */ + @Override public void close() { XMLEventFactory factory = createXmlEventFactory(); @@ -633,6 +638,7 @@ public class StaxEventItemWriter extends ExecutionContextUserSupport implemen * @throws IOException * @throws XmlMappingException */ + @Override public void write(List items) throws XmlMappingException, Exception { currentRecordCount += items.size(); @@ -657,6 +663,7 @@ public class StaxEventItemWriter extends ExecutionContextUserSupport implemen * * @see org.springframework.batch.item.ItemStream#update(ExecutionContext) */ + @Override public void update(ExecutionContext executionContext) { if (saveState) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/stax/AbstractEventReaderWrapper.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/stax/AbstractEventReaderWrapper.java index 12ff67fa2..066cdba5b 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/stax/AbstractEventReaderWrapper.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/stax/AbstractEventReaderWrapper.java @@ -34,39 +34,48 @@ abstract class AbstractEventReaderWrapper implements XMLEventReader { this.wrappedEventReader = wrappedEventReader; } + @Override public void close() throws XMLStreamException { wrappedEventReader.close(); } + @Override public String getElementText() throws XMLStreamException { return wrappedEventReader.getElementText(); } + @Override public Object getProperty(String name) throws IllegalArgumentException { return wrappedEventReader.getProperty(name); } + @Override public boolean hasNext() { return wrappedEventReader.hasNext(); } + @Override public XMLEvent nextEvent() throws XMLStreamException { return wrappedEventReader.nextEvent(); } + @Override public XMLEvent nextTag() throws XMLStreamException { return wrappedEventReader.nextTag(); } + @Override public XMLEvent peek() throws XMLStreamException { return wrappedEventReader.peek(); } + @Override public Object next() { return wrappedEventReader.next(); } + @Override public void remove() { wrappedEventReader.remove(); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/stax/AbstractEventWriterWrapper.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/stax/AbstractEventWriterWrapper.java index 98d988c5b..4648b1c8a 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/stax/AbstractEventWriterWrapper.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/stax/AbstractEventWriterWrapper.java @@ -36,38 +36,47 @@ abstract class AbstractEventWriterWrapper implements XMLEventWriter { this.wrappedEventWriter = wrappedEventWriter; } + @Override public void add(XMLEvent event) throws XMLStreamException { wrappedEventWriter.add(event); } + @Override public void add(XMLEventReader reader) throws XMLStreamException { wrappedEventWriter.add(reader); } + @Override public void close() throws XMLStreamException { wrappedEventWriter.close(); } + @Override public void flush() throws XMLStreamException { wrappedEventWriter.flush(); } + @Override public NamespaceContext getNamespaceContext() { return wrappedEventWriter.getNamespaceContext(); } + @Override public String getPrefix(String uri) throws XMLStreamException { return wrappedEventWriter.getPrefix(uri); } + @Override public void setDefaultNamespace(String uri) throws XMLStreamException { wrappedEventWriter.setDefaultNamespace(uri); } + @Override public void setNamespaceContext(NamespaceContext context) throws XMLStreamException { wrappedEventWriter.setNamespaceContext(context); } + @Override public void setPrefix(String prefix, String uri) throws XMLStreamException { wrappedEventWriter.setPrefix(prefix, uri); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/stax/DefaultFragmentEventReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/stax/DefaultFragmentEventReader.java index 75fe512d9..ab9911ba6 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/stax/DefaultFragmentEventReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/stax/DefaultFragmentEventReader.java @@ -77,11 +77,13 @@ public class DefaultFragmentEventReader extends AbstractEventReaderWrapper imple endDocumentEvent = XMLEventFactory.newInstance().createEndDocument(); } + @Override public void markStartFragment() { startFragmentFollows = true; fragmentRootName = null; } + @Override public boolean hasNext() { try { if (peek() != null) { @@ -94,6 +96,7 @@ public class DefaultFragmentEventReader extends AbstractEventReaderWrapper imple return false; } + @Override public Object next() { try { return nextEvent(); @@ -103,6 +106,7 @@ public class DefaultFragmentEventReader extends AbstractEventReaderWrapper imple } } + @Override public XMLEvent nextEvent() throws XMLStreamException { if (fakeDocumentEnd) { throw new NoSuchElementException(); @@ -161,6 +165,7 @@ public class DefaultFragmentEventReader extends AbstractEventReaderWrapper imple return event; } + @Override public XMLEvent peek() throws XMLStreamException { if (fakeDocumentEnd) { return null; @@ -172,6 +177,7 @@ public class DefaultFragmentEventReader extends AbstractEventReaderWrapper imple * Finishes reading the fragment in case the fragment was processed without * being read until the end. */ + @Override public void markFragmentProcessed() { if (insideFragment|| startFragmentFollows) { try { @@ -186,6 +192,7 @@ public class DefaultFragmentEventReader extends AbstractEventReaderWrapper imple fakeDocumentEnd = false; } + @Override public void reset() { insideFragment = false; startFragmentFollows = false; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/stax/NoStartEndDocumentStreamWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/stax/NoStartEndDocumentStreamWriter.java index 049ac74d2..039b7b3de 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/stax/NoStartEndDocumentStreamWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/stax/NoStartEndDocumentStreamWriter.java @@ -33,6 +33,7 @@ public class NoStartEndDocumentStreamWriter extends AbstractEventWriterWrapper { super(wrappedEventWriter); } + @Override public void add(XMLEvent event) throws XMLStreamException { if ((!event.isStartDocument()) && (!event.isEndDocument())) { wrappedEventWriter.add(event); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/poller/DirectPoller.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/poller/DirectPoller.java index 33bd077a6..ee945fd69 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/poller/DirectPoller.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/poller/DirectPoller.java @@ -46,6 +46,7 @@ public class DirectPoller implements Poller { * * @see Poller#poll(Callable) */ + @Override public Future poll(Callable callable) throws Exception { return new DirectPollingFuture(interval, callable); } @@ -67,11 +68,13 @@ public class DirectPoller implements Poller { this.callable = callable; } + @Override public boolean cancel(boolean mayInterruptIfRunning) { cancelled = true; return true; } + @Override public S get() throws InterruptedException, ExecutionException { try { return get(-1, TimeUnit.MILLISECONDS); @@ -81,6 +84,7 @@ public class DirectPoller implements Poller { } } + @Override public S get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { try { @@ -121,10 +125,12 @@ public class DirectPoller implements Poller { } + @Override public boolean isCancelled() { return cancelled; } + @Override public boolean isDone() { return cancelled || result != null; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/callback/NestedRepeatCallback.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/callback/NestedRepeatCallback.java index ee943e982..7c3d523a2 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/callback/NestedRepeatCallback.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/callback/NestedRepeatCallback.java @@ -55,6 +55,7 @@ public class NestedRepeatCallback implements RepeatCallback { * * @see org.springframework.batch.repeat.RepeatCallback#doInIteration(RepeatContext) */ + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { return template.iterate(callback); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/context/RepeatContextSupport.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/context/RepeatContextSupport.java index 37daf8a1e..5125a8c10 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/context/RepeatContextSupport.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/context/RepeatContextSupport.java @@ -53,6 +53,7 @@ public class RepeatContextSupport extends SynchronizedAttributeAccessor implemen * * @see org.springframework.batch.repeat.RepeatContext#isCompleteOnly() */ + @Override public boolean isCompleteOnly() { return completeOnly; } @@ -62,6 +63,7 @@ public class RepeatContextSupport extends SynchronizedAttributeAccessor implemen * * @see org.springframework.batch.repeat.RepeatContext#setCompleteOnly() */ + @Override public void setCompleteOnly() { completeOnly = true; } @@ -71,6 +73,7 @@ public class RepeatContextSupport extends SynchronizedAttributeAccessor implemen * * @see org.springframework.batch.repeat.RepeatContext#isTerminateOnly() */ + @Override public boolean isTerminateOnly() { return terminateOnly; } @@ -80,6 +83,7 @@ public class RepeatContextSupport extends SynchronizedAttributeAccessor implemen * * @see org.springframework.batch.repeat.RepeatContext#setTerminateOnly() */ + @Override public void setTerminateOnly() { terminateOnly = true; setCompleteOnly(); @@ -90,6 +94,7 @@ public class RepeatContextSupport extends SynchronizedAttributeAccessor implemen * * @see org.springframework.batch.repeat.RepeatContext#getParent() */ + @Override public RepeatContext getParent() { return parent; } @@ -106,6 +111,7 @@ public class RepeatContextSupport extends SynchronizedAttributeAccessor implemen * * @see org.springframework.batch.repeat.RepeatContext#getStartedCount() */ + @Override public synchronized int getStartedCount() { return count; } @@ -117,6 +123,7 @@ public class RepeatContextSupport extends SynchronizedAttributeAccessor implemen * org.springframework.batch.repeat.RepeatContext#registerDestructionCallback * (java.lang.String, java.lang.Runnable) */ + @Override public void registerDestructionCallback(String name, Runnable callback) { synchronized (callbacks) { Set set = callbacks.get(name); @@ -133,6 +140,7 @@ public class RepeatContextSupport extends SynchronizedAttributeAccessor implemen * * @see org.springframework.batch.repeat.RepeatContext#close() */ + @Override public void close() { List errors = new ArrayList(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/context/SynchronizedAttributeAccessor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/context/SynchronizedAttributeAccessor.java index a65c1f43f..97e09abc3 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/context/SynchronizedAttributeAccessor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/context/SynchronizedAttributeAccessor.java @@ -42,6 +42,7 @@ public class SynchronizedAttributeAccessor implements AttributeAccessor { * (non-Javadoc) * @see org.springframework.core.AttributeAccessor#attributeNames() */ + @Override public String[] attributeNames() { synchronized (support) { return support.attributeNames(); @@ -52,6 +53,7 @@ public class SynchronizedAttributeAccessor implements AttributeAccessor { * (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ + @Override public boolean equals(Object other) { if (this == other) { return true; @@ -75,6 +77,7 @@ public class SynchronizedAttributeAccessor implements AttributeAccessor { * (non-Javadoc) * @see org.springframework.core.AttributeAccessor#getAttribute(java.lang.String) */ + @Override public Object getAttribute(String name) { synchronized (support) { return support.getAttribute(name); @@ -85,6 +88,7 @@ public class SynchronizedAttributeAccessor implements AttributeAccessor { * (non-Javadoc) * @see org.springframework.core.AttributeAccessor#hasAttribute(java.lang.String) */ + @Override public boolean hasAttribute(String name) { synchronized (support) { return support.hasAttribute(name); @@ -95,6 +99,7 @@ public class SynchronizedAttributeAccessor implements AttributeAccessor { * (non-Javadoc) * @see java.lang.Object#hashCode() */ + @Override public int hashCode() { return support.hashCode(); } @@ -103,6 +108,7 @@ public class SynchronizedAttributeAccessor implements AttributeAccessor { * (non-Javadoc) * @see org.springframework.core.AttributeAccessor#removeAttribute(java.lang.String) */ + @Override public Object removeAttribute(String name) { synchronized (support) { return support.removeAttribute(name); @@ -114,6 +120,7 @@ public class SynchronizedAttributeAccessor implements AttributeAccessor { * @see org.springframework.core.AttributeAccessor#setAttribute(java.lang.String, * java.lang.Object) */ + @Override public void setAttribute(String name, Object value) { synchronized (support) { support.setAttribute(name, value); @@ -142,6 +149,7 @@ public class SynchronizedAttributeAccessor implements AttributeAccessor { * (non-Javadoc) * @see java.lang.Object#toString() */ + @Override public String toString() { StringBuffer buffer = new StringBuffer("SynchronizedAttributeAccessor: ["); synchronized (support) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/CompositeExceptionHandler.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/CompositeExceptionHandler.java index 697f3c920..7f3748ce0 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/CompositeExceptionHandler.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/CompositeExceptionHandler.java @@ -40,6 +40,7 @@ public class CompositeExceptionHandler implements ExceptionHandler { * * @see ExceptionHandler#handleException(RepeatContext, Throwable) */ + @Override public void handleException(RepeatContext context, Throwable throwable) throws Throwable { for (int i = 0; i < handlers.length; i++) { ExceptionHandler handler = handlers[i]; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/DefaultExceptionHandler.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/DefaultExceptionHandler.java index 108b46a01..56806dfb3 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/DefaultExceptionHandler.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/DefaultExceptionHandler.java @@ -32,6 +32,7 @@ public class DefaultExceptionHandler implements ExceptionHandler { * @see org.springframework.batch.repeat.exception.ExceptionHandler#handleException(RepeatContext, * Throwable) */ + @Override public void handleException(RepeatContext context, Throwable throwable) throws Throwable { throw throwable; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/LogOrRethrowExceptionHandler.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/LogOrRethrowExceptionHandler.java index f50997f4e..6fae383be 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/LogOrRethrowExceptionHandler.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/LogOrRethrowExceptionHandler.java @@ -90,6 +90,7 @@ public class LogOrRethrowExceptionHandler implements ExceptionHandler { * * @see ExceptionHandler#handleException(RepeatContext, Throwable) */ + @Override public void handleException(RepeatContext context, Throwable throwable) throws Throwable { Level key = exceptionClassifier.classify(throwable); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/RethrowOnThresholdExceptionHandler.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/RethrowOnThresholdExceptionHandler.java index 8ffe0e0b7..027baf6e0 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/RethrowOnThresholdExceptionHandler.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/RethrowOnThresholdExceptionHandler.java @@ -44,6 +44,7 @@ public class RethrowOnThresholdExceptionHandler implements ExceptionHandler { protected final Log logger = LogFactory.getLog(RethrowOnThresholdExceptionHandler.class); private Classifier exceptionClassifier = new Classifier() { + @Override public RethrowOnThresholdExceptionHandler.IntegerHolder classify(Throwable classifiable) { return ZERO; } @@ -92,6 +93,7 @@ public class RethrowOnThresholdExceptionHandler implements ExceptionHandler { * @throws Throwable * @see ExceptionHandler#handleException(RepeatContext, Throwable) */ + @Override public void handleException(RepeatContext context, Throwable throwable) throws Throwable { IntegerHolder key = exceptionClassifier.classify(throwable); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/SimpleLimitExceptionHandler.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/SimpleLimitExceptionHandler.java index 6390f8133..4c9be2324 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/SimpleLimitExceptionHandler.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/exception/SimpleLimitExceptionHandler.java @@ -52,6 +52,7 @@ public class SimpleLimitExceptionHandler implements ExceptionHandler, Initializi * * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { if (limit <= 0) { return; @@ -108,6 +109,7 @@ public class SimpleLimitExceptionHandler implements ExceptionHandler, Initializi * @see org.springframework.batch.repeat.exception.ExceptionHandler#handleException(org.springframework.batch.repeat.RepeatContext, * Throwable) */ + @Override public void handleException(RepeatContext context, Throwable throwable) throws Throwable { delegate.handleException(context, throwable); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/interceptor/RepeatOperationsInterceptor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/interceptor/RepeatOperationsInterceptor.java index e352fc10f..c6de1aead 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/interceptor/RepeatOperationsInterceptor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/interceptor/RepeatOperationsInterceptor.java @@ -61,6 +61,7 @@ public class RepeatOperationsInterceptor implements MethodInterceptor { * * @see org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation) */ + @Override public Object invoke(final MethodInvocation invocation) throws Throwable { final ResultHolder result = new ResultHolder(); @@ -75,6 +76,7 @@ public class RepeatOperationsInterceptor implements MethodInterceptor { try { repeatOperations.iterate(new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { try { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/listener/CompositeRepeatListener.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/listener/CompositeRepeatListener.java index ed765f0e0..a0d999127 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/listener/CompositeRepeatListener.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/listener/CompositeRepeatListener.java @@ -54,6 +54,7 @@ public class CompositeRepeatListener implements RepeatListener { /* (non-Javadoc) * @see org.springframework.batch.repeat.RepeatListener#after(org.springframework.batch.repeat.RepeatContext, org.springframework.batch.repeat.ExitStatus) */ + @Override public void after(RepeatContext context, RepeatStatus result) { for (RepeatListener listener : listeners) { listener.after(context, result); @@ -63,6 +64,7 @@ public class CompositeRepeatListener implements RepeatListener { /* (non-Javadoc) * @see org.springframework.batch.repeat.RepeatListener#before(org.springframework.batch.repeat.RepeatContext) */ + @Override public void before(RepeatContext context) { for (RepeatListener listener : listeners) { listener.before(context); @@ -72,6 +74,7 @@ public class CompositeRepeatListener implements RepeatListener { /* (non-Javadoc) * @see org.springframework.batch.repeat.RepeatListener#close(org.springframework.batch.repeat.RepeatContext) */ + @Override public void close(RepeatContext context) { for (RepeatListener listener : listeners) { listener.close(context); @@ -81,6 +84,7 @@ public class CompositeRepeatListener implements RepeatListener { /* (non-Javadoc) * @see org.springframework.batch.repeat.RepeatListener#onError(org.springframework.batch.repeat.RepeatContext, java.lang.Throwable) */ + @Override public void onError(RepeatContext context, Throwable e) { for (RepeatListener listener : listeners) { listener.onError(context, e); @@ -90,6 +94,7 @@ public class CompositeRepeatListener implements RepeatListener { /* (non-Javadoc) * @see org.springframework.batch.repeat.RepeatListener#open(org.springframework.batch.repeat.RepeatContext) */ + @Override public void open(RepeatContext context) { for (RepeatListener listener : listeners) { listener.open(context); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/listener/RepeatListenerSupport.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/listener/RepeatListenerSupport.java index 97229169d..05a121293 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/listener/RepeatListenerSupport.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/listener/RepeatListenerSupport.java @@ -28,18 +28,23 @@ import org.springframework.batch.repeat.RepeatListener; */ public class RepeatListenerSupport implements RepeatListener { + @Override public void before(RepeatContext context) { } + @Override public void after(RepeatContext context, RepeatStatus result) { } + @Override public void close(RepeatContext context) { } + @Override public void onError(RepeatContext context, Throwable e) { } + @Override public void open(RepeatContext context) { } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/CompletionPolicySupport.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/CompletionPolicySupport.java index d13a06168..016b9dbb6 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/CompletionPolicySupport.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/CompletionPolicySupport.java @@ -36,6 +36,7 @@ public class CompletionPolicySupport implements CompletionPolicy { * @see org.springframework.batch.repeat.CompletionPolicy#isComplete(org.springframework.batch.repeat.RepeatContext, * RepeatStatus) */ + @Override public boolean isComplete(RepeatContext context, RepeatStatus result) { if (result != null && !result.isContinuable()) { return true; @@ -50,6 +51,7 @@ public class CompletionPolicySupport implements CompletionPolicy { * * @see org.springframework.batch.repeat.CompletionPolicy#isComplete(org.springframework.batch.repeat.RepeatContext) */ + @Override public boolean isComplete(RepeatContext context) { return true; } @@ -59,6 +61,7 @@ public class CompletionPolicySupport implements CompletionPolicy { * * @see org.springframework.batch.repeat.CompletionPolicy#start(RepeatContext) */ + @Override public RepeatContext start(RepeatContext context) { return new RepeatContextSupport(context); } @@ -68,6 +71,7 @@ public class CompletionPolicySupport implements CompletionPolicy { * * @see org.springframework.batch.repeat.CompletionPolicy#update(org.springframework.batch.repeat.RepeatContext) */ + @Override public void update(RepeatContext context) { if (context instanceof RepeatContextSupport) { ((RepeatContextSupport) context).increment(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/CompositeCompletionPolicy.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/CompositeCompletionPolicy.java index 87763a7a2..4ce9b680d 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/CompositeCompletionPolicy.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/CompositeCompletionPolicy.java @@ -51,6 +51,7 @@ public class CompositeCompletionPolicy implements CompletionPolicy { * @see org.springframework.batch.repeat.CompletionPolicy#isComplete(org.springframework.batch.repeat.RepeatContext, * RepeatStatus) */ + @Override public boolean isComplete(RepeatContext context, RepeatStatus result) { RepeatContext[] contexts = ((CompositeBatchContext) context).contexts; CompletionPolicy[] policies = ((CompositeBatchContext) context).policies; @@ -67,6 +68,7 @@ public class CompositeCompletionPolicy implements CompletionPolicy { * * @see org.springframework.batch.repeat.CompletionPolicy#isComplete(org.springframework.batch.repeat.RepeatContext) */ + @Override public boolean isComplete(RepeatContext context) { RepeatContext[] contexts = ((CompositeBatchContext) context).contexts; CompletionPolicy[] policies = ((CompositeBatchContext) context).policies; @@ -83,6 +85,7 @@ public class CompositeCompletionPolicy implements CompletionPolicy { * * @see org.springframework.batch.repeat.CompletionPolicy#start(RepeatContext) */ + @Override public RepeatContext start(RepeatContext context) { List list = new ArrayList(); for (int i = 0; i < policies.length; i++) { @@ -97,6 +100,7 @@ public class CompositeCompletionPolicy implements CompletionPolicy { * * @see org.springframework.batch.repeat.CompletionPolicy#update(org.springframework.batch.repeat.RepeatContext) */ + @Override public void update(RepeatContext context) { RepeatContext[] contexts = ((CompositeBatchContext) context).contexts; CompletionPolicy[] policies = ((CompositeBatchContext) context).policies; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/CountingCompletionPolicy.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/CountingCompletionPolicy.java index 1550118e1..485099cb9 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/CountingCompletionPolicy.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/CountingCompletionPolicy.java @@ -92,6 +92,7 @@ public abstract class CountingCompletionPolicy extends DefaultResultCompletionPo * (non-Javadoc) * @see org.springframework.batch.repeat.policy.CompletionPolicySupport#isComplete(org.springframework.batch.repeat.BatchContext) */ + @Override final public boolean isComplete(RepeatContext context) { int count = ((CountingBatchContext) context).getCounter().getCount(); return count >= maxCount; @@ -101,6 +102,7 @@ public abstract class CountingCompletionPolicy extends DefaultResultCompletionPo * (non-Javadoc) * @see org.springframework.batch.repeat.policy.CompletionPolicySupport#start(org.springframework.batch.repeat.BatchContext) */ + @Override public RepeatContext start(RepeatContext parent) { return new CountingBatchContext(parent); } @@ -109,6 +111,7 @@ public abstract class CountingCompletionPolicy extends DefaultResultCompletionPo * (non-Javadoc) * @see org.springframework.batch.repeat.policy.CompletionPolicySupport#update(org.springframework.batch.repeat.BatchContext) */ + @Override final public void update(RepeatContext context) { super.update(context); int delta = doUpdate(context); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/DefaultResultCompletionPolicy.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/DefaultResultCompletionPolicy.java index d0a1ad8f7..dec9ce70d 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/DefaultResultCompletionPolicy.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/DefaultResultCompletionPolicy.java @@ -37,6 +37,7 @@ public class DefaultResultCompletionPolicy extends CompletionPolicySupport { * @see org.springframework.batch.repeat.CompletionPolicy#isComplete(org.springframework.batch.repeat.RepeatContext, * RepeatStatus) */ + @Override public boolean isComplete(RepeatContext context, RepeatStatus result) { return (result == null || !result.isContinuable()); } @@ -46,6 +47,7 @@ public class DefaultResultCompletionPolicy extends CompletionPolicySupport { * * @see org.springframework.batch.repeat.CompletionPolicy#isComplete(org.springframework.batch.repeat.RepeatContext) */ + @Override public boolean isComplete(RepeatContext context) { return false; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/SimpleCompletionPolicy.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/SimpleCompletionPolicy.java index 22bb1b12e..c7fdb8cba 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/SimpleCompletionPolicy.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/policy/SimpleCompletionPolicy.java @@ -56,6 +56,7 @@ public class SimpleCompletionPolicy extends DefaultResultCompletionPolicy { * * @see org.springframework.batch.repeat.CompletionPolicy#start(RepeatContext) */ + @Override public RepeatContext start(RepeatContext context) { return new SimpleTerminationContext(context); } @@ -68,6 +69,7 @@ public class SimpleCompletionPolicy extends DefaultResultCompletionPolicy { * @throws RuntimeException (normally terminating the batch) if the result is * itself an exception. */ + @Override public boolean isComplete(RepeatContext context, RepeatStatus result) { return super.isComplete(context, result) || ((SimpleTerminationContext) context).isComplete(); } @@ -77,6 +79,7 @@ public class SimpleCompletionPolicy extends DefaultResultCompletionPolicy { * * @see org.springframework.batch.repeat.CompletionPolicy#isComplete(RepeatContext) */ + @Override public boolean isComplete(RepeatContext context) { return ((SimpleTerminationContext) context).isComplete(); } @@ -86,6 +89,7 @@ public class SimpleCompletionPolicy extends DefaultResultCompletionPolicy { * * @see org.springframework.batch.repeat.CompletionPolicy#update(RepeatContext) */ + @Override public void update(RepeatContext context) { ((SimpleTerminationContext) context).update(); } @@ -108,6 +112,7 @@ public class SimpleCompletionPolicy extends DefaultResultCompletionPolicy { /* (non-Javadoc) * @see java.lang.Object#toString() */ + @Override public String toString() { return ClassUtils.getShortName(SimpleCompletionPolicy.class)+": chunkSize="+chunkSize; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/RepeatInternalStateSupport.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/RepeatInternalStateSupport.java index 16c844e04..cde8c00cf 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/RepeatInternalStateSupport.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/RepeatInternalStateSupport.java @@ -28,6 +28,7 @@ public class RepeatInternalStateSupport implements RepeatInternalState { /* (non-Javadoc) * @see org.springframework.batch.repeat.support.BatchInternalState#getThrowables() */ + @Override public Collection getThrowables() { return throwables; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/RepeatTemplate.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/RepeatTemplate.java index b4f4e38b7..5412304a9 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/RepeatTemplate.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/RepeatTemplate.java @@ -132,6 +132,7 @@ public class RepeatTemplate implements RepeatOperations { * * @see org.springframework.batch.repeat.RepeatOperations#iterate(org.springframework.batch.repeat.RepeatCallback) */ + @Override public RepeatStatus iterate(RepeatCallback callback) { RepeatContext outer = RepeatSynchronizationManager.getContext(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/ResultHolderResultQueue.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/ResultHolderResultQueue.java index 5456e9912..1aecf4f31 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/ResultHolderResultQueue.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/ResultHolderResultQueue.java @@ -51,6 +51,7 @@ public class ResultHolderResultQueue implements ResultQueue { waits = new Semaphore(throttleLimit); } + @Override public boolean isEmpty() { return results.isEmpty(); } @@ -60,6 +61,7 @@ public class ResultHolderResultQueue implements ResultQueue { * * @see org.springframework.batch.repeat.support.ResultQueue#isExpecting() */ + @Override public boolean isExpecting() { // Base the decision about whether we expect more results on a // counter of the number of expected results actually collected. @@ -74,6 +76,7 @@ public class ResultHolderResultQueue implements ResultQueue { * * @see ResultQueue#expect() */ + @Override public void expect() throws InterruptedException { waits.acquire(); // Don't acquire the lock in a synchronized block - might deadlock @@ -82,6 +85,7 @@ public class ResultHolderResultQueue implements ResultQueue { } } + @Override public void put(ResultHolder holder) throws IllegalArgumentException { if (!isExpecting()) { throw new IllegalArgumentException("Not expecting a result. Call expect() before put()."); @@ -115,6 +119,7 @@ public class ResultHolderResultQueue implements ResultQueue { * * @see ResultQueue#take() */ + @Override public ResultHolder take() throws NoSuchElementException, InterruptedException { if (!isExpecting()) { throw new NoSuchElementException("Not expecting a result. Call expect() before take()."); @@ -150,6 +155,7 @@ public class ResultHolderResultQueue implements ResultQueue { * */ private static class ResultHolderComparator implements Comparator { + @Override public int compare(ResultHolder h1, ResultHolder h2) { RepeatStatus result1 = h1.getResult(); RepeatStatus result2 = h2.getResult(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/TaskExecutorRepeatTemplate.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/TaskExecutorRepeatTemplate.java index 521841325..927eceb61 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/TaskExecutorRepeatTemplate.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/TaskExecutorRepeatTemplate.java @@ -95,6 +95,7 @@ public class TaskExecutorRepeatTemplate extends RepeatTemplate { * method so there is no need to synchronize access. * */ + @Override protected RepeatStatus getNextResult(RepeatContext context, RepeatCallback callback, RepeatInternalState state) throws Throwable { @@ -153,6 +154,7 @@ public class TaskExecutorRepeatTemplate extends RepeatTemplate { * * @see org.springframework.batch.repeat.support.RepeatTemplate#waitForResults(org.springframework.batch.repeat.support.RepeatInternalState) */ + @Override protected boolean waitForResults(RepeatInternalState state) { ResultQueue queue = ((ResultQueueInternalState) state).getResultQueue(); @@ -191,6 +193,7 @@ public class TaskExecutorRepeatTemplate extends RepeatTemplate { return result; } + @Override protected RepeatInternalState createInternalState(RepeatContext context) { // Queue of pending results: return new ResultQueueInternalState(throttleLimit); @@ -243,6 +246,7 @@ public class TaskExecutorRepeatTemplate extends RepeatTemplate { * * @see java.lang.Runnable#run() */ + @Override public void run() { boolean clearContext = false; try { @@ -276,6 +280,7 @@ public class TaskExecutorRepeatTemplate extends RepeatTemplate { * Get the result - never blocks because the queue manages waiting for * the task to finish. */ + @Override public RepeatStatus getResult() { return result; } @@ -284,6 +289,7 @@ public class TaskExecutorRepeatTemplate extends RepeatTemplate { * Get the error - never blocks because the queue manages waiting for * the task to finish. */ + @Override public Throwable getError() { return error; } @@ -291,6 +297,7 @@ public class TaskExecutorRepeatTemplate extends RepeatTemplate { /** * Getter for the context. */ + @Override public RepeatContext getContext() { return this.context; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/ThrottleLimitResultQueue.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/ThrottleLimitResultQueue.java index b391e456e..b469d111f 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/ThrottleLimitResultQueue.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/ThrottleLimitResultQueue.java @@ -48,6 +48,7 @@ public class ThrottleLimitResultQueue implements ResultQueue { waits = new Semaphore(throttleLimit); } + @Override public boolean isEmpty() { return results.isEmpty(); } @@ -57,6 +58,7 @@ public class ThrottleLimitResultQueue implements ResultQueue { * * @see org.springframework.batch.repeat.support.ResultQueue#isExpecting() */ + @Override public boolean isExpecting() { // Base the decision about whether we expect more results on a // counter of the number of expected results actually collected. @@ -71,6 +73,7 @@ public class ThrottleLimitResultQueue implements ResultQueue { * * @see ResultQueue#expect() */ + @Override public void expect() throws InterruptedException { synchronized (lock) { waits.acquire(); @@ -78,6 +81,7 @@ public class ThrottleLimitResultQueue implements ResultQueue { } } + @Override public void put(T holder) throws IllegalArgumentException { if (!isExpecting()) { throw new IllegalArgumentException("Not expecting a result. Call expect() before put()."); @@ -89,6 +93,7 @@ public class ThrottleLimitResultQueue implements ResultQueue { waits.release(); } + @Override public T take() throws NoSuchElementException, InterruptedException { if (!isExpecting()) { throw new NoSuchElementException("Not expecting a result. Call expect() before take()."); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/AnnotationMethodResolver.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/AnnotationMethodResolver.java index ea5ace787..eb8ad37e7 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/AnnotationMethodResolver.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/AnnotationMethodResolver.java @@ -64,6 +64,7 @@ public class AnnotationMethodResolver implements MethodResolver { * @throws IllegalArgumentException if more than one Method has the * specified annotation */ + @Override public Method findMethod(Object candidate) { Assert.notNull(candidate, "candidate object must not be null"); Class targetClass = AopUtils.getTargetClass(candidate); @@ -85,10 +86,12 @@ public class AnnotationMethodResolver implements MethodResolver { * @throws IllegalArgumentException if more than one Method has the * specified annotation */ + @Override public Method findMethod(final Class clazz) { Assert.notNull(clazz, "class must not be null"); final AtomicReference annotatedMethod = new AtomicReference(); ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() { + @Override public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { Annotation annotation = AnnotationUtils.findAnnotation(method, annotationType); if (annotation != null) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/DefaultPropertyEditorRegistrar.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/DefaultPropertyEditorRegistrar.java index 319cea4ca..8ec345cf4 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/DefaultPropertyEditorRegistrar.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/DefaultPropertyEditorRegistrar.java @@ -45,6 +45,7 @@ public class DefaultPropertyEditorRegistrar implements PropertyEditorRegistrar { * * @see org.springframework.beans.PropertyEditorRegistrar#registerCustomEditors(org.springframework.beans.PropertyEditorRegistry) */ + @Override public void registerCustomEditors(PropertyEditorRegistry registry) { if (this.customEditors != null) { for (Entry, PropertyEditor> entry : customEditors.entrySet()) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/IntArrayPropertyEditor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/IntArrayPropertyEditor.java index 63a2c2420..1f268d3af 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/IntArrayPropertyEditor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/IntArrayPropertyEditor.java @@ -22,6 +22,7 @@ import org.springframework.util.StringUtils; public class IntArrayPropertyEditor extends PropertyEditorSupport { + @Override public void setAsText(String text) throws IllegalArgumentException { String[] strs = StringUtils.commaDelimitedListToStringArray(text); int[] value = new int[strs.length]; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/LastModifiedResourceComparator.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/LastModifiedResourceComparator.java index e523a4961..593f199ca 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/LastModifiedResourceComparator.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/LastModifiedResourceComparator.java @@ -38,6 +38,7 @@ public class LastModifiedResourceComparator implements Comparator { * * @see Comparator#compare(Object, Object) */ + @Override public int compare(Resource r1, Resource r2) { Assert.isTrue(r1.exists(), "Resource does not exist: " + r1); Assert.isTrue(r2.exists(), "Resource does not exist: " + r2); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/MethodInvokerUtils.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/MethodInvokerUtils.java index e4ecc91cd..fac868f40 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/MethodInvokerUtils.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/MethodInvokerUtils.java @@ -117,6 +117,7 @@ public class MethodInvokerUtils { .getTargetClass() : target.getClass(); if (mi != null) { ReflectionUtils.doWithMethods(targetClass, new ReflectionUtils.MethodCallback() { + @Override public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { Annotation annotation = AnnotationUtils.findAnnotation(method, annotationType); if (annotation != null) { @@ -163,6 +164,7 @@ public class MethodInvokerUtils { } final AtomicReference annotatedMethod = new AtomicReference(); ReflectionUtils.doWithMethods(targetClass, new ReflectionUtils.MethodCallback() { + @Override public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { Annotation annotation = AnnotationUtils.findAnnotation(method, annotationType); if (annotation != null) { @@ -192,6 +194,7 @@ public class MethodInvokerUtils { public static MethodInvoker getMethodInvokerForSingleArgument(Object target) { final AtomicReference methodHolder = new AtomicReference(); ReflectionUtils.doWithMethods(target.getClass(), new ReflectionUtils.MethodCallback() { + @Override public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { if (method.getParameterTypes() == null || method.getParameterTypes().length != 1) { return; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/PatternMatcher.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/PatternMatcher.java index 074983435..3fbfefbd7 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/PatternMatcher.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/PatternMatcher.java @@ -43,6 +43,7 @@ public class PatternMatcher { // Sort keys to start with the most specific sorted = new ArrayList(map.keySet()); Collections.sort(sorted, new Comparator() { + @Override public int compare(String o1, String o2) { String s1 = o1; // .replace('?', '{'); String s2 = o2; // .replace('*', '}'); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/SimpleMethodInvoker.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/SimpleMethodInvoker.java index 83432d3ed..0ad66fda2 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/SimpleMethodInvoker.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/SimpleMethodInvoker.java @@ -81,6 +81,7 @@ public class SimpleMethodInvoker implements MethodInvoker { * org.springframework.batch.core.configuration.util.MethodInvoker#invokeMethod * (java.lang.Object[]) */ + @Override public Object invokeMethod(Object... args) { Class[] parameterTypes = method.getParameterTypes(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/SystemPropertyInitializer.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/SystemPropertyInitializer.java index 9c3c92ec1..5f9d1070a 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/SystemPropertyInitializer.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/SystemPropertyInitializer.java @@ -61,6 +61,7 @@ public class SystemPropertyInitializer implements InitializingBean { * * @see InitializingBean#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { Assert.state(defaultValue != null || System.getProperty(keyName) != null, "Either a default value must be specified or the value should already be set for System property: " diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/ResourcelessTransactionManager.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/ResourcelessTransactionManager.java index f130eebbb..9c7278442 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/ResourcelessTransactionManager.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/ResourcelessTransactionManager.java @@ -26,14 +26,17 @@ import org.springframework.transaction.support.TransactionSynchronizationManager public class ResourcelessTransactionManager extends AbstractPlatformTransactionManager { + @Override protected void doBegin(Object transaction, TransactionDefinition definition) throws TransactionException { ((ResourcelessTransaction) transaction).begin(); } + @Override protected void doCommit(DefaultTransactionStatus status) throws TransactionException { logger.debug("Committing resourceless transaction on [" + status.getTransaction() + "]"); } + @Override protected Object doGetTransaction() throws TransactionException { Object transaction = new ResourcelessTransaction(); Stack resources; @@ -50,10 +53,12 @@ public class ResourcelessTransactionManager extends AbstractPlatformTransactionM return transaction; } + @Override protected void doRollback(DefaultTransactionStatus status) throws TransactionException { logger.debug("Rolling back resourceless transaction on [" + status.getTransaction() + "]"); } + @Override protected boolean isExistingTransaction(Object transaction) throws TransactionException { if (TransactionSynchronizationManager.hasResource(this)) { @SuppressWarnings("unchecked") @@ -63,9 +68,11 @@ public class ResourcelessTransactionManager extends AbstractPlatformTransactionM return ((ResourcelessTransaction) transaction).isActive(); } + @Override protected void doSetRollbackOnly(DefaultTransactionStatus status) throws TransactionException { } + @Override protected void doCleanupAfterCompletion(Object transaction) { @SuppressWarnings("unchecked") Stack list = (Stack) TransactionSynchronizationManager.getResource(this); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/TransactionAwareProxyFactory.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/TransactionAwareProxyFactory.java index c54ac474e..7b18d6ad5 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/TransactionAwareProxyFactory.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/TransactionAwareProxyFactory.java @@ -206,6 +206,7 @@ public class TransactionAwareProxyFactory { this.key = key; } + @Override public void afterCompletion(int status) { super.afterCompletion(status); if (status == TransactionSynchronization.STATUS_COMMITTED) { @@ -219,6 +220,7 @@ public class TransactionAwareProxyFactory { private class TransactionAwareInterceptor implements MethodInterceptor { + @Override public Object invoke(MethodInvocation invocation) throws Throwable { if (!TransactionSynchronizationManager.isActualTransactionActive()) { diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/AbstractItemStreamItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/AbstractItemStreamItemReaderTests.java index 6fb69b7cd..dac63a0da 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/AbstractItemStreamItemReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/AbstractItemStreamItemReaderTests.java @@ -23,6 +23,7 @@ public abstract class AbstractItemStreamItemReaderTests extends AbstractItemRead return (ItemStream) tested; } + @Override @Before public void setUp() throws Exception { super.setUp(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ItemReaderTests.java index 4912d56c1..1c5faf4c7 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ItemReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ItemReaderTests.java @@ -24,6 +24,7 @@ import org.junit.Test; public class ItemReaderTests { ItemReader provider = new ItemReader() { + @Override public String read() { return "foo"; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ItemRecoveryHandlerTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ItemRecoveryHandlerTests.java index ead9b024b..706a197dd 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ItemRecoveryHandlerTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ItemRecoveryHandlerTests.java @@ -23,6 +23,7 @@ import junit.framework.TestCase; public class ItemRecoveryHandlerTests extends TestCase { MethodInvocationRecoverer recoverer = new MethodInvocationRecoverer() { + @Override public String recover(Object[] data, Throwable cause) { return null; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ItemStreamExceptionTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ItemStreamExceptionTests.java index d530508df..4c019e0a4 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ItemStreamExceptionTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ItemStreamExceptionTests.java @@ -20,6 +20,7 @@ import org.springframework.batch.support.AbstractExceptionTests; public class ItemStreamExceptionTests extends AbstractExceptionTests { + @Override public Exception getException(String msg) throws Exception { return new ItemStreamException(msg); } @@ -28,6 +29,7 @@ public class ItemStreamExceptionTests extends AbstractExceptionTests { return new ItemStreamException(t); } + @Override public Exception getException(String msg, Throwable t) throws Exception { return new ItemStreamException(msg, t); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/UnexpectedInputExceptionTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/UnexpectedInputExceptionTests.java index 5a41ddc84..981ea38df 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/UnexpectedInputExceptionTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/UnexpectedInputExceptionTests.java @@ -20,10 +20,12 @@ import org.springframework.batch.repeat.AbstractExceptionTests; public class UnexpectedInputExceptionTests extends AbstractExceptionTests { + @Override public Exception getException(String msg) throws Exception { return new UnexpectedInputException(msg, null); } + @Override public Exception getException(String msg, Throwable t) throws Exception { return new UnexpectedInputException(msg, t); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/HippyMethodInvokerTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/HippyMethodInvokerTests.java index 69d08856e..ccdadd2f6 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/HippyMethodInvokerTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/adapter/HippyMethodInvokerTests.java @@ -114,6 +114,7 @@ public class HippyMethodInvokerTests { public static class TestMethodAdapter extends AbstractMethodInvokingDelegator implements Service { + @Override public String getMessage(double value, String input) { try { return invokeDelegateMethodWithArguments(new Object[] { value, input }); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/AbstractDatabaseItemStreamItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/AbstractDatabaseItemStreamItemReaderTests.java index 3510bceed..95fa9e37a 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/AbstractDatabaseItemStreamItemReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/AbstractDatabaseItemStreamItemReaderTests.java @@ -18,12 +18,14 @@ public abstract class AbstractDatabaseItemStreamItemReaderTests extends Abstract protected ClassPathXmlApplicationContext ctx; + @Override @Before public void setUp() throws Exception { initializeContext(); super.setUp(); } + @Override @After public void tearDown() throws Exception { super.tearDown(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/AbstractHibernateCursorItemReaderIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/AbstractHibernateCursorItemReaderIntegrationTests.java index ca3718340..96fed400b 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/AbstractHibernateCursorItemReaderIntegrationTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/AbstractHibernateCursorItemReaderIntegrationTests.java @@ -17,6 +17,7 @@ import org.springframework.orm.hibernate3.LocalSessionFactoryBean; public abstract class AbstractHibernateCursorItemReaderIntegrationTests extends AbstractGenericDataSourceItemReaderIntegrationTests { + @Override protected ItemReader createItemReader() throws Exception { LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/CompositeKeyFooDao.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/CompositeKeyFooDao.java index 0c9beccfd..cf119f63a 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/CompositeKeyFooDao.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/CompositeKeyFooDao.java @@ -38,12 +38,14 @@ public class CompositeKeyFooDao extends JdbcDaoSupport implements FooDao { /* (non-Javadoc) * @see org.springframework.batch.io.sql.scratch.FooDao#getFoo(java.lang.Object) */ + @Override public Foo getFoo(Object key) { Map keys = (Map)key; Object[] args = keys.values().toArray(); RowMapper fooMapper = new RowMapper(){ + @Override public Object mapRow(ResultSet rs, int rowNum) throws SQLException { Foo foo = new Foo(); foo.setId(rs.getInt(1)); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/ExtendedConnectionDataSourceProxyTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/ExtendedConnectionDataSourceProxyTests.java index 0114e5ee2..24c0dfe14 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/ExtendedConnectionDataSourceProxyTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/ExtendedConnectionDataSourceProxyTests.java @@ -198,6 +198,7 @@ public class ExtendedConnectionDataSourceProxyTests { Connection connection = DataSourceUtils.getConnection(csds); csds.startCloseSuppression(connection); tt.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { template.queryForList("select baz from bar"); template.queryForList("select foo from bar"); @@ -205,9 +206,11 @@ public class ExtendedConnectionDataSourceProxyTests { } }); tt.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { template.queryForList("select ham from foo"); tt2.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { template.queryForList("select 1 from eggs"); return null; @@ -218,6 +221,7 @@ public class ExtendedConnectionDataSourceProxyTests { } }); tt.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { template.queryForList("select spam from ham"); return null; @@ -301,30 +305,37 @@ public class ExtendedConnectionDataSourceProxyTests { private static final String UNWRAP_ERROR_MESSAGE = "supplied type is not implemented by this class"; + @Override public Connection getConnection() throws SQLException { throw new UnsupportedOperationException(); } + @Override public Connection getConnection(String username, String password) throws SQLException { throw new UnsupportedOperationException(); } + @Override public PrintWriter getLogWriter() throws SQLException { throw new UnsupportedOperationException(); } + @Override public int getLoginTimeout() throws SQLException { throw new UnsupportedOperationException(); } + @Override public void setLogWriter(PrintWriter out) throws SQLException { throw new UnsupportedOperationException(); } + @Override public void setLoginTimeout(int seconds) throws SQLException { throw new UnsupportedOperationException(); } + @Override public boolean isWrapperFor(Class iface) throws SQLException { if (iface.equals(Supported.class) || (iface.equals(DataSource.class))) { return true; @@ -332,6 +343,7 @@ public class ExtendedConnectionDataSourceProxyTests { return false; } + @Override @SuppressWarnings("unchecked") public T unwrap(Class iface) throws SQLException { if (iface.equals(Supported.class) || iface.equals(DataSource.class)) { diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/FooRowMapper.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/FooRowMapper.java index f985ce468..503055661 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/FooRowMapper.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/FooRowMapper.java @@ -9,6 +9,7 @@ import org.springframework.jdbc.core.RowMapper; public class FooRowMapper implements RowMapper { + @Override public Object mapRow(ResultSet rs, int rowNum) throws SQLException { Foo foo = new Foo(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernateCursorItemReaderCommonTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernateCursorItemReaderCommonTests.java index 04c76a499..027b0fc1e 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernateCursorItemReaderCommonTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernateCursorItemReaderCommonTests.java @@ -13,6 +13,7 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public class HibernateCursorItemReaderCommonTests extends AbstractDatabaseItemStreamItemReaderTests { + @Override protected ItemReader getItemReader() throws Exception { SessionFactory sessionFactory = createSessionFactory(); @@ -40,6 +41,7 @@ public class HibernateCursorItemReaderCommonTests extends AbstractDatabaseItemSt } + @Override protected void pointToEmptyInput(ItemReader tested) throws Exception { HibernateCursorItemReader reader = (HibernateCursorItemReader) tested; reader.close(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernateCursorItemReaderParametersIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernateCursorItemReaderParametersIntegrationTests.java index c23cebde3..ae8c6284b 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernateCursorItemReaderParametersIntegrationTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernateCursorItemReaderParametersIntegrationTests.java @@ -13,6 +13,7 @@ import org.hibernate.StatelessSession; public class HibernateCursorItemReaderParametersIntegrationTests extends AbstractHibernateCursorItemReaderIntegrationTests { + @Override protected void setQuery(HibernateCursorItemReader reader) { reader.setQueryString("from Foo where name like :name"); reader.setParameterValues(Collections.singletonMap("name", (Object) "bar%")); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernateCursorItemReaderStatefulIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernateCursorItemReaderStatefulIntegrationTests.java index cf6e5d88b..84c6e404a 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernateCursorItemReaderStatefulIntegrationTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernateCursorItemReaderStatefulIntegrationTests.java @@ -20,6 +20,7 @@ import org.springframework.batch.item.sample.Foo; */ public class HibernateCursorItemReaderStatefulIntegrationTests extends AbstractHibernateCursorItemReaderIntegrationTests { + @Override protected boolean isUseStatelessSession() { return false; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernatePagingItemReaderIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernatePagingItemReaderIntegrationTests.java index 69bcb2d94..b3f0adad3 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernatePagingItemReaderIntegrationTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/HibernatePagingItemReaderIntegrationTests.java @@ -17,6 +17,7 @@ import org.springframework.orm.hibernate3.LocalSessionFactoryBean; public class HibernatePagingItemReaderIntegrationTests extends AbstractGenericDataSourceItemReaderIntegrationTests { + @Override protected ItemReader createItemReader() throws Exception { LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderAsyncTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderAsyncTests.java index 3edd5d80f..4ef11aa8a 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderAsyncTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderAsyncTests.java @@ -98,6 +98,7 @@ public class IbatisPagingItemReaderAsyncTests { .newFixedThreadPool(THREAD_COUNT)); for (int i = 0; i < THREAD_COUNT; i++) { completionService.submit(new Callable>() { + @Override public List call() throws Exception { List list = new ArrayList(); Foo next = null; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderCommonTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderCommonTests.java index d4c34b0c1..8bda98f18 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderCommonTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderCommonTests.java @@ -13,6 +13,7 @@ import com.ibatis.sqlmap.client.SqlMapClient; @RunWith(JUnit4.class) public class IbatisPagingItemReaderCommonTests extends AbstractDatabaseItemStreamItemReaderTests { + @Override protected ItemReader getItemReader() throws Exception { SqlMapClientFactoryBean factory = new SqlMapClientFactoryBean(); factory.setConfigLocation(new ClassPathResource("ibatis-config.xml", getClass())); @@ -39,6 +40,7 @@ public class IbatisPagingItemReaderCommonTests extends AbstractDatabaseItemStrea return (SqlMapClient) factory.getObject(); } + @Override protected void pointToEmptyInput(ItemReader tested) throws Exception { IbatisPagingItemReader reader = (IbatisPagingItemReader) tested; reader.close(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderParameterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderParameterTests.java index 0cd545446..265760102 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderParameterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderParameterTests.java @@ -15,6 +15,7 @@ import com.ibatis.sqlmap.client.SqlMapClient; @ContextConfiguration(locations = "/org/springframework/batch/item/database/data-source-context.xml") public class IbatisPagingItemReaderParameterTests extends AbstractPagingItemReaderParameterTests { + @Override protected AbstractPagingItemReader getItemReader() throws Exception { SqlMapClientFactoryBean factory = new SqlMapClientFactoryBean(); factory.setConfigLocation(new ClassPathResource("ibatis-config.xml", getClass())); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcBatchItemWriterClassicTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcBatchItemWriterClassicTests.java index 508f69814..3fb807c38 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcBatchItemWriterClassicTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcBatchItemWriterClassicTests.java @@ -51,6 +51,7 @@ public class JdbcBatchItemWriterClassicTests { public void setUp() throws Exception { ps = createMock(PreparedStatement.class); jdbcTemplate = new JdbcTemplate() { + @Override public Object execute(String sql, PreparedStatementCallback action) throws DataAccessException { list.add(sql); try { @@ -64,6 +65,7 @@ public class JdbcBatchItemWriterClassicTests { writer.setSql("SQL"); writer.setJdbcTemplate(new NamedParameterJdbcTemplate(jdbcTemplate)); writer.setItemPreparedStatementSetter(new ItemPreparedStatementSetter() { + @Override public void setValues(String item, PreparedStatement ps) throws SQLException { list.add(item); } @@ -111,6 +113,7 @@ public class JdbcBatchItemWriterClassicTests { } writer.setItemPreparedStatementSetter( new ItemPreparedStatementSetter() { + @Override public void setValues(String item, PreparedStatement ps) throws SQLException { } @@ -153,6 +156,7 @@ public class JdbcBatchItemWriterClassicTests { public void testWriteAndFlushWithFailure() throws Exception { final RuntimeException ex = new RuntimeException("bar"); writer.setItemPreparedStatementSetter(new ItemPreparedStatementSetter() { + @Override public void setValues(String item, PreparedStatement ps) throws SQLException { list.add(item); throw ex; @@ -171,6 +175,7 @@ public class JdbcBatchItemWriterClassicTests { } assertEquals(2, list.size()); writer.setItemPreparedStatementSetter(new ItemPreparedStatementSetter() { + @Override public void setValues(String item, PreparedStatement ps) throws SQLException { list.add(item); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcBatchItemWriterNamedParameterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcBatchItemWriterNamedParameterTests.java index f3f2f758d..a195d0d8e 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcBatchItemWriterNamedParameterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcBatchItemWriterNamedParameterTests.java @@ -178,6 +178,7 @@ public class JdbcBatchItemWriterNamedParameterTests { this.expected = expected; } + @Override public boolean matches(Object actual) { if (!(actual instanceof SqlParameterSource[])) { return false; @@ -194,6 +195,7 @@ public class JdbcBatchItemWriterNamedParameterTests { return true; } + @Override public void appendTo(StringBuffer buffer) { buffer.append("eqSqlParameterSourceArray("); buffer.append(expected.getClass().getName()); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcCursorItemReaderCommonTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcCursorItemReaderCommonTests.java index c33443f3c..beff99fb9 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcCursorItemReaderCommonTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcCursorItemReaderCommonTests.java @@ -11,6 +11,7 @@ import org.springframework.batch.item.sample.Foo; @RunWith(JUnit4.class) public class JdbcCursorItemReaderCommonTests extends AbstractDatabaseItemStreamItemReaderTests { + @Override protected ItemReader getItemReader() throws Exception { JdbcCursorItemReader result = new JdbcCursorItemReader(); @@ -38,6 +39,7 @@ public class JdbcCursorItemReaderCommonTests extends AbstractDatabaseItemStreamI testRestart(); } + @Override protected void pointToEmptyInput(ItemReader tested) throws Exception { JdbcCursorItemReader reader = (JdbcCursorItemReader) tested; reader.close(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcCursorItemReaderConfigTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcCursorItemReaderConfigTests.java index d5e898710..5d6346aa0 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcCursorItemReaderConfigTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcCursorItemReaderConfigTests.java @@ -49,6 +49,7 @@ public class JdbcCursorItemReaderConfigTests { final ExecutionContext ec = new ExecutionContext(); tt.execute( new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { reader.open(ec); reader.close(); @@ -81,6 +82,7 @@ public class JdbcCursorItemReaderConfigTests { final ExecutionContext ec = new ExecutionContext(); tt.execute( new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { reader.open(ec); reader.close(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcCursorItemReaderIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcCursorItemReaderIntegrationTests.java index f2d4df3e4..7db814b48 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcCursorItemReaderIntegrationTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcCursorItemReaderIntegrationTests.java @@ -13,6 +13,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) public class JdbcCursorItemReaderIntegrationTests extends AbstractGenericDataSourceItemReaderIntegrationTests { + @Override protected ItemReader createItemReader() throws Exception { JdbcCursorItemReader result = new JdbcCursorItemReader(); result.setDataSource(dataSource); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderAsyncTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderAsyncTests.java index e50e5c648..c85c64559 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderAsyncTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderAsyncTests.java @@ -106,6 +106,7 @@ public class JdbcPagingItemReaderAsyncTests { .newFixedThreadPool(THREAD_COUNT)); for (int i = 0; i < THREAD_COUNT; i++) { completionService.submit(new Callable>() { + @Override public List call() throws Exception { List list = new ArrayList(); Foo next = null; @@ -147,6 +148,7 @@ public class JdbcPagingItemReaderAsyncTests { queryProvider.setSortKeys(sortKeys); reader.setQueryProvider(queryProvider); reader.setRowMapper(new ParameterizedRowMapper() { + @Override public Foo mapRow(ResultSet rs, int i) throws SQLException { Foo foo = new Foo(); foo.setId(rs.getInt(1)); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderClassicParameterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderClassicParameterTests.java index 24f133fd8..8f6bcbcd6 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderClassicParameterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderClassicParameterTests.java @@ -38,6 +38,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ContextConfiguration(locations = "/org/springframework/batch/item/database/JdbcPagingItemReaderParameterTests-context.xml") public class JdbcPagingItemReaderClassicParameterTests extends AbstractPagingItemReaderParameterTests { + @Override protected AbstractPagingItemReader getItemReader() throws Exception { JdbcPagingItemReader reader = new JdbcPagingItemReader(); @@ -53,6 +54,7 @@ public class JdbcPagingItemReaderClassicParameterTests extends AbstractPagingIte reader.setQueryProvider(queryProvider); reader.setRowMapper( new ParameterizedRowMapper() { + @Override public Foo mapRow(ResultSet rs, int i) throws SQLException { Foo foo = new Foo(); foo.setId(rs.getInt(1)); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderCommonTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderCommonTests.java index f13e8545f..8950badab 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderCommonTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderCommonTests.java @@ -45,6 +45,7 @@ public class JdbcPagingItemReaderCommonTests extends AbstractItemStreamItemReade @Autowired private DataSource dataSource; + @Override protected ItemReader getItemReader() throws Exception { JdbcPagingItemReader reader = new JdbcPagingItemReader(); @@ -58,6 +59,7 @@ public class JdbcPagingItemReaderCommonTests extends AbstractItemStreamItemReade reader.setQueryProvider(queryProvider); reader.setRowMapper( new ParameterizedRowMapper() { + @Override public Foo mapRow(ResultSet rs, int i) throws SQLException { Foo foo = new Foo(); foo.setId(rs.getInt(1)); @@ -74,6 +76,7 @@ public class JdbcPagingItemReaderCommonTests extends AbstractItemStreamItemReade return reader; } + @Override protected void pointToEmptyInput(ItemReader tested) throws Exception { JdbcPagingItemReader reader = (JdbcPagingItemReader) tested; reader.close(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderIntegrationTests.java index 011023716..02e23040d 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderIntegrationTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderIntegrationTests.java @@ -33,6 +33,7 @@ import org.springframework.jdbc.core.simple.ParameterizedRowMapper; */ public class JdbcPagingItemReaderIntegrationTests extends AbstractGenericDataSourceItemReaderIntegrationTests { + @Override protected ItemReader createItemReader() throws Exception { JdbcPagingItemReader inputSource = new JdbcPagingItemReader(); @@ -46,6 +47,7 @@ public class JdbcPagingItemReaderIntegrationTests extends AbstractGenericDataSou inputSource.setQueryProvider(queryProvider); inputSource.setRowMapper( new ParameterizedRowMapper() { + @Override public Foo mapRow(ResultSet rs, int i) throws SQLException { Foo foo = new Foo(); foo.setId(rs.getInt(1)); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderNamedParameterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderNamedParameterTests.java index f0a0cc297..a78fa9956 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderNamedParameterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderNamedParameterTests.java @@ -37,6 +37,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ContextConfiguration(locations = "/org/springframework/batch/item/database/JdbcPagingItemReaderParameterTests-context.xml") public class JdbcPagingItemReaderNamedParameterTests extends AbstractPagingItemReaderParameterTests { + @Override protected AbstractPagingItemReader getItemReader() throws Exception { JdbcPagingItemReader reader = new JdbcPagingItemReader(); @@ -52,6 +53,7 @@ public class JdbcPagingItemReaderNamedParameterTests extends AbstractPagingItemR reader.setQueryProvider(queryProvider); reader.setRowMapper( new ParameterizedRowMapper() { + @Override public Foo mapRow(ResultSet rs, int i) throws SQLException { Foo foo = new Foo(); foo.setId(rs.getInt(1)); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderOrderIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderOrderIntegrationTests.java index 0cfeb996d..0839197dd 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderOrderIntegrationTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderOrderIntegrationTests.java @@ -33,6 +33,7 @@ import org.springframework.jdbc.core.simple.ParameterizedRowMapper; */ public class JdbcPagingItemReaderOrderIntegrationTests extends AbstractGenericDataSourceItemReaderIntegrationTests { + @Override protected ItemReader createItemReader() throws Exception { JdbcPagingItemReader inputSource = new JdbcPagingItemReader(); @@ -47,6 +48,7 @@ public class JdbcPagingItemReaderOrderIntegrationTests extends AbstractGenericDa inputSource.setQueryProvider(queryProvider); inputSource.setRowMapper( new ParameterizedRowMapper() { + @Override public Foo mapRow(ResultSet rs, int i) throws SQLException { Foo foo = new Foo(); foo.setId(rs.getInt(1)); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderAsyncTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderAsyncTests.java index ca09e3893..3e1ce4ba1 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderAsyncTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderAsyncTests.java @@ -99,6 +99,7 @@ public class JpaPagingItemReaderAsyncTests { .newFixedThreadPool(THREAD_COUNT)); for (int i = 0; i < THREAD_COUNT; i++) { completionService.submit(new Callable>() { + @Override public List call() throws Exception { List list = new ArrayList(); Foo next = null; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderCommonTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderCommonTests.java index af7e757fc..547aaaa5c 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderCommonTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderCommonTests.java @@ -18,6 +18,7 @@ public class JpaPagingItemReaderCommonTests extends AbstractItemStreamItemReader @Autowired private EntityManagerFactory entityManagerFactory; + @Override protected ItemReader getItemReader() throws Exception { String jpqlQuery = "select f from Foo f"; @@ -32,6 +33,7 @@ public class JpaPagingItemReaderCommonTests extends AbstractItemStreamItemReader return reader; } + @Override protected void pointToEmptyInput(ItemReader tested) throws Exception { JpaPagingItemReader reader = (JpaPagingItemReader) tested; reader.close(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderIntegrationTests.java index 2a3ba3139..eb7ade626 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderIntegrationTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderIntegrationTests.java @@ -16,6 +16,7 @@ import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; */ public class JpaPagingItemReaderIntegrationTests extends AbstractGenericDataSourceItemReaderIntegrationTests { + @Override protected ItemReader createItemReader() throws Exception { LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); factoryBean.setDataSource(dataSource); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderNativeQueryIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderNativeQueryIntegrationTests.java index 292117208..cf01a2b96 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderNativeQueryIntegrationTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderNativeQueryIntegrationTests.java @@ -22,6 +22,7 @@ public class JpaPagingItemReaderNativeQueryIntegrationTests extends AbstractPagi @Autowired private EntityManagerFactory entityManagerFactory; + @Override protected AbstractPagingItemReader getItemReader() throws Exception { String sqlQuery = "select * from T_FOOS where value >= :limit"; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderParameterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderParameterTests.java index 32814b8be..ab407cbaa 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderParameterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderParameterTests.java @@ -17,6 +17,7 @@ public class JpaPagingItemReaderParameterTests extends AbstractPagingItemReaderP @Autowired private EntityManagerFactory entityManagerFactory; + @Override protected AbstractPagingItemReader getItemReader() throws Exception { String jpqlQuery = "select f from Foo f where f.value >= :limit"; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/SingleKeyFooDao.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/SingleKeyFooDao.java index 2cc2f2ec9..0004a8a67 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/SingleKeyFooDao.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/SingleKeyFooDao.java @@ -9,9 +9,11 @@ import org.springframework.jdbc.core.support.JdbcDaoSupport; public class SingleKeyFooDao extends JdbcDaoSupport implements FooDao { + @Override public Foo getFoo(Object key){ RowMapper fooMapper = new RowMapper(){ + @Override public Object mapRow(ResultSet rs, int rowNum) throws SQLException { Foo foo = new Foo(); foo.setId(rs.getInt(1)); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/StoredProcedureItemReaderCommonTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/StoredProcedureItemReaderCommonTests.java index f23009730..2fc9b45e6 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/StoredProcedureItemReaderCommonTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/StoredProcedureItemReaderCommonTests.java @@ -18,6 +18,7 @@ import org.springframework.jdbc.core.SqlParameter; @RunWith(JUnit4.class) public class StoredProcedureItemReaderCommonTests extends AbstractDatabaseItemStreamItemReaderTests { + @Override protected ItemReader getItemReader() throws Exception { StoredProcedureItemReader result = new StoredProcedureItemReader(); result.setDataSource(getDataSource()); @@ -28,6 +29,7 @@ public class StoredProcedureItemReaderCommonTests extends AbstractDatabaseItemSt return result; } + @Override protected void initializeContext() throws Exception { ctx = new ClassPathXmlApplicationContext("org/springframework/batch/item/database/stored-procedure-context.xml"); } @@ -43,6 +45,7 @@ public class StoredProcedureItemReaderCommonTests extends AbstractDatabaseItemSt testRestart(); } + @Override protected void pointToEmptyInput(ItemReader tested) throws Exception { StoredProcedureItemReader reader = (StoredProcedureItemReader) tested; reader.close(); @@ -55,6 +58,7 @@ public class StoredProcedureItemReaderCommonTests extends AbstractDatabaseItemSt }); reader.setPreparedStatementSetter( new PreparedStatementSetter() { + @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setInt(1, 1000); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/StoredprocedureItemReaderConfigTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/StoredprocedureItemReaderConfigTests.java index da4b89fc5..26c2bedfd 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/StoredprocedureItemReaderConfigTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/StoredprocedureItemReaderConfigTests.java @@ -59,6 +59,7 @@ public class StoredprocedureItemReaderConfigTests { final ExecutionContext ec = new ExecutionContext(); tt.execute( new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { reader.open(ec); reader.close(); @@ -95,6 +96,7 @@ public class StoredprocedureItemReaderConfigTests { final ExecutionContext ec = new ExecutionContext(); tt.execute( new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { reader.open(ec); reader.close(); @@ -133,6 +135,7 @@ public class StoredprocedureItemReaderConfigTests { new SqlParameter("bar", Types.OTHER)}); reader.setPreparedStatementSetter( new PreparedStatementSetter() { + @Override public void setValues(PreparedStatement ps) throws SQLException { } @@ -141,6 +144,7 @@ public class StoredprocedureItemReaderConfigTests { final ExecutionContext ec = new ExecutionContext(); tt.execute( new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { reader.open(ec); reader.close(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/ColumnMapExecutionContextRowMapperTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/ColumnMapExecutionContextRowMapperTests.java index 75de07fcc..1df7f1020 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/ColumnMapExecutionContextRowMapperTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/ColumnMapExecutionContextRowMapperTests.java @@ -23,6 +23,7 @@ public class ColumnMapExecutionContextRowMapperTests extends TestCase { private PreparedStatement ps; + @Override protected void setUp() throws Exception { super.setUp(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactoryTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactoryTests.java index 3eb51f1bf..9e4782545 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactoryTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactoryTests.java @@ -41,6 +41,7 @@ public class DefaultDataFieldMaxValueIncrementerFactoryTests extends TestCase { /* (non-Javadoc) * @see junit.framework.TestCase#setUp() */ + @Override protected void setUp() throws Exception { super.setUp(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/SqlPagingQueryUtilsTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/SqlPagingQueryUtilsTests.java index 736b17807..0acb9db46 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/SqlPagingQueryUtilsTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/SqlPagingQueryUtilsTests.java @@ -183,14 +183,17 @@ public class SqlPagingQueryUtilsTests { setSortKeys(sortKeys); } + @Override public String generateFirstPageQuery(int pageSize) { return null; } + @Override public String generateRemainingPagesQuery(int pageSize) { return null; } + @Override public String generateJumpToItemQuery(int itemIndex, int pageSize) { return null; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemReaderCommonTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemReaderCommonTests.java index 19412e98a..00afeb397 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemReaderCommonTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemReaderCommonTests.java @@ -20,6 +20,7 @@ public class FlatFileItemReaderCommonTests extends AbstractItemStreamItemReaderT Resource resource = new ByteArrayResource(FOOS.getBytes()); tested.setResource(resource); tested.setLineMapper(new LineMapper() { + @Override public Foo mapLine(String line, int lineNumber) { Foo foo = new Foo(); foo.setValue(Integer.valueOf(line.trim())); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemReaderTests.java index 62ea8e522..4a78d67f1 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemReaderTests.java @@ -48,15 +48,18 @@ public class FlatFileItemReaderTests { // 1 record = 2 lines boolean pair = true; + @Override public boolean isEndOfRecord(String line) { pair = !pair; return pair; } + @Override public String postProcess(String record) { return record; } + @Override public String preProcess(String record) { return record; } @@ -83,15 +86,18 @@ public class FlatFileItemReaderTests { // 1 record = 2 lines boolean pair = true; + @Override public boolean isEndOfRecord(String line) { pair = !pair; return pair; } + @Override public String postProcess(String record) { return record; } + @Override public String preProcess(String record) { return record; } @@ -119,14 +125,17 @@ public class FlatFileItemReaderTests { reader.setRecordSeparatorPolicy(new RecordSeparatorPolicy() { + @Override public boolean isEndOfRecord(String line) { return StringUtils.hasText(line); } + @Override public String postProcess(String record) { return StringUtils.hasText(record) ? record : null; } + @Override public String preProcess(String record) { return record; } @@ -150,6 +159,7 @@ public class FlatFileItemReaderTests { // 1 record = 2 lines boolean pair = true; + @Override public boolean isEndOfRecord(String line) { if (StringUtils.hasText(line)) { pair = !pair; @@ -157,10 +167,12 @@ public class FlatFileItemReaderTests { return pair; } + @Override public String postProcess(String record) { return StringUtils.hasText(record) ? record : null; } + @Override public String preProcess(String record) { return record; } @@ -305,14 +317,17 @@ public class FlatFileItemReaderTests { public void testOpenBadIOInput() throws Exception { reader.setResource(new AbstractResource() { + @Override public String getDescription() { return null; } + @Override public InputStream getInputStream() throws IOException { throw new IOException(); } + @Override public boolean exists() { return true; } @@ -387,6 +402,7 @@ public class FlatFileItemReaderTests { @Test public void testMappingExceptionWrapping() throws Exception { LineMapper exceptionLineMapper = new LineMapper() { + @Override public String mapLine(String line, int lineNumber) throws Exception { if (lineNumber == 2) { throw new Exception("Couldn't map line 2"); @@ -421,14 +437,17 @@ public class FlatFileItemReaderTests { public NonExistentResource() { } + @Override public boolean exists() { return false; } + @Override public String getDescription() { return "NonExistentResource"; } + @Override public InputStream getInputStream() throws IOException { return null; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java index 057294878..875587cba 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileItemWriterTests.java @@ -231,6 +231,7 @@ public class FlatFileItemWriterTests { @Test public void testWriteWithConverter() throws Exception { writer.setLineAggregator(new LineAggregator() { + @Override public String aggregate(String item) { return "FOO:" + item; } @@ -251,6 +252,7 @@ public class FlatFileItemWriterTests { @Test public void testWriteWithConverterAndString() throws Exception { writer.setLineAggregator(new LineAggregator() { + @Override public String aggregate(String item) { return "FOO:" + item; } @@ -288,6 +290,7 @@ public class FlatFileItemWriterTests { writer.setFooterCallback(new FlatFileFooterCallback() { + @Override public void writeFooter(Writer writer) throws IOException { writer.write("footer"); } @@ -342,6 +345,7 @@ public class FlatFileItemWriterTests { writer.open(executionContext); new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { try { writer.write(Collections.singletonList(TEST_STRING)); @@ -362,6 +366,7 @@ public class FlatFileItemWriterTests { writer.setFooterCallback(new FlatFileFooterCallback() { + @Override public void writeFooter(Writer writer) throws IOException { writer.write("footer"); } @@ -373,6 +378,7 @@ public class FlatFileItemWriterTests { PlatformTransactionManager transactionManager = new ResourcelessTransactionManager(); new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { try { // write some lines @@ -395,6 +401,7 @@ public class FlatFileItemWriterTests { writer.open(executionContext); new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { try { // write more lines @@ -507,6 +514,7 @@ public class FlatFileItemWriterTests { public void testWriteFooter() throws Exception { writer.setFooterCallback(new FlatFileFooterCallback() { + @Override public void writeFooter(Writer writer) throws IOException { writer.write("a\nb"); } @@ -524,6 +532,7 @@ public class FlatFileItemWriterTests { public void testWriteHeader() throws Exception { writer.setHeaderCallback(new FlatFileHeaderCallback() { + @Override public void writeHeader(Writer writer) throws IOException { writer.write("a\nb"); } @@ -543,6 +552,7 @@ public class FlatFileItemWriterTests { @Test public void testWriteWithAppendAfterHeaders() throws Exception { writer.setHeaderCallback(new FlatFileHeaderCallback() { + @Override public void writeHeader(Writer writer) throws IOException { writer.write("a\nb"); } @@ -568,6 +578,7 @@ public class FlatFileItemWriterTests { public void testWriteHeaderAndDeleteOnExit() throws Exception { writer.setHeaderCallback(new FlatFileHeaderCallback() { + @Override public void writeHeader(Writer writer) throws IOException { writer.write("a\nb"); } @@ -596,6 +607,7 @@ public class FlatFileItemWriterTests { public void testWriteHeaderAfterRestartOnFirstChunk() throws Exception { writer.setHeaderCallback(new FlatFileHeaderCallback() { + @Override public void writeHeader(Writer writer) throws IOException { writer.write("a\nb"); } @@ -621,6 +633,7 @@ public class FlatFileItemWriterTests { public void testWriteHeaderAfterRestartOnSecondChunk() throws Exception { writer.setHeaderCallback(new FlatFileHeaderCallback() { + @Override public void writeHeader(Writer writer) throws IOException { writer.write("a\nb"); } @@ -659,6 +672,7 @@ public class FlatFileItemWriterTests { writer.setLineAggregator(new LineAggregator() { + @Override public String aggregate(String item) { if (item.equals("2")) { throw new RuntimeException("aggregation failed on " + item); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileParseExceptionTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileParseExceptionTests.java index 40f31e679..fe21a4f47 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileParseExceptionTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/FlatFileParseExceptionTests.java @@ -21,10 +21,12 @@ import org.springframework.batch.support.AbstractExceptionTests; public class FlatFileParseExceptionTests extends AbstractExceptionTests { + @Override public Exception getException(String msg) throws Exception { return new FlatFileParseException(msg, "bar"); } + @Override public Exception getException(String msg, Throwable t) throws Exception { return new FlatFileParseException(msg, t, "bar", 100); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderFlatFileTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderFlatFileTests.java index d9179e59e..46769d2b0 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderFlatFileTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderFlatFileTests.java @@ -15,6 +15,7 @@ import org.springframework.core.io.Resource; public class MultiResourceItemReaderFlatFileTests extends AbstractItemStreamItemReaderTests { + @Override protected ItemReader getItemReader() throws Exception { MultiResourceItemReader multiReader = new MultiResourceItemReader(); @@ -22,6 +23,7 @@ public class MultiResourceItemReaderFlatFileTests extends fileReader.setLineMapper(new LineMapper() { + @Override public Foo mapLine(String line, int lineNumber) throws Exception { Foo foo = new Foo(); foo.setValue(Integer.valueOf(line)); @@ -41,6 +43,7 @@ public class MultiResourceItemReaderFlatFileTests extends multiReader.setResources(new Resource[] { r1, r2, r3, r4 }); multiReader.setSaveState(true); multiReader.setComparator(new Comparator() { + @Override public int compare(Resource arg0, Resource arg1) { return 0; // preserve original ordering } @@ -50,6 +53,7 @@ public class MultiResourceItemReaderFlatFileTests extends return multiReader; } + @Override protected void pointToEmptyInput(ItemReader tested) throws Exception { MultiResourceItemReader multiReader = (MultiResourceItemReader) tested; multiReader.close(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderIntegrationTests.java index 369c11441..05f98fb29 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderIntegrationTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderIntegrationTests.java @@ -53,6 +53,7 @@ public class MultiResourceItemReaderIntegrationTests { tested.setDelegate(itemReader); tested.setComparator(new Comparator() { + @Override public int compare(Resource o1, Resource o2) { return 0; // do not change ordering } @@ -226,6 +227,7 @@ public class MultiResourceItemReaderIntegrationTests { /** * Reversed ordering by filename. */ + @Override public int compare(Resource o1, Resource o2) { Resource r1 = (Resource) o1; Resource r2 = (Resource) o2; @@ -294,10 +296,12 @@ public class MultiResourceItemReaderIntegrationTests { Resource badResource = new AbstractResource() { + @Override public InputStream getInputStream() throws IOException { throw new RuntimeException(); } + @Override public String getDescription() { return null; } @@ -325,10 +329,12 @@ public class MultiResourceItemReaderIntegrationTests { Resource badResource = new AbstractResource() { + @Override public InputStream getInputStream() throws IOException { throw new RuntimeException(); } + @Override public String getDescription() { return null; } @@ -353,16 +359,19 @@ public class MultiResourceItemReaderIntegrationTests { Resource badResource = new AbstractResource() { + @Override public boolean exists() { // Looks good ... return true; } + @Override public InputStream getInputStream() throws IOException { // ... but fails during read throw new RuntimeException(); } + @Override public String getDescription() { return null; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderResourceAwareTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderResourceAwareTests.java index 8d6e9a6c1..4e85bc437 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderResourceAwareTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderResourceAwareTests.java @@ -52,6 +52,7 @@ public class MultiResourceItemReaderResourceAwareTests { tested.setDelegate(itemReader); tested.setComparator(new Comparator() { + @Override public int compare(Resource o1, Resource o2) { return 0; // do not change ordering } @@ -87,6 +88,7 @@ public class MultiResourceItemReaderResourceAwareTests { } static final class FooLineMapper implements LineMapper { + @Override public Foo mapLine(String line, int lineNumber) throws Exception { return new Foo(line); } @@ -101,6 +103,7 @@ public class MultiResourceItemReaderResourceAwareTests { this.value = value; } + @Override public void setResource(Resource resource) { this.resource = resource; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderXmlTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderXmlTests.java index 38d76ac40..0aa09ba1e 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderXmlTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderXmlTests.java @@ -26,6 +26,7 @@ import org.springframework.oxm.XmlMappingException; @RunWith(JUnit4.class) public class MultiResourceItemReaderXmlTests extends AbstractItemStreamItemReaderTests { + @Override protected ItemReader getItemReader() throws Exception { MultiResourceItemReader multiReader = new MultiResourceItemReader(); @@ -33,6 +34,7 @@ public class MultiResourceItemReaderXmlTests extends AbstractItemStreamItemReade reader.setFragmentRootElementName("foo"); reader.setUnmarshaller(new Unmarshaller() { + @Override public Object unmarshal(Source source) throws XmlMappingException, IOException { @@ -51,6 +53,7 @@ public class MultiResourceItemReaderXmlTests extends AbstractItemStreamItemReade return foo; } + @Override @SuppressWarnings("rawtypes") public boolean supports(Class clazz) { return true; @@ -69,6 +72,7 @@ public class MultiResourceItemReaderXmlTests extends AbstractItemStreamItemReade multiReader.setResources(new Resource[] { r1, r2, r3, r4 }); multiReader.setSaveState(true); multiReader.setComparator(new Comparator() { + @Override public int compare(Resource arg0, Resource arg1) { return 0; // preserve original ordering } @@ -77,6 +81,7 @@ public class MultiResourceItemReaderXmlTests extends AbstractItemStreamItemReade return multiReader; } + @Override protected void pointToEmptyInput(ItemReader tested) throws Exception { MultiResourceItemReader multiReader = (MultiResourceItemReader) tested; multiReader.close(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemWriterFlatFileTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemWriterFlatFileTests.java index a53f31db2..20a93ea33 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemWriterFlatFileTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemWriterFlatFileTests.java @@ -35,6 +35,7 @@ public class MultiResourceItemWriterFlatFileTests extends AbstractMultiResourceI this.list = list; } + @Override public Object doInTransaction(TransactionStatus status) { try { tested.write(list); @@ -98,6 +99,7 @@ public class MultiResourceItemWriterFlatFileTests extends AbstractMultiResourceI public void testMultiResourceWriteScenarioWithFooter() throws Exception { delegate.setFooterCallback(new FlatFileFooterCallback() { + @Override public void writeFooter(Writer writer) throws IOException { writer.write("f"); } @@ -124,6 +126,7 @@ public class MultiResourceItemWriterFlatFileTests extends AbstractMultiResourceI public void testTransactionalMultiResourceWriteScenarioWithFooter() throws Exception { delegate.setFooterCallback(new FlatFileFooterCallback() { + @Override public void writeFooter(Writer writer) throws IOException { writer.write("f"); } @@ -181,6 +184,7 @@ public class MultiResourceItemWriterFlatFileTests extends AbstractMultiResourceI public void testRestartWithFooter() throws Exception { delegate.setFooterCallback(new FlatFileFooterCallback() { + @Override public void writeFooter(Writer writer) throws IOException { writer.write("f"); } @@ -215,6 +219,7 @@ public class MultiResourceItemWriterFlatFileTests extends AbstractMultiResourceI public void testTransactionalRestartWithFooter() throws Exception { delegate.setFooterCallback(new FlatFileFooterCallback() { + @Override public void writeFooter(Writer writer) throws IOException { writer.write("f"); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemWriterXmlTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemWriterXmlTests.java index 2f06d8d16..af2ed8cfc 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemWriterXmlTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemWriterXmlTests.java @@ -41,6 +41,7 @@ public class MultiResourceItemWriterXmlTests extends AbstractMultiResourceItemWr */ private static class SimpleMarshaller implements Marshaller { + @Override public void marshal(Object graph, Result result) throws XmlMappingException, IOException { Assert.isInstanceOf(Result.class, result); @@ -57,6 +58,7 @@ public class MultiResourceItemWriterXmlTests extends AbstractMultiResourceItemWr } } + @Override @SuppressWarnings("rawtypes") public boolean supports(Class clazz) { return true; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/mapping/BeanWrapperFieldSetMapperConcurrentTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/mapping/BeanWrapperFieldSetMapperConcurrentTests.java index c47265547..d8b10d434 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/mapping/BeanWrapperFieldSetMapperConcurrentTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/mapping/BeanWrapperFieldSetMapperConcurrentTests.java @@ -45,6 +45,7 @@ public class BeanWrapperFieldSetMapperConcurrentTests { Collection> results = new ArrayList>(); for (int i = 0; i < 10; i++) { Future result = executorService.submit(new Callable() { + @Override public Boolean call() throws Exception { for (int i = 0; i < 10; i++) { GreenBean bean = mapper.mapFieldSet(lineTokenizer.tokenize("blue,green")); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/mapping/PatternMatchingCompositeLineMapperTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/mapping/PatternMatchingCompositeLineMapperTests.java index b3dafd3dd..7aa2e5ee3 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/mapping/PatternMatchingCompositeLineMapperTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/mapping/PatternMatchingCompositeLineMapperTests.java @@ -50,11 +50,13 @@ public class PatternMatchingCompositeLineMapperTests { public void testKeyFound() throws Exception { Map tokenizers = new HashMap(); tokenizers.put("foo*", new LineTokenizer() { + @Override public FieldSet tokenize(String line) { return new DefaultFieldSet(new String[] { "a", "b" }); } }); tokenizers.put("bar*", new LineTokenizer() { + @Override public FieldSet tokenize(String line) { return new DefaultFieldSet(new String[] { "c", "d" }); } @@ -63,11 +65,13 @@ public class PatternMatchingCompositeLineMapperTests { Map> fieldSetMappers = new HashMap>(); fieldSetMappers.put("foo*", new FieldSetMapper() { + @Override public Name mapFieldSet(FieldSet fs) { return new Name(fs.readString(0), fs.readString(1), 0); } }); fieldSetMappers.put("bar*", new FieldSetMapper() { + @Override public Name mapFieldSet(FieldSet fs) { return new Name(fs.readString(1), fs.readString(0), 0); } @@ -82,11 +86,13 @@ public class PatternMatchingCompositeLineMapperTests { public void testMapperKeyNotFound() throws Exception { Map tokenizers = new HashMap(); tokenizers.put("foo*", new LineTokenizer() { + @Override public FieldSet tokenize(String line) { return new DefaultFieldSet(new String[] { "a", "b" }); } }); tokenizers.put("bar*", new LineTokenizer() { + @Override public FieldSet tokenize(String line) { return new DefaultFieldSet(new String[] { "c", "d" }); } @@ -95,6 +101,7 @@ public class PatternMatchingCompositeLineMapperTests { Map> fieldSetMappers = new HashMap>(); fieldSetMappers.put("foo*", new FieldSetMapper() { + @Override public Name mapFieldSet(FieldSet fs) { return new Name(fs.readString(0), fs.readString(1), 0); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/CommonLineTokenizerTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/CommonLineTokenizerTests.java index 4ad3e525f..5528a0c56 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/CommonLineTokenizerTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/CommonLineTokenizerTests.java @@ -17,6 +17,7 @@ public class CommonLineTokenizerTests extends TestCase { */ public void testHasNames() { AbstractLineTokenizer tokenizer = new AbstractLineTokenizer() { + @Override protected List doTokenize(String line) { return null; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/DelimitedLineAggregatorTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/DelimitedLineAggregatorTests.java index c390e6c7c..47b975196 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/DelimitedLineAggregatorTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/DelimitedLineAggregatorTests.java @@ -29,6 +29,7 @@ public class DelimitedLineAggregatorTests { private static DelimitedLineAggregator aggregator; private FieldExtractor defaultFieldExtractor = new FieldExtractor() { + @Override public Object[] extract(String[] item) { return item; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/FormatterLineAggregatorTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/FormatterLineAggregatorTests.java index f284ae4c9..b7bc5dc7d 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/FormatterLineAggregatorTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/FormatterLineAggregatorTests.java @@ -33,6 +33,7 @@ public class FormatterLineAggregatorTests { private FormatterLineAggregator aggregator; private FieldExtractor defaultFieldExtractor = new FieldExtractor() { + @Override public Object[] extract(String[] item) { return item; } @@ -125,6 +126,7 @@ public class FormatterLineAggregatorTests { aggregator.setFieldExtractor(new FieldExtractor() { private int[] widths = new int[] { 13, 12 }; + @Override public Object[] extract(String[] item) { String[] strings = new String[item.length]; for (int i = 0; i < strings.length; i++) { @@ -159,6 +161,7 @@ public class FormatterLineAggregatorTests { aggregator.setFieldExtractor(new FieldExtractor() { private int[] widths = new int[] { 13, 11 }; + @Override public Object[] extract(String[] item) { String[] strings = new String[item.length]; for (int i = 0; i < strings.length; i++) { diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/PatternMatchingCompositeLineTokenizerTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/PatternMatchingCompositeLineTokenizerTests.java index eba968f09..7f9e717b4 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/PatternMatchingCompositeLineTokenizerTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/PatternMatchingCompositeLineTokenizerTests.java @@ -45,6 +45,7 @@ public class PatternMatchingCompositeLineTokenizerTests { Map map = new HashMap(); map.put("*", new DelimitedLineTokenizer()); map.put("foo", new LineTokenizer() { + @Override public FieldSet tokenize(String line) { return null; } @@ -60,6 +61,7 @@ public class PatternMatchingCompositeLineTokenizerTests { Map map = new LinkedHashMap(); map.put("*", new LineTokenizer() { + @Override public FieldSet tokenize(String line) { return null; } @@ -81,6 +83,7 @@ public class PatternMatchingCompositeLineTokenizerTests { @Test public void testMatchWithPrefix() throws Exception { tokenizer.setTokenizers(Collections.singletonMap("foo*", (LineTokenizer) new LineTokenizer() { + @Override public FieldSet tokenize(String line) { return new DefaultFieldSet(new String[] { line }); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/RangeArrayPropertyEditorTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/RangeArrayPropertyEditorTests.java index a45ade8b1..cd7f88097 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/RangeArrayPropertyEditorTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/RangeArrayPropertyEditorTests.java @@ -7,15 +7,18 @@ public class RangeArrayPropertyEditorTests extends TestCase { private Range[] ranges; private RangeArrayPropertyEditor pe; + @Override public void setUp() { ranges = null; pe = new RangeArrayPropertyEditor() { + @Override public void setValue(Object value) { ranges = (Range[]) value; } + @Override public Object getValue() { return ranges; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/RecursiveCollectionItemTransformerTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/RecursiveCollectionItemTransformerTests.java index 0b933b82f..dd8a4a088 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/RecursiveCollectionItemTransformerTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/RecursiveCollectionItemTransformerTests.java @@ -34,6 +34,7 @@ public class RecursiveCollectionItemTransformerTests extends TestCase { public void testSetDelegateAndPassInString() throws Exception { aggregator.setDelegate(new LineAggregator() { + @Override public String aggregate(String item) { return "bar"; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/mail/SimpleMailMessageItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/mail/SimpleMailMessageItemWriterTests.java index b509f90a1..2732ffbae 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/mail/SimpleMailMessageItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/mail/SimpleMailMessageItemWriterTests.java @@ -89,6 +89,7 @@ public class SimpleMailMessageItemWriterTests { final AtomicReference content = new AtomicReference(); writer.setMailErrorHandler(new MailErrorHandler() { + @Override public void handle(MailMessage message, Exception exception) throws MailException { content.set(exception.getMessage()); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/mail/javamail/MimeMessageItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/mail/javamail/MimeMessageItemWriterTests.java index c0bb8ae04..ea0fe8cdc 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/mail/javamail/MimeMessageItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/mail/javamail/MimeMessageItemWriterTests.java @@ -94,6 +94,7 @@ public class MimeMessageItemWriterTests { final AtomicReference content = new AtomicReference(); writer.setMailErrorHandler(new MailErrorHandler() { + @Override public void handle(MailMessage message, Exception exception) throws MailException { content.set(exception.getMessage()); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/Foo.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/Foo.java index 9688f920a..9cc25fe58 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/Foo.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/sample/Foo.java @@ -47,6 +47,7 @@ public class Foo { this.id = id; } + @Override public String toString() { return "Foo[id=" +id +",name=" + name + ",value=" + value + "]"; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/ClassifierCompositeItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/ClassifierCompositeItemWriterTests.java index fb98e624e..de1cf6395 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/ClassifierCompositeItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/ClassifierCompositeItemWriterTests.java @@ -41,11 +41,13 @@ public class ClassifierCompositeItemWriterTests { public void testWrite() throws Exception { Map> map = new HashMap>(); ItemWriter fooWriter = new ItemWriter() { + @Override public void write(List items) throws Exception { foos.addAll(items); } }; ItemWriter defaultWriter = new ItemWriter() { + @Override public void write(List items) throws Exception { defaults.addAll(items); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/CompositeItemStreamTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/CompositeItemStreamTests.java index 7d0652d82..02d8958b4 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/CompositeItemStreamTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/CompositeItemStreamTests.java @@ -38,6 +38,7 @@ public class CompositeItemStreamTests extends TestCase { public void testRegisterAndOpen() { ItemStreamSupport stream = new ItemStreamSupport() { + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { list.add("bar"); } @@ -49,6 +50,7 @@ public class CompositeItemStreamTests extends TestCase { public void testRegisterTwice() { ItemStreamSupport stream = new ItemStreamSupport() { + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { list.add("bar"); } @@ -61,6 +63,7 @@ public class CompositeItemStreamTests extends TestCase { public void testMark() { manager.register(new ItemStreamSupport() { + @Override public void update(ExecutionContext executionContext) { list.add("bar"); } @@ -71,6 +74,7 @@ public class CompositeItemStreamTests extends TestCase { public void testClose() { manager.register(new ItemStreamSupport() { + @Override public void close() throws ItemStreamException { list.add("bar"); } @@ -81,6 +85,7 @@ public class CompositeItemStreamTests extends TestCase { public void testCloseDoesNotUnregister() { manager.setStreams(new ItemStream[] { new ItemStreamSupport() { + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { list.add("bar"); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/TransactionAwareListItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/TransactionAwareListItemReaderTests.java index 6552bd6df..24a299cb0 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/TransactionAwareListItemReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/TransactionAwareListItemReaderTests.java @@ -34,6 +34,7 @@ public class TransactionAwareListItemReaderTests extends TestCase { private ListItemReader reader; + @Override protected void setUp() throws Exception { super.setUp(); reader = new ListItemReader(TransactionAwareProxyFactory.createTransactionalList(Arrays.asList("a", "b", "c"))); @@ -51,6 +52,7 @@ public class TransactionAwareListItemReaderTests extends TestCase { final List taken = new ArrayList(); try { new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { taken.add(reader.read()); return null; @@ -77,6 +79,7 @@ public class TransactionAwareListItemReaderTests extends TestCase { PlatformTransactionManager transactionManager = new ResourcelessTransactionManager(); final List taken = new ArrayList(); new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { Object next = reader.read(); while (next != null) { @@ -95,6 +98,7 @@ public class TransactionAwareListItemReaderTests extends TestCase { final List taken = new ArrayList(); try { new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { taken.add(reader.read()); throw new RuntimeException("Rollback!"); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/util/FileUtilsTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/util/FileUtilsTests.java index 8d10599e2..d0adae092 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/util/FileUtilsTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/util/FileUtilsTests.java @@ -114,6 +114,7 @@ public class FileUtilsTests { public void testBadFile(){ File file = new File("new file"){ + @Override public boolean createNewFile() throws IOException { throw new IOException(); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/validator/SpringValidatorTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/validator/SpringValidatorTests.java index d8b56bcd8..bc09b5440 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/validator/SpringValidatorTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/validator/SpringValidatorTests.java @@ -111,11 +111,13 @@ public class SpringValidatorTests { public static final TestBean REJECT_MULTI_VALUE = new TestBean("foo", "bar"); + @Override @SuppressWarnings({ "rawtypes", "unchecked" }) public boolean supports(Class clazz) { return clazz.isAssignableFrom(TestBean.class); } + @Override public void validate(Object value, Errors errors) { if (value.equals(ACCEPT_VALUE)) { return; // return without adding errors @@ -157,6 +159,7 @@ public class SpringValidatorTests { this.bar = bar; } + @Override public String toString() { return "TestBeanToString"; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/validator/ValidationExceptionTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/validator/ValidationExceptionTests.java index 06edcc78e..676f10cde 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/validator/ValidationExceptionTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/validator/ValidationExceptionTests.java @@ -20,10 +20,12 @@ import org.springframework.batch.repeat.AbstractExceptionTests; public class ValidationExceptionTests extends AbstractExceptionTests { + @Override public Exception getException(String msg) throws Exception { return new ValidationException(msg); } + @Override public Exception getException(String msg, Throwable t) throws Exception { return new ValidationException(msg, t); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemReaderCommonTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemReaderCommonTests.java index c4e828f9a..dbd49d35e 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemReaderCommonTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemReaderCommonTests.java @@ -24,11 +24,13 @@ public class StaxEventItemReaderCommonTests extends AbstractItemStreamItemReader private final static String FOOS = " "; + @Override protected ItemReader getItemReader() throws Exception { StaxEventItemReader reader = new StaxEventItemReader(); reader.setResource(new ByteArrayResource(FOOS.getBytes())); reader.setFragmentRootElementName("foo"); reader.setUnmarshaller(new Unmarshaller() { + @Override public Object unmarshal(Source source) throws XmlMappingException, IOException { Attribute attr = null ; try { @@ -45,6 +47,7 @@ public class StaxEventItemReaderCommonTests extends AbstractItemStreamItemReader return foo; } + @Override @SuppressWarnings("rawtypes") public boolean supports(Class clazz) { return true; @@ -57,6 +60,7 @@ public class StaxEventItemReaderCommonTests extends AbstractItemStreamItemReader return reader; } + @Override protected void pointToEmptyInput(ItemReader tested) throws Exception { StaxEventItemReader reader = (StaxEventItemReader) tested; reader.close(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemReaderTests.java index eb7f4a12d..456ba9c6f 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemReaderTests.java @@ -291,14 +291,17 @@ public class StaxEventItemReaderTests { public void testOpenBadIOInput() throws Exception { source.setResource(new AbstractResource() { + @Override public String getDescription() { return null; } + @Override public InputStream getInputStream() throws IOException { throw new IOException(); } + @Override public boolean exists() { return true; } @@ -403,10 +406,12 @@ public class StaxEventItemReaderTests { public static final String MESSAGE = "Unmarshallers on strike."; + @Override public Object unmarshal(Source source) throws XmlMappingException, IOException { throw new UnmarshallingFailureException(MESSAGE); } + @Override @SuppressWarnings("rawtypes") public boolean supports(Class clazz) { return true; @@ -451,6 +456,7 @@ public class StaxEventItemReaderTests { return events; } + @Override @SuppressWarnings("rawtypes") public boolean supports(Class clazz) { return true; @@ -462,6 +468,7 @@ public class StaxEventItemReaderTests { * @param source * @return list of the events from fragment body */ + @Override public Object unmarshal(Source source) throws XmlMappingException, IOException { List fragmentContent; @@ -502,6 +509,7 @@ public class StaxEventItemReaderTests { private boolean openCalled = false; + @Override public void open(ExecutionContext executionContext) { super.open(executionContext); openCalled = true; @@ -521,14 +529,17 @@ public class StaxEventItemReaderTests { public NonExistentResource() { } + @Override public boolean exists() { return false; } + @Override public String getDescription() { return "NonExistantResource"; } + @Override public InputStream getInputStream() throws IOException { return null; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemWriterTests.java index 703a2783d..10da4a8e9 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/StaxEventItemWriterTests.java @@ -51,6 +51,7 @@ public class StaxEventItemWriterTests { // test item for writing to output private Object item = new Object() { + @Override public String toString() { return ClassUtils.getShortName(StaxEventItemWriter.class) + "-testString"; } @@ -132,6 +133,7 @@ public class StaxEventItemWriterTests { PlatformTransactionManager transactionManager = new ResourcelessTransactionManager(); new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { try { // write item @@ -151,6 +153,7 @@ public class StaxEventItemWriterTests { writer = createItemWriter(); writer.open(executionContext); new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { try { writer.write(items); @@ -180,6 +183,7 @@ public class StaxEventItemWriterTests { writer.open(executionContext); try { new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { try { writer.write(items); @@ -202,6 +206,7 @@ public class StaxEventItemWriterTests { // create new writer from saved restart data and continue writing writer = createItemWriter(); new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { writer.open(executionContext); try { @@ -234,6 +239,7 @@ public class StaxEventItemWriterTests { writer.setHeaderCallback(new StaxWriterCallback() { + @Override public void write(XMLEventWriter writer) throws IOException { XMLEventFactory factory = XMLEventFactory.newInstance(); try { @@ -279,6 +285,7 @@ public class StaxEventItemWriterTests { public void testOpenAndClose() throws Exception { writer.setHeaderCallback(new StaxWriterCallback() { + @Override public void write(XMLEventWriter writer) throws IOException { XMLEventFactory factory = XMLEventFactory.newInstance(); try { @@ -294,6 +301,7 @@ public class StaxEventItemWriterTests { }); writer.setFooterCallback(new StaxWriterCallback() { + @Override public void write(XMLEventWriter writer) throws IOException { XMLEventFactory factory = XMLEventFactory.newInstance(); try { @@ -413,6 +421,7 @@ public class StaxEventItemWriterTests { this.namespacePrefix = namespacePrefix; } + @Override public void marshal(Object graph, Result result) throws XmlMappingException, IOException { Assert.isInstanceOf( Result.class, result); try { @@ -424,6 +433,7 @@ public class StaxEventItemWriterTests { } } + @Override @SuppressWarnings("rawtypes") public boolean supports(Class clazz) { return true; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/TransactionalStaxEventItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/TransactionalStaxEventItemWriterTests.java index 766e27477..abc632f0b 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/TransactionalStaxEventItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/TransactionalStaxEventItemWriterTests.java @@ -47,6 +47,7 @@ public class TransactionalStaxEventItemWriterTests { // test item for writing to output private Object item = new Object() { + @Override public String toString() { return ClassUtils.getShortName(StaxEventItemWriter.class) + "-testString"; } @@ -71,6 +72,7 @@ public class TransactionalStaxEventItemWriterTests { public void testWriteAndFlush() throws Exception { writer.open(executionContext); new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { try { writer.write(items); @@ -93,6 +95,7 @@ public class TransactionalStaxEventItemWriterTests { public void testWriteWithHeaderAfterRollback() throws Exception { writer.setHeaderCallback(new StaxWriterCallback(){ + @Override public void write(XMLEventWriter writer) throws IOException { XMLEventFactory factory = XMLEventFactory.newInstance(); try { @@ -109,6 +112,7 @@ public class TransactionalStaxEventItemWriterTests { writer.open(executionContext); try { new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { try { writer.write(items); @@ -127,6 +131,7 @@ public class TransactionalStaxEventItemWriterTests { writer.close(); writer.open(executionContext); new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { try { writer.write(items); @@ -150,6 +155,7 @@ public class TransactionalStaxEventItemWriterTests { public void testWriteWithHeaderAfterFlushAndRollback() throws Exception { writer.setHeaderCallback(new StaxWriterCallback(){ + @Override public void write(XMLEventWriter writer) throws IOException { XMLEventFactory factory = XMLEventFactory.newInstance(); try { @@ -165,6 +171,7 @@ public class TransactionalStaxEventItemWriterTests { }); writer.open(executionContext); new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { try { writer.write(items); @@ -180,6 +187,7 @@ public class TransactionalStaxEventItemWriterTests { writer.open(executionContext); try { new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { try { writer.write(items); @@ -212,6 +220,7 @@ public class TransactionalStaxEventItemWriterTests { * Writes object's toString representation as XML comment. */ private static class SimpleMarshaller implements Marshaller { + @Override public void marshal(Object graph, Result result) throws XmlMappingException, IOException { try { StaxUtils.getXmlEventWriter(result).add(XMLEventFactory.newInstance().createComment(graph.toString())); @@ -221,6 +230,7 @@ public class TransactionalStaxEventItemWriterTests { } } + @Override @SuppressWarnings("rawtypes") public boolean supports(Class clazz) { return true; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/stax/AbstractEventReaderWrapperTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/stax/AbstractEventReaderWrapperTests.java index 7dae34670..bb12b2c95 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/stax/AbstractEventReaderWrapperTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/stax/AbstractEventReaderWrapperTests.java @@ -36,6 +36,7 @@ public class AbstractEventReaderWrapperTests extends TestCase { AbstractEventReaderWrapper eventReaderWrapper; XMLEventReader xmlEventReader; + @Override protected void setUp() throws Exception { super.setUp(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/stax/AbstractEventWriterWrapperTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/stax/AbstractEventWriterWrapperTests.java index a69ed12b7..55a449f9b 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/stax/AbstractEventWriterWrapperTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/stax/AbstractEventWriterWrapperTests.java @@ -42,6 +42,7 @@ public class AbstractEventWriterWrapperTests extends TestCase { XMLEventWriter xmlEventWriter; + @Override protected void setUp() throws Exception { super.setUp(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/stax/DefaultFragmentEventReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/stax/DefaultFragmentEventReaderTests.java index b7664836c..39193e9a8 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/stax/DefaultFragmentEventReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/stax/DefaultFragmentEventReaderTests.java @@ -32,6 +32,7 @@ public class DefaultFragmentEventReaderTests extends TestCase { /** * Setup the fragmentReader to read the test input. */ + @Override protected void setUp() throws Exception { Resource input = new ByteArrayResource(xml.getBytes()); eventReader = XMLInputFactory.newInstance().createXMLEventReader( diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/stax/NoStartEndDocumentWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/stax/NoStartEndDocumentWriterTests.java index 1a67550bf..51907d232 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/stax/NoStartEndDocumentWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/xml/stax/NoStartEndDocumentWriterTests.java @@ -22,6 +22,7 @@ public class NoStartEndDocumentWriterTests extends TestCase { private XMLEventFactory eventFactory = XMLEventFactory.newInstance(); + @Override protected void setUp() throws Exception { wrappedWriter = createStrictMock(XMLEventWriter.class); writer = new NoStartEndDocumentStreamWriter(wrappedWriter); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/poller/DirectPollerTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/poller/DirectPollerTests.java index 2d9de3b6c..27f451d8f 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/poller/DirectPollerTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/poller/DirectPollerTests.java @@ -40,6 +40,7 @@ public class DirectPollerTests { Callable callback = new Callable() { + @Override public String call() throws Exception { Set executions = new HashSet(repository); if (executions.isEmpty()) { @@ -64,6 +65,7 @@ public class DirectPollerTests { Callable callback = new Callable() { + @Override public String call() throws Exception { Set executions = new HashSet(repository); if (executions.isEmpty()) { @@ -88,6 +90,7 @@ public class DirectPollerTests { Callable callback = new Callable() { + @Override public String call() throws Exception { Set executions = new HashSet(repository); if (executions.isEmpty()) { @@ -115,6 +118,7 @@ public class DirectPollerTests { private void sleepAndCreateStringInBackground(final long duration) { new Thread(new Runnable() { + @Override public void run() { try { Thread.sleep(duration); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/RepeatExceptionTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/RepeatExceptionTests.java index 57c7c6858..36841c902 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/RepeatExceptionTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/RepeatExceptionTests.java @@ -20,10 +20,12 @@ import org.springframework.batch.repeat.RepeatException; public class RepeatExceptionTests extends AbstractExceptionTests { + @Override public Exception getException(String msg) throws Exception { return new RepeatException(msg); } + @Override public Exception getException(String msg, Throwable t) throws Exception { return new RepeatException(msg, t); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/callback/NestedRepeatCallbackTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/callback/NestedRepeatCallbackTests.java index 790c57b44..f2adb24b6 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/callback/NestedRepeatCallbackTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/callback/NestedRepeatCallbackTests.java @@ -29,6 +29,7 @@ public class NestedRepeatCallbackTests extends TestCase { public void testExecute() throws Exception { NestedRepeatCallback callback = new NestedRepeatCallback(new RepeatTemplate(), new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; return RepeatStatus.continueIf(count <= 1); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/context/RepeatContextSupportTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/context/RepeatContextSupportTests.java index eafe4e089..e5db94291 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/context/RepeatContextSupportTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/context/RepeatContextSupportTests.java @@ -35,6 +35,7 @@ public class RepeatContextSupportTests extends TestCase { RepeatContextSupport context = new RepeatContextSupport(null); context.setAttribute("foo", "FOO"); context.registerDestructionCallback("foo", new Runnable() { + @Override public void run() { list.add("bar"); } @@ -50,6 +51,7 @@ public class RepeatContextSupportTests extends TestCase { public void testDestructionCallbackMissingAttribute() throws Exception { RepeatContextSupport context = new RepeatContextSupport(null); context.registerDestructionCallback("foo", new Runnable() { + @Override public void run() { list.add("bar"); } @@ -67,12 +69,14 @@ public class RepeatContextSupportTests extends TestCase { context.setAttribute("foo", "FOO"); context.setAttribute("bar", "BAR"); context.registerDestructionCallback("bar", new Runnable() { + @Override public void run() { list.add("spam"); throw new RuntimeException("fail!"); } }); context.registerDestructionCallback("foo", new Runnable() { + @Override public void run() { list.add("bar"); throw new RuntimeException("fail!"); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/exception/CompositeExceptionHandlerTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/exception/CompositeExceptionHandlerTests.java index 1c77901b7..7a1946989 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/exception/CompositeExceptionHandlerTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/exception/CompositeExceptionHandlerTests.java @@ -28,7 +28,7 @@ import org.springframework.batch.repeat.exception.ExceptionHandler; public class CompositeExceptionHandlerTests extends TestCase { private CompositeExceptionHandler handler = new CompositeExceptionHandler(); - + public void testNewHandler() throws Throwable { try { handler.handleException(null, new RuntimeException()); @@ -37,16 +37,18 @@ public class CompositeExceptionHandlerTests extends TestCase { fail("Unexpected RuntimeException"); } } - + public void testDelegation() throws Throwable { final List list = new ArrayList(); handler.setHandlers(new ExceptionHandler[] { new ExceptionHandler() { + @Override public void handleException(RepeatContext context, Throwable throwable) throws RuntimeException { list.add("1"); } }, new ExceptionHandler() { + @Override public void handleException(RepeatContext context, Throwable throwable) throws RuntimeException { list.add("2"); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/exception/LogOrRethrowExceptionHandlerTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/exception/LogOrRethrowExceptionHandlerTests.java index 9d82bbdf7..6f668a318 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/exception/LogOrRethrowExceptionHandlerTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/exception/LogOrRethrowExceptionHandlerTests.java @@ -35,6 +35,7 @@ public class LogOrRethrowExceptionHandlerTests extends TestCase { private RepeatContext context = null; + @Override protected void setUp() throws Exception { super.setUp(); Logger logger = Logger.getLogger(LogOrRethrowExceptionHandler.class); @@ -67,6 +68,7 @@ public class LogOrRethrowExceptionHandlerTests extends TestCase { public void testNotRethrownErrorLevel() throws Throwable { handler.setExceptionClassifier(new ClassifierSupport(Level.RETHROW) { + @Override public Level classify(Throwable throwable) { return Level.ERROR; } @@ -78,6 +80,7 @@ public class LogOrRethrowExceptionHandlerTests extends TestCase { public void testNotRethrownWarnLevel() throws Throwable { handler.setExceptionClassifier(new ClassifierSupport(Level.RETHROW) { + @Override public Level classify(Throwable throwable) { return Level.WARN; } @@ -89,6 +92,7 @@ public class LogOrRethrowExceptionHandlerTests extends TestCase { public void testNotRethrownDebugLevel() throws Throwable { handler.setExceptionClassifier(new ClassifierSupport(Level.RETHROW) { + @Override public Level classify(Throwable throwable) { return Level.DEBUG; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/interceptor/RepeatOperationsInterceptorTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/interceptor/RepeatOperationsInterceptorTests.java index 5f0649df6..c2cea59d1 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/interceptor/RepeatOperationsInterceptorTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/interceptor/RepeatOperationsInterceptorTests.java @@ -42,6 +42,7 @@ public class RepeatOperationsInterceptorTests extends TestCase { private ServiceImpl target; + @Override protected void setUp() throws Exception { super.setUp(); interceptor = new RepeatOperationsInterceptor(); @@ -68,6 +69,7 @@ public class RepeatOperationsInterceptorTests extends TestCase { public void testSetTemplate() throws Exception { final List calls = new ArrayList(); interceptor.setRepeatOperations(new RepeatOperations() { + @Override public RepeatStatus iterate(RepeatCallback callback) { try { Object result = callback.doInIteration(null); @@ -87,6 +89,7 @@ public class RepeatOperationsInterceptorTests extends TestCase { public void testCallbackNotExecuted() throws Exception { final List calls = new ArrayList(); interceptor.setRepeatOperations(new RepeatOperations() { + @Override public RepeatStatus iterate(RepeatCallback callback) { calls.add(null); return RepeatStatus.FINISHED; @@ -159,6 +162,7 @@ public class RepeatOperationsInterceptorTests extends TestCase { ((Advised) service).addAdvice(interceptor); final List list = new ArrayList(); ((Advised) service).addAdvice(new MethodInterceptor() { + @Override public Object invoke(MethodInvocation invocation) throws Throwable { list.add("chain"); return invocation.proceed(); @@ -175,6 +179,7 @@ public class RepeatOperationsInterceptorTests extends TestCase { public void testIllegalMethodInvocationType() throws Throwable { try { interceptor.invoke(new MethodInvocation() { + @Override public Method getMethod() { try { return Object.class.getMethod("toString", new Class[0]); @@ -184,18 +189,22 @@ public class RepeatOperationsInterceptorTests extends TestCase { } } + @Override public Object[] getArguments() { return null; } + @Override public AccessibleObject getStaticPart() { return null; } + @Override public Object getThis() { return null; } + @Override public Object proceed() throws Throwable { return null; } @@ -235,6 +244,7 @@ public class RepeatOperationsInterceptorTests extends TestCase { this.maxService = maxService; } + @Override public Object service() throws Exception { count++; if (count <= maxService) { @@ -249,18 +259,22 @@ public class RepeatOperationsInterceptorTests extends TestCase { this.complete = complete; } + @Override public void alternate() throws Exception { count++; } + @Override public Object exception() throws Exception { throw new RuntimeException("Duh! Stupid."); } + @Override public Object error() throws Exception { throw new Error("Duh! Stupid error."); } + @Override public boolean isContinuable() throws Exception { count++; return !complete; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/listener/CompositeRepeatListenerTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/listener/CompositeRepeatListenerTests.java index bb990a163..a2f1fce13 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/listener/CompositeRepeatListenerTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/listener/CompositeRepeatListenerTests.java @@ -40,10 +40,12 @@ public class CompositeRepeatListenerTests extends TestCase { */ public void testSetListeners() { listener.setListeners(new RepeatListener[] { new RepeatListenerSupport() { + @Override public void open(RepeatContext context) { list.add("fail"); } }, new RepeatListenerSupport() { + @Override public void open(RepeatContext context) { list.add("continue"); } @@ -58,6 +60,7 @@ public class CompositeRepeatListenerTests extends TestCase { */ public void testSetListener() { listener.register(new RepeatListenerSupport() { + @Override public void before(RepeatContext context) { list.add("fail"); } @@ -68,6 +71,7 @@ public class CompositeRepeatListenerTests extends TestCase { public void testClose() { listener.register(new RepeatListenerSupport() { + @Override public void close(RepeatContext context) { list.add("foo"); } @@ -78,6 +82,7 @@ public class CompositeRepeatListenerTests extends TestCase { public void testOnError() { listener.register(new RepeatListenerSupport() { + @Override public void onError(RepeatContext context, Throwable e) { list.add(e); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/listener/RepeatListenerTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/listener/RepeatListenerTests.java index 659d07f51..7b5275a77 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/listener/RepeatListenerTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/listener/RepeatListenerTests.java @@ -37,15 +37,18 @@ public class RepeatListenerTests extends TestCase { RepeatTemplate template = new RepeatTemplate(); final List calls = new ArrayList(); template.setListeners(new RepeatListener[] { new RepeatListenerSupport() { + @Override public void before(RepeatContext context) { calls.add("1"); } }, new RepeatListenerSupport() { + @Override public void before(RepeatContext context) { calls.add("2"); } } }); template.iterate(new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; return RepeatStatus.continueIf(count <= 1); @@ -63,12 +66,14 @@ public class RepeatListenerTests extends TestCase { RepeatTemplate template = new RepeatTemplate(); final List calls = new ArrayList(); template.registerListener(new RepeatListenerSupport() { + @Override public void before(RepeatContext context) { calls.add("1"); context.setCompleteOnly(); } }); template.iterate(new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; return RepeatStatus.FINISHED; @@ -83,15 +88,18 @@ public class RepeatListenerTests extends TestCase { RepeatTemplate template = new RepeatTemplate(); final List calls = new ArrayList(); template.setListeners(new RepeatListener[] { new RepeatListenerSupport() { + @Override public void after(RepeatContext context, RepeatStatus result) { calls.add("1"); } }, new RepeatListenerSupport() { + @Override public void after(RepeatContext context, RepeatStatus result) { calls.add("2"); } } }); template.iterate(new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; return RepeatStatus.continueIf(count <= 1); @@ -107,16 +115,19 @@ public class RepeatListenerTests extends TestCase { RepeatTemplate template = new RepeatTemplate(); final List calls = new ArrayList(); template.setListeners(new RepeatListener[] { new RepeatListenerSupport() { + @Override public void open(RepeatContext context) { calls.add("1"); } }, new RepeatListenerSupport() { + @Override public void open(RepeatContext context) { calls.add("2"); context.setCompleteOnly(); } } }); template.iterate(new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; return RepeatStatus.CONTINUABLE; @@ -130,11 +141,13 @@ public class RepeatListenerTests extends TestCase { RepeatTemplate template = new RepeatTemplate(); final List calls = new ArrayList(); template.registerListener(new RepeatListenerSupport() { + @Override public void open(RepeatContext context) { calls.add("1"); } }); template.iterate(new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; context.setCompleteOnly(); @@ -149,15 +162,18 @@ public class RepeatListenerTests extends TestCase { RepeatTemplate template = new RepeatTemplate(); final List calls = new ArrayList(); template.setListeners(new RepeatListener[] { new RepeatListenerSupport() { + @Override public void close(RepeatContext context) { calls.add("1"); } }, new RepeatListenerSupport() { + @Override public void close(RepeatContext context) { calls.add("2"); } } }); template.iterate(new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; return RepeatStatus.continueIf(count < 2); @@ -174,16 +190,19 @@ public class RepeatListenerTests extends TestCase { RepeatTemplate template = new RepeatTemplate(); final List calls = new ArrayList(); template.setListeners(new RepeatListener[] { new RepeatListenerSupport() { + @Override public void onError(RepeatContext context, Throwable t) { calls.add("1"); } }, new RepeatListenerSupport() { + @Override public void onError(RepeatContext context, Throwable t) { calls.add("2"); } } }); try { template.iterate(new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { throw new IllegalStateException("Bogus"); } @@ -201,16 +220,19 @@ public class RepeatListenerTests extends TestCase { RepeatTemplate template = new RepeatTemplate(); final List calls = new ArrayList(); template.setListeners(new RepeatListener[] { new RepeatListenerSupport() { + @Override public void after(RepeatContext context, RepeatStatus result) { calls.add("1"); } }, new RepeatListenerSupport() { + @Override public void onError(RepeatContext context, Throwable t) { calls.add("2"); } } }); try { template.iterate(new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { throw new IllegalStateException("Bogus"); } @@ -231,10 +253,12 @@ public class RepeatListenerTests extends TestCase { final List calls = new ArrayList(); final List fails = new ArrayList(); template.setListeners(new RepeatListener[] { new RepeatListenerSupport() { + @Override public void after(RepeatContext context, RepeatStatus result) { calls.add("1"); } }, new RepeatListenerSupport() { + @Override public void onError(RepeatContext context, Throwable t) { calls.add("2"); fails.add("2"); @@ -242,6 +266,7 @@ public class RepeatListenerTests extends TestCase { } }); try { template.iterate(new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { throw new IllegalStateException("Bogus"); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/policy/CompositeCompletionPolicyTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/policy/CompositeCompletionPolicyTests.java index 1805d584b..7959f4177 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/policy/CompositeCompletionPolicyTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/policy/CompositeCompletionPolicyTests.java @@ -47,6 +47,7 @@ public class CompositeCompletionPolicyTests extends TestCase { CompositeCompletionPolicy policy = new CompositeCompletionPolicy(); policy.setPolicies(new CompletionPolicy[] { new MockCompletionPolicySupport(), new MockCompletionPolicySupport() { + @Override public boolean isComplete(RepeatContext context) { return true; } @@ -59,6 +60,7 @@ public class CompositeCompletionPolicyTests extends TestCase { CompositeCompletionPolicy policy = new CompositeCompletionPolicy(); policy.setPolicies(new CompletionPolicy[] { new MockCompletionPolicySupport(), new MockCompletionPolicySupport() { + @Override public boolean isComplete(RepeatContext context, RepeatStatus result) { return true; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/policy/CountingCompletionPolicyTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/policy/CountingCompletionPolicyTests.java index e4ef2623b..44a9699ee 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/policy/CountingCompletionPolicyTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/policy/CountingCompletionPolicyTests.java @@ -26,6 +26,7 @@ public class CountingCompletionPolicyTests extends TestCase { public void testDefaultBehaviour() throws Exception { CountingCompletionPolicy policy = new CountingCompletionPolicy() { + @Override protected int getCount(RepeatContext context) { return 1; }; @@ -36,6 +37,7 @@ public class CountingCompletionPolicyTests extends TestCase { public void testNullResult() throws Exception { CountingCompletionPolicy policy = new CountingCompletionPolicy() { + @Override protected int getCount(RepeatContext context) { return 1; }; @@ -47,6 +49,7 @@ public class CountingCompletionPolicyTests extends TestCase { public void testFinishedResult() throws Exception { CountingCompletionPolicy policy = new CountingCompletionPolicy() { + @Override protected int getCount(RepeatContext context) { return 1; }; @@ -60,10 +63,12 @@ public class CountingCompletionPolicyTests extends TestCase { CountingCompletionPolicy policy = new CountingCompletionPolicy() { int count = 0; + @Override protected int getCount(RepeatContext context) { return count; }; + @Override protected int doUpdate(RepeatContext context) { count++; return 1; @@ -81,16 +86,19 @@ public class CountingCompletionPolicyTests extends TestCase { CountingCompletionPolicy policy = new CountingCompletionPolicy() { int count = 0; + @Override protected int getCount(RepeatContext context) { return count; }; + @Override protected int doUpdate(RepeatContext context) { super.doUpdate(context); count++; return 1; } + @Override public RepeatContext start(RepeatContext context) { count = 0; return super.start(context); @@ -110,16 +118,19 @@ public class CountingCompletionPolicyTests extends TestCase { CountingCompletionPolicy policy = new CountingCompletionPolicy() { int count = 0; + @Override protected int getCount(RepeatContext context) { return count; }; + @Override protected int doUpdate(RepeatContext context) { super.doUpdate(context); count++; return 1; } + @Override public RepeatContext start(RepeatContext context) { count = 0; return super.start(context); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/policy/MockCompletionPolicySupport.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/policy/MockCompletionPolicySupport.java index 6f1231567..5459f4fd6 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/policy/MockCompletionPolicySupport.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/policy/MockCompletionPolicySupport.java @@ -20,6 +20,7 @@ import org.springframework.batch.repeat.RepeatContext; public class MockCompletionPolicySupport extends CompletionPolicySupport { + @Override public boolean isComplete(RepeatContext context) { return false; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/policy/SimpleCompletionPolicyTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/policy/SimpleCompletionPolicyTests.java index 8890aa886..f92232175 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/policy/SimpleCompletionPolicyTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/policy/SimpleCompletionPolicyTests.java @@ -29,6 +29,7 @@ public class SimpleCompletionPolicyTests extends TestCase { RepeatStatus dummy = RepeatStatus.CONTINUABLE; + @Override protected void setUp() throws Exception { super.setUp(); context = policy.start(null); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/AbstractTradeBatchTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/AbstractTradeBatchTests.java index da53e30ce..13e28883c 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/AbstractTradeBatchTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/AbstractTradeBatchTests.java @@ -66,6 +66,7 @@ public abstract class AbstractTradeBatchTests { } protected static class TradeMapper implements FieldSetMapper { + @Override public Trade mapFieldSet(FieldSet fs) { return new Trade(fs); } @@ -76,6 +77,7 @@ public abstract class AbstractTradeBatchTests { // This has to be synchronized because we are going to test the state // (count) at the end of a concurrent batch run. + @Override public synchronized void write(List data) { count++; System.out.println("Executing trade '" + data + "'"); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/ChunkedRepeatTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/ChunkedRepeatTests.java index a5cbdf920..a014e5091 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/ChunkedRepeatTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/ChunkedRepeatTests.java @@ -59,6 +59,7 @@ public class ChunkedRepeatTests extends AbstractTradeBatchTests { RepeatStatus result = repeatTemplate.iterate(new NestedRepeatCallback(chunkTemplate, callback) { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; // for test assertion return super.doInIteration(context); @@ -95,6 +96,7 @@ public class ChunkedRepeatTests extends AbstractTradeBatchTests { RepeatStatus result = repeatTemplate.iterate(new NestedRepeatCallback(chunkTemplate, callback) { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; // for test assertion return super.doInIteration(context); @@ -157,6 +159,7 @@ public class ChunkedRepeatTests extends AbstractTradeBatchTests { ItemReader truncated = new ItemReader() { int count = 0; + @Override public Trade read() throws Exception { if (count++ < 2) return provider.read(); @@ -166,6 +169,7 @@ public class ChunkedRepeatTests extends AbstractTradeBatchTests { chunker.reset(); template.iterate(new ItemReaderRepeatCallback(truncated, processor) { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { RepeatStatus result = super.doInIteration(context); if (!result.isContinuable() && chunker.first()) { diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/ItemReaderRepeatCallback.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/ItemReaderRepeatCallback.java index f194e5999..e53a0d444 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/ItemReaderRepeatCallback.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/ItemReaderRepeatCallback.java @@ -44,6 +44,7 @@ public class ItemReaderRepeatCallback implements RepeatCallback { /* (non-Javadoc) * @see org.springframework.batch.repeat.RepeatCallback#doInIteration(org.springframework.batch.repeat.RepeatContext) */ + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { T item = reader.read(); if (item==null) { diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/RepeatSynchronizationManagerTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/RepeatSynchronizationManagerTests.java index 9fbdd380c..eaa702cc1 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/RepeatSynchronizationManagerTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/RepeatSynchronizationManagerTests.java @@ -25,10 +25,12 @@ public class RepeatSynchronizationManagerTests extends TestCase { private RepeatContext context = new RepeatContextSupport(null); + @Override protected void setUp() throws Exception { RepeatSynchronizationManager.clear(); } + @Override protected void tearDown() throws Exception { RepeatSynchronizationManager.clear(); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/ResultHolderResultQueueTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/ResultHolderResultQueueTests.java index f2f17710d..921e2b151 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/ResultHolderResultQueueTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/ResultHolderResultQueueTests.java @@ -45,14 +45,17 @@ public class ResultHolderResultQueueTests { this.result = result; } + @Override public RepeatContext getContext() { return null; } + @Override public Throwable getError() { return error; } + @Override public RepeatStatus getResult() { return result; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/SimpleRepeatTemplateTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/SimpleRepeatTemplateTests.java index 2f4797b7e..6d0e04fe5 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/SimpleRepeatTemplateTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/SimpleRepeatTemplateTests.java @@ -88,6 +88,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests { try { template.iterate(new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; throw new IllegalStateException("foo!"); @@ -115,17 +116,20 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests { final List list = new ArrayList(); final RepeatContext context = new RepeatContextSupport(null) { + @Override public void close() { super.close(); list.add("close"); } }; template.setCompletionPolicy(new CompletionPolicySupport() { + @Override public RepeatContext start(RepeatContext c) { return context; } }); template.iterate(new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; return RepeatStatus.continueIf(count < 1); @@ -148,12 +152,14 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests { final List list = new ArrayList(); final RepeatContext context = new RepeatContextSupport(null) { + @Override public void close() { super.close(); list.add("close"); } }; template.setCompletionPolicy(new CompletionPolicySupport() { + @Override public RepeatContext start(RepeatContext c) { return context; } @@ -161,6 +167,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests { try { template.iterate(new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; throw new RuntimeException("foo"); @@ -187,6 +194,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests { final List list = new ArrayList(); template.setExceptionHandler(new ExceptionHandler() { + @Override public void handleException(RepeatContext context, Throwable throwable) throws RuntimeException { list.add(throwable); throw (RuntimeException) throwable; @@ -195,6 +203,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests { try { template.iterate(new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; throw new RuntimeException("foo"); @@ -220,6 +229,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests { RepeatStatus result = template.iterate(new ItemReaderRepeatCallback(provider, processor) { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { RepeatStatus result = super.doInIteration(context); if (processor.count >= 2) { @@ -249,6 +259,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests { RepeatStatus result = template.iterate(new ItemReaderRepeatCallback(provider, processor) { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { RepeatStatus result = super.doInIteration(context); if (processor.count >= 2) { @@ -273,6 +284,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests { RepeatTemplate outer = getRepeatTemplate(); RepeatTemplate inner = getRepeatTemplate(); outer.iterate(new NestedRepeatCallback(inner, new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; assertNotNull(context); @@ -281,6 +293,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests { return RepeatStatus.FINISHED; } }) { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; assertSame(context, RepeatSynchronizationManager.getContext()); @@ -295,6 +308,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests { RepeatTemplate outer = getRepeatTemplate(); RepeatTemplate inner = getRepeatTemplate(); outer.iterate(new NestedRepeatCallback(inner, new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; assertEquals(2, count); @@ -302,6 +316,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests { return RepeatStatus.FINISHED; } }) { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; context.setCompleteOnly(); @@ -317,6 +332,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests { outer.setCompletionPolicy(new SimpleCompletionPolicy(2)); RepeatTemplate inner = getRepeatTemplate(); outer.iterate(new NestedRepeatCallback(inner, new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; assertNotNull(context); @@ -325,6 +341,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests { return RepeatStatus.FINISHED; } }) { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; assertSame(context, RepeatSynchronizationManager.getContext()); @@ -352,6 +369,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests { template.setCompletionPolicy(new SimpleCompletionPolicy(2)); try { template.iterate(new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; if (count < 2) { @@ -384,6 +402,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests { try { result = template.iterate(new ItemReaderRepeatCallback(provider, processor) { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { RepeatStatus result = super.doInIteration(context); if (processor.count >= 2) { @@ -428,6 +447,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests { class ExceptionHandlerStub implements ExceptionHandler { boolean called = false; + @Override public void handleException(RepeatContext context, Throwable throwable) throws Throwable { called = true; assertSame(exception, throwable); @@ -440,6 +460,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests { class RepeatListenerStub extends RepeatListenerSupport { boolean called = false; + @Override public void onError(RepeatContext context, Throwable throwable) { called = true; assertSame(exception, throwable); @@ -452,6 +473,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests { try { template.iterate(new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { throw new RepeatException("typically thrown by nested repeat template", exception); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/TaskExecutorRepeatTemplateAsynchronousTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/TaskExecutorRepeatTemplateAsynchronousTests.java index b195c4dd2..1547e2ca1 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/TaskExecutorRepeatTemplateAsynchronousTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/TaskExecutorRepeatTemplateAsynchronousTests.java @@ -64,6 +64,7 @@ public class TaskExecutorRepeatTemplateAsynchronousTests extends AbstractTradeBa template.setTaskExecutor(taskExecutor); try { template.iterate(new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; throw new IllegalStateException("foo!"); @@ -90,11 +91,13 @@ public class TaskExecutorRepeatTemplateAsynchronousTests extends AbstractTradeBa template.setTaskExecutor(taskExecutor); template.setExceptionHandler(new ExceptionHandler() { + @Override public void handleException(RepeatContext context, Throwable throwable) throws Throwable { count++; } }); template.iterate(new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { throw new IllegalStateException("foo!"); } @@ -112,6 +115,7 @@ public class TaskExecutorRepeatTemplateAsynchronousTests extends AbstractTradeBa RepeatTemplate inner = new RepeatTemplate(); outer.iterate(new NestedRepeatCallback(inner, new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; assertNotNull(context); @@ -120,6 +124,7 @@ public class TaskExecutorRepeatTemplateAsynchronousTests extends AbstractTradeBa return RepeatStatus.FINISHED; } }) { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { count++; assertNotNull(context); @@ -147,6 +152,7 @@ public class TaskExecutorRepeatTemplateAsynchronousTests extends AbstractTradeBa final Set threadNames = new HashSet(); final RepeatCallback callback = new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { assertNotSame(threadName, Thread.currentThread().getName()); threadNames.add(Thread.currentThread().getName()); @@ -182,6 +188,7 @@ public class TaskExecutorRepeatTemplateAsynchronousTests extends AbstractTradeBa final List items = new ArrayList(); final RepeatCallback callback = new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { assertNotSame(threadName, Thread.currentThread().getName()); Trade item = provider.read(); @@ -230,6 +237,7 @@ public class TaskExecutorRepeatTemplateAsynchronousTests extends AbstractTradeBa final Set threadNames = new HashSet(); final RepeatCallback stepCallback = new ItemReaderRepeatCallback(provider, processor) { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { assertNotSame(threadName, Thread.currentThread().getName()); threadNames.add(Thread.currentThread().getName()); @@ -242,6 +250,7 @@ public class TaskExecutorRepeatTemplateAsynchronousTests extends AbstractTradeBa } }; RepeatCallback jobCallback = new RepeatCallback() { + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { stepTemplate.iterate(stepCallback); return RepeatStatus.FINISHED; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/TaskExecutorRepeatTemplateTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/TaskExecutorRepeatTemplateTests.java index 74d14b18f..a0b58f723 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/TaskExecutorRepeatTemplateTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/TaskExecutorRepeatTemplateTests.java @@ -26,6 +26,7 @@ import org.junit.Test; */ public class TaskExecutorRepeatTemplateTests extends SimpleRepeatTemplateTests { + @Override public RepeatTemplate getRepeatTemplate() { return new TaskExecutorRepeatTemplate(); } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/ThrottleLimitResultQueueTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/ThrottleLimitResultQueueTests.java index e4e4391e4..527063a12 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/ThrottleLimitResultQueueTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/ThrottleLimitResultQueueTests.java @@ -70,6 +70,7 @@ public class ThrottleLimitResultQueueTests { public void testThrottleLimit() throws Exception { queue.expect(); new Thread(new Runnable() { + @Override public void run() { try { Thread.sleep(100L); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/Trade.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/Trade.java index 91100a690..e749868e7 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/Trade.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/Trade.java @@ -49,6 +49,7 @@ public class Trade { return quantity; } + @Override public String toString() { return "Trade: [isin=" + isin + ",quantity=" + quantity + ",price=" + price + "]"; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/ConcurrentTransactionAwareProxyTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/ConcurrentTransactionAwareProxyTests.java index 968bb4980..485b271f7 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/ConcurrentTransactionAwareProxyTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/ConcurrentTransactionAwareProxyTests.java @@ -126,6 +126,7 @@ public class ConcurrentTransactionAwareProxyTests { public void testTransactionalContains() throws Exception { final Map> map = TransactionAwareProxyFactory.createAppendOnlyTransactionalMap(); boolean result = (Boolean) new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { return map.containsKey("foo"); } @@ -139,6 +140,7 @@ public class ConcurrentTransactionAwareProxyTests { final int count = i; completionService.submit(new Callable>() { + @Override public List call() throws Exception { List list = new ArrayList(); for (int i = 0; i < innerMax; i++) { @@ -166,6 +168,7 @@ public class ConcurrentTransactionAwareProxyTests { for (int i = 0; i < outerMax; i++) { completionService.submit(new Callable>() { + @Override public List call() throws Exception { List result = new ArrayList(); for (int i = 0; i < innerMax; i++) { @@ -205,6 +208,7 @@ public class ConcurrentTransactionAwareProxyTests { final long id = j * 1000 + 123L + i; completionService.submit(new Callable>() { + @Override public List call() throws Exception { List list = new ArrayList(); for (int i = 0; i < innerMax; i++) { @@ -227,6 +231,7 @@ public class ConcurrentTransactionAwareProxyTests { private String saveInSetAndAssert(final Set set, final String value) { new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { set.add(value); return null; @@ -242,6 +247,7 @@ public class ConcurrentTransactionAwareProxyTests { private String saveInListAndAssert(final List list, final String value) { new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { list.add(value); return null; @@ -258,6 +264,7 @@ public class ConcurrentTransactionAwareProxyTests { final String value) { new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { if (!map.containsKey(id)) { map.put(id, new HashMap()); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/ResourcelessTransactionManagerTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/ResourcelessTransactionManagerTests.java index be5878d24..d9ebdbb55 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/ResourcelessTransactionManagerTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/ResourcelessTransactionManagerTests.java @@ -38,8 +38,10 @@ public class ResourcelessTransactionManagerTests { @Test public void testCommit() throws Exception { new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { + @Override public void afterCompletion(int status) { super.afterCompletion(status); txStatus = status; @@ -56,8 +58,10 @@ public class ResourcelessTransactionManagerTests { testCommit(); txStatus = -1; new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { + @Override public void afterCompletion(int status) { super.afterCompletion(status); txStatus = status; @@ -73,8 +77,10 @@ public class ResourcelessTransactionManagerTests { public void testCommitNested() throws Exception { final TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager); transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { + @Override public void afterCompletion(int status) { super.afterCompletion(status); txStatus = status; @@ -82,6 +88,7 @@ public class ResourcelessTransactionManagerTests { } }); transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { assertEquals(0, count); count++; @@ -103,8 +110,10 @@ public class ResourcelessTransactionManagerTests { txStatus = -1; final TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager); transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { + @Override public void afterCompletion(int status) { super.afterCompletion(status); txStatus = status; @@ -112,6 +121,7 @@ public class ResourcelessTransactionManagerTests { } }); transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { assertEquals(0, count); count++; @@ -130,8 +140,10 @@ public class ResourcelessTransactionManagerTests { public void testRollback() throws Exception { try { new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { + @Override public void afterCompletion(int status) { super.afterCompletion(status); txStatus = status; @@ -153,8 +165,10 @@ public class ResourcelessTransactionManagerTests { final TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager); try { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { + @Override public void afterCompletion(int status) { super.afterCompletion(status); txStatus = status; @@ -162,6 +176,7 @@ public class ResourcelessTransactionManagerTests { } }); transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { assertEquals(0, count); count++; @@ -186,8 +201,10 @@ public class ResourcelessTransactionManagerTests { final TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager); try { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { + @Override public void afterCompletion(int status) { super.afterCompletion(status); txStatus = status; @@ -195,6 +212,7 @@ public class ResourcelessTransactionManagerTests { } }); transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { assertEquals(0, count); count++; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareBufferedWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareBufferedWriterTests.java index e9db8e161..f8a2f3847 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareBufferedWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareBufferedWriterTests.java @@ -52,6 +52,7 @@ public class TransactionAwareBufferedWriterTests { fileChannel = createMock(FileChannel.class); writer = new TransactionAwareBufferedWriter(fileChannel, new Runnable() { + @Override public void run() { try { ByteBuffer bb = ByteBuffer.wrap("c".getBytes()); @@ -125,6 +126,7 @@ public class TransactionAwareBufferedWriterTests { replay(fileChannel); new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { try { writer.write("foo"); @@ -149,6 +151,7 @@ public class TransactionAwareBufferedWriterTests { replay(fileChannel); new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { try { writer.write("foo"); @@ -173,6 +176,7 @@ public class TransactionAwareBufferedWriterTests { replay(fileChannel); new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { try { writer.write("foo"); @@ -194,6 +198,7 @@ public class TransactionAwareBufferedWriterTests { public void testWriteWithRollback() throws Exception { try { new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { try { writer.write("foo"); @@ -224,12 +229,14 @@ public class TransactionAwareBufferedWriterTests { @SuppressWarnings({"unchecked", "rawtypes"}) public void testExceptionOnFlush() throws Exception { writer = new TransactionAwareBufferedWriter(fileChannel, new Runnable() { + @Override public void run() { } }); try { new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { try { writer.write("foo"); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareListFactoryTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareListFactoryTests.java index 0e76d1e78..f65562b6a 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareListFactoryTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareListFactoryTests.java @@ -66,6 +66,7 @@ public class TransactionAwareListFactoryTests { @Test public void testTransactionalAdd() throws Exception { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { testAdd(); return null; @@ -77,6 +78,7 @@ public class TransactionAwareListFactoryTests { @Test public void testTransactionalRemove() throws Exception { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { testRemove(); return null; @@ -88,6 +90,7 @@ public class TransactionAwareListFactoryTests { @Test public void testTransactionalClear() throws Exception { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { testClear(); return null; @@ -100,6 +103,7 @@ public class TransactionAwareListFactoryTests { public void testTransactionalAddWithRollback() throws Exception { try { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { testAdd(); throw new RuntimeException("Rollback!"); @@ -117,6 +121,7 @@ public class TransactionAwareListFactoryTests { public void testTransactionalRemoveWithRollback() throws Exception { try { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { testRemove(); throw new RuntimeException("Rollback!"); @@ -134,6 +139,7 @@ public class TransactionAwareListFactoryTests { public void testTransactionalClearWithRollback() throws Exception { try { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { testClear(); throw new RuntimeException("Rollback!"); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareMapFactoryTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareMapFactoryTests.java index d5f73d953..789953de4 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareMapFactoryTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareMapFactoryTests.java @@ -31,6 +31,7 @@ public class TransactionAwareMapFactoryTests extends TestCase { Map map; + @Override protected void setUp() throws Exception { Map seed = new HashMap(); seed.put("foo", "oof"); @@ -72,6 +73,7 @@ public class TransactionAwareMapFactoryTests extends TestCase { public void testTransactionalAdd() throws Exception { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { testAdd(); return null; @@ -82,6 +84,7 @@ public class TransactionAwareMapFactoryTests extends TestCase { public void testTransactionalEmpty() throws Exception { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { testEmpty(); return null; @@ -92,6 +95,7 @@ public class TransactionAwareMapFactoryTests extends TestCase { public void testTransactionalValues() throws Exception { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { testValues(); return null; @@ -102,6 +106,7 @@ public class TransactionAwareMapFactoryTests extends TestCase { public void testTransactionalRemove() throws Exception { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { testRemove(); return null; @@ -112,6 +117,7 @@ public class TransactionAwareMapFactoryTests extends TestCase { public void testTransactionalClear() throws Exception { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { testClear(); return null; @@ -123,6 +129,7 @@ public class TransactionAwareMapFactoryTests extends TestCase { public void testTransactionalAddWithRollback() throws Exception { try { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { testAdd(); throw new RuntimeException("Rollback!"); @@ -139,6 +146,7 @@ public class TransactionAwareMapFactoryTests extends TestCase { public void testTransactionalRemoveWithRollback() throws Exception { try { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { testRemove(); throw new RuntimeException("Rollback!"); @@ -155,6 +163,7 @@ public class TransactionAwareMapFactoryTests extends TestCase { public void testTransactionalClearWithRollback() throws Exception { try { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { testClear(); throw new RuntimeException("Rollback!"); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareSetFactoryTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareSetFactoryTests.java index 0ce9f9658..515a332fd 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareSetFactoryTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/TransactionAwareSetFactoryTests.java @@ -67,6 +67,7 @@ public class TransactionAwareSetFactoryTests { @Test public void testTransactionalAdd() throws Exception { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { testAdd(); return null; @@ -78,6 +79,7 @@ public class TransactionAwareSetFactoryTests { @Test public void testTransactionalRemove() throws Exception { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { testRemove(); return null; @@ -89,6 +91,7 @@ public class TransactionAwareSetFactoryTests { @Test public void testTransactionalClear() throws Exception { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { testClear(); return null; @@ -101,6 +104,7 @@ public class TransactionAwareSetFactoryTests { public void testTransactionalAddWithRollback() throws Exception { try { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { testAdd(); throw new RuntimeException("Rollback!"); @@ -118,6 +122,7 @@ public class TransactionAwareSetFactoryTests { public void testTransactionalRemoveWithRollback() throws Exception { try { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { testRemove(); throw new RuntimeException("Rollback!"); @@ -135,6 +140,7 @@ public class TransactionAwareSetFactoryTests { public void testTransactionalClearWithRollback() throws Exception { try { transactionTemplate.execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { testClear(); throw new RuntimeException("Rollback!"); diff --git a/spring-batch-infrastructure/src/test/java/test/jdbc/datasource/DataSourceInitializer.java b/spring-batch-infrastructure/src/test/java/test/jdbc/datasource/DataSourceInitializer.java index 0f34deaaa..a13153ba6 100644 --- a/spring-batch-infrastructure/src/test/java/test/jdbc/datasource/DataSourceInitializer.java +++ b/spring-batch-infrastructure/src/test/java/test/jdbc/datasource/DataSourceInitializer.java @@ -80,12 +80,14 @@ public class DataSourceInitializer implements InitializingBean, DisposableBean { * @throws Throwable * @see java.lang.Object#finalize() */ + @Override protected void finalize() throws Throwable { logger.debug("finalize called for " + dataSource); super.finalize(); initialized = false; } + @Override public void destroy() { logger.info("destroy called for " + dataSource); doDestroy(); @@ -109,6 +111,7 @@ public class DataSourceInitializer implements InitializingBean, DisposableBean { } } + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(dataSource); initialize(); @@ -135,6 +138,7 @@ public class DataSourceInitializer implements InitializingBean, DisposableBean { TransactionTemplate transactionTemplate = new TransactionTemplate(new DataSourceTransactionManager(dataSource)); transactionTemplate.execute(new TransactionCallback() { + @Override @SuppressWarnings("unchecked") public Object doInTransaction(TransactionStatus status) { String[] scripts; diff --git a/spring-batch-infrastructure/src/test/java/test/jdbc/datasource/DerbyDataSourceFactoryBean.java b/spring-batch-infrastructure/src/test/java/test/jdbc/datasource/DerbyDataSourceFactoryBean.java index c9b6e0ab4..b9cfd1a3e 100644 --- a/spring-batch-infrastructure/src/test/java/test/jdbc/datasource/DerbyDataSourceFactoryBean.java +++ b/spring-batch-infrastructure/src/test/java/test/jdbc/datasource/DerbyDataSourceFactoryBean.java @@ -19,6 +19,7 @@ public class DerbyDataSourceFactoryBean extends AbstractFactoryBean { this.dataDirectory = dataDirectory; } + @Override protected Object createInstance() throws Exception { File directory = new File(dataDirectory); System.setProperty("derby.system.home", directory.getCanonicalPath()); @@ -34,6 +35,7 @@ public class DerbyDataSourceFactoryBean extends AbstractFactoryBean { return ds; } + @Override public Class getObjectType() { return DataSource.class; } diff --git a/spring-batch-infrastructure/src/test/java/test/jdbc/datasource/DerbyShutdownBean.java b/spring-batch-infrastructure/src/test/java/test/jdbc/datasource/DerbyShutdownBean.java index eb5955074..0c551f820 100644 --- a/spring-batch-infrastructure/src/test/java/test/jdbc/datasource/DerbyShutdownBean.java +++ b/spring-batch-infrastructure/src/test/java/test/jdbc/datasource/DerbyShutdownBean.java @@ -22,6 +22,7 @@ public class DerbyShutdownBean implements DisposableBean { this.dataSource = dataSource; } + @Override public void destroy() throws Exception { logger.info("Attempting Derby database shut down on: " + dataSource); if (!isShutdown && dataSource != null diff --git a/spring-batch-test/pom.xml b/spring-batch-test/pom.xml index 025dc172a..0a4f06922 100755 --- a/spring-batch-test/pom.xml +++ b/spring-batch-test/pom.xml @@ -11,20 +11,6 @@ 2.2.0.BUILD-SNAPSHOT ../spring-batch-parent - - - tiger - - 1.5 - - - - stax - stax - - - - org.springframework.batch diff --git a/spring-batch-test/src/main/java/org/springframework/batch/test/AbstractJobTests.java b/spring-batch-test/src/main/java/org/springframework/batch/test/AbstractJobTests.java index 35b2d5a26..00dbb07a8 100644 --- a/spring-batch-test/src/main/java/org/springframework/batch/test/AbstractJobTests.java +++ b/spring-batch-test/src/main/java/org/springframework/batch/test/AbstractJobTests.java @@ -88,6 +88,7 @@ public abstract class AbstractJobTests implements ApplicationContextAware { /** * {@inheritDoc} */ + @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } diff --git a/spring-batch-test/src/main/java/org/springframework/batch/test/DataSourceInitializer.java b/spring-batch-test/src/main/java/org/springframework/batch/test/DataSourceInitializer.java index 27138b43c..0f4ddfd3c 100755 --- a/spring-batch-test/src/main/java/org/springframework/batch/test/DataSourceInitializer.java +++ b/spring-batch-test/src/main/java/org/springframework/batch/test/DataSourceInitializer.java @@ -76,6 +76,7 @@ public class DataSourceInitializer implements InitializingBean, DisposableBean { DataSourceInitializer.class.getSimpleName() + "-context.xml")); } + @Override public void destroy() { if (destroyScripts==null) return; for (int i = 0; i < destroyScripts.length; i++) { @@ -94,6 +95,7 @@ public class DataSourceInitializer implements InitializingBean, DisposableBean { } } + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(dataSource); initialize(); @@ -118,6 +120,7 @@ public class DataSourceInitializer implements InitializingBean, DisposableBean { TransactionTemplate transactionTemplate = new TransactionTemplate(new DataSourceTransactionManager(dataSource)); transactionTemplate.execute(new TransactionCallback() { + @Override @SuppressWarnings("unchecked") public Object doInTransaction(TransactionStatus status) { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); diff --git a/spring-batch-test/src/main/java/org/springframework/batch/test/JobRepositoryTestUtils.java b/spring-batch-test/src/main/java/org/springframework/batch/test/JobRepositoryTestUtils.java index 0a50af87b..49d3dd0b5 100644 --- a/spring-batch-test/src/main/java/org/springframework/batch/test/JobRepositoryTestUtils.java +++ b/spring-batch-test/src/main/java/org/springframework/batch/test/JobRepositoryTestUtils.java @@ -58,6 +58,7 @@ public class JobRepositoryTestUtils extends AbstractJdbcBatchMetadataDao impleme Long count = 0L; + @Override public JobParameters getNext(JobParameters parameters) { return new JobParameters(Collections.singletonMap("count", new JobParameter(count++))); } @@ -69,6 +70,7 @@ public class JobRepositoryTestUtils extends AbstractJdbcBatchMetadataDao impleme /** * @see InitializingBean#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(jobRepository, "JobRepository must be set"); Assert.notNull(jdbcTemplate, "DataSource must be set"); @@ -165,6 +167,7 @@ public class JobRepositoryTestUtils extends AbstractJdbcBatchMetadataDao impleme List stepExecutionIds = jdbcTemplate.query( getQuery("select STEP_EXECUTION_ID from %PREFIX%STEP_EXECUTION where JOB_EXECUTION_ID=?"), new ParameterizedRowMapper() { + @Override public Long mapRow(ResultSet rs, int rowNum) throws SQLException { return rs.getLong(1); } diff --git a/spring-batch-test/src/main/java/org/springframework/batch/test/StepRunner.java b/spring-batch-test/src/main/java/org/springframework/batch/test/StepRunner.java index b8a5cbca8..c5b87685b 100755 --- a/spring-batch-test/src/main/java/org/springframework/batch/test/StepRunner.java +++ b/spring-batch-test/src/main/java/org/springframework/batch/test/StepRunner.java @@ -143,6 +143,7 @@ public class StepRunner { // if (jobExecutionContext != null && !jobExecutionContext.isEmpty()) { job.setJobExecutionListeners(new JobExecutionListener[] { new JobExecutionListenerSupport() { + @Override public void beforeJob(JobExecution jobExecution) { ExecutionContext jobContext = jobExecution.getExecutionContext(); for (Map.Entry entry : jobExecutionContext.entrySet()) { diff --git a/spring-batch-test/src/main/java/org/springframework/batch/test/StepScopeTestExecutionListener.java b/spring-batch-test/src/main/java/org/springframework/batch/test/StepScopeTestExecutionListener.java index ec82fb980..c0783f49a 100644 --- a/spring-batch-test/src/main/java/org/springframework/batch/test/StepScopeTestExecutionListener.java +++ b/spring-batch-test/src/main/java/org/springframework/batch/test/StepScopeTestExecutionListener.java @@ -74,6 +74,7 @@ public class StepScopeTestExecutionListener implements TestExecutionListener { * @throws Exception if there is a problem * @see TestExecutionListener#prepareTestInstance(TestContext) */ + @Override public void prepareTestInstance(TestContext testContext) throws Exception { StepExecution stepExecution = getStepExecution(testContext); if (stepExecution != null) { @@ -86,6 +87,7 @@ public class StepScopeTestExecutionListener implements TestExecutionListener { * @throws Exception if there is a problem * @see TestExecutionListener#beforeTestMethod(TestContext) */ + @Override public void beforeTestMethod(org.springframework.test.context.TestContext testContext) throws Exception { if (testContext.hasAttribute(STEP_EXECUTION)) { StepExecution stepExecution = (StepExecution) testContext.getAttribute(STEP_EXECUTION); @@ -99,6 +101,7 @@ public class StepScopeTestExecutionListener implements TestExecutionListener { * @throws Exception if there is a problem * @see TestExecutionListener#afterTestMethod(TestContext) */ + @Override public void afterTestMethod(TestContext testContext) throws Exception { if (testContext.hasAttribute(STEP_EXECUTION)) { StepSynchronizationManager.close(); @@ -108,12 +111,14 @@ public class StepScopeTestExecutionListener implements TestExecutionListener { /* * Support for Spring 3.0 (empty). */ + @Override public void afterTestClass(TestContext testContext) throws Exception { } /* * Support for Spring 3.0 (empty). */ + @Override public void beforeTestClass(TestContext testContext) throws Exception { } @@ -168,6 +173,7 @@ public class StepScopeTestExecutionListener implements TestExecutionListener { return result == null ? null : result.getName(); } + @Override public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { Class type = method.getReturnType(); if (preferredType.isAssignableFrom(type)) { diff --git a/spring-batch-test/src/test/java/org/springframework/batch/test/JobRepositoryTestUtilsTests.java b/spring-batch-test/src/test/java/org/springframework/batch/test/JobRepositoryTestUtilsTests.java index 42b403373..0da88c6ad 100644 --- a/spring-batch-test/src/test/java/org/springframework/batch/test/JobRepositoryTestUtilsTests.java +++ b/spring-batch-test/src/test/java/org/springframework/batch/test/JobRepositoryTestUtilsTests.java @@ -134,6 +134,7 @@ public class JobRepositoryTestUtilsTests { public void testCreateJobExecutionsWithIncrementer() throws Exception { utils = new JobRepositoryTestUtils(jobRepository, dataSource); utils.setJobParametersIncrementer(new JobParametersIncrementer() { + @Override public JobParameters getNext(JobParameters parameters) { return new JobParametersBuilder().addString("foo","bar").toJobParameters(); } diff --git a/spring-batch-test/src/test/java/org/springframework/batch/test/SampleStepTests.java b/spring-batch-test/src/test/java/org/springframework/batch/test/SampleStepTests.java index 171788e85..daca86a87 100755 --- a/spring-batch-test/src/test/java/org/springframework/batch/test/SampleStepTests.java +++ b/spring-batch-test/src/test/java/org/springframework/batch/test/SampleStepTests.java @@ -53,6 +53,7 @@ public class SampleStepTests implements ApplicationContextAware { assertEquals(2, jdbcTemplate.queryForInt("SELECT ID from TESTS where NAME = 'SampleTasklet2'")); } + @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.context = applicationContext; } diff --git a/spring-batch-test/src/test/java/org/springframework/batch/test/jmx/JobExecutionNotificationPublisher.java b/spring-batch-test/src/test/java/org/springframework/batch/test/jmx/JobExecutionNotificationPublisher.java index 1fe1d04b5..be5386702 100755 --- a/spring-batch-test/src/test/java/org/springframework/batch/test/jmx/JobExecutionNotificationPublisher.java +++ b/spring-batch-test/src/test/java/org/springframework/batch/test/jmx/JobExecutionNotificationPublisher.java @@ -44,6 +44,7 @@ public class JobExecutionNotificationPublisher implements ApplicationListener, N * * @see org.springframework.jmx.export.notification.NotificationPublisherAware#setNotificationPublisher(org.springframework.jmx.export.notification.NotificationPublisher) */ + @Override public void setNotificationPublisher(NotificationPublisher notificationPublisher) { this.notificationPublisher = notificationPublisher; } @@ -55,6 +56,7 @@ public class JobExecutionNotificationPublisher implements ApplicationListener, N * * @see ApplicationListener#onApplicationEvent(ApplicationEvent) */ + @Override public void onApplicationEvent(ApplicationEvent applicationEvent) { if (applicationEvent instanceof SimpleMessageApplicationEvent) { String message = applicationEvent.toString(); diff --git a/spring-batch-test/src/test/java/org/springframework/batch/test/jmx/SimpleMessageApplicationEvent.java b/spring-batch-test/src/test/java/org/springframework/batch/test/jmx/SimpleMessageApplicationEvent.java index a5a239368..e62f2f35e 100755 --- a/spring-batch-test/src/test/java/org/springframework/batch/test/jmx/SimpleMessageApplicationEvent.java +++ b/spring-batch-test/src/test/java/org/springframework/batch/test/jmx/SimpleMessageApplicationEvent.java @@ -19,8 +19,9 @@ public class SimpleMessageApplicationEvent extends ApplicationEvent { /* (non-Javadoc) * @see java.util.EventObject#toString() */ + @Override public String toString() { return "message=["+message+"], " + super.toString(); } -} \ No newline at end of file +} diff --git a/spring-batch-test/src/test/java/org/springframework/batch/test/jmx/StepExecutionApplicationEventAdvice.java b/spring-batch-test/src/test/java/org/springframework/batch/test/jmx/StepExecutionApplicationEventAdvice.java index 815552b00..727491f6e 100755 --- a/spring-batch-test/src/test/java/org/springframework/batch/test/jmx/StepExecutionApplicationEventAdvice.java +++ b/spring-batch-test/src/test/java/org/springframework/batch/test/jmx/StepExecutionApplicationEventAdvice.java @@ -36,6 +36,7 @@ public class StepExecutionApplicationEventAdvice implements ApplicationEventPubl * (non-Javadoc) * @see org.springframework.context.ApplicationEventPublisherAware#setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) */ + @Override public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) { this.applicationEventPublisher = applicationEventPublisher; } diff --git a/spring-batch-test/src/test/java/org/springframework/batch/test/sample/LoggingTasklet.java b/spring-batch-test/src/test/java/org/springframework/batch/test/sample/LoggingTasklet.java index 1a94fcc26..07f9256b8 100644 --- a/spring-batch-test/src/test/java/org/springframework/batch/test/sample/LoggingTasklet.java +++ b/spring-batch-test/src/test/java/org/springframework/batch/test/sample/LoggingTasklet.java @@ -17,6 +17,7 @@ public class LoggingTasklet implements Tasklet { this.id = id; } + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { logger.info("tasklet executing: id=" + id); return RepeatStatus.FINISHED; diff --git a/spring-batch-test/src/test/java/org/springframework/batch/test/sample/SampleTasklet.java b/spring-batch-test/src/test/java/org/springframework/batch/test/sample/SampleTasklet.java index 9acd41268..e9a75575a 100755 --- a/spring-batch-test/src/test/java/org/springframework/batch/test/sample/SampleTasklet.java +++ b/spring-batch-test/src/test/java/org/springframework/batch/test/sample/SampleTasklet.java @@ -26,6 +26,7 @@ public class SampleTasklet implements Tasklet { this.id = id; } + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { this.jdbcTemplate.update("insert into TESTS(ID, NAME) values (?, 'SampleTasklet" + id + "')", id);