Loading sharding-jdbc-example/orchestration-example/orchestration-spring-namespace-example/src/main/java/org/apache/shardingsphere/example/orchestration/spring/namespace/SpringNamespaceExample.java +3 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ public class SpringNamespaceExample { private static ShardingType shardingType = ShardingType.SHARDING_DATABASES_AND_TABLES; // private static ShardingType shardingType = ShardingType.MASTER_SLAVE; // private static ShardingType shardingType = ShardingType.ENCRYPT; private static boolean loadConfigFromRegCenter = false; // private static boolean loadConfigFromRegCenter = true; Loading @@ -49,6 +50,8 @@ public class SpringNamespaceExample { return String.format("META-INF/%s/%s/application-sharding-databases-tables.xml", registryCenterType.name().toLowerCase(), loadConfigFromRegCenter ? "cloud" : "local"); case MASTER_SLAVE: return String.format("META-INF/%s/%s/application-master-slave.xml", registryCenterType.name().toLowerCase(), loadConfigFromRegCenter ? "cloud" : "local"); case ENCRYPT: return String.format("META-INF/%s/%s/application-encrypt.xml", registryCenterType.name().toLowerCase(), loadConfigFromRegCenter ? "cloud" : "local"); default: throw new UnsupportedOperationException(shardingType.name()); } Loading sharding-jdbc-example/orchestration-example/orchestration-spring-namespace-example/src/main/resources/META-INF/zookeeper/cloud/application-encrypt.xml 0 → 100755 +52 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <!-- ~ Copyright 2016-2018 shardingsphere.io. ~ <p> ~ 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. ~ </p> --> <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:orchestraion="http://shardingsphere.apache.org/schema/shardingsphere/orchestration" 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/orchestration http://shardingsphere.apache.org/schema/shardingsphere/orchestration/orchestration.xsd"> <import resource="classpath*:META-INF/zookeeper/registry-center.xml" /> <context:component-scan base-package="org.apache.shardingsphere.example.common.mybatis" /> <orchestraion:encrypt-data-source id="encryptDataSource" registry-center-ref="regCenter" /> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="encryptDataSource" /> </bean> <tx:annotation-driven /> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="encryptDataSource"/> <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.common.mybatis.repository"/> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/> </bean> </beans> sharding-jdbc-example/orchestration-example/orchestration-spring-namespace-example/src/main/resources/META-INF/zookeeper/local/application-encrypt.xml 0 → 100755 +74 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <!-- ~ Copyright 2016-2018 shardingsphere.io. ~ <p> ~ 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. ~ </p> --> <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:bean="http://www.springframework.org/schema/util" xmlns:encrypt="http://shardingsphere.apache.org/schema/shardingsphere/encrypt" xmlns:orchestraion="http://shardingsphere.apache.org/schema/shardingsphere/orchestration" 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://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://shardingsphere.apache.org/schema/shardingsphere/encrypt http://shardingsphere.apache.org/schema/shardingsphere/encrypt/encrypt.xsd http://shardingsphere.apache.org/schema/shardingsphere/orchestration http://shardingsphere.apache.org/schema/shardingsphere/orchestration/orchestration.xsd"> <import resource="classpath*:META-INF/zookeeper/registry-center.xml" /> <context:component-scan base-package="org.apache.shardingsphere.example.common.mybatis" /> <bean id="demo_ds_encrypt" 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_ds"/> <property name="username" value="root"/> <property name="password" value=""/> </bean> <bean:properties id="props"> <prop key="aes.key.value">123456</prop> </bean:properties> <encrypt:data-source id="realEncryptDataSource" data-source-name="demo_ds_encrypt" > <encrypt:encryptor-rule id="pwd_encryptor" type="assistedTest" qualified-columns="t_user.pwd" assisted-query-columns="t_user.assisted_query_pwd" /> <encrypt:encryptor-rule id="name_encryptor" type="AES" qualified-columns="t_user.user_name" props-ref="props" /> </encrypt:data-source> <orchestraion:encrypt-data-source id="encryptDataSource" data-source-ref="realEncryptDataSource" registry-center-ref="regCenter" overwrite="true" /> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="encryptDataSource" /> </bean> <tx:annotation-driven /> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="encryptDataSource"/> <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.common.mybatis.repository"/> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/> </bean> </beans> Loading
sharding-jdbc-example/orchestration-example/orchestration-spring-namespace-example/src/main/java/org/apache/shardingsphere/example/orchestration/spring/namespace/SpringNamespaceExample.java +3 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ public class SpringNamespaceExample { private static ShardingType shardingType = ShardingType.SHARDING_DATABASES_AND_TABLES; // private static ShardingType shardingType = ShardingType.MASTER_SLAVE; // private static ShardingType shardingType = ShardingType.ENCRYPT; private static boolean loadConfigFromRegCenter = false; // private static boolean loadConfigFromRegCenter = true; Loading @@ -49,6 +50,8 @@ public class SpringNamespaceExample { return String.format("META-INF/%s/%s/application-sharding-databases-tables.xml", registryCenterType.name().toLowerCase(), loadConfigFromRegCenter ? "cloud" : "local"); case MASTER_SLAVE: return String.format("META-INF/%s/%s/application-master-slave.xml", registryCenterType.name().toLowerCase(), loadConfigFromRegCenter ? "cloud" : "local"); case ENCRYPT: return String.format("META-INF/%s/%s/application-encrypt.xml", registryCenterType.name().toLowerCase(), loadConfigFromRegCenter ? "cloud" : "local"); default: throw new UnsupportedOperationException(shardingType.name()); } Loading
sharding-jdbc-example/orchestration-example/orchestration-spring-namespace-example/src/main/resources/META-INF/zookeeper/cloud/application-encrypt.xml 0 → 100755 +52 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <!-- ~ Copyright 2016-2018 shardingsphere.io. ~ <p> ~ 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. ~ </p> --> <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:orchestraion="http://shardingsphere.apache.org/schema/shardingsphere/orchestration" 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/orchestration http://shardingsphere.apache.org/schema/shardingsphere/orchestration/orchestration.xsd"> <import resource="classpath*:META-INF/zookeeper/registry-center.xml" /> <context:component-scan base-package="org.apache.shardingsphere.example.common.mybatis" /> <orchestraion:encrypt-data-source id="encryptDataSource" registry-center-ref="regCenter" /> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="encryptDataSource" /> </bean> <tx:annotation-driven /> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="encryptDataSource"/> <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.common.mybatis.repository"/> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/> </bean> </beans>
sharding-jdbc-example/orchestration-example/orchestration-spring-namespace-example/src/main/resources/META-INF/zookeeper/local/application-encrypt.xml 0 → 100755 +74 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <!-- ~ Copyright 2016-2018 shardingsphere.io. ~ <p> ~ 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. ~ </p> --> <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:bean="http://www.springframework.org/schema/util" xmlns:encrypt="http://shardingsphere.apache.org/schema/shardingsphere/encrypt" xmlns:orchestraion="http://shardingsphere.apache.org/schema/shardingsphere/orchestration" 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://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://shardingsphere.apache.org/schema/shardingsphere/encrypt http://shardingsphere.apache.org/schema/shardingsphere/encrypt/encrypt.xsd http://shardingsphere.apache.org/schema/shardingsphere/orchestration http://shardingsphere.apache.org/schema/shardingsphere/orchestration/orchestration.xsd"> <import resource="classpath*:META-INF/zookeeper/registry-center.xml" /> <context:component-scan base-package="org.apache.shardingsphere.example.common.mybatis" /> <bean id="demo_ds_encrypt" 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_ds"/> <property name="username" value="root"/> <property name="password" value=""/> </bean> <bean:properties id="props"> <prop key="aes.key.value">123456</prop> </bean:properties> <encrypt:data-source id="realEncryptDataSource" data-source-name="demo_ds_encrypt" > <encrypt:encryptor-rule id="pwd_encryptor" type="assistedTest" qualified-columns="t_user.pwd" assisted-query-columns="t_user.assisted_query_pwd" /> <encrypt:encryptor-rule id="name_encryptor" type="AES" qualified-columns="t_user.user_name" props-ref="props" /> </encrypt:data-source> <orchestraion:encrypt-data-source id="encryptDataSource" data-source-ref="realEncryptDataSource" registry-center-ref="regCenter" overwrite="true" /> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="encryptDataSource" /> </bean> <tx:annotation-driven /> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="encryptDataSource"/> <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.common.mybatis.repository"/> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/> </bean> </beans>