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

jianglongtao 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 2f46b2e  Migration sharding-readwrite-splitting example. (#12949)
2f46b2e is described below

commit 2f46b2eee2201525500eb3f419cf7fd05de77271
Author: yx9o <[email protected]>
AuthorDate: Fri Oct 8 23:39:57 2021 +0800

    Migration sharding-readwrite-splitting example. (#12949)
    
    * 'sharding-readwrite-splitting-spring-namespace-mybatis-example' module 
increase example
    
    * Remove the sharding-readwrite-splitting example
    
    * Update pom.xml
---
 .../application-sharding-readwrite-splitting.xml   | 151 ---------------------
 .../pom.xml                                        |  14 +-
 .../ShardingSpringNamespaceMybatisExample.java     |   8 +-
 .../application-sharding-readwrite-splitting.xml   |   0
 .../{pom.xml => src/main/resources/logback.xml}    |  29 ++--
 .../ShardingSpringNamespaceMybatisExample.java     |   1 -
 6 files changed, 31 insertions(+), 172 deletions(-)

diff --git 
a/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-namespace-mybatis-example/application-sharding-readwrite-splitting.xml
 
b/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-namespace-mybatis-example/application-sharding-readwrite-splitting.xml
deleted file mode 100644
index 8bdd529..0000000
--- 
a/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-namespace-mybatis-example/application-sharding-readwrite-splitting.xml
+++ /dev/null
@@ -1,151 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ 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.
-  -->
-
-<beans xmlns="http://www.springframework.org/schema/beans";
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-       xmlns:context="http://www.springframework.org/schema/context";
-       xmlns:tx="http://www.springframework.org/schema/tx";
-       
xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource";
-       
xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding";
-       
xmlns:readwrite-splitting="http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting";
-       xsi:schemaLocation="http://www.springframework.org/schema/beans
-                           
http://www.springframework.org/schema/beans/spring-beans.xsd 
-                           http://www.springframework.org/schema/context 
-                           
http://www.springframework.org/schema/context/spring-context.xsd
-                           http://www.springframework.org/schema/tx 
-                           
http://www.springframework.org/schema/tx/spring-tx.xsd
-                           
http://shardingsphere.apache.org/schema/shardingsphere/datasource
-                           
http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
-                           
http://shardingsphere.apache.org/schema/shardingsphere/sharding
-                           
http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
-                           
http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting
-                           
http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting/readwrite-splitting.xsd
-                           ">
-    <context:component-scan 
base-package="org.apache.shardingsphere.example.core.mybatis" />
-    
-    <bean id="demo_write_ds_0" class="com.zaxxer.hikari.HikariDataSource" 
destroy-method="close">
-        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
-        <property name="jdbcUrl" 
value="jdbc:mysql://localhost:3306/demo_write_ds_0?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"
 />
-        <property name="username" value="root" />
-        <property name="password" value="" />
-    </bean>
-    
-    <bean id="demo_write_ds_0_read_0" 
class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
-        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
-        <property name="jdbcUrl" 
value="jdbc:mysql://localhost:3306/demo_write_ds_0_read_0?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"
 />
-        <property name="username" value="root" />
-        <property name="password" value="" />
-    </bean>
-    
-    <bean id="demo_write_ds_0_read_1" 
class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
-        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
-        <property name="jdbcUrl" 
value="jdbc:mysql://localhost:3306/demo_write_ds_0_read_1?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"
 />
-        <property name="username" value="root" />
-        <property name="password" value="" />
-    </bean>
-    
-    <bean id="demo_write_ds_1" class="com.zaxxer.hikari.HikariDataSource" 
destroy-method="close">
-        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
-        <property name="jdbcUrl" 
value="jdbc:mysql://localhost:3306/demo_write_ds_1?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"
 />
-        <property name="username" value="root" />
-        <property name="password" value="" />
-    </bean>
-    
-    <bean id="demo_write_ds_1_read_0" 
class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
-        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
-        <property name="jdbcUrl" 
value="jdbc:mysql://localhost:3306/demo_write_ds_1_read_0?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"
 />
-        <property name="username" value="root" />
-        <property name="password" value="" />
-    </bean>
-    
-    <bean id="demo_write_ds_1_read_1" 
class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
-        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
-        <property name="jdbcUrl" 
value="jdbc:mysql://localhost:3306/demo_write_ds_1_read_1?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"
 />
-        <property name="username" value="root" />
-        <property name="password" value="" />
-    </bean>
-    
-    <sharding:standard-strategy id="databaseStrategy" 
sharding-column="user_id" algorithm-ref="inlineDatabaseStrategyAlgorithm" />
-    <sharding:standard-strategy id="orderTableStrategy" 
sharding-column="order_id" algorithm-ref="inlineOrderTableStrategyAlgorithm" />
-    <sharding:standard-strategy id="orderItemTableStrategy" 
sharding-column="order_item_id" 
algorithm-ref="inlineOrderItemTableStrategyAlgorithm" />
-
-    <sharding:sharding-algorithm id="inlineDatabaseStrategyAlgorithm" 
type="INLINE">
-        <props>
-            <prop key="algorithm-expression">demo_pr_ds_${user_id % 2}</prop>
-        </props>
-    </sharding:sharding-algorithm>
-    <sharding:sharding-algorithm id="inlineOrderTableStrategyAlgorithm" 
type="INLINE">
-        <props>
-            <prop key="algorithm-expression">t_order_${order_id % 2}</prop>
-        </props>
-    </sharding:sharding-algorithm>
-    <sharding:sharding-algorithm id="inlineOrderItemTableStrategyAlgorithm" 
type="INLINE">
-        <props>
-            <prop key="algorithm-expression">t_order_item_${order_item_id % 
2}</prop>
-        </props>
-    </sharding:sharding-algorithm>
-
-    <sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
-        <props>
-            <prop key="worker-id">123</prop>
-        </props>
-    </sharding:key-generate-algorithm>
-    
-    <sharding:key-generate-strategy id="orderKeyGenerator" column="order_id" 
algorithm-ref="snowflakeAlgorithm" />
-    <sharding:key-generate-strategy id="itemKeyGenerator" 
column="order_item_id" algorithm-ref="snowflakeAlgorithm" />
-    
-    <readwrite-splitting:load-balance-algorithm id="randomStrategy" 
type="RANDOM" />
-    
-    <sharding:rule id="shardingRule">
-        <sharding:table-rules>
-            <sharding:table-rule logic-table="t_order" 
actual-data-nodes="demo_pr_ds_${0..1}.t_order_${0..1}" 
database-strategy-ref="databaseStrategy" 
table-strategy-ref="orderTableStrategy" 
key-generate-strategy-ref="orderKeyGenerator"/>
-            <sharding:table-rule logic-table="t_order_item" 
actual-data-nodes="demo_pr_ds_${0..1}.t_order_item_${0..1}" 
database-strategy-ref="databaseStrategy" 
table-strategy-ref="orderItemTableStrategy" 
key-generate-strategy-ref="itemKeyGenerator"/>
-        </sharding:table-rules>
-        <sharding:binding-table-rules>
-            <sharding:binding-table-rule logic-tables="t_order,t_order_item"/>
-        </sharding:binding-table-rules>
-        <sharding:broadcast-table-rules>
-            <sharding:broadcast-table-rule table="t_address"/>
-        </sharding:broadcast-table-rules>
-    </sharding:rule>
-    <readwrite-splitting:rule id="readWriteSplittingRule">
-        <readwrite-splitting:data-source-rule id="demo_pr_ds_0" 
write-data-source-name="demo_write_ds_0" 
read-data-source-names="demo_write_ds_0_read_0, demo_write_ds_0_read_1" 
load-balance-algorithm-ref="randomStrategy" />
-        <readwrite-splitting:data-source-rule id="demo_pr_ds_1" 
write-data-source-name="demo_write_ds_1" 
read-data-source-names="demo_write_ds_1_read_0, demo_write_ds_1_read_1" 
load-balance-algorithm-ref="randomStrategy" />
-    </readwrite-splitting:rule>
-    
-    <shardingsphere:data-source id="shardingDataSource" 
data-source-names="demo_write_ds_0,demo_write_ds_0_read_0,demo_write_ds_0_read_1,demo_write_ds_1,demo_write_ds_1_read_0,demo_write_ds_1_read_1"
 rule-refs="shardingRule, readWriteSplittingRule">
-        <props>
-            <prop key="sql-show">false</prop>
-        </props>
-    </shardingsphere:data-source>
-    
-    <bean id="transactionManager" 
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
-        <property name="dataSource" ref="shardingDataSource" />
-    </bean>
-    <tx:annotation-driven />
-    
-    <bean id="sqlSessionFactory" 
class="org.mybatis.spring.SqlSessionFactoryBean">
-        <property name="dataSource" ref="shardingDataSource"/>
-        <property name="mapperLocations" 
value="classpath*:META-INF/mappers/*.xml"/>
-    </bean>
-    
-    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
-        <property name="basePackage" 
value="org.apache.shardingsphere.example.core.mybatis.repository"/>
-        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
-    </bean>
-</beans>
\ No newline at end of file
diff --git 
a/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-namespace-mybatis-example/pom.xml
 
b/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-namespace-mybatis-example/pom.xml
index c2978dd..0828d94 100644
--- 
a/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-namespace-mybatis-example/pom.xml
+++ 
b/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-namespace-mybatis-example/pom.xml
@@ -26,6 +26,18 @@
         <version>5.0.0-RC1-SNAPSHOT</version>
     </parent>
     
<artifactId>sharding-readwrite-splitting-spring-namespace-mybatis-example</artifactId>
-    <packaging>pom</packaging>
     <name>${project.artifactId}</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shardingsphere.example</groupId>
+            <artifactId>example-spring-mybatis</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-jdbc-core-spring-namespace</artifactId>
+        </dependency>
+    </dependencies>
 </project>
diff --git 
a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/ShardingSpringNamespaceMybatisExample.java
 
b/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/readwrite/splitting
 [...]
similarity index 75%
copy from 
examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/ShardingSpringNamespaceMybatisExample.java
copy to 
examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/readwrite/splitting/spring/namespace/mybatis/ShardingSpringNamespaceMybatisExample.java
index df7a22b..a8b58d4 100644
--- 
a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/ShardingSpringNamespaceMybatisExample.java
+++ 
b/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/readwrite/splitting/spring/namespace/mybatis/ShardingSpringNamespaceMybatisExample.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.example.sharding.spring.namespace.mybatis;
+package 
org.apache.shardingsphere.example.sharding.readwrite.splitting.spring.namespace.mybatis;
 
 import org.apache.shardingsphere.example.core.api.ExampleExecuteTemplate;
 import org.apache.shardingsphere.example.core.api.service.ExampleService;
@@ -26,11 +26,7 @@ import java.sql.SQLException;
 
 public final class ShardingSpringNamespaceMybatisExample {
     
-    private static final String CONFIG_FILE = 
"META-INF/application-sharding-databases.xml";
-//    private static final String CONFIG_FILE = 
"META-INF/application-sharding-tables.xml";
-//    private static final String CONFIG_FILE = 
"META-INF/application-sharding-databases-tables.xml";
-//    private static final String CONFIG_FILE = 
"META-INF/application-readwrite-splitting.xml";
-//    private static final String CONFIG_FILE = 
"META-INF/application-sharding-readwrite-splitting.xml";
+    private static final String CONFIG_FILE = 
"META-INF/application-sharding-readwrite-splitting.xml";
     
     public static void main(final String[] args) throws SQLException {
         try (ConfigurableApplicationContext applicationContext = new 
ClassPathXmlApplicationContext(CONFIG_FILE)) {
diff --git 
a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-readwrite-splitting.xml
 
b/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-readwrite-splitting.xml
similarity index 100%
rename from 
examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-readwrite-splitting.xml
rename to 
examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-readwrite-splitting.xml
diff --git 
a/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-namespace-mybatis-example/pom.xml
 
b/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-namespace-mybatis-example/src/main/resources/logback.xml
similarity index 57%
copy from 
examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-namespace-mybatis-example/pom.xml
copy to 
examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-namespace-mybatis-example/src/main/resources/logback.xml
index c2978dd..415124d 100644
--- 
a/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-namespace-mybatis-example/pom.xml
+++ 
b/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-namespace-mybatis-example/src/main/resources/logback.xml
@@ -16,16 +16,19 @@
   ~ limitations under the License.
   -->
 
-<project xmlns="http://maven.apache.org/POM/4.0.0";
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.shardingsphere.example</groupId>
-        <artifactId>sharding-readwrite-splitting-example</artifactId>
-        <version>5.0.0-RC1-SNAPSHOT</version>
-    </parent>
-    
<artifactId>sharding-readwrite-splitting-spring-namespace-mybatis-example</artifactId>
-    <packaging>pom</packaging>
-    <name>${project.artifactId}</name>
-</project>
+<configuration>
+    <property name="log.context.name" 
value="sharding-readwrite-splitting-spring-namespace-mybatis-example" />
+    <property name="log.charset" value="UTF-8" />
+    <property name="log.pattern" value="[%-5level] %date --%thread-- [%logger] 
%msg %n" />
+    <contextName>${log.context.name}</contextName>
+    
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder charset="${log.charset}">
+            <pattern>${log.pattern}</pattern>
+        </encoder>
+    </appender>
+    <root>
+        <level value="INFO" />
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>
diff --git 
a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/ShardingSpringNamespaceMybatisExample.java
 
b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/ShardingSpringNamespaceMybatisExa
 [...]
index df7a22b..7925762 100644
--- 
a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/ShardingSpringNamespaceMybatisExample.java
+++ 
b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/ShardingSpringNamespaceMybatisExample.java
@@ -30,7 +30,6 @@ public final class ShardingSpringNamespaceMybatisExample {
 //    private static final String CONFIG_FILE = 
"META-INF/application-sharding-tables.xml";
 //    private static final String CONFIG_FILE = 
"META-INF/application-sharding-databases-tables.xml";
 //    private static final String CONFIG_FILE = 
"META-INF/application-readwrite-splitting.xml";
-//    private static final String CONFIG_FILE = 
"META-INF/application-sharding-readwrite-splitting.xml";
     
     public static void main(final String[] args) throws SQLException {
         try (ConfigurableApplicationContext applicationContext = new 
ClassPathXmlApplicationContext(CONFIG_FILE)) {

Reply via email to