diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/BatchConfigurationException.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/BatchConfigurationException.java new file mode 100644 index 000000000..6b1da62a6 --- /dev/null +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/BatchConfigurationException.java @@ -0,0 +1,34 @@ +/* + * Copyright 2014 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.configuration; + +/** + * Represents an error has occured in the configuration of base batch + * infrastructure (creation of a {@link org.springframework.batch.core.repository.JobRepository} + * for example. + * + * @author Michael Minella + * @since 2.2.6 + */ +public class BatchConfigurationException extends RuntimeException { + + /** + * @param t an exception to be wrapped + */ + public BatchConfigurationException(Throwable t) { + super(t); + } +} diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/DefaultBatchConfigurer.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/DefaultBatchConfigurer.java index 5564bbd86..213dff77a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/DefaultBatchConfigurer.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/DefaultBatchConfigurer.java @@ -17,6 +17,12 @@ package org.springframework.batch.core.configuration.annotation; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.batch.core.configuration.BatchConfigurationException; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import javax.sql.DataSource; + import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.launch.support.SimpleJobLauncher; import org.springframework.batch.core.repository.JobRepository; @@ -25,12 +31,8 @@ import org.springframework.batch.core.repository.support.MapJobRepositoryFactory import org.springframework.batch.support.transaction.ResourcelessTransactionManager; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.datasource.DataSourceTransactionManager; -import org.springframework.stereotype.Component; import org.springframework.transaction.PlatformTransactionManager; -import javax.annotation.PostConstruct; -import javax.sql.DataSource; - @Component public class DefaultBatchConfigurer implements BatchConfigurer { private static final Log logger = LogFactory.getLog(DefaultBatchConfigurer.class); @@ -68,6 +70,7 @@ public class DefaultBatchConfigurer implements BatchConfigurer { } @PostConstruct +<<<<<<< HEAD public void initialize() throws Exception { if(dataSource == null) { logger.warn("No datasource was provided...using a Map based JobRepository"); @@ -84,6 +87,15 @@ public class DefaultBatchConfigurer implements BatchConfigurer { } this.jobLauncher = createJobLauncher(); +======= + public void initialize() throws BatchConfigurationException { + try { + this.jobRepository = createJobRepository(); + this.jobLauncher = createJobLauncher(); + } catch (Exception e) { + throw new BatchConfigurationException(e); + } +>>>>>>> 3a2cac3... BATCH-2189: Wrapped checked exception with a custom RuntimeException to follow rules for @PostConstruct } private JobLauncher createJobLauncher() throws Exception { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/SimpleFlow.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/SimpleFlow.java index dff195011..cb4ccb6bd 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/SimpleFlow.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/SimpleFlow.java @@ -183,25 +183,9 @@ public class SimpleFlow implements Flow, InitializingBean { } -<<<<<<< HEAD protected Map> getTransitionMap() { return transitionMap; } -======= - private boolean isFlowContinued(State state, FlowExecutionStatus status, StepExecution stepExecution) { - boolean continued = true; - - continued = state != null && status!=FlowExecutionStatus.STOPPED; - - if(stepExecution != null) { - Boolean reRun = (Boolean) stepExecution.getExecutionContext().get("batch.restart"); - Boolean executed = (Boolean) stepExecution.getExecutionContext().get("batch.executed"); - - if((executed == null || !executed) && reRun != null && reRun && status == FlowExecutionStatus.STOPPED && !state.getName().endsWith(stepExecution.getStepName())) { - continued = true; - } - } ->>>>>>> 4e5b4c1... BATCH-2016: Added new flag to indicate if the step is being executed on protected Map getStateMap() { return stateMap;