Polish contribution
Closes gh-6543
This commit is contained in:
@@ -28,20 +28,21 @@ import org.springframework.jdbc.support.MetaDataAccessException;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Abstract base class for database schema initializers.
|
||||
* Base class used for database initialization.
|
||||
*
|
||||
* @author Vedran Pavic
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public abstract class AbstractDatabaseInitializer {
|
||||
|
||||
private static final String PLATFORM_PLACEHOLDER = "@@platform@@";
|
||||
|
||||
private DataSource dataSource;
|
||||
private final DataSource dataSource;
|
||||
|
||||
private ResourceLoader resourceLoader;
|
||||
private final ResourceLoader resourceLoader;
|
||||
|
||||
public AbstractDatabaseInitializer(DataSource dataSource, ResourceLoader resourceLoader) {
|
||||
protected AbstractDatabaseInitializer(DataSource dataSource, ResourceLoader resourceLoader) {
|
||||
Assert.notNull(dataSource, "DataSource must not be null");
|
||||
Assert.notNull(resourceLoader, "ResourceLoader must not be null");
|
||||
this.dataSource = dataSource;
|
||||
@@ -54,7 +55,7 @@ public abstract class AbstractDatabaseInitializer {
|
||||
ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
|
||||
String schemaLocation = getSchemaLocation();
|
||||
if (schemaLocation.contains(PLATFORM_PLACEHOLDER)) {
|
||||
String platform = customizeDatabaseName(getDatabaseName());
|
||||
String platform = getDatabaseName();
|
||||
schemaLocation = schemaLocation.replace(PLATFORM_PLACEHOLDER, platform);
|
||||
}
|
||||
populator.addScript(this.resourceLoader.getResource(schemaLocation));
|
||||
@@ -67,11 +68,7 @@ public abstract class AbstractDatabaseInitializer {
|
||||
|
||||
protected abstract String getSchemaLocation();
|
||||
|
||||
protected String customizeDatabaseName(String databaseName) {
|
||||
return databaseName;
|
||||
}
|
||||
|
||||
private String getDatabaseName() {
|
||||
protected String getDatabaseName() {
|
||||
try {
|
||||
String databaseProductName = JdbcUtils.extractDatabaseMetaData(
|
||||
this.dataSource, "getDatabaseProductName").toString();
|
||||
@@ -81,7 +78,7 @@ public abstract class AbstractDatabaseInitializer {
|
||||
if (databaseDriver == DatabaseDriver.UNKNOWN) {
|
||||
throw new IllegalStateException("Unable to detect database type");
|
||||
}
|
||||
return databaseDriver.toString().toLowerCase();
|
||||
return databaseDriver.getId();
|
||||
}
|
||||
catch (MetaDataAccessException ex) {
|
||||
throw new IllegalStateException("Unable to detect database type", ex);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2016 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.
|
||||
@@ -30,7 +30,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class BatchDatabaseInitializer extends AbstractDatabaseInitializer {
|
||||
|
||||
private BatchProperties properties;
|
||||
private final BatchProperties properties;
|
||||
|
||||
public BatchDatabaseInitializer(DataSource dataSource,
|
||||
ResourceLoader resourceLoader, BatchProperties properties) {
|
||||
@@ -50,7 +50,8 @@ public class BatchDatabaseInitializer extends AbstractDatabaseInitializer {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String customizeDatabaseName(String databaseName) {
|
||||
protected String getDatabaseName() {
|
||||
String databaseName = super.getDatabaseName();
|
||||
if ("oracle".equals(databaseName)) {
|
||||
return "oracle10g";
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class JdbcSessionDatabaseInitializer extends AbstractDatabaseInitializer {
|
||||
|
||||
private SessionProperties.Jdbc properties;
|
||||
private final SessionProperties.Jdbc properties;
|
||||
|
||||
public JdbcSessionDatabaseInitializer(DataSource dataSource,
|
||||
ResourceLoader resourceLoader, SessionProperties properties) {
|
||||
|
||||
Reference in New Issue
Block a user