This is an automated email from the ASF dual-hosted git repository.

linghengqian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new c12a657526e Add p6spy driver support to ShardingJDBC infra (#31814)
c12a657526e is described below

commit c12a657526e20713ac3cc1a30be34fe8c54dedc1
Author: lcjing <[email protected]>
AuthorDate: Sat Jun 22 15:21:07 2024 +0800

    Add p6spy driver support to ShardingJDBC infra (#31814)
    
    * add p6spy driver support to ShardingJDBC infra
    
    * remove unnecessary dependency and testcontainers modify
---
 infra/common/pom.xml                               |  5 +++
 infra/database/type/{ => p6spy}/pom.xml            | 34 ++++++++--------
 .../p6spy/type/P6spyMySQLDatabaseType.java         | 46 ++++++++++++++++++++++
 ...ingsphere.infra.database.core.type.DatabaseType | 18 +++++++++
 .../p6spy/type/P6spyMySQLDatabaseTypeTest.java     | 35 ++++++++++++++++
 infra/database/type/pom.xml                        |  1 +
 6 files changed, 121 insertions(+), 18 deletions(-)

diff --git a/infra/common/pom.xml b/infra/common/pom.xml
index 5dbe8e92400..5d22f597767 100644
--- a/infra/common/pom.xml
+++ b/infra/common/pom.xml
@@ -78,6 +78,11 @@
             <artifactId>shardingsphere-infra-database-sql92</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-infra-database-p6spy</artifactId>
+            <version>${project.version}</version>
+        </dependency>
         <dependency>
             <groupId>org.apache.shardingsphere</groupId>
             
<artifactId>shardingsphere-infra-data-source-pool-hikari</artifactId>
diff --git a/infra/database/type/pom.xml b/infra/database/type/p6spy/pom.xml
similarity index 66%
copy from infra/database/type/pom.xml
copy to infra/database/type/p6spy/pom.xml
index 53f7d88a8bb..223fec86591 100644
--- a/infra/database/type/pom.xml
+++ b/infra/database/type/p6spy/pom.xml
@@ -20,26 +20,24 @@
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.apache.shardingsphere</groupId>
-        <artifactId>shardingsphere-infra-database</artifactId>
+        <artifactId>shardingsphere-infra-database-type</artifactId>
         <version>5.5.1-SNAPSHOT</version>
     </parent>
-    <artifactId>shardingsphere-infra-database-type</artifactId>
-    <packaging>pom</packaging>
+    <artifactId>shardingsphere-infra-database-p6spy</artifactId>
     <name>${project.artifactId}</name>
     
-    <modules>
-        <module>mysql</module>
-        <module>mariadb</module>
-        <module>postgresql</module>
-        <module>opengauss</module>
-        <module>oracle</module>
-        <module>sqlserver</module>
-        <module>clickhouse</module>
-        <module>doris</module>
-        <module>hive</module>
-        <module>presto</module>
-        <module>h2</module>
-        <module>sql92</module>
-        <module>testcontainers</module>
-    </modules>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-infra-database-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-test-util</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
 </project>
diff --git 
a/infra/database/type/p6spy/src/main/java/org/apache/shardingsphere/infra/database/p6spy/type/P6spyMySQLDatabaseType.java
 
b/infra/database/type/p6spy/src/main/java/org/apache/shardingsphere/infra/database/p6spy/type/P6spyMySQLDatabaseType.java
new file mode 100644
index 00000000000..cefd418c3c9
--- /dev/null
+++ 
b/infra/database/type/p6spy/src/main/java/org/apache/shardingsphere/infra/database/p6spy/type/P6spyMySQLDatabaseType.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.shardingsphere.infra.database.p6spy.type;
+
+import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Optional;
+
+/**
+ * Database type of MySQL under P6Spy.
+ */
+public class P6spyMySQLDatabaseType implements DatabaseType {
+    
+    @Override
+    public Collection<String> getJdbcUrlPrefixes() {
+        return Collections.singletonList("jdbc:p6spy:mysql:");
+    }
+    
+    @Override
+    public Optional<DatabaseType> getTrunkDatabaseType() {
+        return Optional.of(TypedSPILoader.getService(DatabaseType.class, 
"MySQL"));
+    }
+    
+    @Override
+    public String getType() {
+        return "P6spyMySQL";
+    }
+}
diff --git 
a/infra/database/type/p6spy/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.database.core.type.DatabaseType
 
b/infra/database/type/p6spy/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.database.core.type.DatabaseType
new file mode 100644
index 00000000000..eda25d0b620
--- /dev/null
+++ 
b/infra/database/type/p6spy/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.database.core.type.DatabaseType
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+
+org.apache.shardingsphere.infra.database.p6spy.type.P6spyMySQLDatabaseType
diff --git 
a/infra/database/type/p6spy/src/test/java/org/apache/shardingsphere/infra/database/p6spy/type/P6spyMySQLDatabaseTypeTest.java
 
b/infra/database/type/p6spy/src/test/java/org/apache/shardingsphere/infra/database/p6spy/type/P6spyMySQLDatabaseTypeTest.java
new file mode 100644
index 00000000000..a476838e644
--- /dev/null
+++ 
b/infra/database/type/p6spy/src/test/java/org/apache/shardingsphere/infra/database/p6spy/type/P6spyMySQLDatabaseTypeTest.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.shardingsphere.infra.database.p6spy.type;
+
+import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import org.junit.jupiter.api.Test;
+
+import java.util.Collections;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+class P6spyMySQLDatabaseTypeTest {
+    
+    @Test
+    void assertGetJdbcUrlPrefixes() {
+        assertThat(TypedSPILoader.getService(DatabaseType.class, 
"P6spyMySQL").getJdbcUrlPrefixes(), 
is(Collections.singletonList("jdbc:p6spy:mysql:")));
+    }
+}
diff --git a/infra/database/type/pom.xml b/infra/database/type/pom.xml
index 53f7d88a8bb..b5d3f89f554 100644
--- a/infra/database/type/pom.xml
+++ b/infra/database/type/pom.xml
@@ -40,6 +40,7 @@
         <module>presto</module>
         <module>h2</module>
         <module>sql92</module>
+        <module>p6spy</module>
         <module>testcontainers</module>
     </modules>
 </project>

Reply via email to