This repository has been archived by the owner on Jan 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 694
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Splits the SQL starter into a MySQL and a PostgreSQL one (#364)
- Loading branch information
1 parent
03f327e
commit 6042d64
Showing
17 changed files
with
370 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...ringframework/cloud/gcp/autoconfigure/sql/AppEngineJdbcInfoProviderAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright 2018 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.cloud.gcp.autoconfigure.sql; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
|
||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.cloud.gcp.autoconfigure.core.AppEngineCondition; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Conditional; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* Provides the {@link CloudSqlJdbcInfoProvider} for apps running on Google App Engine. | ||
* | ||
* @author João André Martins | ||
*/ | ||
@Configuration | ||
@ConditionalOnClass({com.google.cloud.sql.mysql.SocketFactory.class}) | ||
@Conditional(AppEngineCondition.class) | ||
class AppEngineJdbcInfoProviderAutoConfiguration { | ||
|
||
private static final Log LOGGER = | ||
LogFactory.getLog(AppEngineJdbcInfoProviderAutoConfiguration.class); | ||
|
||
@Bean | ||
@ConditionalOnMissingBean(CloudSqlJdbcInfoProvider.class) | ||
public CloudSqlJdbcInfoProvider appengineCloudSqlJdbcInfoProvider( | ||
GcpCloudSqlProperties gcpCloudSqlProperties) { | ||
CloudSqlJdbcInfoProvider appEngineProvider = | ||
new AppEngineCloudSqlJdbcInfoProvider(gcpCloudSqlProperties); | ||
|
||
if (LOGGER.isInfoEnabled()) { | ||
LOGGER.info("App Engine JdbcUrl provider. Connecting to " | ||
+ appEngineProvider.getJdbcUrl() + " with driver " | ||
+ appEngineProvider.getJdbcDriverClass()); | ||
} | ||
|
||
return appEngineProvider; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...g/springframework/cloud/gcp/autoconfigure/sql/MySqlJdbcInfoProviderAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright 2018 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.cloud.gcp.autoconfigure.sql; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
|
||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* Provides the {@link CloudSqlJdbcInfoProvider} for MySQL. | ||
* | ||
* @author João André Martins | ||
*/ | ||
@Configuration | ||
@ConditionalOnClass({com.google.cloud.sql.mysql.SocketFactory.class, com.mysql.jdbc.Driver.class}) | ||
class MySqlJdbcInfoProviderAutoConfiguration { | ||
|
||
private static final Log LOGGER = | ||
LogFactory.getLog(MySqlJdbcInfoProviderAutoConfiguration.class); | ||
|
||
@Bean | ||
@ConditionalOnMissingBean(CloudSqlJdbcInfoProvider.class) | ||
public CloudSqlJdbcInfoProvider defaultMySqlJdbcInfoProvider( | ||
GcpCloudSqlProperties gcpCloudSqlProperties) { | ||
CloudSqlJdbcInfoProvider defaultProvider = | ||
new DefaultCloudSqlJdbcInfoProvider(gcpCloudSqlProperties, DatabaseType.MYSQL); | ||
|
||
if (LOGGER.isInfoEnabled()) { | ||
LOGGER.info("Default " + DatabaseType.MYSQL.name() | ||
+ " JdbcUrl provider. Connecting to " | ||
+ defaultProvider.getJdbcUrl() + " with driver " | ||
+ defaultProvider.getJdbcDriverClass()); | ||
} | ||
|
||
return defaultProvider; | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...ingframework/cloud/gcp/autoconfigure/sql/PostgreSqlJdbcInfoProviderAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2018 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.cloud.gcp.autoconfigure.sql; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
|
||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* Provides the {@link CloudSqlJdbcInfoProvider} for PostgreSQL. | ||
* | ||
* @author João André Martins | ||
*/ | ||
@Configuration | ||
@ConditionalOnClass({com.google.cloud.sql.postgres.SocketFactory.class, | ||
org.postgresql.Driver.class}) | ||
class PostgreSqlJdbcInfoProviderAutoConfiguration { | ||
|
||
private static final Log LOGGER = | ||
LogFactory.getLog(PostgreSqlJdbcInfoProviderAutoConfiguration.class); | ||
|
||
@Bean | ||
@ConditionalOnMissingBean(CloudSqlJdbcInfoProvider.class) | ||
public CloudSqlJdbcInfoProvider defaultPostgreSqlJdbcInfoProvider( | ||
GcpCloudSqlProperties gcpCloudSqlProperties) { | ||
CloudSqlJdbcInfoProvider defaultProvider = | ||
new DefaultCloudSqlJdbcInfoProvider(gcpCloudSqlProperties, DatabaseType.POSTGRESQL); | ||
|
||
if (LOGGER.isInfoEnabled()) { | ||
LOGGER.info("Default " + DatabaseType.POSTGRESQL.name() | ||
+ " JdbcUrl provider. Connecting to " | ||
+ defaultProvider.getJdbcUrl() + " with driver " | ||
+ defaultProvider.getJdbcDriverClass()); | ||
} | ||
|
||
return defaultProvider; | ||
} | ||
} |
Oops, something went wrong.