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

kimmking 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 5f65923  Remove useless constructor of 
AlgorithmProvidedShardingRuleConfiguration (#10707)
5f65923 is described below

commit 5f65923662569e27294ac510e6bfab9853d18dbf
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Jun 7 22:53:33 2021 +0800

    Remove useless constructor of AlgorithmProvidedShardingRuleConfiguration 
(#10707)
    
    * Remove useless constructor of AlgorithmProvidedShardingRuleConfiguration
    
    * Remove useless constructor of AlgorithmProvidedShardingRuleConfiguration
---
 ...AlgorithmProvidedShardingRuleConfiguration.java |  4 ---
 .../rule/ShardingRuleBeanDefinitionParser.java     | 42 ++++++++--------------
 2 files changed, 15 insertions(+), 31 deletions(-)

diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/config/AlgorithmProvidedShardingRuleConfiguration.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/config/AlgorithmProvidedShardingRuleConfiguration.java
index c388d74..bccfdf4 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/config/AlgorithmProvidedShardingRuleConfiguration.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/config/AlgorithmProvidedShardingRuleConfiguration.java
@@ -17,9 +17,7 @@
 
 package org.apache.shardingsphere.sharding.algorithm.config;
 
-import lombok.AllArgsConstructor;
 import lombok.Getter;
-import lombok.NoArgsConstructor;
 import lombok.Setter;
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
@@ -37,8 +35,6 @@ import java.util.Map;
 /**
  * Algorithm provided sharding rule configuration.
  */
-@NoArgsConstructor
-@AllArgsConstructor
 @Getter
 @Setter
 public final class AlgorithmProvidedShardingRuleConfiguration implements 
RuleConfiguration {
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/parser/rule/ShardingRuleBeanDefinitionParser.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/parser/rule/ShardingRuleBeanDefinitionParser.java
index b1f8b82..36aa1e2 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/parser/rule/ShardingRuleBeanDefinitionParser.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/parser/rule/ShardingRuleBeanDefinitionParser.java
@@ -47,15 +47,15 @@ public final class ShardingRuleBeanDefinitionParser extends 
AbstractBeanDefiniti
     @Override
     protected AbstractBeanDefinition parseInternal(final Element element, 
final ParserContext parserContext) {
         BeanDefinitionBuilder factory = 
BeanDefinitionBuilder.rootBeanDefinition(AlgorithmProvidedShardingRuleConfiguration.class);
-        factory.addConstructorArgValue(parseTableRulesConfiguration(element));
-        
factory.addConstructorArgValue(parseAutoTableRulesConfiguration(element));
-        
factory.addConstructorArgValue(parseBindingTablesConfiguration(element));
-        factory.addConstructorArgValue(parseBroadcastTables(element));
-        addDefaultDatabaseShardingStrategyRef(element, factory);
-        addDefaultTableShardingStrategyRef(element, factory);
-        addDefaultKeyGenerateStrategyRef(element, factory);
-        
factory.addConstructorArgValue(ShardingSphereAlgorithmBeanRegistry.getAlgorithmBeanReferences(parserContext,
 ShardingAlgorithmFactoryBean.class));
-        
factory.addConstructorArgValue(ShardingSphereAlgorithmBeanRegistry.getAlgorithmBeanReferences(parserContext,
 KeyGenerateAlgorithmFactoryBean.class));
+        factory.addPropertyValue("tables", 
parseTableRulesConfiguration(element));
+        factory.addPropertyValue("autoTables", 
parseAutoTableRulesConfiguration(element));
+        factory.addPropertyValue("bindingTableGroups", 
parseBindingTablesConfiguration(element));
+        factory.addPropertyValue("broadcastTables", 
parseBroadcastTables(element));
+        setDefaultDatabaseShardingStrategyRef(element, factory);
+        setDefaultTableShardingStrategyRef(element, factory);
+        setDefaultKeyGenerateStrategyRef(element, factory);
+        factory.addPropertyValue("shardingAlgorithms", 
ShardingSphereAlgorithmBeanRegistry.getAlgorithmBeanReferences(parserContext, 
ShardingAlgorithmFactoryBean.class));
+        factory.addPropertyValue("keyGenerators", 
ShardingSphereAlgorithmBeanRegistry.getAlgorithmBeanReferences(parserContext, 
KeyGenerateAlgorithmFactoryBean.class));
         return factory.getBeanDefinition();
     }
     
@@ -172,31 +172,19 @@ public final class ShardingRuleBeanDefinitionParser 
extends AbstractBeanDefiniti
         return result;
     }
     
-    private void addDefaultDatabaseShardingStrategyRef(final Element element, 
final BeanDefinitionBuilder factory) {
+    private void setDefaultDatabaseShardingStrategyRef(final Element element, 
final BeanDefinitionBuilder factory) {
         Optional<String> strategyRef = parseStrategyRef(element, 
ShardingRuleBeanDefinitionTag.DEFAULT_DATABASE_STRATEGY_REF_ATTRIBUTE);
-        if (strategyRef.isPresent()) {
-            factory.addConstructorArgReference(strategyRef.get());
-        } else {
-            factory.addConstructorArgValue(null);
-        }
+        strategyRef.ifPresent(optional -> 
factory.addPropertyReference("defaultDatabaseShardingStrategy", optional));
     }
     
-    private void addDefaultTableShardingStrategyRef(final Element element, 
final BeanDefinitionBuilder factory) {
+    private void setDefaultTableShardingStrategyRef(final Element element, 
final BeanDefinitionBuilder factory) {
         Optional<String> strategyRef = parseStrategyRef(element, 
ShardingRuleBeanDefinitionTag.DEFAULT_TABLE_STRATEGY_REF_ATTRIBUTE);
-        if (strategyRef.isPresent()) {
-            factory.addConstructorArgReference(strategyRef.get());
-        } else {
-            factory.addConstructorArgValue(null);
-        }
+        strategyRef.ifPresent(optional -> 
factory.addPropertyReference("defaultTableShardingStrategy", optional));
     }
     
-    private void addDefaultKeyGenerateStrategyRef(final Element element, final 
BeanDefinitionBuilder factory) {
+    private void setDefaultKeyGenerateStrategyRef(final Element element, final 
BeanDefinitionBuilder factory) {
         Optional<String> strategyRef = parseStrategyRef(element, 
ShardingRuleBeanDefinitionTag.DEFAULT_KEY_GENERATE_STRATEGY_REF_ATTRIBUTE);
-        if (strategyRef.isPresent()) {
-            factory.addConstructorArgReference(strategyRef.get());
-        } else {
-            factory.addConstructorArgValue(null);
-        }
+        strategyRef.ifPresent(optional -> 
factory.addPropertyReference("defaultKeyGenerateStrategy", optional));
     }
     
     private Optional<String> parseStrategyRef(final Element element, final 
String tagName) {

Reply via email to