spring-batch JobParserJobFactoryBean 源码
spring-batch JobParserJobFactoryBean 代码
文件路径:/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobParserJobFactoryBean.java
/*
* Copyright 2006-2022 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
*
* https://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.xml;
import org.springframework.batch.core.JobExecutionListener;
import org.springframework.batch.core.JobParametersIncrementer;
import org.springframework.batch.core.JobParametersValidator;
import org.springframework.batch.core.job.flow.Flow;
import org.springframework.batch.core.job.flow.FlowJob;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.SmartFactoryBean;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* This {@link FactoryBean} is used by the batch namespace parser to create
* {@link FlowJob} objects. It stores all of the properties that are configurable on the
* <job/>.
*
* @author Dan Garrette
* @author Dave Syer
* @since 2.0.1
*/
public class JobParserJobFactoryBean implements SmartFactoryBean<FlowJob> {
private String name;
private Boolean restartable;
private JobRepository jobRepository;
private JobParametersValidator jobParametersValidator;
private JobExecutionListener[] jobExecutionListeners;
private JobParametersIncrementer jobParametersIncrementer;
private Flow flow;
/**
* Constructor for the factory bean that initializes the name.
* @param name The name to be used by the factory bean.
*/
public JobParserJobFactoryBean(String name) {
this.name = name;
}
@Override
public final FlowJob getObject() throws Exception {
Assert.isTrue(StringUtils.hasText(name), "The job must have an id.");
FlowJob flowJob = new FlowJob(name);
if (restartable != null) {
flowJob.setRestartable(restartable);
}
if (jobRepository != null) {
flowJob.setJobRepository(jobRepository);
}
if (jobParametersValidator != null) {
flowJob.setJobParametersValidator(jobParametersValidator);
}
if (jobExecutionListeners != null) {
flowJob.setJobExecutionListeners(jobExecutionListeners);
}
if (jobParametersIncrementer != null) {
flowJob.setJobParametersIncrementer(jobParametersIncrementer);
}
if (flow != null) {
flowJob.setFlow(flow);
}
flowJob.afterPropertiesSet();
return flowJob;
}
/**
* Set the restartable flag for the factory bean.
* @param restartable The restartable flag to be used by the factory bean.
*/
public void setRestartable(Boolean restartable) {
this.restartable = restartable;
}
/**
* Set the {@link JobRepository} for the factory bean.
* @param jobRepository The {@link JobRepository} to be used by the factory bean.
*/
public void setJobRepository(JobRepository jobRepository) {
this.jobRepository = jobRepository;
}
/**
* Set the {@link JobParametersValidator} for the factory bean.
* @param jobParametersValidator The {@link JobParametersValidator} to be used by the
* factory bean.
*/
public void setJobParametersValidator(JobParametersValidator jobParametersValidator) {
this.jobParametersValidator = jobParametersValidator;
}
/**
* @return The {@link JobRepository} used by the factory bean.
*/
public JobRepository getJobRepository() {
return this.jobRepository;
}
public void setJobExecutionListeners(JobExecutionListener[] jobExecutionListeners) {
this.jobExecutionListeners = jobExecutionListeners;
}
/**
* Set the {@link JobParametersIncrementer} for the factory bean.
* @param jobParametersIncrementer The {@link JobParametersIncrementer} to be used by
* the factory bean.
*/
public void setJobParametersIncrementer(JobParametersIncrementer jobParametersIncrementer) {
this.jobParametersIncrementer = jobParametersIncrementer;
}
/**
* Set the flow for the factory bean.
* @param flow The {@link Flow} to be used by the factory bean.
*/
public void setFlow(Flow flow) {
this.flow = flow;
}
@Override
public Class<FlowJob> getObjectType() {
return FlowJob.class;
}
@Override
public boolean isSingleton() {
return true;
}
@Override
public boolean isEagerInit() {
return true;
}
@Override
public boolean isPrototype() {
return false;
}
}
相关信息
相关文章
spring-batch AbstractFlowParser 源码
spring-batch AbstractListenerParser 源码
spring-batch AbstractStepParser 源码
spring-batch BeanDefinitionUtils 源码
spring-batch ChunkElementParser 源码
spring-batch CoreNamespaceHandler 源码
spring-batch CoreNamespacePostProcessor 源码
spring-batch CoreNamespaceUtils 源码
0
赞
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