Allow platform to be configured in DataSourceInitializers
Closes gh-28932
This commit is contained in:
@@ -23,6 +23,7 @@ import org.springframework.boot.jdbc.AbstractDataSourceInitializer;
|
||||
import org.springframework.boot.jdbc.DataSourceInitializationMode;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Initialize the Spring Batch schema (ignoring errors, so it should be idempotent).
|
||||
@@ -54,6 +55,10 @@ public class BatchDataSourceInitializer extends AbstractDataSourceInitializer {
|
||||
|
||||
@Override
|
||||
protected String getDatabaseName() {
|
||||
String platform = this.jdbcProperties.getPlatform();
|
||||
if (StringUtils.hasText(platform)) {
|
||||
return platform;
|
||||
}
|
||||
String databaseName = super.getDatabaseName();
|
||||
if ("oracle".equals(databaseName)) {
|
||||
return "oracle10g";
|
||||
|
||||
@@ -122,6 +122,12 @@ public class BatchProperties {
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@@ -140,6 +146,14 @@ public class BatchProperties {
|
||||
this.schema = schema;
|
||||
}
|
||||
|
||||
public String getPlatform() {
|
||||
return this.platform;
|
||||
}
|
||||
|
||||
public void setPlatform(String platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
public String getTablePrefix() {
|
||||
return this.tablePrefix;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -22,6 +22,7 @@ import org.springframework.boot.jdbc.AbstractDataSourceInitializer;
|
||||
import org.springframework.boot.jdbc.DataSourceInitializationMode;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Initializer for Spring Integration schema.
|
||||
@@ -50,4 +51,13 @@ public class IntegrationDataSourceInitializer extends AbstractDataSourceInitiali
|
||||
return this.properties.getSchema();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDatabaseName() {
|
||||
String platform = this.properties.getPlatform();
|
||||
if (StringUtils.hasText(platform)) {
|
||||
return platform;
|
||||
}
|
||||
return super.getDatabaseName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -196,6 +196,12 @@ public class IntegrationProperties {
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* Database schema initialization mode.
|
||||
*/
|
||||
@@ -209,6 +215,14 @@ public class IntegrationProperties {
|
||||
this.schema = schema;
|
||||
}
|
||||
|
||||
public String getPlatform() {
|
||||
return this.platform;
|
||||
}
|
||||
|
||||
public void setPlatform(String platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
public DataSourceInitializationMode getInitializeSchema() {
|
||||
return this.initializeSchema;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.boot.jdbc.DataSourceInitializationMode;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Initialize the Quartz Scheduler schema.
|
||||
@@ -58,6 +59,10 @@ public class QuartzDataSourceInitializer extends AbstractDataSourceInitializer {
|
||||
|
||||
@Override
|
||||
protected String getDatabaseName() {
|
||||
String platform = this.properties.getJdbc().getPlatform();
|
||||
if (StringUtils.hasText(platform)) {
|
||||
return platform;
|
||||
}
|
||||
String databaseName = super.getDatabaseName();
|
||||
if ("db2".equals(databaseName)) {
|
||||
return "db2_v95";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -141,6 +141,12 @@ public class QuartzProperties {
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* Database schema initialization mode.
|
||||
*/
|
||||
@@ -159,6 +165,14 @@ public class QuartzProperties {
|
||||
this.schema = schema;
|
||||
}
|
||||
|
||||
public String getPlatform() {
|
||||
return this.platform;
|
||||
}
|
||||
|
||||
public void setPlatform(String platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
public DataSourceInitializationMode getInitializeSchema() {
|
||||
return this.initializeSchema;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -22,6 +22,7 @@ import org.springframework.boot.jdbc.AbstractDataSourceInitializer;
|
||||
import org.springframework.boot.jdbc.DataSourceInitializationMode;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Initializer for Spring Session schema.
|
||||
@@ -50,4 +51,13 @@ public class JdbcSessionDataSourceInitializer extends AbstractDataSourceInitiali
|
||||
return this.properties.getSchema();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDatabaseName() {
|
||||
String platform = this.properties.getPlatform();
|
||||
if (StringUtils.hasText(platform)) {
|
||||
return platform;
|
||||
}
|
||||
return super.getDatabaseName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -42,6 +42,12 @@ public class JdbcSessionProperties {
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* Name of the database table used to store sessions.
|
||||
*/
|
||||
@@ -77,6 +83,14 @@ public class JdbcSessionProperties {
|
||||
this.schema = schema;
|
||||
}
|
||||
|
||||
public String getPlatform() {
|
||||
return this.platform;
|
||||
}
|
||||
|
||||
public void setPlatform(String platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return this.tableName;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user