BATCH-2189: Wrapped checked exception with a custom RuntimeException to follow rules for @PostConstruct

This commit is contained in:
Michael Minella
2014-03-18 13:06:21 -05:00
parent 3dc2ea3cb0
commit b0e1f30a57
3 changed files with 50 additions and 20 deletions

View File

@@ -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);
}
}

View File

@@ -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 {

View File

@@ -183,25 +183,9 @@ public class SimpleFlow implements Flow, InitializingBean {
}
<<<<<<< HEAD
protected Map<String, Set<StateTransition>> 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<String, State> getStateMap() {
return stateMap;