diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java
index 4e785956c..edf7aa2bf 100644
--- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java
+++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java
@@ -58,6 +58,13 @@ public class SimpleJobRepository implements JobRepository {
private StepDao stepDao;
+ /**
+ * Provide default constructor with low visibility in case user wants to use
+ * use aop:proxy-target-class="true" for transaction interceptor.
+ */
+ SimpleJobRepository() {
+ }
+
public SimpleJobRepository(JobDao jobDao, StepDao stepDao) {
super();
this.jobDao = jobDao;
@@ -67,19 +74,18 @@ public class SimpleJobRepository implements JobRepository {
/**
*
* Create a (@link {@link JobExecution}) based on the passed in
- * {@link JobIdentifier} and {@link Job}. However, unique
- * identification of a job can only come from the database, and therefore
- * must come from JobDao by either creating a new job or finding an existing
- * one, which will ensure that the id of the job is populated with the
- * correct value.
+ * {@link JobIdentifier} and {@link Job}. However, unique identification of
+ * a job can only come from the database, and therefore must come from
+ * JobDao by either creating a new job or finding an existing one, which
+ * will ensure that the id of the job is populated with the correct value.
*
*
*
* There are two ways in which the method determines if a job should be
* created or an existing one should be returned. The first is
- * restartability. The {@link Job} restartable property will be
- * checked first. If it is not false, a new job will be created, regardless
- * of whether or not one exists. If it is true, the {@link JobDao} will be
+ * restartability. The {@link Job} restartable property will be checked
+ * first. If it is not false, a new job will be created, regardless of
+ * whether or not one exists. If it is true, the {@link JobDao} will be
* checked to determine if the job already exists, if it does, it's steps
* will be populated (there must be at least 1) and a new
* {@link JobExecution} will be returned. If no job is found, a new one will
@@ -95,11 +101,11 @@ public class SimpleJobRepository implements JobRepository {
*
What happens then depends on how many existing job instances we
* find:
*
- * - If there are none, or the {@link Job} is marked
- * restartable, then we create a new {@link JobInstance}
- * - If there is more than one and the {@link Job} is not
- * marked as restartable, it is an error. This could be caused by a job
- * whose restartable flag has changed to be more strict (true not false)
+ *
- If there are none, or the {@link Job} is marked restartable, then we
+ * create a new {@link JobInstance}
+ * - If there is more than one and the {@link Job} is not marked as
+ * restartable, it is an error. This could be caused by a job whose
+ * restartable flag has changed to be more strict (true not false)
* after it has been executed at least once.
* - If there is precisely one existing {@link JobInstance} then we check
* the {@link JobExecution} instances for that job, and if any of them tells
@@ -121,22 +127,18 @@ public class SimpleJobRepository implements JobRepository {
*
* @see JobRepository#createJobExecution(Job, JobInstanceProperties)
*
- * @throws BatchRestartException
- * if more than one JobInstance if found or if
- * JobInstance.getJobExecutionCount() is greater than
- * Job.getStartLimit()
- * @throws JobExecutionAlreadyRunningException
- * if a job execution is found for the given
- * {@link JobIdentifier} that is already running
+ * @throws BatchRestartException if more than one JobInstance if found or if
+ * JobInstance.getJobExecutionCount() is greater than Job.getStartLimit()
+ * @throws JobExecutionAlreadyRunningException if a job execution is found
+ * for the given {@link JobIdentifier} that is already running
*
*/
- public JobExecution createJobExecution(Job job,
- JobInstanceProperties jobInstanceProperties)
+ public JobExecution createJobExecution(Job job, JobInstanceProperties jobInstanceProperties)
throws JobExecutionAlreadyRunningException {
Assert.notNull(job, "Job must not be null.");
Assert.notNull(jobInstanceProperties, "JobInstanceProperties must not be null.");
-
+
List jobs = new ArrayList();
JobInstance jobInstance;
@@ -158,30 +160,28 @@ public class SimpleJobRepository implements JobRepository {
if (jobs.size() == 1) {
// One job was found
jobInstance = (JobInstance) jobs.get(0);
- jobInstance.setStepInstances(findStepInstances(job.getSteps(),
- jobInstance));
+ jobInstance.setStepInstances(findStepInstances(job.getSteps(), jobInstance));
jobInstance.setJobExecutionCount(jobDao.getJobExecutionCount(jobInstance.getId()));
if (jobInstance.getJobExecutionCount() > job.getStartLimit()) {
- throw new BatchRestartException(
- "Restart Max exceeded for Job: " + jobInstance.toString());
+ throw new BatchRestartException("Restart Max exceeded for Job: " + jobInstance.toString());
}
List executions = jobDao.findJobExecutions(jobInstance);
for (Iterator iterator = executions.iterator(); iterator.hasNext();) {
JobExecution execution = (JobExecution) iterator.next();
if (execution.isRunning()) {
- throw new JobExecutionAlreadyRunningException(
- "A job execution for this job is already running: "
- + jobInstance);
+ throw new JobExecutionAlreadyRunningException("A job execution for this job is already running: "
+ + jobInstance);
}
}
- } else if (jobs.size() == 0) {
+ }
+ else if (jobs.size() == 0) {
// no job found, create one
jobInstance = createJobInstance(job, jobInstanceProperties);
- } else {
+ }
+ else {
// More than one job found, throw exception
- throw new BatchRestartException(
- "Error restarting job, more than one JobInstance found for: "
- + job.toString());
+ throw new BatchRestartException("Error restarting job, more than one JobInstance found for: "
+ + job.toString());
}
return generateJobExecution(jobInstance);
@@ -204,21 +204,19 @@ public class SimpleJobRepository implements JobRepository {
* a new JobExecution is created, if one is found, the current row is
* updated.
*
- * @param JobExecution
- * to be stored.
- * @throws IllegalArgumentException
- * if jobExecution is null.
+ * @param JobExecution to be stored.
+ * @throws IllegalArgumentException if jobExecution is null.
*/
public void saveOrUpdate(JobExecution jobExecution) {
Assert.notNull(jobExecution, "JobExecution cannot be null.");
- Assert.notNull(jobExecution.getJobId(),
- "JobExecution must have a Job ID set.");
+ Assert.notNull(jobExecution.getJobId(), "JobExecution must have a Job ID set.");
if (jobExecution.getId() == null) {
// existing instance
jobDao.save(jobExecution);
- } else {
+ }
+ else {
// new execution
jobDao.update(jobExecution);
}
@@ -229,19 +227,14 @@ public class SimpleJobRepository implements JobRepository {
* findOrCreateJob method, otherwise it is likely that the id is incorrect
* or non-existant.
*
- * @param job
- * to be updated.
- * @throws IllegalArgumentException
- * if Job or it's Id is null.
+ * @param job to be updated.
+ * @throws IllegalArgumentException if Job or it's Id is null.
*/
public void update(JobInstance job) {
Assert.notNull(job, "Job cannot be null.");
- Assert
- .notNull(
- job.getId(),
- "Job cannot be updated if it's ID is null. It must be obtained"
- + "from SimpleJobRepository.findOrCreateJob to be considered valid.");
+ Assert.notNull(job.getId(), "Job cannot be updated if it's ID is null. It must be obtained"
+ + "from SimpleJobRepository.findOrCreateJob to be considered valid.");
jobDao.update(job);
}
@@ -252,21 +245,19 @@ public class SimpleJobRepository implements JobRepository {
* noted that assigning an ID randomly will likely cause an exception
* depending on the StepDao implementation.
*
- * @param StepExecution
- * to be saved.
- * @throws IllegalArgumentException
- * if stepExecution is null.
+ * @param StepExecution to be saved.
+ * @throws IllegalArgumentException if stepExecution is null.
*/
public void saveOrUpdate(StepExecution stepExecution) {
Assert.notNull(stepExecution, "StepExecution cannot be null.");
- Assert.notNull(stepExecution.getStepId(),
- "StepExecution's Step Id cannot be null.");
+ Assert.notNull(stepExecution.getStepId(), "StepExecution's Step Id cannot be null.");
if (stepExecution.getId() == null) {
// new execution, obtain id and insert
stepDao.save(stepExecution);
- } else {
+ }
+ else {
// existing execution, update
stepDao.update(stepExecution);
}
@@ -275,17 +266,14 @@ public class SimpleJobRepository implements JobRepository {
/**
* Update the given step.
*
- * @param StepInstance
- * to be updated.
- * @throws IllegalArgumentException
- * if step or it's id is null.
+ * @param StepInstance to be updated.
+ * @throws IllegalArgumentException if step or it's id is null.
*/
public void update(StepInstance step) {
Assert.notNull(step, "Step cannot be null.");
- Assert.notNull(step.getId(),
- "Step cannot be updated if it's ID is null. It must be obtained"
- + "from SimpleJobRepository.findOrCreateJob to be considered valid.");
+ Assert.notNull(step.getId(), "Step cannot be updated if it's ID is null. It must be obtained"
+ + "from SimpleJobRepository.findOrCreateJob to be considered valid.");
stepDao.update(step);
@@ -312,11 +300,9 @@ public class SimpleJobRepository implements JobRepository {
Iterator i = steps.iterator();
while (i.hasNext()) {
Step step = (Step) i.next();
- StepInstance stepInstance = stepDao.createStep(job, step
- .getName());
+ StepInstance stepInstance = stepDao.createStep(job, step.getName());
// Ensure valid restart data is being returned.
- if (stepInstance.getRestartData() == null
- || stepInstance.getRestartData().getProperties() == null) {
+ if (stepInstance.getRestartData() == null || stepInstance.getRestartData().getProperties() == null) {
stepInstance.setRestartData(new GenericRestartData(new Properties()));
}
stepInstances.add(stepInstance);
@@ -334,18 +320,13 @@ public class SimpleJobRepository implements JobRepository {
while (i.hasNext()) {
Step stepConfiguration = (Step) i.next();
- StepInstance step = stepDao.findStep(job, stepConfiguration
- .getName());
+ StepInstance step = stepDao.findStep(job, stepConfiguration.getName());
if (step != null) {
- step.setStepExecutionCount(stepDao.getStepExecutionCount(step
- .getId()));
+ step.setStepExecutionCount(stepDao.getStepExecutionCount(step.getId()));
// Ensure valid restart data is being returned.
- if (step.getRestartData() == null
- || step.getRestartData().getProperties() == null) {
- step
- .setRestartData(new GenericRestartData(
- new Properties()));
+ if (step.getRestartData() == null || step.getRestartData().getProperties() == null) {
+ step.setRestartData(new GenericRestartData(new Properties()));
}
stepInstances.add(step);
}
diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/DefaultFlatFileItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/DefaultFlatFileItemReader.java
index 94e662dc4..d493bac9a 100644
--- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/DefaultFlatFileItemReader.java
+++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/DefaultFlatFileItemReader.java
@@ -44,6 +44,7 @@ import org.springframework.transaction.support.TransactionSynchronizationAdapter
*/
public class DefaultFlatFileItemReader extends SimpleFlatFileItemReader implements Skippable, Restartable,
StatisticsProvider {
+
private static Log log = LogFactory.getLog(DefaultFlatFileItemReader.class);
public static final String READ_STATISTICS_NAME = "lines.read.count";
diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/SimpleFlatFileItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/SimpleFlatFileItemReader.java
index b79912285..3d68c92b2 100644
--- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/SimpleFlatFileItemReader.java
+++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/SimpleFlatFileItemReader.java
@@ -18,6 +18,8 @@ package org.springframework.batch.io.file;
import java.io.IOException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.springframework.batch.io.exception.FlatFileParsingException;
import org.springframework.batch.io.file.mapping.DefaultFieldSet;
import org.springframework.batch.io.file.mapping.FieldSetMapper;
@@ -55,6 +57,8 @@ import org.springframework.util.Assert;
public class SimpleFlatFileItemReader extends AbstractItemReader implements ItemReader,
InitializingBean, DisposableBean {
+ private static Log log = LogFactory.getLog(SimpleFlatFileItemReader.class);
+
// default encoding for input files - set to ISO-8859-1
public static final String DEFAULT_CHARSET = "ISO-8859-1";
@@ -136,6 +140,8 @@ public class SimpleFlatFileItemReader extends AbstractItemReader implements Item
Assert.state(resource.exists(), "Resource must exist: [" + resource
+ "]");
+ log.debug("Opening flat file for reading: "+resource);
+
if (this.reader == null) {
ResourceLineReader reader = new ResourceLineReader(resource, encoding);
if (recordSeparatorPolicy != null) {
@@ -172,6 +178,7 @@ public class SimpleFlatFileItemReader extends AbstractItemReader implements Item
public void close() {
try {
if (reader != null) {
+ log.debug("Closing flat file for reading: "+resource);
reader.close();
}
} finally {
diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/separator/ResourceLineReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/separator/ResourceLineReader.java
index afc31ed32..2fc61a725 100644
--- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/separator/ResourceLineReader.java
+++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/file/separator/ResourceLineReader.java
@@ -133,7 +133,6 @@ public class ResourceLineReader extends AbstractItemReader implements LineReader
if (line != null) {
while (line != null && !recordSeparatorPolicy.isEndOfRecord(record)) {
record = recordSeparatorPolicy.preProcess(record) + (line = readLine());
- // record = new StringBuilder(recordSeparatorPolicy.preProcess(record)).append(line = readLine()).toString();
}
}
return recordSeparatorPolicy.postProcess(record);
diff --git a/spring-batch-samples/.project b/spring-batch-samples/.project
index eda96ec30..5b9fc2e46 100644
--- a/spring-batch-samples/.project
+++ b/spring-batch-samples/.project
@@ -1,32 +1,32 @@
-
-
- spring-batch-samples
- Example batch jobs using Spring Batch Core and Execution.
-
- spring-batch-infrastructure
- spring-batch-core
- spring-batch-execution
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.springframework.ide.eclipse.core.springbuilder
-
-
-
-
- org.devzuz.q.maven.jdt.core.mavenIncrementalBuilder
-
-
-
-
-
- org.springframework.ide.eclipse.core.springnature
- org.eclipse.jdt.core.javanature
- org.devzuz.q.maven.jdt.core.mavenNature
-
-
+
+
+ spring-batch-samples
+ Example batch jobs using Spring Batch Core and Execution.
+
+ spring-batch-infrastructure
+ spring-batch-core
+ spring-batch-execution
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.springframework.ide.eclipse.core.springbuilder
+
+
+
+
+ org.devzuz.q.maven.jdt.core.mavenIncrementalBuilder
+
+
+
+
+
+ org.springframework.ide.eclipse.core.springnature
+ org.eclipse.jdt.core.javanature
+ org.devzuz.q.maven.jdt.core.mavenNature
+
+
diff --git a/spring-batch-samples/.settings/org.eclipse.jdt.core.prefs b/spring-batch-samples/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 92d8d451e..000000000
--- a/spring-batch-samples/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,5 +0,0 @@
-#Mon Dec 10 14:44:37 EST 2007
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.source=1.4
-org.eclipse.jdt.core.compiler.compliance=1.4
diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/advice/ProcessorLogAdvice.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/advice/ProcessorLogAdvice.java
index 9c3c57e28..42f249c5f 100644
--- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/advice/ProcessorLogAdvice.java
+++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/advice/ProcessorLogAdvice.java
@@ -38,11 +38,15 @@ public class ProcessorLogAdvice {
Object[] args = pjp.getArgs();
StringBuffer output = new StringBuffer();
+ output.append(pjp.getTarget().getClass().getName()+": ");
+ output.append(pjp.toShortString()+": ");
+
for(int i = 0; i < args.length; i++){
output.append(args[i] + " ");
}
- log.info("Processed: " + output.toString());
+
+ log.info("Basic: " + output.toString());
}
public void doStronglyTypedLogging(Object item){
diff --git a/spring-batch-samples/src/main/resources/jobs/parallelJob.xml b/spring-batch-samples/src/main/resources/jobs/parallelJob.xml
index 77b7ed6ff..c58d80c08 100644
--- a/spring-batch-samples/src/main/resources/jobs/parallelJob.xml
+++ b/spring-batch-samples/src/main/resources/jobs/parallelJob.xml
@@ -12,7 +12,7 @@
-
+
diff --git a/spring-batch-samples/src/main/resources/log4j.properties b/spring-batch-samples/src/main/resources/log4j.properties
index 8b7608fac..03dcc339a 100644
--- a/spring-batch-samples/src/main/resources/log4j.properties
+++ b/spring-batch-samples/src/main/resources/log4j.properties
@@ -29,5 +29,6 @@ log4j.logger.org.springframework.batch.sample=info
#log4j.logger.org.springframework.orm=debug
### debug your specific package or classes with the following example
+log4j.logger.org.springframework.batch.io=debug
log4j.logger.org.springframework.batch.sample.module.OrderDataProvider=debug
log4j.logger.org.springframework.batch.container.common.module.process.support.DefaultXmlDataProvider=debug
diff --git a/spring-batch-samples/src/main/resources/simple-container-definition.xml b/spring-batch-samples/src/main/resources/simple-container-definition.xml
index cdfa7387f..c08163f88 100644
--- a/spring-batch-samples/src/main/resources/simple-container-definition.xml
+++ b/spring-batch-samples/src/main/resources/simple-container-definition.xml
@@ -5,9 +5,9 @@
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
+ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
@@ -160,6 +160,10 @@
pointcut="execution( * org.springframework.batch.item.ItemProcessor+.process(Object)) and args(item)"
method="doStronglyTypedLogging" />
+
+