RESOLVED - issue BATCH-158: Dependency cycle between execution.step and execution.step.simple

http://opensource.atlassian.com/projects/spring/browse/BATCH-158

StepConfiguration had to pick up an extra flag in the interface, and the configuration implementations had to be separate from the executor implementations.

Also fixed a cycle in core (JobIdentifier is part of domain).
This commit is contained in:
dsyer
2007-10-05 09:05:50 +00:00
parent 4ae712f35f
commit fce6554597
32 changed files with 202 additions and 99 deletions

View File

@@ -26,7 +26,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.core.configuration.JobConfiguration;
import org.springframework.batch.core.configuration.NoSuchJobConfigurationException;
import org.springframework.batch.core.runtime.JobIdentifier;
import org.springframework.batch.core.domain.JobIdentifier;
import org.springframework.batch.core.runtime.JobIdentifierFactory;
import org.springframework.batch.execution.facade.JobExecutorFacade;
import org.springframework.batch.execution.facade.NoSuchJobExecutionException;
@@ -252,7 +252,7 @@ public abstract class AbstractJobLauncher implements JobLauncher,
*
* @throws NoSuchJobExecutionException
*
* @see org.springframework.batch.execution.bootstrap.JobLauncher#stop(org.springframework.batch.core.runtime.JobIdentifier)
* @see org.springframework.batch.execution.bootstrap.JobLauncher#stop(org.springframework.batch.core.domain.JobIdentifier)
* @see BatchContainer#stop(JobRuntimeInformation))
*/
final public void stop(JobIdentifier runtimeInformation)

View File

@@ -16,7 +16,7 @@
package org.springframework.batch.execution.bootstrap;
import org.springframework.batch.core.configuration.NoSuchJobConfigurationException;
import org.springframework.batch.core.runtime.JobIdentifier;
import org.springframework.batch.core.domain.JobIdentifier;
import org.springframework.batch.execution.facade.JobExecutorFacade;
import org.springframework.batch.repeat.ExitStatus;

View File

@@ -18,7 +18,7 @@ package org.springframework.batch.execution.bootstrap;
import org.springframework.batch.core.configuration.JobConfiguration;
import org.springframework.batch.core.configuration.NoSuchJobConfigurationException;
import org.springframework.batch.core.runtime.JobIdentifier;
import org.springframework.batch.core.domain.JobIdentifier;
import org.springframework.batch.core.runtime.JobIdentifierFactory;
import org.springframework.batch.execution.facade.JobExecutorFacade;
import org.springframework.batch.execution.runtime.ScheduledJobIdentifierFactory;

View File

@@ -23,7 +23,7 @@ import javax.management.Notification;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.core.configuration.NoSuchJobConfigurationException;
import org.springframework.batch.core.runtime.JobIdentifier;
import org.springframework.batch.core.domain.JobIdentifier;
import org.springframework.batch.execution.facade.JobExecutorFacade;
import org.springframework.batch.execution.facade.NoSuchJobExecutionException;
import org.springframework.batch.repeat.ExitStatus;

View File

