spring BatchProperties 源码

  • 2022-08-12
  • 浏览 (408)

springboot BatchProperties 代码

文件路径:/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchProperties.java

/*
 * Copyright 2012-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.boot.autoconfigure.batch;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.sql.init.DatabaseInitializationMode;

/**
 * Configuration properties for Spring Batch.
 *
 * @author Stephane Nicoll
 * @author Eddú Meléndez
 * @author Vedran Pavic
 * @author Mukul Kumar Chaundhyan
 * @since 1.2.0
 */
@ConfigurationProperties(prefix = "spring.batch")
public class BatchProperties {

	private final Job job = new Job();

	private final Jdbc jdbc = new Jdbc();

	public Job getJob() {
		return this.job;
	}

	public Jdbc getJdbc() {
		return this.jdbc;
	}

	public static class Job {

		/**
		 * Job name to execute on startup. Must be specified if multiple Jobs are found in
		 * the context.
		 */
		private String name = "";

		public String getName() {
			return this.name;
		}

		public void setName(String name) {
			this.name = name;
		}

	}

	public static class Jdbc {

		private static final String DEFAULT_SCHEMA_LOCATION = "classpath:org/springframework/"
				+ "batch/core/schema-@@platform@@.sql";

		/**
		 * Transaction isolation level to use when creating job meta-data for new jobs.
		 * Auto-detected based on whether JPA is being used or not.
		 */
		private Isolation isolationLevelForCreate;

		/**
		 * Path to the SQL file to use to initialize the database schema.
		 */
		private String schema = DEFAULT_SCHEMA_LOCATION;

		/**
		 * Platform to use in initialization scripts if the @@platform@@ placeholder is
		 * used. Auto-detected by default.
		 */
		private String platform;

		/**
		 * Table prefix for all the batch meta-data tables.
		 */
		private String tablePrefix;

		/**
		 * Database schema initialization mode.
		 */
		private DatabaseInitializationMode initializeSchema = DatabaseInitializationMode.EMBEDDED;

		public Isolation getIsolationLevelForCreate() {
			return this.isolationLevelForCreate;
		}

		public void setIsolationLevelForCreate(Isolation isolationLevelForCreate) {
			this.isolationLevelForCreate = isolationLevelForCreate;
		}

		public String getSchema() {
			return this.schema;
		}

		public void setSchema(String schema) {
			this.schema = schema;
		}

		public String getPlatform() {
			return this.platform;
		}

		public void setPlatform(String platform) {
			this.platform = platform;
		}

		public String getTablePrefix() {
			return this.tablePrefix;
		}

		public void setTablePrefix(String tablePrefix) {
			this.tablePrefix = tablePrefix;
		}

		public DatabaseInitializationMode getInitializeSchema() {
			return this.initializeSchema;
		}

		public void setInitializeSchema(DatabaseInitializationMode initializeSchema) {
			this.initializeSchema = initializeSchema;
		}

	}

	/**
	 * Available transaction isolation levels.
	 */
	public enum Isolation {

		/**
		 * Use the default isolation level of the underlying datastore.
		 */
		DEFAULT,

		/**
		 * Indicates that dirty reads, non-repeatable reads and phantom reads can occur.
		 */
		READ_UNCOMMITTED,

		/**
		 * Indicates that dirty reads are prevented; non-repeatable reads and phantom
		 * reads can occur.
		 */
		READ_COMMITTED,

		/**
		 * Indicates that dirty reads and non-repeatable reads are prevented; phantom
		 * reads can occur.
		 */
		REPEATABLE_READ,

		/**
		 * Indicate that dirty reads, non-repeatable reads and phantom reads are
		 * prevented.
		 */
		SERIALIZABLE;

		private static final String PREFIX = "ISOLATION_";

		String toIsolationName() {
			return PREFIX + name();
		}

	}

}

相关信息

spring 源码目录

相关文章

spring BasicBatchConfigurer 源码

spring BatchAutoConfiguration 源码

spring BatchConfigurerConfiguration 源码

spring BatchDataSource 源码

spring BatchDataSourceScriptDatabaseInitializer 源码

spring JobExecutionEvent 源码

spring JobExecutionExitCodeGenerator 源码

spring JobLauncherApplicationRunner 源码

spring JobRepositoryDependsOnDatabaseInitializationDetector 源码

spring JpaBatchConfigurer 源码

0  赞