From 24c324fd73ce879abab3dedac3a643eda78bb745 Mon Sep 17 00:00:00 2001 From: dsyer Date: Fri, 5 Oct 2007 09:11:58 +0000 Subject: [PATCH] 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). --- .../repository/SimpleJobRepository.java | 7 +- .../repository/dao/EntityNameInterceptor.java | 2 +- .../execution/repository/dao/JobDao.java | 2 +- .../execution/repository/dao/MapJobDao.java | 2 +- .../execution/repository/dao/SqlJobDao.java | 2 +- .../ChunkOperationsStepConfiguration.java | 69 ------------------- .../step/simple/SimpleStepConfiguration.java | 56 --------------- 7 files changed, 7 insertions(+), 133 deletions(-) delete mode 100644 execution/src/main/java/org/springframework/batch/execution/step/simple/ChunkOperationsStepConfiguration.java delete mode 100644 execution/src/main/java/org/springframework/batch/execution/step/simple/SimpleStepConfiguration.java diff --git a/execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java b/execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java index 04b6c7348..4f7fdeba5 100644 --- a/execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java +++ b/execution/src/main/java/org/springframework/batch/execution/repository/SimpleJobRepository.java @@ -24,16 +24,15 @@ import java.util.Properties; import org.springframework.batch.core.configuration.JobConfiguration; import org.springframework.batch.core.configuration.StepConfiguration; 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.StepExecution; import org.springframework.batch.core.domain.StepInstance; import org.springframework.batch.core.repository.BatchRestartException; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.runtime.JobIdentifier; import org.springframework.batch.execution.repository.dao.JobDao; import org.springframework.batch.execution.repository.dao.StepDao; import org.springframework.batch.restart.GenericRestartData; -import org.springframework.dao.IncorrectResultSizeDataAccessException; import org.springframework.util.Assert; /** @@ -117,8 +116,8 @@ public class SimpleJobRepository implements JobRepository { } else { // More than one job found, throw exception - throw new IncorrectResultSizeDataAccessException("Error restarting job, more than one JobInstance found for: " - + jobConfiguration.toString(), 1, jobs.size()); + throw new BatchRestartException("Error restarting job, more than one JobInstance found for: " + + jobConfiguration.toString()); } } diff --git a/execution/src/main/java/org/springframework/batch/execution/repository/dao/EntityNameInterceptor.java b/execution/src/main/java/org/springframework/batch/execution/repository/dao/EntityNameInterceptor.java index 5d9d1aadb..6fd89e2c0 100644 --- a/execution/src/main/java/org/springframework/batch/execution/repository/dao/EntityNameInterceptor.java +++ b/execution/src/main/java/org/springframework/batch/execution/repository/dao/EntityNameInterceptor.java @@ -5,8 +5,8 @@ import java.util.Iterator; import java.util.Map; import org.hibernate.EmptyInterceptor; +import org.springframework.batch.core.domain.JobIdentifier; import org.springframework.batch.core.domain.JobInstance; -import org.springframework.batch.core.runtime.JobIdentifier; import org.springframework.batch.execution.runtime.ScheduledJobIdentifier; import org.springframework.util.ClassUtils; diff --git a/execution/src/main/java/org/springframework/batch/execution/repository/dao/JobDao.java b/execution/src/main/java/org/springframework/batch/execution/repository/dao/JobDao.java index c0562dac9..fb96dcca5 100644 --- a/execution/src/main/java/org/springframework/batch/execution/repository/dao/JobDao.java +++ b/execution/src/main/java/org/springframework/batch/execution/repository/dao/JobDao.java @@ -19,8 +19,8 @@ package org.springframework.batch.execution.repository.dao; import java.util.List; 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.JobIdentifier; /** * Data Access Object for jobs. diff --git a/execution/src/main/java/org/springframework/batch/execution/repository/dao/MapJobDao.java b/execution/src/main/java/org/springframework/batch/execution/repository/dao/MapJobDao.java index b2532383e..9a77b7537 100644 --- a/execution/src/main/java/org/springframework/batch/execution/repository/dao/MapJobDao.java +++ b/execution/src/main/java/org/springframework/batch/execution/repository/dao/MapJobDao.java @@ -23,8 +23,8 @@ 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.JobIdentifier; import org.springframework.batch.support.transaction.TransactionAwareProxyFactory; public class MapJobDao implements JobDao { diff --git a/execution/src/main/java/org/springframework/batch/execution/repository/dao/SqlJobDao.java b/execution/src/main/java/org/springframework/batch/execution/repository/dao/SqlJobDao.java index 35f5fc05f..dfd9c9ebf 100644 --- a/execution/src/main/java/org/springframework/batch/execution/repository/dao/SqlJobDao.java +++ b/execution/src/main/java/org/springframework/batch/execution/repository/dao/SqlJobDao.java @@ -22,9 +22,9 @@ import java.util.List; import org.springframework.batch.core.domain.BatchStatus; 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.repository.NoSuchBatchDomainObjectException; -import org.springframework.batch.core.runtime.JobIdentifier; import org.springframework.batch.execution.runtime.ScheduledJobIdentifier; import org.springframework.batch.repeat.ExitStatus; import org.springframework.beans.factory.InitializingBean; diff --git a/execution/src/main/java/org/springframework/batch/execution/step/simple/ChunkOperationsStepConfiguration.java b/execution/src/main/java/org/springframework/batch/execution/step/simple/ChunkOperationsStepConfiguration.java deleted file mode 100644 index 9ff54d3e0..000000000 --- a/execution/src/main/java/org/springframework/batch/execution/step/simple/ChunkOperationsStepConfiguration.java +++ /dev/null @@ -1,69 +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.step.simple; - -import org.springframework.batch.core.configuration.StepConfiguration; -import org.springframework.batch.core.tasklet.Tasklet; -import org.springframework.batch.execution.step.RepeatOperationsHolder; -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; - } - -} diff --git a/execution/src/main/java/org/springframework/batch/execution/step/simple/SimpleStepConfiguration.java b/execution/src/main/java/org/springframework/batch/execution/step/simple/SimpleStepConfiguration.java deleted file mode 100644 index b6bdd667c..000000000 --- a/execution/src/main/java/org/springframework/batch/execution/step/simple/SimpleStepConfiguration.java +++ /dev/null @@ -1,56 +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.step.simple; - -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; - } - -}