You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/12/29 09:49:29 UTC

[GitHub] [shardingsphere] vikiuvb commented on a diff in pull request #22857: Condition engine refactoring

vikiuvb commented on code in PR #22857:
URL: https://github.com/apache/shardingsphere/pull/22857#discussion_r1058850252


##########
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/ShardingConditionEngine.java:
##########
@@ -21,11 +21,22 @@
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
 
 import java.util.List;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.util.spi.type.required.RequiredSPI;
+import org.apache.shardingsphere.sharding.rule.ShardingRule;
 
 /**
  * Sharding condition engine.
  */
-public interface ShardingConditionEngine<T extends SQLStatementContext<?>> {
+public interface ShardingConditionEngine<T extends SQLStatementContext<?>> extends RequiredSPI {
+    
+    /**
+     * Initialize the sharding condition engine.
+     *
+     * @param rule sharding rule
+     * @param database sharding database
+     */
+    void init(ShardingRule rule, ShardingSphereDatabase database);

Review Comment:
   @strongduanmu The Java `ServiceLoader` implementation requires a class with a default constructor, so we cannot have a parameterized constructor `public DefaultShardingConditionEngine(final ShardingRule rule, final ShardingSphereDatabase database)`.  The method `void init(ShardingRule rule, ShardingSphereDatabase database)` is added to allow the implementation class to prepare its internal structures. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org