@@ -17,7 +17,7 @@
package org.springframework.batch.execution.facade;
import org.springframework.batch.core.configuration.NoSuchJobConfigurationException;
import org.springframework.batch.core.runtime.JobIdentifier;
import org.springframework.batch.core.domain.JobIdentifier;
import org.springframework.batch.repeat.ExitStatus;
/**

View File

@@ -23,11 +23,11 @@ import org.springframework.batch.core.configuration.JobConfiguration;
import org.springframework.batch.core.configuration.JobConfigurationLocator;
import org.springframework.batch.core.configuration.NoSuchJobConfigurationException;
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.executor.JobExecutor;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.runtime.JobExecutionRegistry;
import org.springframework.batch.core.runtime.JobIdentifier;
import org.springframework.batch.execution.job.DefaultJobExecutor;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.batch.repeat.RepeatContext;
@@ -101,7 +101,7 @@ public class SimpleJobExecutorFacade implements JobExecutorFacade, StatisticsPro
* {@link JobIdentifier} and the {@link JobConfigurationLocator}.
*
* @see org.springframework.batch.execution.facade.JobExecutorFacade#start(org.springframework.batch.execution.common.domain.JobConfiguration,
* org.springframework.batch.core.runtime.JobIdentifier)
* org.springframework.batch.core.domain.JobIdentifier)
*
* @throws IllegalArgumentException if the runtime information is null or
* its name is null

View File

@@ -23,9 +23,9 @@ import java.util.Map;
import java.util.Set;
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.runtime.JobExecutionRegistry;
import org.springframework.batch.core.runtime.JobIdentifier;
/**
* Simple in-memory implementation of {@link JobExecutionRegistry}.

View File

@@ -20,7 +20,7 @@ import java.util.Date;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.springframework.batch.core.runtime.JobIdentifier;
import org.springframework.batch.core.domain.JobIdentifier;
import org.springframework.batch.core.runtime.SimpleJobIdentifier;
public class ScheduledJobIdentifier extends SimpleJobIdentifier implements JobIdentifier {

View File

@@ -18,7 +18,7 @@ package org.springframework.batch.execution.runtime;
import java.util.Date;
import org.springframework.batch.core.runtime.JobIdentifier;
import org.springframework.batch.core.domain.JobIdentifier;
import org.springframework.batch.core.runtime.JobIdentifierFactory;
/**

View File

@@ -23,7 +23,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.springframework.batch.core.runtime.JobIdentifier;
import org.springframework.batch.core.domain.JobIdentifier;
import org.springframework.batch.repeat.context.SynchronizedAttributeAccessor;
/**

View File

@@ -15,7 +15,7 @@
*/
package org.springframework.batch.execution.scope;
import org.springframework.batch.core.runtime.JobIdentifier;
import org.springframework.batch.core.domain.JobIdentifier;
import org.springframework.core.AttributeAccessor;
/**

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.execution.step.simple;
package org.springframework.batch.execution.step;
import org.springframework.batch.core.configuration.StepConfiguration;
import org.springframework.batch.core.configuration.StepConfigurationSupport;
@@ -33,8 +33,6 @@ public class AbstractStepConfiguration extends StepConfigurationSupport implemen
private int skipLimit = 0;
private boolean saveRestartData = false;
private ExceptionHandler exceptionHandler;
/**
@@ -80,12 +78,4 @@ public class AbstractStepConfiguration extends StepConfigurationSupport implemen
return skipLimit;
}
public void setSaveRestartData(boolean saveRestartData) {
this.saveRestartData = saveRestartData;
}
public boolean isSaveRestartData() {
return saveRestartData;
}
}

View File

@@ -0,0 +1,68 @@
/*
* 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.step;
import org.springframework.batch.core.configuration.StepConfiguration;
import org.springframework.batch.core.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatOperations;
/**
* {@link StepConfiguration} implementation that allows full configuration of
* the {@link RepeatOperations} that will be used in the chunk (inner loop).
*
* @author Lucas Ward
* @author Dave Syer
*
*/
public class ChunkOperationsStepConfiguration extends AbstractStepConfiguration implements RepeatOperationsHolder {
// default StepExecutor is null
private RepeatOperations chunkOperations;
public ChunkOperationsStepConfiguration() {
super();
}
public ChunkOperationsStepConfiguration(RepeatOperations repeatOperations) {
this();
this.chunkOperations = repeatOperations;
}
public ChunkOperationsStepConfiguration(Tasklet module) {
this();
setTasklet(module);
}
/**
* Public accessor for the chunkOperations property.
*
* @return the executor
*/
public RepeatOperations getChunkOperations() {
return chunkOperations;
}
/**
* Public setter for the chunkOperations.
*
* @param chunkOperations the repeatOperations to set
*/
public void setChunkOperations(RepeatOperations chunkOperations) {
this.chunkOperations = chunkOperations;
}
}

View File

@@ -18,7 +18,6 @@ package org.springframework.batch.execution.step;
import org.springframework.batch.core.configuration.StepConfiguration;
import org.springframework.batch.core.executor.StepExecutor;
import org.springframework.batch.core.executor.StepExecutorFactory;
import org.springframework.batch.execution.step.simple.SimpleStepConfiguration;
import org.springframework.batch.execution.step.simple.SimpleStepExecutor;
import org.springframework.batch.repeat.RepeatOperations;
import org.springframework.batch.repeat.policy.SimpleCompletionPolicy;
@@ -42,7 +41,7 @@ import org.springframework.util.Assert;
* @author Dave Syer
*
*/
public class DefaultStepExecutorFactory implements StepExecutorFactory,
public class PrototypeBeanStepExecutorFactory implements StepExecutorFactory,
BeanFactoryAware, InitializingBean {
private String stepExecutorName = null;

View File

@@ -0,0 +1,56 @@
/*
* 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.step;
import org.springframework.batch.core.configuration.StepConfiguration;
import org.springframework.batch.core.tasklet.Tasklet;
/**
* Simple {@link StepConfiguration} good enough for most purposes and easy to
* configure simple properties, principally the commit interval.
*
* @author Lucas Ward
* @author Dave Syer
*
*/
public class SimpleStepConfiguration extends AbstractStepConfiguration {
// default commit interval is one
private int commitInterval = 1;
public SimpleStepConfiguration() {
super();
}
public SimpleStepConfiguration(String name) {
super(name);
}
public SimpleStepConfiguration(Tasklet module) {
this();
setTasklet(module);
}
public void setCommitInterval(int commitInterval) {
this.commitInterval = commitInterval;
}
public int getCommitInterval() {
return commitInterval;
}
}

View File

@@ -19,7 +19,6 @@ import org.springframework.batch.core.configuration.StepConfiguration;
import org.springframework.batch.core.executor.StepExecutor;
import org.springframework.batch.core.executor.StepExecutorFactory;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.execution.step.simple.SimpleStepConfiguration;
import org.springframework.batch.execution.step.simple.SimpleStepExecutor;
import org.springframework.batch.repeat.RepeatOperations;
import org.springframework.batch.repeat.policy.SimpleCompletionPolicy;

View File

@@ -166,7 +166,7 @@ public class SimpleStepExecutor implements StepExecutor {
stepExecution.setStartTime(new Timestamp(System.currentTimeMillis()));
updateStatus(stepExecution, BatchStatus.STARTED);
final boolean saveRestartData = ((AbstractStepConfiguration) configuration).isSaveRestartData();
final boolean saveRestartData = configuration.isSaveRestartData();
if (saveRestartData && isRestart) {
restoreFromRestartData(module, step.getRestartData());