Tidy up build problems overnight.
This commit is contained in:
@@ -18,7 +18,6 @@ package org.springframework.batch.core.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,6 @@ import java.util.Date;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.runtime.SimpleJobIdentifier;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,9 +17,6 @@ package org.springframework.batch.core.domain;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.batch.core.runtime.SimpleJobIdentifier;
|
||||
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
|
||||
@@ -110,7 +110,6 @@ public class SimpleCommandLineJobRunner {
|
||||
private ExitCodeExceptionClassifier exceptionClassifier = new SimpleExitCodeExceptionClassifier();
|
||||
|
||||
private JobLauncher launcher;
|
||||
|
||||
private JobLocator jobLocator;
|
||||
|
||||
private SystemExiter systemExiter = new JvmSystemExiter();
|
||||
|
||||
@@ -1,168 +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.execution.launch;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobIdentifier;
|
||||
import org.springframework.batch.core.domain.JobLocator;
|
||||
import org.springframework.batch.core.domain.NoSuchJobException;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
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;
|
||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
|
||||
/**
|
||||
* A test implementation of the JobLauncher interface. It exists solely to work
|
||||
* through interface design issues for the JobLauncher, JobRepository,
|
||||
* JobLocator, and JobExecutor interfaces. It is designed for simplicity, and
|
||||
* despite unit testing may not be completely threadsafe, and therefore should
|
||||
* not be used.
|
||||
*
|
||||
* Rather than using a JobExecutorFacade, a JobExecutor is worked with directly.
|
||||
* Not every method of the JobLauncher interface is used. Instead, new versions
|
||||
* that take JobIdentifier as an argument were added. A JobExecution is
|
||||
* considered to be running if it's JobIdentifier (the one it was ran with)
|
||||
* exists in the HashMap execution registry. When a JobExecutor is finished
|
||||
* processing it removes it's identifier from the map.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class DefaultJobLauncher implements JobLauncher {
|
||||
|
||||
private Map jobExecutionRegistry = new HashMap();
|
||||
|
||||
private Object monitor = new Object();
|
||||
|
||||
private JobRepository jobRepository;
|
||||
|
||||
private JobLocator jobLocator;
|
||||
|
||||
private JobExecutor jobExecutor;
|
||||
|
||||
private TaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.batch.execution.launch.JobLauncher#isRunning()
|
||||
*/
|
||||
public boolean isRunning() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.batch.execution.launch.JobLauncher#run(org.springframework.batch.core.domain.JobIdentifier)
|
||||
*/
|
||||
public JobExecution run(JobIdentifier jobIdentifier) throws NoSuchJobException, JobExecutionAlreadyRunningException {
|
||||
|
||||
JobExecution jobExecution;
|
||||
|
||||
synchronized (monitor) {
|
||||
if (jobExecutionRegistry.containsKey(jobIdentifier)) {
|
||||
throw new JobExecutionAlreadyRunningException("Job: " + jobIdentifier + "is already running.");
|
||||
}
|
||||
|
||||
Job job = jobLocator.getJob(jobIdentifier.getName());
|
||||
jobExecution = jobRepository.findOrCreateJob(job, jobIdentifier);
|
||||
jobExecutionRegistry.put(jobIdentifier, jobExecution);
|
||||
|
||||
runJobExecution(job, jobExecution, jobIdentifier);
|
||||
}
|
||||
|
||||
return jobExecution;
|
||||
}
|
||||
|
||||
private void runJobExecution(final Job job, final JobExecution jobExecution, final JobIdentifier jobIdentifier) {
|
||||
|
||||
taskExecutor.execute(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
ExitStatus status = jobExecutor.run(job, jobExecution);
|
||||
jobExecution.setExitStatus(status);
|
||||
synchronized (monitor) {
|
||||
jobExecutionRegistry.remove(jobIdentifier);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.batch.execution.launch.JobLauncher#stop()
|
||||
*/
|
||||
public void stop() {
|
||||
// TODO add code to stop ALL jobExecutions
|
||||
}
|
||||
|
||||
public void stop(JobIdentifier jobIdentifier) {
|
||||
|
||||
synchronized (monitor) {
|
||||
|
||||
if(!jobExecutionRegistry.containsKey(jobIdentifier)){
|
||||
return;
|
||||
}
|
||||
|
||||
JobExecution jobExecution = (JobExecution)jobExecutionRegistry.get(jobIdentifier);
|
||||
|
||||
for (Iterator iter = jobExecution.getStepExecutions().iterator(); iter
|
||||
.hasNext();) {
|
||||
StepExecution context = (StepExecution) iter.next();
|
||||
context.setTerminateOnly();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isRunning(JobIdentifier jobIdentifier) {
|
||||
|
||||
synchronized (monitor) {
|
||||
if (jobExecutionRegistry.containsKey(jobIdentifier)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setJobRepository(JobRepository jobRepository) {
|
||||
this.jobRepository = jobRepository;
|
||||
}
|
||||
|
||||
public void setJobLocator(JobLocator jobLocator) {
|
||||
this.jobLocator = jobLocator;
|
||||
}
|
||||
|
||||
public void setJobExecutor(JobExecutor jobExecutor) {
|
||||
this.jobExecutor = jobExecutor;
|
||||
}
|
||||
|
||||
public void setTaskExecutor(TaskExecutor taskExecutor) {
|
||||
this.taskExecutor = taskExecutor;
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ package org.springframework.batch.execution.launch;
|
||||
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobIdentifier;
|
||||
import org.springframework.batch.core.domain.JobInstanceProperties;
|
||||
import org.springframework.batch.core.domain.NoSuchJobException;
|
||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||
|
||||
@@ -73,8 +73,15 @@ public class SimpleJobLauncher implements JobLauncher {
|
||||
catch(Throwable t){
|
||||
logger.info("Job: [" + job + "] failed with the following parameters: ["
|
||||
+ jobInstanceProperties + "]", t);
|
||||
throw new RuntimeException(t);
|
||||
rethrow(t);
|
||||
}
|
||||
}
|
||||
|
||||
private void rethrow(Throwable t) {
|
||||
if (t instanceof RuntimeException) {
|
||||
throw (RuntimeException) t;
|
||||
}
|
||||
throw new RuntimeException(t);
|
||||
}});
|
||||
|
||||
return jobExecution;
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.sql.Types;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -33,13 +32,10 @@ import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobIdentifier;
|
||||
import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.JobInstanceProperties;
|
||||
import org.springframework.batch.core.domain.JobInstancePropertiesBuilder;
|
||||
import org.springframework.batch.core.repository.NoSuchBatchDomainObjectException;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.dao.DataRetrievalFailureException;
|
||||
import org.springframework.jdbc.core.JdbcOperations;
|
||||
import org.springframework.jdbc.core.RowCallbackHandler;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -447,19 +443,6 @@ public class JdbcJobDao implements JobDao, InitializingBean {
|
||||
"JobExecution status cannot be null.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate {@link JobIdentifier}. Due to differing requirements, it is
|
||||
* acceptable for any field to be blank, however null fields may cause odd
|
||||
* and vague exception reports from the database driver.
|
||||
*/
|
||||
private void validateJobIdentifier(JobIdentifier jobIdentifier) {
|
||||
|
||||
Assert.notNull(jobIdentifier, "JobIdentifier cannot be null.");
|
||||
Assert.notNull(jobIdentifier.getName(),
|
||||
"JobIdentifier name cannot be null.");
|
||||
Assert.notNull(jobIdentifier.getJobInstanceProperties(), "JobIdentifier runtime parameters must not be null.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-usable mapper for {@link JobExecution} instances.
|
||||
*
|
||||
@@ -493,49 +476,7 @@ public class JdbcJobDao implements JobDao, InitializingBean {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Private inner class for mapping values from the JOB_PARAMETERS table into the java
|
||||
* JobParameters class. TODO: is this going to be used? If not can we delete it?
|
||||
*/
|
||||
private static class JobParameterCallbackHandler implements RowCallbackHandler{
|
||||
|
||||
private JobInstancePropertiesBuilder parametersBuilder;
|
||||
|
||||
public JobParameterCallbackHandler() {
|
||||
parametersBuilder = new JobInstancePropertiesBuilder();
|
||||
}
|
||||
|
||||
public void processRow(ResultSet rs) throws SQLException {
|
||||
|
||||
ParameterType parameterType = ParameterType.getType(rs.getString("TYPE_CD"));
|
||||
|
||||
String key = rs.getString("KEY");
|
||||
|
||||
if(parameterType == ParameterType.STRING){
|
||||
parametersBuilder.addString(key, rs.getString("STRING_VAL"));
|
||||
}
|
||||
else if(parameterType == ParameterType.LONG){
|
||||
parametersBuilder.addLong(key, new Long(rs.getLong("LONG_VAL")));
|
||||
}
|
||||
else if(parameterType == ParameterType.DATE){
|
||||
//I debated about just passing the Timestamp in, however, I didn't want there to be any equality
|
||||
//issues when comparing a java.util.Date to a timestamp.
|
||||
Timestamp ts = rs.getTimestamp("DATE_VAL");
|
||||
parametersBuilder.addDate(key, new Date(ts.getTime()));
|
||||
}
|
||||
else{
|
||||
//invalid type code, error out.
|
||||
throw new DataRetrievalFailureException("Invalid JobParameter type");
|
||||
}
|
||||
}
|
||||
|
||||
public JobInstanceProperties getJobParmeters(){
|
||||
return parametersBuilder.toJobParameters();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ParameterType {
|
||||
|
||||
private final String type;
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.Set;
|
||||
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobIdentifier;
|
||||
import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.JobInstanceProperties;
|
||||
import org.springframework.batch.support.transaction.TransactionAwareProxyFactory;
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.batch.execution.resource;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.springframework.batch.core.domain.JobIdentifier;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
import org.springframework.batch.execution.scope.StepContext;
|
||||
import org.springframework.batch.execution.scope.StepContextAware;
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.JobInstanceProperties;
|
||||
import org.springframework.batch.core.runtime.SimpleJobIdentifier;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.beans.factory.access.BeanFactoryLocator;
|
||||
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
||||
|
||||
@@ -2,9 +2,7 @@ package org.springframework.batch.execution.bootstrap.support;
|
||||
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobIdentifier;
|
||||
import org.springframework.batch.core.domain.JobInstanceProperties;
|
||||
import org.springframework.batch.core.domain.NoSuchJobException;
|
||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||
import org.springframework.batch.execution.launch.JobLauncher;
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.springframework.batch.core.executor.StepExecutor;
|
||||
import org.springframework.batch.core.executor.StepExecutorFactory;
|
||||
import org.springframework.batch.core.executor.StepInterruptedException;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.runtime.SimpleJobIdentifier;
|
||||
import org.springframework.batch.core.tasklet.Tasklet;
|
||||
import org.springframework.batch.execution.repository.SimpleJobRepository;
|
||||
import org.springframework.batch.execution.repository.dao.JobDao;
|
||||
|
||||
@@ -1,122 +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.execution.launch;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.NoSuchJobException;
|
||||
import org.springframework.batch.core.executor.JobExecutor;
|
||||
import org.springframework.batch.core.runtime.SimpleJobIdentifier;
|
||||
import org.springframework.batch.execution.bootstrap.support.ThreadInterruptJobExecutionListener;
|
||||
import org.springframework.batch.execution.configuration.MapJobRegistry;
|
||||
import org.springframework.batch.execution.launch.JobExecutorFacade;
|
||||
import org.springframework.batch.execution.launch.SimpleJobExecutorFacade;
|
||||
import org.springframework.batch.execution.repository.SimpleJobRepository;
|
||||
import org.springframework.batch.execution.repository.dao.MapJobDao;
|
||||
import org.springframework.batch.execution.repository.dao.MapStepDao;
|
||||
import org.springframework.batch.io.exception.BatchCriticalException;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class InterruptJobTests extends TestCase {
|
||||
|
||||
//JabExecutorFacade is deprecated.
|
||||
// public void testInterruptUsingListener() throws Exception {
|
||||
//
|
||||
// // final InterruptibleFacade facade = new InterruptibleFacade();
|
||||
// // facade.setListener(new ThreadInterruptJobExecutionListener());
|
||||
// final SimpleJobExecutorFacade facade = new SimpleJobExecutorFacade();
|
||||
// facade.setJobExecutor(new InterruptibleJobExecutor());
|
||||
//
|
||||
// facade.setJobRepository(new SimpleJobRepository(new MapJobDao(),
|
||||
// new MapStepDao()));
|
||||
//
|
||||
// facade.setJobExecutionListeners(Collections
|
||||
// .singletonList(new ThreadInterruptJobExecutionListener()));
|
||||
//
|
||||
// MapJobRegistry registry = new MapJobRegistry();
|
||||
// facade.setJobLocator(registry);
|
||||
//
|
||||
// registry.register(new Job("foo"));
|
||||
// final SimpleJobIdentifier identifier = new SimpleJobIdentifier("foo");
|
||||
// final JobExecution execution = facade.createExecutionFrom(identifier);
|
||||
//
|
||||
// TaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
|
||||
// Runnable launcherRunnable = new Runnable() {
|
||||
// public void run() {
|
||||
// try {
|
||||
// facade.start(execution);
|
||||
// } catch (NoSuchJobException e) {
|
||||
// fail("Unexpected NoSuchJobConfigurationException");
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// taskExecutor.execute(launcherRunnable);
|
||||
//
|
||||
// // give the thread a second to start up
|
||||
// Thread.sleep(100);
|
||||
// assertTrue(facade.isRunning());
|
||||
// facade.stop(execution);
|
||||
// Thread.sleep(100);
|
||||
// assertFalse(facade.isRunning());
|
||||
// }
|
||||
|
||||
public void testBlank(){}
|
||||
|
||||
/**
|
||||
* Simple {@link JobExecutorFacade} that can be used to test thread
|
||||
* interruption. Mimics the implementation of the
|
||||
* {@link SimpleJobExecutorFacade} with the use of a listener, but silently
|
||||
* allows the current thread to be interrupted.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
private class InterruptibleJobExecutor implements JobExecutor {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.batch.core.executor.JobExecutor#run(org.springframework.batch.core.configuration.JobConfiguration,
|
||||
* org.springframework.batch.core.domain.JobExecution)
|
||||
*/
|
||||
public ExitStatus run(Job configuration,
|
||||
JobExecution execution) throws BatchCriticalException {
|
||||
try {
|
||||
// 1 seconds should be long enough to allow the thread to be
|
||||
// run and for interrupt to be called;
|
||||
Thread.sleep(3000);
|
||||
return ExitStatus.FAILED;
|
||||
|
||||
} catch (InterruptedException ex) {
|
||||
// thread interrupted, allow to exit normally
|
||||
return ExitStatus.FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,304 +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.execution.launch;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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.JobInstance;
|
||||
import org.springframework.batch.core.domain.JobInstanceProperties;
|
||||
import org.springframework.batch.core.executor.JobExecutor;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.runtime.SimpleJobIdentifier;
|
||||
|
||||
/**
|
||||
* SimpleBatchContainer unit tests.
|
||||
*
|
||||
* SimpleJobExector should be removed, commented out the tests in case they were useful.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class SimpleJobExecutorFacadeTests extends TestCase {
|
||||
|
||||
private SimpleJobExecutorFacade jobExecutorFacade = new SimpleJobExecutorFacade();
|
||||
|
||||
private JobExecutor jobExecutor;
|
||||
|
||||
private JobRepository jobRepository;
|
||||
|
||||
private MockControl jobRepositoryControl = MockControl.createControl(JobRepository.class);
|
||||
|
||||
private Job jobConfiguration = new Job();
|
||||
|
||||
private volatile boolean running = false;
|
||||
|
||||
private SimpleJobIdentifier jobIdentifier = new SimpleJobIdentifier("TestJob");
|
||||
|
||||
private JobInstanceProperties jobInstanceProperties = new JobInstanceProperties();
|
||||
|
||||
private JobExecution jobExecution = new JobExecution(new JobInstance(new Long(0), jobInstanceProperties));
|
||||
|
||||
private List list = new ArrayList();
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
|
||||
super.setUp();
|
||||
jobConfiguration.setBeanName("TestJob");
|
||||
jobExecutorFacade.setJobExecutor(jobExecutor);
|
||||
jobRepository = (JobRepository) jobRepositoryControl.getMock();
|
||||
jobExecutorFacade.setJobRepository(jobRepository);
|
||||
|
||||
}
|
||||
|
||||
// public void testCreateNewExecution() throws Exception {
|
||||
//
|
||||
// JobInstance job = setUpFacadeForNormalStart();
|
||||
// jobExecution = jobExecutorFacade.createExecutionFrom(jobIdentifier);
|
||||
// assertEquals(job, jobExecution.getJobInstance());
|
||||
// jobRepositoryControl.verify();
|
||||
//
|
||||
// }
|
||||
//
|
||||
public void testNormalStart() throws Exception {
|
||||
//
|
||||
// JobInstance job = setUpFacadeForNormalStart();
|
||||
// jobExecution = jobExecutorFacade.createExecutionFrom(jobIdentifier);
|
||||
// jobExecutorFacade.start(jobExecution);
|
||||
// assertEquals(job, jobExecution.getJobInstance());
|
||||
// jobRepositoryControl.verify();
|
||||
//
|
||||
}
|
||||
//
|
||||
// private JobInstance setUpFacadeForNormalStart() throws Exception {
|
||||
// jobIdentifier = new SimpleJobIdentifier("bar");
|
||||
// jobExecutor = new JobExecutor() {
|
||||
// public ExitStatus run(Job configuration, JobExecution execution) throws BatchCriticalException {
|
||||
// jobExecution = execution;
|
||||
// return ExitStatus.FINISHED;
|
||||
// }
|
||||
// };
|
||||
// jobExecutorFacade.setJobExecutor(jobExecutor);
|
||||
// JobInstance job = new JobInstance(new Long(0), jobInstanceProperties);
|
||||
// jobExecution = new JobExecution(job);
|
||||
// jobRepository.createJobExecution(jobConfiguration, null);
|
||||
// jobRepositoryControl.setReturnValue(jobExecution);
|
||||
// jobRepositoryControl.replay();
|
||||
// jobExecutorFacade
|
||||
// .setJobLocator(new JobLocator() {
|
||||
// public Job getJob(String name)
|
||||
// throws NoSuchJobException {
|
||||
// return jobConfiguration;
|
||||
// }
|
||||
// });
|
||||
// job.setJob(new Job());
|
||||
// return job;
|
||||
// }
|
||||
//
|
||||
//// public void testIsRunning() throws Exception {
|
||||
//// jobExecutorFacade.setJobExecutor(new JobExecutor() {
|
||||
//// public ExitStatus run(Job configuration,
|
||||
//// JobExecution execution) throws BatchCriticalException {
|
||||
//// while (running) {
|
||||
//// try {
|
||||
//// Thread.sleep(100L);
|
||||
//// } catch (InterruptedException e) {
|
||||
//// throw new BatchCriticalException(
|
||||
//// "Interrupted unexpectedly!");
|
||||
//// }
|
||||
//// }
|
||||
//// return ExitStatus.FINISHED;
|
||||
//// }
|
||||
//// });
|
||||
//// jobExecutorFacade
|
||||
//// .setJobLocator(new JobLocator() {
|
||||
//// public Job getJob(String name)
|
||||
//// throws NoSuchJobException {
|
||||
//// return jobConfiguration;
|
||||
//// }
|
||||
//// });
|
||||
////
|
||||
//// running = true;
|
||||
//// new Thread(new Runnable() {
|
||||
//// public void run() {
|
||||
//// try {
|
||||
//// jobExecutorFacade.start(jobExecution);
|
||||
//// } catch (NoSuchJobException e) {
|
||||
//// throw new IllegalStateException("Shouldn't happen");
|
||||
//// }
|
||||
//// }
|
||||
//// }).start();
|
||||
//// // Give Thread time to start
|
||||
//// Thread.sleep(100L);
|
||||
//// assertTrue(jobExecutorFacade.isRunning());
|
||||
//// running = false;
|
||||
//// int count = 0;
|
||||
//// while (jobExecutorFacade.isRunning() && count++ < 5) {
|
||||
//// Thread.sleep(100L);
|
||||
//// }
|
||||
//// assertFalse(jobExecutorFacade.isRunning());
|
||||
//// }
|
||||
//
|
||||
// public void testInvalidInitialisation() throws Exception {
|
||||
//
|
||||
// jobExecutorFacade = new SimpleJobExecutorFacade();
|
||||
//
|
||||
// try {
|
||||
// jobExecutorFacade.afterPropertiesSet();
|
||||
// fail("Expected IllegalStateException");
|
||||
// }
|
||||
// catch (IllegalArgumentException ex) {
|
||||
// // expected
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//// public void testStopWithNoJob() throws Exception {
|
||||
//// SimpleJobIdentifier runtimeInformation = new SimpleJobIdentifier(
|
||||
//// "TestJob");
|
||||
//// JobExecution execution = new JobExecution(new JobInstance(
|
||||
//// new Long(0), jobInstanceProperties));
|
||||
//// try {
|
||||
//// jobExecutorFacade.stop(execution);
|
||||
//// fail("Expected NoSuchJobExecutionException");
|
||||
//// } catch (NoSuchJobExecutionException e) {
|
||||
//// // expected
|
||||
//// assertTrue("Wrong message in exception: "+e.getMessage(), e.getMessage().indexOf("TestJob") >= 0);
|
||||
//// }
|
||||
//// }
|
||||
//
|
||||
// public void testStop() throws Exception {
|
||||
// SimpleJobIdentifier runtimeInformation = new SimpleJobIdentifier(
|
||||
// "TestJob");
|
||||
// JobExecution execution = new JobExecution(new JobInstance(
|
||||
// new Long(0), jobInstanceProperties));
|
||||
//
|
||||
// List listeners = new ArrayList();
|
||||
// listeners.add(new JobExecutionListenerSupport() {
|
||||
// public void onStop(JobExecution execution) {
|
||||
// list.add("one");
|
||||
// }
|
||||
// });
|
||||
// jobExecutorFacade.setJobExecutionListeners(listeners);
|
||||
//
|
||||
// registerExecution(runtimeInformation, execution);
|
||||
//
|
||||
// jobExecutorFacade.stop(execution);
|
||||
//
|
||||
// assertTrue(stepExecution.isTerminateOnly());
|
||||
// assertEquals(1, list.size());
|
||||
// }
|
||||
//
|
||||
// public void testStatisticsWithNoContext() throws Exception {
|
||||
// assertNotNull(jobExecutorFacade.getStatistics());
|
||||
// }
|
||||
//
|
||||
// public void testStatisticsWithContext() throws Exception {
|
||||
// SimpleJobIdentifier runtimeInformation = new SimpleJobIdentifier(
|
||||
// "TestJob");
|
||||
// JobExecution execution = new JobExecution(new JobInstance(
|
||||
// new Long(0), jobInstanceProperties));
|
||||
// registerExecution(runtimeInformation, execution);
|
||||
// execution.createStepExecution(new StepInstance(jobInstance, "step"));
|
||||
// Properties statistics = jobExecutorFacade.getStatistics();
|
||||
// assertNotNull(statistics);
|
||||
// assertTrue(statistics.containsKey("job1.step1"));
|
||||
// }
|
||||
//
|
||||
// public void testJobAlreadyExecutingLocally() throws Exception {
|
||||
// SimpleJobIdentifier runtimeInformation = new SimpleJobIdentifier(
|
||||
// "TestJob");
|
||||
// JobExecution execution = new JobExecution(new JobInstance(
|
||||
// new Long(0), jobInstanceProperties));
|
||||
// registerExecution(runtimeInformation, execution);
|
||||
// try {
|
||||
// jobExecutorFacade.createExecutionFrom(runtimeInformation);
|
||||
// fail("Expected JobExecutionAlreadyRunningException");
|
||||
// }
|
||||
// catch (JobExecutionAlreadyRunningException e) {
|
||||
// // expected
|
||||
// assertTrue("Message does not contain TestJob: " + e.getMessage(), e.getMessage().indexOf("TestJob") >= 0);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void testListenersCalledLastOnStop() throws Exception {
|
||||
// List listeners = new ArrayList();
|
||||
// listeners.add(new JobExecutionListenerSupport() {
|
||||
// public void onStop(JobExecution execution) {
|
||||
// list.add("one");
|
||||
// }
|
||||
// });
|
||||
// listeners.add(new JobExecutionListenerSupport() {
|
||||
// public void onStop(JobExecution execution) {
|
||||
// list.add("two");
|
||||
// }
|
||||
// });
|
||||
// jobExecutorFacade.setJobExecutionListeners(listeners);
|
||||
// jobExecutorFacade.onStop(jobExecution);
|
||||
// assertEquals(2, list.size());
|
||||
// assertEquals("two", list.get(1));
|
||||
// }
|
||||
//
|
||||
// public void testListenersCalledLastOnAfter() throws Exception {
|
||||
// List listeners = new ArrayList();
|
||||
// listeners.add(new JobExecutionListenerSupport() {
|
||||
// public void after(JobExecution execution) {
|
||||
// list.add("two");
|
||||
// }
|
||||
// });
|
||||
// listeners.add(new JobExecutionListenerSupport() {
|
||||
// public void after(JobExecution execution) {
|
||||
// list.add("one");
|
||||
// }
|
||||
// });
|
||||
// jobExecutorFacade.setJobExecutionListeners(listeners);
|
||||
// jobExecutorFacade.after(jobExecution);
|
||||
// assertEquals(2, list.size());
|
||||
// assertEquals("two", list.get(1));
|
||||
// }
|
||||
//
|
||||
// public void testOrderedListenersCalledFirstOnBefore() throws Exception {
|
||||
// List listeners = new ArrayList();
|
||||
// listeners.add(new JobExecutionListenerSupport() {
|
||||
// public void before(JobExecution execution) {
|
||||
// list.add("one");
|
||||
// }
|
||||
// });
|
||||
// listeners.add(new JobExecutionListenerSupport() {
|
||||
// public void before(JobExecution execution) {
|
||||
// list.add("two");
|
||||
// }
|
||||
// });
|
||||
// jobExecutorFacade.setJobExecutionListeners(listeners);
|
||||
// jobExecutorFacade.before(jobExecution);
|
||||
// assertEquals(2, list.size());
|
||||
// assertEquals("two", list.get(1));
|
||||
// }
|
||||
//
|
||||
// private void registerExecution(SimpleJobIdentifier runtimeInformation, JobExecution execution)
|
||||
// throws NoSuchFieldException, IllegalAccessException {
|
||||
// Field field = SimpleJobExecutorFacade.class.getDeclaredField("jobExecutionRegistry");
|
||||
// ReflectionUtils.makeAccessible(field);
|
||||
// Map map = (Map) field.get(jobExecutorFacade);
|
||||
// map.put(runtimeInformation, execution);
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -25,19 +25,16 @@ import junit.framework.TestCase;
|
||||
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.JobIdentifier;
|
||||
import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.JobInstanceProperties;
|
||||
import org.springframework.batch.core.domain.Step;
|
||||
import org.springframework.batch.core.executor.StepExecutor;
|
||||
import org.springframework.batch.core.executor.StepExecutorFactory;
|
||||
import org.springframework.batch.core.runtime.SimpleJobIdentifier;
|
||||
import org.springframework.batch.core.tasklet.Tasklet;
|
||||
import org.springframework.batch.execution.job.DefaultJobExecutor;
|
||||
import org.springframework.batch.execution.repository.SimpleJobRepository;
|
||||
import org.springframework.batch.execution.repository.dao.MapJobDao;
|
||||
import org.springframework.batch.execution.repository.dao.MapStepDao;
|
||||
import org.springframework.batch.execution.runtime.ScheduledJobIdentifierFactory;
|
||||
import org.springframework.batch.execution.step.SimpleStep;
|
||||
import org.springframework.batch.execution.step.simple.SimpleStepExecutor;
|
||||
import org.springframework.batch.execution.tasklet.ItemOrientedTasklet;
|
||||
@@ -114,9 +111,6 @@ public class SimpleJobTests extends TestCase {
|
||||
public void testSimpleJob() throws Exception {
|
||||
|
||||
Job jobConfiguration = new Job();
|
||||
JobIdentifier runtimeInformation = new ScheduledJobIdentifierFactory()
|
||||
.getJobIdentifier("real.job");
|
||||
|
||||
jobConfiguration.addStep(new SimpleStep(getTasklet("foo", "bar")));
|
||||
jobConfiguration.addStep(new SimpleStep(getTasklet("spam")));
|
||||
|
||||
@@ -134,7 +128,6 @@ public class SimpleJobTests extends TestCase {
|
||||
public void testSimpleJobWithRecovery() throws Exception {
|
||||
|
||||
Job jobConfiguration = new Job();
|
||||
JobIdentifier runtimeInformation = new SimpleJobIdentifier("real.job");
|
||||
final List throwables = new ArrayList();
|
||||
|
||||
RepeatTemplate chunkOperations = new RepeatTemplate();
|
||||
@@ -183,7 +176,6 @@ public class SimpleJobTests extends TestCase {
|
||||
public void testExceptionTerminates() throws Exception {
|
||||
|
||||
Job jobConfiguration = new Job();
|
||||
JobIdentifier runtimeInformation = new SimpleJobIdentifier("real.job");
|
||||
final ItemOrientedTasklet module = getTasklet(new String[] { "foo", "bar", "spam" });
|
||||
Step step = new SimpleStep(module);
|
||||
module.setItemProcessor(new ItemProcessor() {
|
||||
|
||||
@@ -1,232 +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.execution.launch;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.easymock.MockControl;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobIdentifier;
|
||||
import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.NoSuchJobException;
|
||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||
import org.springframework.batch.core.runtime.SimpleJobIdentifier;
|
||||
import org.springframework.batch.core.runtime.SimpleJobIdentifierFactory;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.batch.statistics.StatisticsProvider;
|
||||
import org.springframework.batch.support.PropertiesConverter;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
import org.springframework.scheduling.timer.TimerTaskExecutor;
|
||||
|
||||
public class TaskExecutorJobLauncherTests extends TestCase {
|
||||
|
||||
private SimpleJobLauncher launcher = new SimpleJobLauncher();
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
|
||||
//Under construction
|
||||
// public void testStopContainer() throws Exception {
|
||||
//
|
||||
// // Important (otherwise start() does not return!)
|
||||
// launcher.setTaskExecutor(new SimpleAsyncTaskExecutor());
|
||||
//
|
||||
// InterruptibleContainer container = new InterruptibleContainer();
|
||||
//
|
||||
// JobExecution execution = launcher.run(new SimpleJobIdentifier("foo"));
|
||||
// // give the thread some time to start up...
|
||||
// Thread.sleep(100);
|
||||
// assertTrue(launcher.isRunning());
|
||||
// launcher.stop();
|
||||
// // ...and to shut down:
|
||||
// Thread.sleep(400);
|
||||
// assertFalse(launcher.isRunning());
|
||||
// assertEquals("COMPLETED_BY_TEST", execution.getExitStatus().getExitCode());
|
||||
// }
|
||||
//
|
||||
// public void testStopContainerWhenJobNotRunning() throws Exception {
|
||||
//
|
||||
// final List list = new ArrayList();
|
||||
//
|
||||
// // Important (otherwise start() does not return!)
|
||||
// TimerTaskExecutor taskExecutor = new TimerTaskExecutor(new Timer() {
|
||||
// public void schedule(final TimerTask task, long delay) {
|
||||
// TimerTask wrapper = new TimerTask() {
|
||||
// public void run() {
|
||||
// list.add(task);
|
||||
// task.run();
|
||||
// }
|
||||
// };
|
||||
// super.schedule(wrapper, 400);
|
||||
// }
|
||||
// });
|
||||
// taskExecutor.afterPropertiesSet();
|
||||
// launcher.setTaskExecutor(taskExecutor);
|
||||
//
|
||||
// InterruptibleContainer container = new InterruptibleContainer();
|
||||
// launcher.setJobExecutorFacade(container);
|
||||
//
|
||||
// JobExecution execution = launcher.run(new SimpleJobIdentifier("foo"));
|
||||
// // give the thread some time to start up...
|
||||
// Thread.sleep(100);
|
||||
// // The launcher thinks it has started the job...
|
||||
// assertTrue(launcher.isRunning());
|
||||
// // ...but the task has not been started yet
|
||||
// assertEquals(0, list.size());
|
||||
// launcher.stop();
|
||||
// // ...and to shut down:
|
||||
// Thread.sleep(1000);
|
||||
// assertFalse(launcher.isRunning());
|
||||
// // The timer task has been started...
|
||||
// assertEquals(1, list.size());
|
||||
// // ...but the job is not executed
|
||||
// assertEquals(ExitStatus.UNKNOWN, execution.getExitStatus());
|
||||
// }
|
||||
//
|
||||
// public void testRunTwice() throws Exception {
|
||||
//
|
||||
// // Important (otherwise start() does not return!)
|
||||
// launcher.setTaskExecutor(new SimpleAsyncTaskExecutor());
|
||||
//
|
||||
// InterruptibleContainer container = new InterruptibleContainer();
|
||||
// launcher.setJobExecutorFacade(container);
|
||||
//
|
||||
// launcher.run(new SimpleJobIdentifier("foo"));
|
||||
// // give the thread some time to start up:
|
||||
// Thread.sleep(100);
|
||||
// assertTrue(launcher.isRunning());
|
||||
// try {
|
||||
// launcher.run(new SimpleJobIdentifier("foo"));
|
||||
// fail("Expected JobExecutionAlreadyRunningException");
|
||||
// } catch (JobExecutionAlreadyRunningException e) {
|
||||
// // expected
|
||||
// }
|
||||
// // give the thread some time to start up...
|
||||
// Thread.sleep(100);
|
||||
// launcher.stop();
|
||||
// // ...and to shut down:
|
||||
// Thread.sleep(400);
|
||||
// assertFalse(launcher.isRunning());
|
||||
// }
|
||||
//
|
||||
// public void testStatisticsRetrieved() throws Exception {
|
||||
// MockControl control = MockControl
|
||||
// .createControl(JobExecutorFacadeWithStatistics.class);
|
||||
// JobExecutorFacadeWithStatistics batchContainer = (JobExecutorFacadeWithStatistics) control
|
||||
// .getMock();
|
||||
// launcher.setJobExecutorFacade(batchContainer);
|
||||
//
|
||||
// Properties properties = PropertiesConverter.stringToProperties("a=b");
|
||||
// control.expectAndReturn(batchContainer.getStatistics(), properties);
|
||||
//
|
||||
// control.replay();
|
||||
// assertEquals(properties, launcher.getStatistics());
|
||||
// control.verify();
|
||||
// }
|
||||
//
|
||||
// public void testStatisticsNotRetrieved() throws Exception {
|
||||
// MockControl control = MockControl
|
||||
// .createControl(JobExecutorFacade.class);
|
||||
// JobExecutorFacade batchContainer = (JobExecutorFacade) control
|
||||
// .getMock();
|
||||
// launcher.setJobExecutorFacade(batchContainer);
|
||||
//
|
||||
// Properties properties = new Properties();
|
||||
// control.replay();
|
||||
// assertEquals(properties, launcher.getStatistics());
|
||||
// control.verify();
|
||||
// }
|
||||
//
|
||||
public void testPublishApplicationEvent() throws Exception {
|
||||
// final List list = new ArrayList();
|
||||
// launcher.setApplicationEventPublisher(new ApplicationEventPublisher() {
|
||||
// public void publishEvent(ApplicationEvent event) {
|
||||
// list.add(event);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// MockControl control = MockControl
|
||||
// .createControl(JobExecutorFacade.class);
|
||||
// JobExecutorFacade facade = (JobExecutorFacade) control.getMock();
|
||||
// launcher.setJobExecutorFacade(facade);
|
||||
// SimpleJobIdentifier jobRuntimeInformation = new SimpleJobIdentifier(
|
||||
// "spam");
|
||||
// JobExecution execution = new JobExecution(new JobInstance(
|
||||
// jobRuntimeInformation, null));
|
||||
// control.expectAndReturn(facade
|
||||
// .createExecutionFrom(jobRuntimeInformation), execution);
|
||||
// facade.start(execution);
|
||||
// control.setThrowable(new NoSuchJobException("SPAM"));
|
||||
//
|
||||
// control.replay();
|
||||
// launcher.run(jobRuntimeInformation);
|
||||
// assertEquals(1, list.size());
|
||||
// control.verify();
|
||||
}
|
||||
//
|
||||
// private class InterruptibleContainer implements JobExecutorFacade {
|
||||
// private volatile boolean running = true;
|
||||
//
|
||||
// private void start() {
|
||||
// while (running) {
|
||||
// try {
|
||||
// // 1 seconds should be long enough to allow the thread to be
|
||||
// // started and
|
||||
// // for interrupt to be called;
|
||||
// Thread.sleep(300);
|
||||
// } catch (InterruptedException ex) {
|
||||
// // thread interrupted, allow to exit normally
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void start(JobExecution execution)
|
||||
// throws NoSuchJobException {
|
||||
// start();
|
||||
// execution.setExitStatus(new ExitStatus(false, "COMPLETED_BY_TEST"));
|
||||
// }
|
||||
//
|
||||
// public JobExecution createExecutionFrom(JobIdentifier jobIdentifier)
|
||||
// throws NoSuchJobException {
|
||||
// return new JobExecution(new JobInstance(jobIdentifier, null));
|
||||
// }
|
||||
//
|
||||
// public void stop(JobExecution execution) {
|
||||
// running = false;
|
||||
// }
|
||||
//
|
||||
// public boolean isRunning() {
|
||||
// // not needed
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private interface JobExecutorFacadeWithStatistics extends
|
||||
// JobExecutorFacade, StatisticsProvider {
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.batch.execution.repository.dao;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -28,9 +27,6 @@ import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.JobInstanceProperties;
|
||||
import org.springframework.batch.core.domain.JobInstancePropertiesBuilder;
|
||||
import org.springframework.batch.core.repository.NoSuchBatchDomainObjectException;
|
||||
import org.springframework.batch.core.runtime.SimpleJobIdentifier;
|
||||
import org.springframework.batch.execution.runtime.DefaultJobIdentifier;
|
||||
import org.springframework.batch.execution.runtime.ScheduledJobIdentifier;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
|
||||
import org.springframework.util.ClassUtils;
|
||||
@@ -247,7 +243,6 @@ public abstract class AbstractJobDaoTests extends
|
||||
}
|
||||
|
||||
public void testJobWithSimpleJobIdentifier() throws Exception {
|
||||
SimpleJobIdentifier jobIdentifier = new SimpleJobIdentifier("Job1");
|
||||
|
||||
// Create job.
|
||||
jobInstance = jobDao.createJobInstance("test", jobInstanceProperties);
|
||||
|
||||
@@ -23,13 +23,11 @@ import java.util.Properties;
|
||||
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.JobIdentifier;
|
||||
import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.JobInstanceProperties;
|
||||
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.execution.runtime.ScheduledJobIdentifier;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.batch.restart.GenericRestartData;
|
||||
import org.springframework.batch.restart.RestartData;
|
||||
|
||||
@@ -22,7 +22,6 @@ import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.JobInstanceProperties;
|
||||
import org.springframework.batch.core.runtime.SimpleJobIdentifier;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;
|
||||
|
||||
@@ -23,7 +23,6 @@ import junit.framework.TestCase;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.JobInstanceProperties;
|
||||
import org.springframework.batch.core.runtime.SimpleJobIdentifier;
|
||||
|
||||
public class MapJobDaoTests extends TestCase {
|
||||
|
||||
|
||||
@@ -18,19 +18,15 @@ package org.springframework.batch.execution.resource;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.domain.Job;
|
||||
import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobIdentifier;
|
||||
import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.JobInstanceProperties;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
import org.springframework.batch.core.domain.StepInstance;
|
||||
import org.springframework.batch.execution.resource.BatchResourceFactoryBean;
|
||||
import org.springframework.batch.execution.runtime.ScheduledJobIdentifier;
|
||||
import org.springframework.batch.execution.scope.SimpleStepContext;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
|
||||
@@ -30,7 +30,6 @@ import org.springframework.batch.core.domain.StepContribution;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
import org.springframework.batch.core.domain.StepInstance;
|
||||
import org.springframework.batch.core.domain.StepSupport;
|
||||
import org.springframework.batch.core.runtime.SimpleJobIdentifier;
|
||||
import org.springframework.batch.core.tasklet.Tasklet;
|
||||
import org.springframework.batch.execution.repository.SimpleJobRepository;
|
||||
import org.springframework.batch.execution.repository.dao.MapJobDao;
|
||||
|
||||
@@ -23,7 +23,6 @@ import junit.framework.TestCase;
|
||||
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.JobIdentifier;
|
||||
import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.JobInstanceProperties;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
@@ -31,7 +30,6 @@ import org.springframework.batch.core.domain.StepInstance;
|
||||
import org.springframework.batch.core.domain.StepSupport;
|
||||
import org.springframework.batch.core.executor.StepInterruptedException;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.runtime.SimpleJobIdentifier;
|
||||
import org.springframework.batch.core.tasklet.Tasklet;
|
||||
import org.springframework.batch.execution.repository.SimpleJobRepository;
|
||||
import org.springframework.batch.execution.repository.dao.JobDao;
|
||||
@@ -64,7 +62,6 @@ public class StepExecutorInterruptionTests extends TestCase {
|
||||
Job jobConfiguration = new Job();
|
||||
stepConfiguration = new SimpleStep();
|
||||
jobConfiguration.addStep(stepConfiguration);
|
||||
JobIdentifier runtimeInformation = new SimpleJobIdentifier("TestJob");
|
||||
jobConfiguration.setBeanName("testJob");
|
||||
job = jobRepository.createJobExecution(jobConfiguration, new JobInstanceProperties()).getJobInstance();
|
||||
executor = new SimpleStepExecutor();
|
||||
|
||||
@@ -1,114 +1,115 @@
|
||||
<?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.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">
|
||||
|
||||
<bean id="simpleContainerLauncher"
|
||||
class="org.springframework.batch.execution.launch.SimpleJobLauncher">
|
||||
<property name="jobRepository" ref="simpleJobRepository" />
|
||||
<property name="jobExecutor" ref="jobLifecycle" />
|
||||
</bean>
|
||||
|
||||
<bean id="jobConfigurationRegistry"
|
||||
class="org.springframework.batch.execution.configuration.MapJobRegistry" />
|
||||
|
||||
<bean id="jobLifecycle"
|
||||
class="org.springframework.batch.execution.job.DefaultJobExecutor">
|
||||
<property name="jobRepository" ref="simpleJobRepository" />
|
||||
<property name="stepExecutorFactory">
|
||||
<bean
|
||||
class="org.springframework.batch.execution.step.PrototypeBeanStepExecutorFactory">
|
||||
<property name="stepExecutorName" value="stepLifecycle" />
|
||||
</bean>
|
||||
</property>
|
||||
</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.SimpleStep"
|
||||
abstract="true">
|
||||
<property name="allowStartIfComplete" value="true" />
|
||||
<property name="saveRestartData" value="false" />
|
||||
<property name="exceptionHandler">
|
||||
<bean
|
||||
class="org.springframework.batch.repeat.exception.handler.SimpleLimitExceptionHandler">
|
||||
<property name="limit" value="5" />
|
||||
<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" />
|
||||
</bean>
|
||||
|
||||
<bean id="transactionManager"
|
||||
class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
|
||||
|
||||
<bean id="simpleJobRepository"
|
||||
class="org.springframework.batch.execution.repository.SimpleJobRepository">
|
||||
<constructor-arg ref="jobDao" />
|
||||
<constructor-arg ref="stepDao" />
|
||||
</bean>
|
||||
|
||||
<bean id="jobDao"
|
||||
class="org.springframework.batch.execution.repository.dao.MapJobDao" />
|
||||
<!-- init-method="clear"/-->
|
||||
|
||||
<bean id="stepDao"
|
||||
class="org.springframework.batch.execution.repository.dao.MapStepDao" />
|
||||
<!-- init-method="clear"/-->
|
||||
|
||||
<bean id="jobRuntimeInformationFactory"
|
||||
class="org.springframework.batch.execution.runtime.ScheduledJobIdentifierFactory">
|
||||
<property name="jobKey" value="TestStream" />
|
||||
<property name="scheduleDate" value="20070505" />
|
||||
</bean>
|
||||
|
||||
<bean
|
||||
class="org.springframework.batch.execution.bootstrap.support.SimpleJvmExitCodeMapper" />
|
||||
|
||||
<bean
|
||||
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
|
||||
class="org.springframework.batch.execution.bootstrap.support.SimpleCommandLineJobRunnerTests$StubSystemExiter" />
|
||||
|
||||
</beans>
|
||||
<bean id="simpleContainerLauncher"
|
||||
class="org.springframework.batch.execution.launch.SimpleJobLauncher">
|
||||
<property name="jobRepository" ref="simpleJobRepository" />
|
||||
<property name="jobExecutor" ref="jobLifecycle" />
|
||||
</bean>
|
||||
|
||||
<bean id="jobConfigurationRegistry"
|
||||
class="org.springframework.batch.execution.configuration.MapJobRegistry" />
|
||||
|
||||
<bean id="jobLifecycle"
|
||||
class="org.springframework.batch.execution.job.DefaultJobExecutor">
|
||||
<property name="jobRepository" ref="simpleJobRepository" />
|
||||
<property name="stepExecutorFactory">
|
||||
<bean
|
||||
class="org.springframework.batch.execution.step.PrototypeBeanStepExecutorFactory">
|
||||
<property name="stepExecutorName" value="stepLifecycle" />
|
||||
</bean>
|
||||
</property>
|
||||
</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.SimpleStep"
|
||||
abstract="true">
|
||||
<property name="allowStartIfComplete" value="true" />
|
||||
<property name="saveRestartData" value="false" />
|
||||
<property name="exceptionHandler">
|
||||
<bean
|
||||
class="org.springframework.batch.repeat.exception.handler.SimpleLimitExceptionHandler">
|
||||
<property name="limit" value="5" />
|
||||
<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" />
|
||||
</bean>
|
||||
|
||||
<bean id="transactionManager"
|
||||
class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
|
||||
|
||||
<bean id="simpleJobRepository"
|
||||
class="org.springframework.batch.execution.repository.SimpleJobRepository">
|
||||
<constructor-arg ref="jobDao" />
|
||||
<constructor-arg ref="stepDao" />
|
||||
</bean>
|
||||
|
||||
<bean id="jobDao"
|
||||
class="org.springframework.batch.execution.repository.dao.MapJobDao" />
|
||||
<!-- init-method="clear"/-->
|
||||
|
||||
<bean id="stepDao"
|
||||
class="org.springframework.batch.execution.repository.dao.MapStepDao" />
|
||||
<!-- init-method="clear"/-->
|
||||
|
||||
<bean id="jobRuntimeInformationFactory"
|
||||
class="org.springframework.batch.execution.runtime.ScheduledJobIdentifierFactory">
|
||||
<property name="jobKey" value="TestStream" />
|
||||
<property name="scheduleDate" value="20070505" />
|
||||
</bean>
|
||||
|
||||
<bean
|
||||
class="org.springframework.batch.execution.bootstrap.support.SimpleJvmExitCodeMapper" />
|
||||
|
||||
<bean
|
||||
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
|
||||
class="org.springframework.batch.execution.bootstrap.support.SimpleCommandLineJobRunnerTests$StubSystemExiter" />
|
||||
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user