You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/09/09 03:19:49 UTC

[shardingsphere] branch master updated: Support spring config for sharding audit. (#20811)

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

duanzhengqiang 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 2c9ab805986 Support spring config for sharding audit. (#20811)
2c9ab805986 is described below

commit 2c9ab805986e501e8a29a1222db27973d59bc6dd
Author: Zonglei Dong <do...@apache.org>
AuthorDate: Fri Sep 9 11:19:41 2022 +0800

    Support spring config for sharding audit. (#20811)
    
    * Support spring config for sharding audit.
    
    * fix variable name.
    
    * Fixes sharding audit spring test case.
    
    * Support spring boot config for sharding audit.
    
    * Fixes checkstyle problem.
---
 .../boot/ShardingRuleSpringBootConfiguration.java  | 19 ++++++-
 ...ShardingAuditAlgorithmProvidedBeanRegistry.java | 40 +++++++++++++++
 .../additional-spring-configuration-metadata.json  | 25 +++++++++
 .../spring/boot/ShardingSpringBootStarterTest.java |  7 +++
 .../test/resources/application-sharding.properties |  6 +++
 .../ShardingAuditAlgorithmFactoryBean.java         | 40 +++++++++++++++
 .../handler/ShardingNamespaceHandler.java          |  6 +++
 .../rule/ShardingRuleBeanDefinitionParser.java     |  2 +
 .../ShardingAuditStrategyBeanDefinitionParser.java | 59 ++++++++++++++++++++++
 .../ShardingAuditAlgorithmBeanDefinitionTag.java   | 30 +++++++++++
 .../ShardingAuditStrategyBeanDefinitionTag.java    | 38 ++++++++++++++
 .../main/resources/META-INF/namespace/sharding.xsd | 36 +++++++++++++
 .../namespace/ShardingSpringNamespaceTest.java     | 28 ++++++++++
 .../fixture/IncrementKeyGenerateAlgorithm.java     | 47 +++++++++++++++++
 ...hardingsphere.sharding.spi.KeyGenerateAlgorithm | 18 +++++++
 .../spring/sharding-application-context.xml        | 17 ++++++-
 ...hardingSphereAlgorithmBeanDefinitionParser.java |  3 ++
 17 files changed, 418 insertions(+), 3 deletions(-)

diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/main/java/org/apache/shardingsphere/sharding/spring/boot/ShardingRuleSpringBootConfiguration.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/main/java/org/apache/shardingsphere/sharding/spring/boot/ShardingRuleSpringBootConfiguration.java
index 16f6e578b03..3859a50cb5d 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/main/java/org/apache/shardingsphere/sharding/spring/boot/ShardingRuleSpringBootConfiguration.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/main/java/org/apache/shardingsphere/sharding/spring/boot/ShardingRuleSpringBootConfiguration.java
@@ -22,8 +22,10 @@ import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
 import org.apache.shardingsphere.sharding.algorithm.config.AlgorithmProvidedShardingRuleConfiguration;
 import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
 import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
+import org.apache.shardingsphere.sharding.spi.ShardingAuditAlgorithm;
 import org.apache.shardingsphere.sharding.spring.boot.algorithm.KeyGenerateAlgorithmProvidedBeanRegistry;
 import org.apache.shardingsphere.sharding.spring.boot.algorithm.ShardingAlgorithmProvidedBeanRegistry;
+import org.apache.shardingsphere.sharding.spring.boot.algorithm.ShardingAuditAlgorithmProvidedBeanRegistry;
 import org.apache.shardingsphere.sharding.spring.boot.condition.ShardingSpringBootCondition;
 import org.apache.shardingsphere.sharding.spring.boot.rule.YamlShardingRuleSpringBootConfiguration;
 import org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration;
@@ -59,16 +61,20 @@ public class ShardingRuleSpringBootConfiguration {
      *
      * @param shardingAlgorithmProvider sharding algorithm provider
      * @param keyGenerateAlgorithmProvider key generate algorithm provider
+     * @param shardingAuditAlgorithmProvider sharding audit algorithm provider
      * @return sharding rule configuration
      */
     @Bean
     public RuleConfiguration shardingRuleConfiguration(final ObjectProvider<Map<String, ShardingAlgorithm>> shardingAlgorithmProvider,
-                                                       final ObjectProvider<Map<String, KeyGenerateAlgorithm>> keyGenerateAlgorithmProvider) {
+                                                       final ObjectProvider<Map<String, KeyGenerateAlgorithm>> keyGenerateAlgorithmProvider,
+                                                       final ObjectProvider<Map<String, ShardingAuditAlgorithm>> shardingAuditAlgorithmProvider) {
         Map<String, ShardingAlgorithm> shardingAlgorithmMap = Optional.ofNullable(shardingAlgorithmProvider.getIfAvailable()).orElse(Collections.emptyMap());
         Map<String, KeyGenerateAlgorithm> keyGenerateAlgorithmMap = Optional.ofNullable(keyGenerateAlgorithmProvider.getIfAvailable()).orElse(Collections.emptyMap());
+        Map<String, ShardingAuditAlgorithm> shardingAuditAlgorithmMap = Optional.ofNullable(shardingAuditAlgorithmProvider.getIfAvailable()).orElse(Collections.emptyMap());
         AlgorithmProvidedShardingRuleConfiguration result = swapper.swapToObject(yamlConfig.getSharding());
         result.setShardingAlgorithms(shardingAlgorithmMap);
         result.setKeyGenerators(keyGenerateAlgorithmMap);
+        result.setAuditors(shardingAuditAlgorithmMap);
         return result;
     }
     
@@ -93,4 +99,15 @@ public class ShardingRuleSpringBootConfiguration {
     public static KeyGenerateAlgorithmProvidedBeanRegistry keyGenerateAlgorithmProvidedBeanRegistry(final Environment environment) {
         return new KeyGenerateAlgorithmProvidedBeanRegistry(environment);
     }
+    
+    /**
+     * Create sharding auditor algorithm provided bean registry.
+     *
+     * @param environment environment
+     * @return sharding auditor algorithm provided bean registry
+     */
+    @Bean
+    public static ShardingAuditAlgorithmProvidedBeanRegistry shardingAuditAlgorithmProvidedBeanRegistry(final Environment environment) {
+        return new ShardingAuditAlgorithmProvidedBeanRegistry(environment);
+    }
 }
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/main/java/org/apache/shardingsphere/sharding/spring/boot/algorithm/ShardingAuditAlgorithmProvidedBeanRegistry.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/main/java/org/apache/shardingsphere/sharding/spring/boot/algorithm/ShardingAuditAlgorithmProvidedBeanRegistry.java
new file mode 100644
index 00000000000..d41d570f3de
--- /dev/null
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/main/java/org/apache/shardingsphere/sharding/spring/boot/algorithm/ShardingAuditAlgorithmProvidedBeanRegistry.java
@@ -0,0 +1,40 @@
+/*
+ * 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.sharding.spring.boot.algorithm;
+
+import org.apache.shardingsphere.sharding.spi.ShardingAuditAlgorithm;
+import org.apache.shardingsphere.spring.boot.registry.AbstractAlgorithmProvidedBeanRegistry;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.core.env.Environment;
+
+/**
+ * Sharding audit algorithm provided bean registry.
+ */
+public final class ShardingAuditAlgorithmProvidedBeanRegistry extends AbstractAlgorithmProvidedBeanRegistry<ShardingAuditAlgorithm> {
+    
+    private static final String AUDITORS = "spring.shardingsphere.rules.sharding.auditors.";
+    
+    public ShardingAuditAlgorithmProvidedBeanRegistry(final Environment environment) {
+        super(environment);
+    }
+    
+    @Override
+    public void postProcessBeanDefinitionRegistry(final BeanDefinitionRegistry registry) {
+        registerBean(AUDITORS, ShardingAuditAlgorithm.class, registry);
+    }
+}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
index 70de8e6f68a..f177affe3f1 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@@ -87,6 +87,11 @@
       "type": "org.apache.shardingsphere.sharding.yaml.config.strategy.keygen.YamlKeyGenerateStrategyConfiguration",
       "sourceType": "org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration"
     },
+    {
+      "name": "spring.shardingsphere.rules.sharding.default-audit-strategy",
+      "type": "org.apache.shardingsphere.sharding.yaml.config.strategy.audit.YamlShardingAuditStrategyConfiguration",
+      "sourceType": "org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration"
+    },
     {
       "name": "spring.shardingsphere.rules.sharding.sharding-algorithms",
       "type": "java.util.Map<java.lang.String, org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlAlgorithmConfiguration>",
@@ -96,6 +101,11 @@
       "name": "spring.shardingsphere.rules.sharding.key-generators",
       "type": "java.util.Map<java.lang.String, org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlAlgorithmConfiguration>",
       "sourceType": "org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration"
+    },
+    {
+      "name": "spring.shardingsphere.rules.sharding.auditors",
+      "type": "java.util.Map<java.lang.String, org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlAlgorithmConfiguration>",
+      "sourceType": "org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration"
     }
   ],
   "properties": [
@@ -124,6 +134,16 @@
       "type": "java.lang.String",
       "sourceType": "org.apache.shardingsphere.sharding.yaml.config.strategy.keygen.YamlKeyGenerateStrategyConfiguration"
     },
+    {
+      "name": "spring.shardingsphere.rules.sharding.default-audit-strategy.auditor-names",
+      "type": "java.util.Collection<java.lang.String>",
+      "sourceType": "org.apache.shardingsphere.sharding.yaml.config.strategy.audit.YamlShardingAuditStrategyConfiguration"
+    },
+    {
+      "name": "spring.shardingsphere.rules.sharding.default-audit-strategy.allow-hint-disable",
+      "type": "java.lang.Boolean",
+      "sourceType": "org.apache.shardingsphere.sharding.yaml.config.strategy.audit.YamlShardingAuditStrategyConfiguration"
+    },
     {
       "name": "spring.shardingsphere.rules.sharding.default-table-strategy.hint.sharding-algorithm-name",
       "type": "java.lang.String",
@@ -193,6 +213,11 @@
       "name": "spring.shardingsphere.rules.sharding.key-generators",
       "type": "java.util.Map<java.lang.String, org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlAlgorithmConfiguration>",
       "sourceType": "org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration"
+    },
+    {
+      "name": "spring.shardingsphere.rules.sharding.auditors",
+      "type": "java.util.Map<java.lang.String, org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlAlgorithmConfiguration>",
+      "sourceType": "org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration"
     }
   ],
   "hints": [
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/test/java/org/apache/shardingsphere/sharding/spring/boot/ShardingSpringBootStarterTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/test/java/org/apache/shardingsphere/sharding/spring/boot/ShardingSpringBootStarterTest.java
index 94d55d399c4..50c2341093c 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/test/java/org/apache/shardingsphere/sharding/spring/boot/ShardingSpringBootStarterTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/test/java/org/apache/shardingsphere/sharding/spring/boot/ShardingSpringBootStarterTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.sharding.spring.boot;
 
+import org.apache.shardingsphere.sharding.algorithm.audit.DMLShardingConditionsShardingAuditAlgorithm;
 import org.apache.shardingsphere.sharding.algorithm.config.AlgorithmProvidedShardingRuleConfiguration;
 import org.apache.shardingsphere.sharding.algorithm.keygen.SnowflakeKeyGenerateAlgorithm;
 import org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineShardingAlgorithm;
@@ -71,6 +72,7 @@ public class ShardingSpringBootStarterTest {
         assertShardingConfigurationDefaultDatabaseShardingStrategy();
         assertShardingConfigurationShardingAlgorithms();
         assertShardingConfigurationKeyGenerators();
+        assertShardingConfigurationAuditors();
     }
     
     private void assertShardingConfigurationTables() {
@@ -133,4 +135,9 @@ public class ShardingSpringBootStarterTest {
         assertThat(shardingRuleConfig.getKeyGenerators().size(), is(1));
         assertThat(shardingRuleConfig.getKeyGenerators().get("keyGenerator"), instanceOf(SnowflakeKeyGenerateAlgorithm.class));
     }
+    
+    private void assertShardingConfigurationAuditors() {
+        assertThat(shardingRuleConfig.getAuditors().size(), is(1));
+        assertThat(shardingRuleConfig.getAuditors().get("shardingKeyAudit"), instanceOf(DMLShardingConditionsShardingAuditAlgorithm.class));
+    }
 }
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/test/resources/application-sharding.properties b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/test/resources/application-sharding.properties
index 1de81608c9f..242147d75a0 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/test/resources/application-sharding.properties
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/test/resources/application-sharding.properties
@@ -26,6 +26,8 @@ spring.shardingsphere.rules.sharding.sharding-algorithms.orderItemTableShardingA
 
 spring.shardingsphere.rules.sharding.key-generators.keyGenerator.type=SNOWFLAKE
 
+spring.shardingsphere.rules.sharding.auditors.shardingKeyAudit.type=DML_SHARDING_CONDITIONS
+
 spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
 spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=databaseShardingAlgorithm
 
@@ -36,6 +38,8 @@ spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.shar
 
 spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
 spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=keyGenerator
+spring.shardingsphere.rules.sharding.tables.t_order.audit-strategy.auditor-names=shardingKeyAudit
+spring.shardingsphere.rules.sharding.tables.t_order.audit-strategy.allow-hint-disable=true
 
 spring.shardingsphere.rules.sharding.tables.t_order_item.actual-data-nodes=ds_$->{0..1}.t_order_item_$->{0..1}
 
@@ -44,6 +48,8 @@ spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard
 
 spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.column=order_item_id
 spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=keyGenerator
+spring.shardingsphere.rules.sharding.tables.t_order_item.audit-strategy.auditor-names=shardingKeyAudit
+spring.shardingsphere.rules.sharding.tables.t_order_item.audit-strategy.allow-hint-disable=true
 
 spring.shardingsphere.rules.sharding.auto-tables.t_order_auto.actual-data-sources=ds0, ds1
 
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/factorybean/ShardingAuditAlgorithmFactoryBean.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/factorybean/ShardingAuditAlgorithmFactoryBean.java
new file mode 100644
index 00000000000..609889e7bf9
--- /dev/null
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/factorybean/ShardingAuditAlgorithmFactoryBean.java
@@ -0,0 +1,40 @@
+/*
+ * 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.sharding.spring.namespace.factorybean;
+
+import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
+import org.apache.shardingsphere.sharding.factory.ShardingAuditAlgorithmFactory;
+import org.apache.shardingsphere.sharding.spi.ShardingAuditAlgorithm;
+import org.apache.shardingsphere.spring.namespace.factorybean.ShardingSphereAlgorithmFactoryBean;
+
+import java.util.Properties;
+
+/**
+ * Sharding audit algorithm factory bean.
+ */
+public final class ShardingAuditAlgorithmFactoryBean extends ShardingSphereAlgorithmFactoryBean<ShardingAuditAlgorithm> {
+    
+    public ShardingAuditAlgorithmFactoryBean(final String type, final Properties props) {
+        super(type, props, ShardingAuditAlgorithm.class);
+    }
+    
+    @Override
+    public ShardingAuditAlgorithm getObject() {
+        return ShardingAuditAlgorithmFactory.newInstance(new AlgorithmConfiguration(getType(), getProps()));
+    }
+}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/handler/ShardingNamespaceHandler.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/handler/ShardingNamespaceHandler.java
index 98479e8bf10..c2de157eb78 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/handler/ShardingNamespaceHandler.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/handler/ShardingNamespaceHandler.java
@@ -19,13 +19,17 @@ package org.apache.shardingsphere.sharding.spring.namespace.handler;
 
 import org.apache.shardingsphere.sharding.spring.namespace.factorybean.KeyGenerateAlgorithmFactoryBean;
 import org.apache.shardingsphere.sharding.spring.namespace.factorybean.ShardingAlgorithmFactoryBean;
+import org.apache.shardingsphere.sharding.spring.namespace.factorybean.ShardingAuditAlgorithmFactoryBean;
 import org.apache.shardingsphere.sharding.spring.namespace.parser.rule.ShardingRuleBeanDefinitionParser;
 import org.apache.shardingsphere.sharding.spring.namespace.parser.strategy.KeyGenerateStrategyBeanDefinitionParser;
+import org.apache.shardingsphere.sharding.spring.namespace.parser.strategy.ShardingAuditStrategyBeanDefinitionParser;
 import org.apache.shardingsphere.sharding.spring.namespace.parser.strategy.ShardingStrategyBeanDefinitionParser;
 import org.apache.shardingsphere.sharding.spring.namespace.tag.algorithm.KeyGenerateAlgorithmBeanDefinitionTag;
 import org.apache.shardingsphere.sharding.spring.namespace.tag.algorithm.ShardingAlgorithmBeanDefinitionTag;
+import org.apache.shardingsphere.sharding.spring.namespace.tag.algorithm.ShardingAuditAlgorithmBeanDefinitionTag;
 import org.apache.shardingsphere.sharding.spring.namespace.tag.rule.ShardingRuleBeanDefinitionTag;
 import org.apache.shardingsphere.sharding.spring.namespace.tag.strategy.KeyGenerateStrategyBeanDefinitionTag;
+import org.apache.shardingsphere.sharding.spring.namespace.tag.strategy.ShardingAuditStrategyBeanDefinitionTag;
 import org.apache.shardingsphere.sharding.spring.namespace.tag.strategy.ShardingStrategyBeanDefinitionTag;
 import org.apache.shardingsphere.spring.namespace.parser.ShardingSphereAlgorithmBeanDefinitionParser;
 import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
@@ -45,5 +49,7 @@ public final class ShardingNamespaceHandler extends NamespaceHandlerSupport {
         registerBeanDefinitionParser(ShardingAlgorithmBeanDefinitionTag.ROOT_TAG, new ShardingSphereAlgorithmBeanDefinitionParser(ShardingAlgorithmFactoryBean.class));
         registerBeanDefinitionParser(KeyGenerateStrategyBeanDefinitionTag.ROOT_TAG, new KeyGenerateStrategyBeanDefinitionParser());
         registerBeanDefinitionParser(KeyGenerateAlgorithmBeanDefinitionTag.ROOT_TAG, new ShardingSphereAlgorithmBeanDefinitionParser(KeyGenerateAlgorithmFactoryBean.class));
+        registerBeanDefinitionParser(ShardingAuditStrategyBeanDefinitionTag.ROOT_TAG, new ShardingAuditStrategyBeanDefinitionParser());
+        registerBeanDefinitionParser(ShardingAuditAlgorithmBeanDefinitionTag.ROOT_TAG, new ShardingSphereAlgorithmBeanDefinitionParser(ShardingAuditAlgorithmFactoryBean.class));
     }
 }
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 6514c169581..85d9dafa7c6 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
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleC
 import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
 import org.apache.shardingsphere.sharding.spring.namespace.factorybean.KeyGenerateAlgorithmFactoryBean;
 import org.apache.shardingsphere.sharding.spring.namespace.factorybean.ShardingAlgorithmFactoryBean;
+import org.apache.shardingsphere.sharding.spring.namespace.factorybean.ShardingAuditAlgorithmFactoryBean;
 import org.apache.shardingsphere.sharding.spring.namespace.tag.rule.ShardingRuleBeanDefinitionTag;
 import org.apache.shardingsphere.spring.namespace.registry.ShardingSphereAlgorithmBeanRegistry;
 import org.springframework.beans.factory.config.BeanDefinition;
@@ -57,6 +58,7 @@ public final class ShardingRuleBeanDefinitionParser extends AbstractBeanDefiniti
         setDefaultShardingColumn(element, factory);
         factory.addPropertyValue("shardingAlgorithms", ShardingSphereAlgorithmBeanRegistry.getAlgorithmBeanReferences(parserContext, ShardingAlgorithmFactoryBean.class));
         factory.addPropertyValue("keyGenerators", ShardingSphereAlgorithmBeanRegistry.getAlgorithmBeanReferences(parserContext, KeyGenerateAlgorithmFactoryBean.class));
+        factory.addPropertyValue("auditors", ShardingSphereAlgorithmBeanRegistry.getAlgorithmBeanReferences(parserContext, ShardingAuditAlgorithmFactoryBean.class));
         return factory.getBeanDefinition();
     }
     
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/parser/strategy/ShardingAuditStrategyBeanDefinitionParser.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/parser/strategy/ShardingAuditStrategyBeanDe [...]
new file mode 100644
index 00000000000..15da940152d
--- /dev/null
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/parser/strategy/ShardingAuditStrategyBeanDefinitionParser.java
@@ -0,0 +1,59 @@
+/*
+ * 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.sharding.spring.namespace.parser.strategy;
+
+import org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration;
+import org.apache.shardingsphere.sharding.spring.namespace.tag.strategy.ShardingAuditStrategyBeanDefinitionTag;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.ManagedList;
+import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.xml.DomUtils;
+import org.w3c.dom.Element;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Sharding audit strategy bean parser for spring namespace.
+ */
+public final class ShardingAuditStrategyBeanDefinitionParser extends AbstractBeanDefinitionParser {
+    
+    @Override
+    protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
+        BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(ShardingAuditStrategyConfiguration.class);
+        factory.addConstructorArgValue(parseAuditorsConfiguration(element));
+        factory.addConstructorArgValue(element.getAttribute(ShardingAuditStrategyBeanDefinitionTag.ALLOW_HINT_DISABLE_ATTRIBUTE));
+        return factory.getBeanDefinition();
+    }
+    
+    private List<String> parseAuditorsConfiguration(final Element element) {
+        Element auditorsElement = DomUtils.getChildElementByTagName(element, ShardingAuditStrategyBeanDefinitionTag.AUDITORS_TAG);
+        if (null == auditorsElement) {
+            return Collections.emptyList();
+        }
+        List<Element> auditorElements = DomUtils.getChildElementsByTagName(auditorsElement, ShardingAuditStrategyBeanDefinitionTag.AUDITOR_TAG);
+        List<String> result = new ManagedList<>(auditorElements.size());
+        for (Element each : auditorElements) {
+            String algorithmRef = each.getAttribute(ShardingAuditStrategyBeanDefinitionTag.ALGORITHM_REF_ATTRIBUTE);
+            result.add(algorithmRef);
+        }
+        return result;
+    }
+}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/tag/algorithm/ShardingAuditAlgorithmBeanDefinitionTag.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/tag/algorithm/ShardingAuditAlgorithmBeanDefinit [...]
new file mode 100644
index 00000000000..186ea32bd7c
--- /dev/null
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/tag/algorithm/ShardingAuditAlgorithmBeanDefinitionTag.java
@@ -0,0 +1,30 @@
+/*
+ * 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.sharding.spring.namespace.tag.algorithm;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+/**
+ * Sharding audit algorithm bean definition tag.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class ShardingAuditAlgorithmBeanDefinitionTag {
+    
+    public static final String ROOT_TAG = "audit-algorithm";
+}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/tag/strategy/ShardingAuditStrategyBeanDefinitionTag.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/tag/strategy/ShardingAuditStrategyBeanDefinitionTag.java
new file mode 100644
index 00000000000..4254f79a8ef
--- /dev/null
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/tag/strategy/ShardingAuditStrategyBeanDefinitionTag.java
@@ -0,0 +1,38 @@
+/*
+ * 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.sharding.spring.namespace.tag.strategy;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+/**
+ * Sharding audit strategy bean definition tag.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class ShardingAuditStrategyBeanDefinitionTag {
+    
+    public static final String ROOT_TAG = "audit-strategy";
+    
+    public static final String AUDITORS_TAG = "auditors";
+    
+    public static final String AUDITOR_TAG = "auditor";
+    
+    public static final String ALLOW_HINT_DISABLE_ATTRIBUTE = "allow-hint-disable";
+    
+    public static final String ALGORITHM_REF_ATTRIBUTE = "algorithm-ref";
+}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/resources/META-INF/namespace/sharding.xsd b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/resources/META-INF/namespace/sharding.xsd
index eb146836574..2177d16208d 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/resources/META-INF/namespace/sharding.xsd
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/resources/META-INF/namespace/sharding.xsd
@@ -36,6 +36,7 @@
             <xsd:attribute name="default-table-strategy-ref" type="xsd:string" />
             <xsd:attribute name="default-key-generate-strategy-ref" type="xsd:string" />
             <xsd:attribute name="default-sharding-column" type="xsd:string" />
+            <xsd:attribute name="default-audit-strategy-ref" type="xsd:string" />
         </xsd:complexType>
     </xsd:element>
     
@@ -53,6 +54,7 @@
             <xsd:attribute name="database-strategy-ref" type="xsd:string" />
             <xsd:attribute name="table-strategy-ref" type="xsd:string" />
             <xsd:attribute name="key-generate-strategy-ref" type="xsd:string" />
+            <xsd:attribute name="audit-strategy-ref" type="xsd:string" />
         </xsd:complexType>
     </xsd:element>
     <xsd:element name="auto-table-rules">
@@ -148,4 +150,38 @@
             <xsd:attribute name="type" type="xsd:string" />
         </xsd:complexType>
     </xsd:element>
+
+    <xsd:element name="audit-strategy">
+        <xsd:complexType>
+            <xsd:all>
+                <xsd:element ref="auditors" minOccurs="0" />
+            </xsd:all>
+            <xsd:attribute name="id" type="xsd:string" use="required" />
+            <xsd:attribute name="allow-hint-disable" type="xsd:boolean" use="required" />
+        </xsd:complexType>
+    </xsd:element>
+
+    <xsd:element name="auditors">
+        <xsd:complexType>
+            <xsd:sequence>
+                <xsd:element ref="auditor" maxOccurs="unbounded" />
+            </xsd:sequence>
+        </xsd:complexType>
+    </xsd:element>
+
+    <xsd:element name="auditor">
+        <xsd:complexType>
+            <xsd:attribute name="algorithm-ref" type="xsd:string" />
+        </xsd:complexType>
+    </xsd:element>
+
+    <xsd:element name="audit-algorithm">
+        <xsd:complexType>
+            <xsd:all>
+                <xsd:element ref="beans:props" minOccurs="0" />
+            </xsd:all>
+            <xsd:attribute name="id" type="xsd:string" use="required" />
+            <xsd:attribute name="type" type="xsd:string" />
+        </xsd:complexType>
+    </xsd:element>
 </xsd:schema>
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/ShardingSpringNamespaceTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/ShardingSpringNamespaceTest.java
index 6776f8d1412..28f997684d8 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/ShardingSpringNamespaceTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/ShardingSpringNamespaceTest.java
@@ -22,6 +22,7 @@ import org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineShardi
 import org.apache.shardingsphere.sharding.algorithm.sharding.mod.ModShardingAlgorithm;
 import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
 import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
+import org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration;
 import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
 import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ComplexShardingStrategyConfiguration;
 import org.apache.shardingsphere.sharding.api.config.strategy.sharding.HintShardingStrategyConfiguration;
@@ -30,6 +31,7 @@ import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardS
 import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingAlgorithm;
 import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingAlgorithm;
 import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+import org.apache.shardingsphere.sharding.spi.ShardingAuditAlgorithm;
 import org.junit.Test;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
@@ -67,6 +69,9 @@ public final class ShardingSpringNamespaceTest extends AbstractJUnit4SpringConte
     @Resource
     private KeyGenerateAlgorithm keyGenerateAlgorithm;
     
+    @Resource
+    private ShardingAuditAlgorithm auditAlgorithm;
+    
     @Resource
     private StandardShardingStrategyConfiguration dataSourceShardingStrategy;
     
@@ -88,6 +93,12 @@ public final class ShardingSpringNamespaceTest extends AbstractJUnit4SpringConte
     @Resource
     private KeyGenerateStrategyConfiguration orderKeyGenerator;
     
+    @Resource
+    private ShardingAuditStrategyConfiguration defaultAudit;
+    
+    @Resource
+    private ShardingAuditStrategyConfiguration shardingKeyAudit;
+    
     @Resource
     private NoneShardingStrategyConfiguration noneStrategy;
     
@@ -188,6 +199,23 @@ public final class ShardingSpringNamespaceTest extends AbstractJUnit4SpringConte
         assertThat(orderKeyGenerator.getKeyGeneratorName(), is("uuidAlgorithm"));
     }
     
+    @Test
+    public void assertShardingAuditAlgorithm() {
+        assertThat(auditAlgorithm.getType(), is("DML_SHARDING_CONDITIONS"));
+    }
+    
+    @Test
+    public void assertDefaultAudit() {
+        assertTrue(defaultAudit.getAuditorNames().contains("auditAlgorithm"));
+        assertTrue(defaultAudit.isAllowHintDisable());
+    }
+    
+    @Test
+    public void assertShardingKeyAudit() {
+        assertTrue(shardingKeyAudit.getAuditorNames().contains("auditAlgorithm"));
+        assertTrue(shardingKeyAudit.isAllowHintDisable());
+    }
+    
     @Test
     public void assertSimpleRule() {
         Collection<ShardingTableRuleConfiguration> actualSimpleRuleConfigs = simpleRule.getTables();
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/fixture/IncrementKeyGenerateAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/fixture/IncrementKeyGenerateAlgorithm.java
new file mode 100644
index 00000000000..d3045ffe0ce
--- /dev/null
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/fixture/IncrementKeyGenerateAlgorithm.java
@@ -0,0 +1,47 @@
+/*
+ * 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.sharding.spring.namespace.fixture;
+
+import lombok.Getter;
+import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
+
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
+
+@Getter
+public final class IncrementKeyGenerateAlgorithm implements KeyGenerateAlgorithm {
+    
+    private final AtomicInteger count = new AtomicInteger();
+    
+    private Properties props;
+    
+    @Override
+    public void init(final Properties props) {
+        this.props = props;
+    }
+    
+    @Override
+    public Comparable<?> generateKey() {
+        return count.incrementAndGet();
+    }
+    
+    @Override
+    public String getType() {
+        return "JDBC.INCREMENT.FIXTURE";
+    }
+}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm
new file mode 100644
index 00000000000..590d964c6c3
--- /dev/null
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm
@@ -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.sharding.spring.namespace.fixture.IncrementKeyGenerateAlgorithm
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/resources/META-INF/spring/sharding-application-context.xml b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/resources/META-INF/spring/sharding-application-context.xml
index c4ba9fca3e0..11197960ed2 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/resources/META-INF/spring/sharding-application-context.xml
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/resources/META-INF/spring/sharding-application-context.xml
@@ -54,6 +54,19 @@
     
     <sharding:key-generate-strategy id="defaultKeyGenerator" column="id" algorithm-ref="uuidAlgorithm" />
     <sharding:key-generate-strategy id="orderKeyGenerator" column="order_id" algorithm-ref="uuidAlgorithm" />
+
+    <sharding:audit-algorithm id="auditAlgorithm" type="DML_SHARDING_CONDITIONS" />
+
+    <sharding:audit-strategy id="defaultAudit" allow-hint-disable="true">
+        <sharding:auditors>
+            <sharding:auditor algorithm-ref="auditAlgorithm" />
+        </sharding:auditors>
+    </sharding:audit-strategy>
+    <sharding:audit-strategy id="shardingKeyAudit" allow-hint-disable="true">
+        <sharding:auditors>
+            <sharding:auditor algorithm-ref="auditAlgorithm" />
+        </sharding:auditors>
+    </sharding:audit-strategy>
     
     <sharding:rule id="simpleRule">
         <sharding:table-rules>
@@ -61,9 +74,9 @@
         </sharding:table-rules>
     </sharding:rule>
     
-    <sharding:rule id="complexRule" default-key-generate-strategy-ref="defaultKeyGenerator">
+    <sharding:rule id="complexRule" default-key-generate-strategy-ref="defaultKeyGenerator" default-audit-strategy-ref="defaultAudit">
         <sharding:table-rules>
-            <sharding:table-rule logic-table="t_order" actual-data-nodes="ds_$->{0..1}.t_order_$->{0..3}" database-strategy-ref="dataSourceShardingStrategy" table-strategy-ref="orderTableShardingStrategy" key-generate-strategy-ref="orderKeyGenerator" />
+            <sharding:table-rule logic-table="t_order" actual-data-nodes="ds_$->{0..1}.t_order_$->{0..3}" database-strategy-ref="dataSourceShardingStrategy" table-strategy-ref="orderTableShardingStrategy" key-generate-strategy-ref="orderKeyGenerator" audit-strategy-ref="shardingKeyAudit" />
         </sharding:table-rules>
     </sharding:rule>
     
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/main/java/org/apache/shardingsphere/spring/namespace/parser/ShardingSphereAlgorithmBeanDefinitionParser.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/main/java/org/apache/shardingsphere/spring/namespace/parser/ShardingSphereAlgorithmBeanDefinitionParser.java
index 81d2e990ea1..336104c091f 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/main/java/org/apache/shardingsphere/spring/namespace/parser/ShardingSphereAlgorithmBeanDefinitionParser.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/main/java/org/apache/shardingsphere/spring/namespace/parser/ShardingSphereAlgorithmBeanDefinitionParser.java
@@ -77,6 +77,9 @@ public final class ShardingSphereAlgorithmBeanDefinitionParser extends AbstractB
             case "sharding:key-generate-algorithm":
                 setPropertyValue(parserContext, element.getAttribute(ID_ATTRIBUTE), AlgorithmProvidedShardingRuleConfiguration.class, "keyGenerators");
                 break;
+            case "sharding:audit-algorithm":
+                setPropertyValue(parserContext, element.getAttribute(ID_ATTRIBUTE), AlgorithmProvidedShardingRuleConfiguration.class, "auditors");
+                break;
             default:
                 break;
         }