OPEN - issue BATCH-324: Step as factory for StepExecutor
http://jira.springframework.org/browse/BATCH-324 Substantial re-org of core domain packages to align concerns
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2008 the original author 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.domain;
|
||||
|
||||
/**
|
||||
* Checked exception indicating that an Incorrect number of jobs has
|
||||
* been found.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class IncorrectJobCountException extends JobException {
|
||||
|
||||
public IncorrectJobCountException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public IncorrectJobCountException(String msg, Throwable e) {
|
||||
super(msg, e);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.executor;
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -14,10 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.core.executor;
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import org.springframework.batch.core.executor.StepExecutor;
|
||||
|
||||
/**
|
||||
* Batch domain interface representing the configuration of a step. As with the
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author 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.domain;
|
||||
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
* Interface for processing a step. Implementations are free to process the step
|
||||
* and return when finished, or to schedule the step for processing
|
||||
* concurrently, or in the future. The status of the execution should be
|
||||
* trackable with the step execution. The step should be treated as immutable.<br/>
|
||||
*
|
||||
* Because step execution parameters and policies can vary from step to step, a
|
||||
* {@link StepExecutor} should be created by the caller using a {@link Step}.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public interface StepExecutor {
|
||||
|
||||
/**
|
||||
* It is not safe to re-use an instance of {@link StepExecutor} to process
|
||||
* multiple concurrent executions. Use the factory method in {@link Step} to
|
||||
* create a new instance and execute that.
|
||||
*
|
||||
* @param stepExecution an entity representing the step to be executed
|
||||
*
|
||||
* @throws StepInterruptedException if the step is interrupted externally
|
||||
* @throws BatchCriticalException if there is a problem that needs to be
|
||||
* signalled to the caller
|
||||
*/
|
||||
ExitStatus process(StepExecution stepExecution) throws StepInterruptedException, BatchCriticalException;
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.core.executor;
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import org.springframework.batch.core.executor.StepExecutor;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author 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.executor;
|
||||
|
||||
import org.springframework.batch.core.domain.Step;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
* Interface for processing a step. Implementations are free to process the step
|
||||
* and return when finished, or to schedule the step for processing
|
||||
* concurrently, or in the future. The status of the execution should be
|
||||
* trackable with the step execution. The step should be treated as
|
||||
* immutable.<br/>
|
||||
*
|
||||
* Because step execution parameters and policies can vary from step to step, a
|
||||
* {@link StepExecutor} should be created by the caller using a
|
||||
* {@link StepExecutorFactory}.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public interface StepExecutor {
|
||||
|
||||
/**
|
||||
* Process the step according to the given step. Implementations
|
||||
* can be expected to modify their state when this method is called, to take
|
||||
* account of any policy information in the step. Thus it is not
|
||||
* safe to re-use an instance of {@link StepExecutor} to process multiple
|
||||
* concurrent executions.
|
||||
*
|
||||
* @param step
|
||||
* the configuration to use when running the step. Contains a
|
||||
* recipe for the business logic of an individual processing
|
||||
* operation. Also used to determine policies for commit
|
||||
* intervals and exception handling, for instance.
|
||||
*
|
||||
* @param stepExecution
|
||||
* an entity representing the step to be executed
|
||||
* @throws StepInterruptedException
|
||||
* if the step is interrupted externally
|
||||
* @throws BatchCriticalException
|
||||
* if there is a problem that needs to be signalled to the
|
||||
* caller
|
||||
*/
|
||||
ExitStatus process(Step step,
|
||||
StepExecution stepExecution) throws StepInterruptedException,
|
||||
BatchCriticalException;
|
||||
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
Interfaces and generic implementations of executor concerns.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -13,7 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
package org.springframework.batch.core.repository;
|
||||
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
|
||||
/**
|
||||
* Checked exception that indicates a name clash when registering
|
||||
@@ -13,7 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
package org.springframework.batch.core.repository;
|
||||
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
|
||||
/**
|
||||
* Base class for checked exceptions related to {@link Job}
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.batch.core.repository;
|
||||
|
||||
import org.springframework.batch.core.executor.JobExecutionException;
|
||||
import org.springframework.batch.core.domain.JobExecutionException;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
package org.springframework.batch.core.repository;
|
||||
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
|
||||
/**
|
||||
* A runtime service locator interface for retrieving job configurations by
|
||||
@@ -13,7 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
package org.springframework.batch.core.repository;
|
||||
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
|
||||
/**
|
||||
* A runtime service registry interface for registering job configurations by
|
||||
@@ -13,10 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
package org.springframework.batch.core.repository;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
|
||||
/**
|
||||
* A listable extension of {@link JobRegistry}.
|
||||
*
|
||||
@@ -13,7 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
package org.springframework.batch.core.repository;
|
||||
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
|
||||
|
||||
/**
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.executor;
|
||||
package org.springframework.batch.core.runtime;
|
||||
|
||||
import org.springframework.batch.common.ExceptionClassifier;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
@@ -13,9 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.executor;
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import org.springframework.batch.core.AbstractExceptionTests;
|
||||
import org.springframework.batch.core.domain.JobExecutionException;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.configuration;
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.core.configuration;
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -13,9 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.executor;
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import org.springframework.batch.core.AbstractExceptionTests;
|
||||
import org.springframework.batch.core.domain.StepInterruptedException;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.configuration;
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.configuration;
|
||||
package org.springframework.batch.core.repository;
|
||||
|
||||
import org.springframework.batch.core.AbstractExceptionTests;
|
||||
import org.springframework.batch.core.domain.DuplicateJobException;
|
||||
import org.springframework.batch.core.repository.DuplicateJobException;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.configuration;
|
||||
package org.springframework.batch.core.repository;
|
||||
|
||||
import org.springframework.batch.core.AbstractExceptionTests;
|
||||
import org.springframework.batch.core.domain.JobException;
|
||||
import org.springframework.batch.core.repository.JobException;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.configuration;
|
||||
package org.springframework.batch.core.repository;
|
||||
|
||||
import org.springframework.batch.core.AbstractExceptionTests;
|
||||
import org.springframework.batch.core.domain.NoSuchJobException;
|
||||
import org.springframework.batch.core.repository.NoSuchJobException;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -21,9 +21,9 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobLocator;
|
||||
import org.springframework.batch.core.domain.JobParameters;
|
||||
import org.springframework.batch.core.executor.ExitCodeExceptionClassifier;
|
||||
import org.springframework.batch.core.repository.JobLocator;
|
||||
import org.springframework.batch.core.runtime.ExitCodeExceptionClassifier;
|
||||
import org.springframework.batch.core.runtime.JobParametersFactory;
|
||||
import org.springframework.batch.execution.launch.JobLauncher;
|
||||
import org.springframework.batch.execution.step.simple.SimpleExitCodeExceptionClassifier;
|
||||
|
||||
@@ -22,11 +22,11 @@ import java.util.Properties;
|
||||
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobLocator;
|
||||
import org.springframework.batch.core.domain.JobParameters;
|
||||
import org.springframework.batch.core.domain.NoSuchJobException;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||
import org.springframework.batch.core.repository.JobLocator;
|
||||
import org.springframework.batch.core.repository.NoSuchJobException;
|
||||
import org.springframework.batch.core.runtime.JobParametersFactory;
|
||||
import org.springframework.batch.execution.launch.JobLauncher;
|
||||
import org.springframework.batch.support.PropertiesConverter;
|
||||
|
||||
@@ -19,10 +19,10 @@ import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.springframework.batch.core.domain.DuplicateJobException;
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobLocator;
|
||||
import org.springframework.batch.core.domain.JobRegistry;
|
||||
import org.springframework.batch.core.repository.DuplicateJobException;
|
||||
import org.springframework.batch.core.repository.JobLocator;
|
||||
import org.springframework.batch.core.repository.JobRegistry;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.FatalBeanException;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
|
||||
@@ -21,11 +21,11 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.batch.core.domain.DuplicateJobException;
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobRegistry;
|
||||
import org.springframework.batch.core.domain.ListableJobRegistry;
|
||||
import org.springframework.batch.core.domain.NoSuchJobException;
|
||||
import org.springframework.batch.core.repository.DuplicateJobException;
|
||||
import org.springframework.batch.core.repository.JobRegistry;
|
||||
import org.springframework.batch.core.repository.ListableJobRegistry;
|
||||
import org.springframework.batch.core.repository.NoSuchJobException;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,15 +24,15 @@ import org.springframework.batch.common.ExceptionClassifier;
|
||||
import org.springframework.batch.core.domain.BatchStatus;
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobExecutor;
|
||||
import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.Step;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
import org.springframework.batch.core.domain.StepExecutor;
|
||||
import org.springframework.batch.core.domain.StepInstance;
|
||||
import org.springframework.batch.core.executor.ExitCodeExceptionClassifier;
|
||||
import org.springframework.batch.core.executor.JobExecutor;
|
||||
import org.springframework.batch.core.executor.StepExecutor;
|
||||
import org.springframework.batch.core.executor.StepInterruptedException;
|
||||
import org.springframework.batch.core.domain.StepInterruptedException;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.runtime.ExitCodeExceptionClassifier;
|
||||
import org.springframework.batch.execution.step.simple.SimpleExitCodeExceptionClassifier;
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
@@ -54,7 +54,7 @@ public class DefaultJobExecutor implements JobExecutor {
|
||||
* Run the specified job by looping through the steps and delegating to the
|
||||
* {@link StepExecutor}.
|
||||
*
|
||||
* @see org.springframework.batch.core.executor.JobExecutor#run(org.springframework.batch.core.domain.Job,
|
||||
* @see org.springframework.batch.core.domain.JobExecutor#run(org.springframework.batch.core.domain.Job,
|
||||
* org.springframework.batch.core.domain.JobExecution)
|
||||
*/
|
||||
public ExitStatus run(Job job, JobExecution execution)
|
||||
@@ -85,8 +85,7 @@ public class DefaultJobExecutor implements JobExecutor {
|
||||
updateStatus(execution, BatchStatus.STARTED);
|
||||
StepExecutor stepExecutor = step.createStepExecutor();
|
||||
StepExecution stepExecution = execution.createStepExecution(stepInstance);
|
||||
status = stepExecutor.process(step,
|
||||
stepExecution);
|
||||
status = stepExecutor.process(stepExecution);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobExecutor;
|
||||
import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.JobParameters;
|
||||
import org.springframework.batch.core.executor.JobExecutor;
|
||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
package org.springframework.batch.execution.step.simple;
|
||||
|
||||
import org.springframework.batch.core.domain.Step;
|
||||
import org.springframework.batch.core.domain.StepExecutor;
|
||||
import org.springframework.batch.core.domain.StepSupport;
|
||||
import org.springframework.batch.core.executor.StepExecutor;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.tasklet.Tasklet;
|
||||
import org.springframework.batch.repeat.exception.handler.ExceptionHandler;
|
||||
@@ -113,7 +113,7 @@ public abstract class AbstractStep extends StepSupport {
|
||||
*/
|
||||
public StepExecutor createStepExecutor() {
|
||||
assertMandatoryProperties();
|
||||
SimpleStepExecutor executor = new SimpleStepExecutor();
|
||||
SimpleStepExecutor executor = new SimpleStepExecutor(this);
|
||||
executor.setRepository(jobRepository);
|
||||
executor.applyConfiguration(this);
|
||||
executor.setTasklet(tasklet);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
package org.springframework.batch.execution.step.simple;
|
||||
|
||||
import org.springframework.batch.core.domain.Step;
|
||||
import org.springframework.batch.core.executor.StepExecutor;
|
||||
import org.springframework.batch.core.domain.StepExecutor;
|
||||
import org.springframework.batch.repeat.RepeatOperations;
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.batch.execution.step.simple;
|
||||
|
||||
import org.springframework.batch.core.domain.Step;
|
||||
import org.springframework.batch.core.executor.StepExecutor;
|
||||
import org.springframework.batch.core.domain.StepExecutor;
|
||||
import org.springframework.batch.repeat.RepeatOperations;
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,8 +18,8 @@ package org.springframework.batch.execution.step.simple;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import org.springframework.batch.core.executor.ExitCodeExceptionClassifier;
|
||||
import org.springframework.batch.core.executor.StepInterruptedException;
|
||||
import org.springframework.batch.core.domain.StepInterruptedException;
|
||||
import org.springframework.batch.core.runtime.ExitCodeExceptionClassifier;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,11 +23,11 @@ import org.springframework.batch.core.domain.BatchStatus;
|
||||
import org.springframework.batch.core.domain.Step;
|
||||
import org.springframework.batch.core.domain.StepContribution;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
import org.springframework.batch.core.domain.StepExecutor;
|
||||
import org.springframework.batch.core.domain.StepInstance;
|
||||
import org.springframework.batch.core.executor.ExitCodeExceptionClassifier;
|
||||
import org.springframework.batch.core.executor.StepExecutor;
|
||||
import org.springframework.batch.core.executor.StepInterruptedException;
|
||||
import org.springframework.batch.core.domain.StepInterruptedException;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.runtime.ExitCodeExceptionClassifier;
|
||||
import org.springframework.batch.core.tasklet.Tasklet;
|
||||
import org.springframework.batch.execution.scope.SimpleStepContext;
|
||||
import org.springframework.batch.execution.scope.StepContext;
|
||||
@@ -96,6 +96,15 @@ public class SimpleStepExecutor implements StepExecutor {
|
||||
|
||||
private Tasklet tasklet;
|
||||
|
||||
private AbstractStep step;
|
||||
|
||||
/**
|
||||
* Package private constructor so the factory can create a the executor.
|
||||
*/
|
||||
SimpleStepExecutor(AbstractStep abstractStep) {
|
||||
this.step = abstractStep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Public setter for the {@link StatisticsService}. This will be used to
|
||||
* create the {@link StepContext}, and hence any component that is a
|
||||
@@ -163,9 +172,9 @@ public class SimpleStepExecutor implements StepExecutor {
|
||||
* @throws StepInterruptedException if the step or a chunk is interrupted
|
||||
* @throws RuntimeException if there is an exception during a chunk
|
||||
* execution
|
||||
* @see StepExecutor#process(Step, StepExecution)
|
||||
* @see StepExecutor#process(StepExecution)
|
||||
*/
|
||||
public ExitStatus process(final Step step, final StepExecution stepExecution) throws BatchCriticalException,
|
||||
public ExitStatus process(final StepExecution stepExecution) throws BatchCriticalException,
|
||||
StepInterruptedException {
|
||||
|
||||
final StepInstance stepInstance = stepExecution.getStep();
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.batch.execution.step.simple;
|
||||
|
||||
import org.springframework.batch.core.executor.StepExecutor;
|
||||
import org.springframework.batch.core.executor.StepInterruptedException;
|
||||
import org.springframework.batch.core.domain.StepExecutor;
|
||||
import org.springframework.batch.core.domain.StepInterruptedException;
|
||||
import org.springframework.batch.repeat.RepeatContext;
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.batch.execution.step.simple;
|
||||
|
||||
import org.springframework.batch.core.executor.StepInterruptedException;
|
||||
import org.springframework.batch.core.domain.StepInterruptedException;
|
||||
import org.springframework.batch.repeat.RepeatContext;
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,8 +20,8 @@ import junit.framework.TestCase;
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobParameters;
|
||||
import org.springframework.batch.core.executor.ExitCodeExceptionClassifier;
|
||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||
import org.springframework.batch.core.runtime.ExitCodeExceptionClassifier;
|
||||
import org.springframework.batch.execution.launch.JobLauncher;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ import java.util.Collection;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.domain.DuplicateJobException;
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.NoSuchJobException;
|
||||
import org.springframework.batch.core.repository.DuplicateJobException;
|
||||
import org.springframework.batch.core.repository.NoSuchJobException;
|
||||
import org.springframework.beans.FatalBeanException;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ import java.util.Collection;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.domain.DuplicateJobException;
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.NoSuchJobException;
|
||||
import org.springframework.batch.core.repository.DuplicateJobException;
|
||||
import org.springframework.batch.core.repository.NoSuchJobException;
|
||||
import org.springframework.batch.execution.configuration.MapJobRegistry;
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,11 +28,11 @@ import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.JobParameters;
|
||||
import org.springframework.batch.core.domain.Step;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
import org.springframework.batch.core.domain.StepExecutor;
|
||||
import org.springframework.batch.core.domain.StepInstance;
|
||||
import org.springframework.batch.core.executor.ExitCodeExceptionClassifier;
|
||||
import org.springframework.batch.core.executor.StepExecutor;
|
||||
import org.springframework.batch.core.executor.StepInterruptedException;
|
||||
import org.springframework.batch.core.domain.StepInterruptedException;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.runtime.ExitCodeExceptionClassifier;
|
||||
import org.springframework.batch.core.tasklet.Tasklet;
|
||||
import org.springframework.batch.execution.repository.SimpleJobRepository;
|
||||
import org.springframework.batch.execution.repository.dao.JobDao;
|
||||
@@ -61,8 +61,7 @@ public class DefaultJobExecutorTests extends TestCase {
|
||||
private List list = new ArrayList();
|
||||
|
||||
StepExecutor defaultStepLifecycle = new StubStepExecutor() {
|
||||
public ExitStatus process(Step configuration,
|
||||
StepExecution stepExecution) throws StepInterruptedException,
|
||||
public ExitStatus process(StepExecution stepExecution) throws StepInterruptedException,
|
||||
BatchCriticalException {
|
||||
list.add("default");
|
||||
return ExitStatus.FINISHED;
|
||||
@@ -70,8 +69,7 @@ public class DefaultJobExecutorTests extends TestCase {
|
||||
};
|
||||
|
||||
StepExecutor configurationStepLifecycle = new StubStepExecutor() {
|
||||
public ExitStatus process(Step configuration,
|
||||
StepExecution stepExecution) throws StepInterruptedException,
|
||||
public ExitStatus process(StepExecution stepExecution) throws StepInterruptedException,
|
||||
BatchCriticalException {
|
||||
list.add("special");
|
||||
return ExitStatus.FINISHED;
|
||||
@@ -193,8 +191,7 @@ public class DefaultJobExecutorTests extends TestCase {
|
||||
final StepInterruptedException exception = new StepInterruptedException(
|
||||
"Interrupt!");
|
||||
defaultStepLifecycle = new StubStepExecutor() {
|
||||
public ExitStatus process(Step configuration,
|
||||
StepExecution stepExecution)
|
||||
public ExitStatus process(StepExecution stepExecution)
|
||||
throws StepInterruptedException, BatchCriticalException {
|
||||
throw exception;
|
||||
}
|
||||
@@ -214,8 +211,7 @@ public class DefaultJobExecutorTests extends TestCase {
|
||||
stepConfiguration2.setStartLimit(5);
|
||||
final RuntimeException exception = new RuntimeException("Foo!");
|
||||
defaultStepLifecycle = new StubStepExecutor() {
|
||||
public ExitStatus process(Step configuration,
|
||||
StepExecution stepExecution)
|
||||
public ExitStatus process(StepExecution stepExecution)
|
||||
throws StepInterruptedException, BatchCriticalException {
|
||||
throw exception;
|
||||
}
|
||||
@@ -289,8 +285,7 @@ public class DefaultJobExecutorTests extends TestCase {
|
||||
public void applyConfiguration(Step configuration) {
|
||||
}
|
||||
|
||||
public ExitStatus process(Step configuration,
|
||||
StepExecution stepExecution) throws StepInterruptedException,
|
||||
public ExitStatus process(StepExecution stepExecution) throws StepInterruptedException,
|
||||
BatchCriticalException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ import junit.framework.TestCase;
|
||||
import org.easymock.MockControl;
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobExecutor;
|
||||
import org.springframework.batch.core.domain.JobParameters;
|
||||
import org.springframework.batch.core.executor.JobExecutor;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.springframework.batch.execution.repository.dao.MapStepDao;
|
||||
import org.springframework.batch.execution.step.simple.AbstractStep;
|
||||
import org.springframework.batch.execution.step.simple.RepeatOperationsStep;
|
||||
import org.springframework.batch.execution.step.simple.SimpleStep;
|
||||
import org.springframework.batch.execution.step.simple.SimpleStepExecutor;
|
||||
import org.springframework.batch.execution.tasklet.ItemOrientedTasklet;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemRecoverer;
|
||||
@@ -66,12 +65,9 @@ public class SimpleJobTests extends TestCase {
|
||||
|
||||
private DefaultJobExecutor jobExecutor = new DefaultJobExecutor();;
|
||||
|
||||
private SimpleStepExecutor stepLifecycle = new SimpleStepExecutor();
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
jobExecutor.setJobRepository(repository);
|
||||
stepLifecycle.setRepository(repository);
|
||||
}
|
||||
|
||||
private Tasklet getTasklet(String arg) throws Exception {
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.JobParameters;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
import org.springframework.batch.core.domain.StepInstance;
|
||||
import org.springframework.batch.core.executor.ExitCodeExceptionClassifier;
|
||||
import org.springframework.batch.core.runtime.ExitCodeExceptionClassifier;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.batch.restart.GenericRestartData;
|
||||
import org.springframework.batch.restart.RestartData;
|
||||
|
||||
@@ -82,7 +82,7 @@ public class RepeatOperationsStepTests extends TestCase {
|
||||
new Long(11)), new JobExecution(new JobInstance(new Long(0L), new JobParameters()),
|
||||
new Long(12)));
|
||||
try {
|
||||
executor.process(configuration, stepExecution);
|
||||
executor.process(stepExecution);
|
||||
fail("Expected RuntimeException");
|
||||
} catch (NullPointerException e) {
|
||||
// expected
|
||||
@@ -122,7 +122,7 @@ public class RepeatOperationsStepTests extends TestCase {
|
||||
StepExecution stepExecution = new StepExecution(new StepInstance(
|
||||
new Long(11)), new JobExecution(new JobInstance(new Long(0L), new JobParameters()),
|
||||
new Long(12)));
|
||||
executor.process(configuration, stepExecution);
|
||||
executor.process(stepExecution);
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(1, steps.size());
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
package org.springframework.batch.execution.step.simple;
|
||||
|
||||
|
||||
import org.springframework.batch.core.executor.ExitCodeExceptionClassifier;
|
||||
import org.springframework.batch.core.executor.StepInterruptedException;
|
||||
import org.springframework.batch.core.domain.StepInterruptedException;
|
||||
import org.springframework.batch.core.runtime.ExitCodeExceptionClassifier;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -122,7 +122,7 @@ public class SimpleStepExecutorTests extends TestCase {
|
||||
StepExecution stepExecution = new StepExecution(step,
|
||||
jobExecutionContext);
|
||||
|
||||
stepExecutor.process(stepConfiguration, stepExecution);
|
||||
stepExecutor.process(stepExecution);
|
||||
assertEquals(1, processed.size());
|
||||
assertEquals(1, stepExecution.getTaskCount().intValue());
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class SimpleStepExecutorTests extends TestCase {
|
||||
}
|
||||
});
|
||||
|
||||
stepExecutor.process(stepConfiguration, stepExecution);
|
||||
stepExecutor.process(stepExecution);
|
||||
assertEquals(1, processed.size());
|
||||
|
||||
}
|
||||
@@ -197,7 +197,7 @@ public class SimpleStepExecutorTests extends TestCase {
|
||||
}
|
||||
});
|
||||
|
||||
stepExecutor.process(stepConfiguration, stepExecution);
|
||||
stepExecutor.process(stepExecution);
|
||||
assertEquals(1, processed.size());
|
||||
|
||||
}
|
||||
@@ -212,7 +212,7 @@ public class SimpleStepExecutorTests extends TestCase {
|
||||
StepExecution stepExecution = new StepExecution(step,
|
||||
jobExecutionContext);
|
||||
|
||||
stepExecutor.process(stepConfiguration, stepExecution);
|
||||
stepExecutor.process(stepExecution);
|
||||
assertEquals(1, processed.size());
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ public class SimpleStepExecutorTests extends TestCase {
|
||||
jobExecutionContext);
|
||||
|
||||
try {
|
||||
stepExecutor.process(stepConfiguration, stepExecution);
|
||||
stepExecutor.process(stepExecution);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
assertEquals(stepExecution.getRollbackCount(), new Integer(1));
|
||||
@@ -272,7 +272,7 @@ public class SimpleStepExecutorTests extends TestCase {
|
||||
jobExecutionContext);
|
||||
|
||||
try {
|
||||
stepExecutor.process(stepConfiguration, stepExecution);
|
||||
stepExecutor.process(stepExecution);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ExitStatus status = stepExecution.getExitStatus();
|
||||
@@ -294,7 +294,7 @@ public class SimpleStepExecutorTests extends TestCase {
|
||||
jobExecutionContext);
|
||||
|
||||
try {
|
||||
stepExecutor.process(stepConfiguration, stepExecution);
|
||||
stepExecutor.process(stepExecution);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
fail();
|
||||
@@ -319,7 +319,7 @@ public class SimpleStepExecutorTests extends TestCase {
|
||||
jobExecutionContext);
|
||||
|
||||
try {
|
||||
stepExecutor.process(stepConfiguration, stepExecution);
|
||||
stepExecutor.process(stepExecution);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
fail();
|
||||
@@ -344,7 +344,7 @@ public class SimpleStepExecutorTests extends TestCase {
|
||||
jobExecutionContext);
|
||||
|
||||
try {
|
||||
stepExecutor.process(stepConfiguration, stepExecution);
|
||||
stepExecutor.process(stepExecution);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
fail();
|
||||
@@ -371,7 +371,7 @@ public class SimpleStepExecutorTests extends TestCase {
|
||||
StepExecution stepExecution = new StepExecution(step, jobExecution);
|
||||
|
||||
try {
|
||||
stepExecutor.process(stepConfiguration, stepExecution);
|
||||
stepExecutor.process(stepExecution);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
fail();
|
||||
@@ -442,7 +442,7 @@ public class SimpleStepExecutorTests extends TestCase {
|
||||
});
|
||||
|
||||
try {
|
||||
stepExecutor.process(stepConfiguration, stepExecution);
|
||||
stepExecutor.process(stepExecution);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
fail();
|
||||
|
||||
@@ -60,7 +60,7 @@ public class SimpleStepTests extends TestCase {
|
||||
new Long(11)), new JobExecution(new JobInstance(new Long(0L), new JobParameters()),
|
||||
new Long(12)));
|
||||
try {
|
||||
executor.process(configuration, stepExecution);
|
||||
executor.process(stepExecution);
|
||||
fail("Expected RuntimeException");
|
||||
} catch (NullPointerException e) {
|
||||
throw e;
|
||||
|
||||
@@ -26,9 +26,9 @@ import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.JobParameters;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
import org.springframework.batch.core.domain.StepExecutor;
|
||||
import org.springframework.batch.core.domain.StepInstance;
|
||||
import org.springframework.batch.core.executor.StepExecutor;
|
||||
import org.springframework.batch.core.executor.StepInterruptedException;
|
||||
import org.springframework.batch.core.domain.StepInterruptedException;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.tasklet.Tasklet;
|
||||
import org.springframework.batch.execution.repository.SimpleJobRepository;
|
||||
@@ -90,7 +90,7 @@ public class StepExecutorInterruptionTests extends TestCase {
|
||||
Thread processingThread = new Thread() {
|
||||
public void run() {
|
||||
try {
|
||||
executor.process(stepConfiguration, stepExecution);
|
||||
executor.process(stepExecution);
|
||||
}
|
||||
catch (StepInterruptedException e) {
|
||||
// do nothing...
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.batch.execution.step.simple;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.executor.StepInterruptedException;
|
||||
import org.springframework.batch.core.domain.StepInterruptedException;
|
||||
import org.springframework.batch.repeat.RepeatContext;
|
||||
import org.springframework.batch.repeat.context.RepeatContextSupport;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
|
||||
|
||||
<bean class="org.springframework.batch.execution.configuration.JobRegistryBeanPostProcessor">
|
||||
<property name="jobConfigurationRegistry" ref="jobConfigurationRegistry"/>
|
||||
<property name="jobConfigurationRegistry" ref="jobRegistry"/>
|
||||
</bean>
|
||||
|
||||
<bean id="test-job" class="org.springframework.batch.core.domain.Job">
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<property name="jobExecutor" ref="jobLifecycle" />
|
||||
</bean>
|
||||
|
||||
<bean id="jobConfigurationRegistry"
|
||||
<bean id="jobRegistry"
|
||||
class="org.springframework.batch.execution.configuration.MapJobRegistry" />
|
||||
|
||||
<bean id="jobLifecycle"
|
||||
@@ -40,13 +40,8 @@
|
||||
<property name="useParent" value="true" />
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="stepLifecycle"
|
||||
class="org.springframework.batch.execution.step.simple.SimpleStepExecutor"
|
||||
scope="prototype">
|
||||
<property name="transactionManager" ref="transactionManager" />
|
||||
<property name="repository" ref="simpleJobRepository" />
|
||||
<property name="jobRepository" ref="jobRegistry"/>
|
||||
<property name="transactionManager" ref="transactionManager"/>
|
||||
</bean>
|
||||
|
||||
<bean id="transactionManager"
|
||||
|
||||
@@ -20,10 +20,9 @@ import java.util.ArrayList;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.batch.core.domain.Step;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
import org.springframework.batch.io.file.mapping.FieldSetMapper;
|
||||
import org.springframework.batch.io.file.mapping.FieldSet;
|
||||
import org.springframework.batch.io.file.mapping.FieldSetMapper;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.reader.AbstractItemReader;
|
||||
import org.springframework.batch.item.validator.Validator;
|
||||
@@ -76,7 +75,7 @@ public class OrderItemReader extends AbstractItemReader {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.springframework.batch.execution.io.FieldSetCallback#process(Step, StepExecution)
|
||||
* @see org.springframework.batch.execution.io.FieldSetCallback#process(StepExecution)
|
||||
*/
|
||||
private void process(FieldSet fieldSet) {
|
||||
//finish processing if we hit the end of file
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
<bean id="loopJob" parent="simpleJob">
|
||||
<property name="steps">
|
||||
<bean id="step1" parent="simpleStep">
|
||||
<bean id="step1" parent="repeatOperationsStep">
|
||||
<property name="tasklet">
|
||||
<bean id="module"
|
||||
class="org.springframework.batch.sample.tasklet.InfiniteLoopTasklet"
|
||||
@@ -23,20 +23,27 @@
|
||||
<aop:scoped-proxy />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="commitInterval" value="2" />
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="notifyingStepExecutor" parent="stepExecutor"
|
||||
scope="prototype">
|
||||
<property name="stepOperations">
|
||||
<bean
|
||||
class="org.springframework.batch.repeat.support.RepeatTemplate">
|
||||
<property name="interceptor">
|
||||
<property name="chunkOperations">
|
||||
<bean
|
||||
class="org.springframework.batch.repeat.interceptor.ApplicationEventPublisherRepeatInterceptor" />
|
||||
class="org.springframework.batch.repeat.support.RepeatTemplate">
|
||||
<property name="completionPolicy">
|
||||
<bean
|
||||
class="org.springframework.batch.repeat.policy.SimpleCompletionPolicy">
|
||||
<property name="chunkSize" value="2"/>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="stepOperations">
|
||||
<bean
|
||||
class="org.springframework.batch.repeat.support.RepeatTemplate">
|
||||
<property name="interceptor">
|
||||
<bean
|
||||
class="org.springframework.batch.repeat.interceptor.ApplicationEventPublisherRepeatInterceptor" />
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
@@ -108,7 +115,7 @@
|
||||
<bean id="jobLauncher"
|
||||
class="org.springframework.batch.execution.launch.SimpleJobLauncher">
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
<property name="jobExecutor" ref="jobExecutor"/>
|
||||
<property name="jobExecutor" ref="jobExecutor" />
|
||||
<property name="taskExecutor">
|
||||
<bean
|
||||
class="org.springframework.core.task.SimpleAsyncTaskExecutor" />
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
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.5.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
|
||||
@@ -12,154 +12,150 @@
|
||||
<import resource="data-source-context.xml" />
|
||||
|
||||
<!-- register the step scope with the application context -->
|
||||
<bean id="stepScope"
|
||||
class="org.springframework.batch.execution.scope.StepScope" />
|
||||
|
||||
<bean id="jobConfigurationRegistryBeanPostProcessor" abstract="true"
|
||||
class="org.springframework.batch.execution.configuration.JobRegistryBeanPostProcessor">
|
||||
<property name="jobConfigurationRegistry"
|
||||
ref="jobConfigurationRegistry" />
|
||||
</bean>
|
||||
|
||||
<bean id="jobLauncher"
|
||||
class="org.springframework.batch.execution.launch.SimpleJobLauncher">
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
<property name="jobExecutor" ref="jobExecutor" />
|
||||
</bean>
|
||||
|
||||
<bean id="jobConfigurationRegistry"
|
||||
class="org.springframework.batch.execution.configuration.MapJobRegistry" />
|
||||
|
||||
<aop:config>
|
||||
<aop:advisor
|
||||
pointcut="execution(* org.springframework.batch.execution..*Repository+.*(..))"
|
||||
advice-ref="txAdvice" />
|
||||
</aop:config>
|
||||
|
||||
<tx:advice id="txAdvice" transaction-manager="transactionManager">
|
||||
<tx:attributes>
|
||||
<tx:method name="*Create*" propagation="REQUIRES_NEW" isolation="SERIALIZABLE"/>
|
||||
<tx:method name="*"/>
|
||||
</tx:attributes>
|
||||
</tx:advice>
|
||||
|
||||
<bean id="jobExecutor"
|
||||
class="org.springframework.batch.execution.job.DefaultJobExecutor">
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
</bean>
|
||||
|
||||
<bean id="stepExecutor"
|
||||
class="org.springframework.batch.execution.step.simple.SimpleStepExecutor"
|
||||
scope="prototype">
|
||||
<property name="transactionManager" ref="transactionManager" />
|
||||
<property name="repository" ref="jobRepository" />
|
||||
</bean>
|
||||
|
||||
<bean id="jobRepository"
|
||||
class="org.springframework.batch.execution.repository.SimpleJobRepository">
|
||||
<constructor-arg ref="jobDao" />
|
||||
<constructor-arg ref="stepDao" />
|
||||
</bean>
|
||||
|
||||
<bean id="jobDao" lazy-init="true"
|
||||
class="org.springframework.batch.execution.repository.dao.JdbcJobDao">
|
||||
<property name="jdbcTemplate" ref="jdbcTemplate" />
|
||||
<property name="jobIncrementer" ref="jobIncrementer" />
|
||||
<property name="jobExecutionIncrementer"
|
||||
ref="jobExecutionIncrementer" />
|
||||
</bean>
|
||||
|
||||
<bean id="stepDao" lazy-init="true"
|
||||
class="org.springframework.batch.execution.repository.dao.JdbcStepDao">
|
||||
<property name="jdbcTemplate" ref="jdbcTemplate" />
|
||||
<property name="stepIncrementer" ref="stepIncrementer" />
|
||||
<property name="stepExecutionIncrementer"
|
||||
ref="stepExecutionIncrementer" />
|
||||
<property name="jobDao" ref="jobDao" />
|
||||
</bean>
|
||||
|
||||
<bean id="stepScope"
|
||||
class="org.springframework.batch.execution.scope.StepScope" />
|
||||
|
||||
<bean id="jobConfigurationRegistryBeanPostProcessor" abstract="true"
|
||||
class="org.springframework.batch.execution.configuration.JobRegistryBeanPostProcessor">
|
||||
<property name="jobConfigurationRegistry"
|
||||
ref="jobConfigurationRegistry" />
|
||||
</bean>
|
||||
|
||||
<bean id="jobLauncher"
|
||||
class="org.springframework.batch.execution.launch.SimpleJobLauncher">
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
<property name="jobExecutor" ref="jobExecutor" />
|
||||
</bean>
|
||||
|
||||
<bean id="jobConfigurationRegistry"
|
||||
class="org.springframework.batch.execution.configuration.MapJobRegistry" />
|
||||
|
||||
<aop:config>
|
||||
<aop:advisor
|
||||
pointcut="execution(* org.springframework.batch.execution..*Repository+.*(..))"
|
||||
advice-ref="txAdvice" />
|
||||
</aop:config>
|
||||
|
||||
<tx:advice id="txAdvice" transaction-manager="transactionManager">
|
||||
<tx:attributes>
|
||||
<tx:method name="*Create*" propagation="REQUIRES_NEW"
|
||||
isolation="SERIALIZABLE" />
|
||||
<tx:method name="*" />
|
||||
</tx:attributes>
|
||||
</tx:advice>
|
||||
|
||||
<bean id="jobExecutor"
|
||||
class="org.springframework.batch.execution.job.DefaultJobExecutor">
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
</bean>
|
||||
|
||||
<bean id="jobRepository"
|
||||
class="org.springframework.batch.execution.repository.SimpleJobRepository">
|
||||
<constructor-arg ref="jobDao" />
|
||||
<constructor-arg ref="stepDao" />
|
||||
</bean>
|
||||
|
||||
<bean id="jobDao" lazy-init="true"
|
||||
class="org.springframework.batch.execution.repository.dao.JdbcJobDao">
|
||||
<property name="jdbcTemplate" ref="jdbcTemplate" />
|
||||
<property name="jobIncrementer" ref="jobIncrementer" />
|
||||
<property name="jobExecutionIncrementer"
|
||||
ref="jobExecutionIncrementer" />
|
||||
</bean>
|
||||
|
||||
<bean id="stepDao" lazy-init="true"
|
||||
class="org.springframework.batch.execution.repository.dao.JdbcStepDao">
|
||||
<property name="jdbcTemplate" ref="jdbcTemplate" />
|
||||
<property name="stepIncrementer" ref="stepIncrementer" />
|
||||
<property name="stepExecutionIncrementer"
|
||||
ref="stepExecutionIncrementer" />
|
||||
<property name="jobDao" ref="jobDao" />
|
||||
</bean>
|
||||
|
||||
<bean id="mapJobDao" lazy-init="true"
|
||||
class="org.springframework.batch.execution.repository.dao.MapJobDao"/>
|
||||
class="org.springframework.batch.execution.repository.dao.MapJobDao" />
|
||||
|
||||
<bean id="mapStepDao" lazy-init="true"
|
||||
class="org.springframework.batch.execution.repository.dao.MapStepDao"/>
|
||||
class="org.springframework.batch.execution.repository.dao.MapStepDao" />
|
||||
|
||||
<bean id="jdbcTemplate"
|
||||
class="org.springframework.jdbc.core.JdbcTemplate">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="simpleJob"
|
||||
class="org.springframework.batch.core.domain.Job"
|
||||
abstract="true">
|
||||
<property name="restartable" value="true" />
|
||||
</bean>
|
||||
|
||||
<bean id="simpleStep"
|
||||
class="org.springframework.batch.execution.step.simple.SimpleStep"
|
||||
abstract="true">
|
||||
<property name="allowStartIfComplete" value="true" />
|
||||
<bean id="jdbcTemplate"
|
||||
class="org.springframework.jdbc.core.JdbcTemplate">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="simpleJob"
|
||||
class="org.springframework.batch.core.domain.Job" abstract="true">
|
||||
<property name="restartable" value="true" />
|
||||
</bean>
|
||||
|
||||
<bean id="abstractStep" abstract="true">
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
<property name="transactionManager" ref="transactionManager" />
|
||||
<property name="allowStartIfComplete" value="true" />
|
||||
<property name="saveRestartData" value="false" />
|
||||
<property name="jobRepository" ref="jobRepository"/>
|
||||
<property name="transactionManager" ref="transactionManager"/>
|
||||
<property name="exceptionHandler">
|
||||
<bean
|
||||
class="org.springframework.batch.repeat.exception.handler.SimpleLimitExceptionHandler">
|
||||
<property name="limit" value="5" />
|
||||
<property name="useParent" value="true" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="commitInterval" value="1" />
|
||||
</bean>
|
||||
|
||||
<bean id="repeatOperationsStep"
|
||||
</bean>
|
||||
|
||||
<bean id="simpleStep" parent="abstractStep"
|
||||
class="org.springframework.batch.execution.step.simple.SimpleStep"
|
||||
abstract="true">
|
||||
<property name="exceptionHandler">
|
||||
<bean
|
||||
class="org.springframework.batch.repeat.exception.handler.SimpleLimitExceptionHandler">
|
||||
<property name="limit" value="5" />
|
||||
<property name="useParent" value="true" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="commitInterval" value="1" />
|
||||
</bean>
|
||||
|
||||
<bean id="repeatOperationsStep" parent="abstractStep"
|
||||
class="org.springframework.batch.execution.step.simple.RepeatOperationsStep"
|
||||
abstract="true">
|
||||
<property name="allowStartIfComplete" value="true" />
|
||||
<property name="saveRestartData" value="false" />
|
||||
<property name="jobRepository" ref="jobRepository"/>
|
||||
<property name="transactionManager" ref="transactionManager"/>
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
<property name="transactionManager" ref="transactionManager" />
|
||||
</bean>
|
||||
|
||||
<bean id="customEditorConfigurer"
|
||||
class="org.springframework.beans.factory.config.CustomEditorConfigurer">
|
||||
<property name="customEditors">
|
||||
<map>
|
||||
<entry key="int[]">
|
||||
<bean
|
||||
class="org.springframework.batch.support.IntArrayPropertyEditor" />
|
||||
</entry>
|
||||
<entry
|
||||
key="org.springframework.batch.io.file.transform.Range[]">
|
||||
<bean
|
||||
class="org.springframework.batch.io.file.transform.RangeArrayPropertyEditor" />
|
||||
</entry>
|
||||
<entry key="java.util.Date">
|
||||
<bean
|
||||
class="org.springframework.beans.propertyeditors.CustomDateEditor">
|
||||
<constructor-arg>
|
||||
<bean class="java.text.SimpleDateFormat">
|
||||
<constructor-arg value="yyyyMMdd" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
<constructor-arg value="false" />
|
||||
</bean>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="itemProcessorLogAdvice"
|
||||
class="org.springframework.batch.sample.advice.ProcessorLogAdvice" />
|
||||
|
||||
<aop:config>
|
||||
<aop:aspect id="moduleLogging" ref="itemProcessorLogAdvice">
|
||||
|
||||
<aop:after
|
||||
pointcut="execution( * org.springframework.batch.item.ItemWriter+.write(Object)) and args(item)"
|
||||
method="doStronglyTypedLogging" />
|
||||
|
||||
</aop:aspect>
|
||||
</aop:config>
|
||||
|
||||
</beans>
|
||||
<bean id="customEditorConfigurer"
|
||||
class="org.springframework.beans.factory.config.CustomEditorConfigurer">
|
||||
<property name="customEditors">
|
||||
<map>
|
||||
<entry key="int[]">
|
||||
<bean
|
||||
class="org.springframework.batch.support.IntArrayPropertyEditor" />
|
||||
</entry>
|
||||
<entry
|
||||
key="org.springframework.batch.io.file.transform.Range[]">
|
||||
<bean
|
||||
class="org.springframework.batch.io.file.transform.RangeArrayPropertyEditor" />
|
||||
</entry>
|
||||
<entry key="java.util.Date">
|
||||
<bean
|
||||
class="org.springframework.beans.propertyeditors.CustomDateEditor">
|
||||
<constructor-arg>
|
||||
<bean class="java.text.SimpleDateFormat">
|
||||
<constructor-arg value="yyyyMMdd" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
<constructor-arg value="false" />
|
||||
</bean>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="itemProcessorLogAdvice"
|
||||
class="org.springframework.batch.sample.advice.ProcessorLogAdvice" />
|
||||
|
||||
<aop:config>
|
||||
<aop:aspect id="moduleLogging" ref="itemProcessorLogAdvice">
|
||||
|
||||
<aop:after
|
||||
pointcut="execution( * org.springframework.batch.item.ItemWriter+.write(Object)) and args(item)"
|
||||
method="doStronglyTypedLogging" />
|
||||
|
||||
</aop:aspect>
|
||||
</aop:config>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -8,8 +8,8 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.ListableJobRegistry;
|
||||
import org.springframework.batch.core.domain.NoSuchJobException;
|
||||
import org.springframework.batch.core.repository.ListableJobRegistry;
|
||||
import org.springframework.batch.core.repository.NoSuchJobException;
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.PropertyAccessorUtils;
|
||||
|
||||
Reference in New Issue
Block a user