Use different default database names for Oracle XE and Oracle Free
Closes gh-38476
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2012-2023 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.docker.compose.service.connection.oracle;
|
||||
|
||||
/**
|
||||
* Enumeration of supported Oracle containers.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
enum OracleContainer {
|
||||
|
||||
FREE("gvenzl/oracle-free", "freepdb1"),
|
||||
|
||||
XE("gvenzl/oracle-xe", "xepdb1");
|
||||
|
||||
private final String imageName;
|
||||
|
||||
private final String defaultDatabase;
|
||||
|
||||
OracleContainer(String imageName, String defaultDatabase) {
|
||||
this.imageName = imageName;
|
||||
this.defaultDatabase = defaultDatabase;
|
||||
}
|
||||
|
||||
String getImageName() {
|
||||
return this.imageName;
|
||||
}
|
||||
|
||||
String getDefaultDatabase() {
|
||||
return this.defaultDatabase;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,18 +28,16 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
class OracleEnvironment {
|
||||
|
||||
static final String[] CONTAINER_NAMES = { "gvenzl/oracle-xe", "gvenzl/oracle-free" };
|
||||
|
||||
private final String username;
|
||||
|
||||
private final String password;
|
||||
|
||||
private final String database;
|
||||
|
||||
OracleEnvironment(Map<String, String> env) {
|
||||
OracleEnvironment(Map<String, String> env, String defaultDatabase) {
|
||||
this.username = env.getOrDefault("APP_USER", "system");
|
||||
this.password = extractPassword(env);
|
||||
this.database = env.getOrDefault("ORACLE_DATABASE", "xepdb1");
|
||||
this.database = env.getOrDefault("ORACLE_DATABASE", defaultDatabase);
|
||||
}
|
||||
|
||||
private String extractPassword(Map<String, String> env) {
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2012-2023 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.docker.compose.service.connection.oracle;
|
||||
|
||||
import org.springframework.boot.autoconfigure.jdbc.JdbcConnectionDetails;
|
||||
import org.springframework.boot.docker.compose.service.connection.DockerComposeConnectionDetailsFactory;
|
||||
|
||||
/**
|
||||
* {@link DockerComposeConnectionDetailsFactory} to create {@link JdbcConnectionDetails}
|
||||
* for an {@link OracleContainer#FREE} service.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
class OracleFreeJdbcDockerComposeConnectionDetailsFactory extends OracleJdbcDockerComposeConnectionDetailsFactory {
|
||||
|
||||
protected OracleFreeJdbcDockerComposeConnectionDetailsFactory() {
|
||||
super(OracleContainer.FREE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2012-2023 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.docker.compose.service.connection.oracle;
|
||||
|
||||
import org.springframework.boot.autoconfigure.r2dbc.R2dbcConnectionDetails;
|
||||
import org.springframework.boot.docker.compose.service.connection.DockerComposeConnectionDetailsFactory;
|
||||
|
||||
/**
|
||||
* {@link DockerComposeConnectionDetailsFactory} to create {@link R2dbcConnectionDetails}
|
||||
* for an {@link OracleContainer#FREE} service.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
class OracleFreeR2dbcDockerComposeConnectionDetailsFactory extends OracleR2dbcDockerComposeConnectionDetailsFactory {
|
||||
|
||||
protected OracleFreeR2dbcDockerComposeConnectionDetailsFactory() {
|
||||
super(OracleContainer.FREE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,27 +23,30 @@ import org.springframework.boot.docker.compose.service.connection.DockerComposeC
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* {@link DockerComposeConnectionDetailsFactory} to create {@link JdbcConnectionDetails}
|
||||
* for an {@code oracle-xe} service.
|
||||
* Base class for a {@link DockerComposeConnectionDetailsFactory} to create
|
||||
* {@link JdbcConnectionDetails} for an {@code oracle-free} or {@code oracle-xe} service.
|
||||
*
|
||||
* @author Moritz Halbritter
|
||||
* @author Andy Wilkinson
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class OracleJdbcDockerComposeConnectionDetailsFactory
|
||||
abstract class OracleJdbcDockerComposeConnectionDetailsFactory
|
||||
extends DockerComposeConnectionDetailsFactory<JdbcConnectionDetails> {
|
||||
|
||||
protected OracleJdbcDockerComposeConnectionDetailsFactory() {
|
||||
super(OracleEnvironment.CONTAINER_NAMES);
|
||||
private final String defaultDatabase;
|
||||
|
||||
protected OracleJdbcDockerComposeConnectionDetailsFactory(OracleContainer container) {
|
||||
super(container.getImageName());
|
||||
this.defaultDatabase = container.getDefaultDatabase();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JdbcConnectionDetails getDockerComposeConnectionDetails(DockerComposeConnectionSource source) {
|
||||
return new OracleJdbcDockerComposeConnectionDetails(source.getRunningService());
|
||||
return new OracleJdbcDockerComposeConnectionDetails(source.getRunningService(), this.defaultDatabase);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link JdbcConnectionDetails} backed by an {@code oracle-xe}
|
||||
* {@link JdbcConnectionDetails} backed by an {@code oracle-xe} or {@code oracle-free}
|
||||
* {@link RunningService}.
|
||||
*/
|
||||
static class OracleJdbcDockerComposeConnectionDetails extends DockerComposeConnectionDetails
|
||||
@@ -55,9 +58,9 @@ class OracleJdbcDockerComposeConnectionDetailsFactory
|
||||
|
||||
private final String jdbcUrl;
|
||||
|
||||
OracleJdbcDockerComposeConnectionDetails(RunningService service) {
|
||||
OracleJdbcDockerComposeConnectionDetails(RunningService service, String defaultDatabase) {
|
||||
super(service);
|
||||
this.environment = new OracleEnvironment(service.env());
|
||||
this.environment = new OracleEnvironment(service.env(), defaultDatabase);
|
||||
this.jdbcUrl = "jdbc:oracle:thin:@" + service.host() + ":" + service.ports().get(1521) + "/"
|
||||
+ this.environment.getDatabase() + getParameters(service);
|
||||
}
|
||||
|
||||
@@ -25,23 +25,26 @@ import org.springframework.boot.docker.compose.service.connection.DockerComposeC
|
||||
import org.springframework.boot.docker.compose.service.connection.r2dbc.ConnectionFactoryOptionsBuilder;
|
||||
|
||||
/**
|
||||
* {@link DockerComposeConnectionDetailsFactory} to create {@link R2dbcConnectionDetails}
|
||||
* for an {@code oracle-xe} service.
|
||||
* Base class for a {@link DockerComposeConnectionDetailsFactory} to create
|
||||
* {@link R2dbcConnectionDetails} for an {@code oracle-free} or {@code oracle-xe} service.
|
||||
*
|
||||
* @author Moritz Halbritter
|
||||
* @author Andy Wilkinson
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class OracleR2dbcDockerComposeConnectionDetailsFactory
|
||||
abstract class OracleR2dbcDockerComposeConnectionDetailsFactory
|
||||
extends DockerComposeConnectionDetailsFactory<R2dbcConnectionDetails> {
|
||||
|
||||
OracleR2dbcDockerComposeConnectionDetailsFactory() {
|
||||
super(OracleEnvironment.CONTAINER_NAMES, "io.r2dbc.spi.ConnectionFactoryOptions");
|
||||
private final String defaultDatabase;
|
||||
|
||||
OracleR2dbcDockerComposeConnectionDetailsFactory(OracleContainer container) {
|
||||
super(container.getImageName(), "io.r2dbc.spi.ConnectionFactoryOptions");
|
||||
this.defaultDatabase = container.getDefaultDatabase();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected R2dbcConnectionDetails getDockerComposeConnectionDetails(DockerComposeConnectionSource source) {
|
||||
return new OracleDbR2dbcDockerComposeConnectionDetails(source.getRunningService());
|
||||
return new OracleDbR2dbcDockerComposeConnectionDetails(source.getRunningService(), this.defaultDatabase);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,9 +59,9 @@ class OracleR2dbcDockerComposeConnectionDetailsFactory
|
||||
|
||||
private final ConnectionFactoryOptions connectionFactoryOptions;
|
||||
|
||||
OracleDbR2dbcDockerComposeConnectionDetails(RunningService service) {
|
||||
OracleDbR2dbcDockerComposeConnectionDetails(RunningService service, String defaultDatabase) {
|
||||
super(service);
|
||||
OracleEnvironment environment = new OracleEnvironment(service.env());
|
||||
OracleEnvironment environment = new OracleEnvironment(service.env(), defaultDatabase);
|
||||
this.connectionFactoryOptions = connectionFactoryOptionsBuilder.build(service, environment.getDatabase(),
|
||||
environment.getUsername(), environment.getPassword());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2012-2023 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.docker.compose.service.connection.oracle;
|
||||
|
||||
import org.springframework.boot.autoconfigure.jdbc.JdbcConnectionDetails;
|
||||
import org.springframework.boot.docker.compose.service.connection.DockerComposeConnectionDetailsFactory;
|
||||
|
||||
/**
|
||||
* {@link DockerComposeConnectionDetailsFactory} to create {@link JdbcConnectionDetails}
|
||||
* for an {@link OracleContainer#XE} service.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
class OracleXeJdbcDockerComposeConnectionDetailsFactory extends OracleJdbcDockerComposeConnectionDetailsFactory {
|
||||
|
||||
protected OracleXeJdbcDockerComposeConnectionDetailsFactory() {
|
||||
super(OracleContainer.XE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2012-2023 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.docker.compose.service.connection.oracle;
|
||||
|
||||
import org.springframework.boot.autoconfigure.r2dbc.R2dbcConnectionDetails;
|
||||
import org.springframework.boot.docker.compose.service.connection.DockerComposeConnectionDetailsFactory;
|
||||
|
||||
/**
|
||||
* {@link DockerComposeConnectionDetailsFactory} to create {@link R2dbcConnectionDetails}
|
||||
* for an {@link OracleContainer#XE} service.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
class OracleXeR2dbcDockerComposeConnectionDetailsFactory extends OracleR2dbcDockerComposeConnectionDetailsFactory {
|
||||
|
||||
protected OracleXeR2dbcDockerComposeConnectionDetailsFactory() {
|
||||
super(OracleContainer.XE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,8 +16,10 @@ org.springframework.boot.docker.compose.service.connection.mongo.MongoDockerComp
|
||||
org.springframework.boot.docker.compose.service.connection.mysql.MySqlJdbcDockerComposeConnectionDetailsFactory,\
|
||||
org.springframework.boot.docker.compose.service.connection.mysql.MySqlR2dbcDockerComposeConnectionDetailsFactory,\
|
||||
org.springframework.boot.docker.compose.service.connection.neo4j.Neo4jDockerComposeConnectionDetailsFactory,\
|
||||
org.springframework.boot.docker.compose.service.connection.oracle.OracleJdbcDockerComposeConnectionDetailsFactory,\
|
||||
org.springframework.boot.docker.compose.service.connection.oracle.OracleR2dbcDockerComposeConnectionDetailsFactory,\
|
||||
org.springframework.boot.docker.compose.service.connection.oracle.OracleFreeJdbcDockerComposeConnectionDetailsFactory,\
|
||||
org.springframework.boot.docker.compose.service.connection.oracle.OracleXeJdbcDockerComposeConnectionDetailsFactory,\
|
||||
org.springframework.boot.docker.compose.service.connection.oracle.OracleFreeR2dbcDockerComposeConnectionDetailsFactory,\
|
||||
org.springframework.boot.docker.compose.service.connection.oracle.OracleXeR2dbcDockerComposeConnectionDetailsFactory,\
|
||||
org.springframework.boot.docker.compose.service.connection.otlp.OpenTelemetryMetricsDockerComposeConnectionDetailsFactory,\
|
||||
org.springframework.boot.docker.compose.service.connection.otlp.OpenTelemetryTracingDockerComposeConnectionDetailsFactory,\
|
||||
org.springframework.boot.docker.compose.service.connection.postgres.PostgresJdbcDockerComposeConnectionDetailsFactory,\
|
||||
|
||||
Reference in New Issue
Block a user