BATCH-2189: Wrapped checked exception with a custom RuntimeException to follow rules for @PostConstruct
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ package org.springframework.batch.core.configuration.annotation;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.batch.core.configuration.BatchConfigurationException;
|
||||
import org.springframework.batch.core.launch.JobLauncher;
|
||||
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
@@ -63,9 +64,13 @@ public class DefaultBatchConfigurer implements BatchConfigurer {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void initialize() throws Exception {
|
||||
this.jobRepository = createJobRepository();
|
||||
this.jobLauncher = createJobLauncher();
|
||||
public void initialize() throws BatchConfigurationException {
|
||||
try {
|
||||
this.jobRepository = createJobRepository();
|
||||
this.jobLauncher = createJobLauncher();
|
||||
} catch (Exception e) {
|
||||
throw new BatchConfigurationException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private JobLauncher createJobLauncher() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user