Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Apache Shardingsphere RuleItemConfigurationChangedProcessor SPI

From Leeroopedia


Knowledge Sources
Domains SPI, Rule_Management
Last Updated 2026-02-10 00:00 GMT

Overview

RuleItemConfigurationChangedProcessor is an SPI interface for processing rule item configuration changes with swap, find, change, and drop operations.

Description

RuleItemConfigurationChangedProcessor is a generic interface parameterized by T extends RuleConfiguration and I (rule item type). It is annotated with @SingletonSPI and extends TypedSPI. The interface defines four operations: swapRuleItemConfiguration deserializes YAML content into a rule item configuration, findRuleConfiguration locates the current rule configuration from a database, changeRuleItemConfiguration applies a change to a specific named item within the current config, and dropRuleItemConfiguration removes a named item from the current config. The getType method returns a RuleChangedItemType to identify which rule item type this processor handles.

Usage

Implement this SPI for each rule item type that can be dynamically changed (e.g., sharding tables, encryption columns, algorithms). The mode subsystem loads processors via SPI and dispatches configuration change events to the matching processor based on RuleChangedItemType.

Code Reference

Source Location

Signature

@SingletonSPI
public interface RuleItemConfigurationChangedProcessor<T extends RuleConfiguration, I> extends TypedSPI {

    I swapRuleItemConfiguration(String itemName, String yamlContent);

    T findRuleConfiguration(ShardingSphereDatabase database);

    void changeRuleItemConfiguration(String itemName, T currentRuleConfig, I toBeChangedItemConfig);

    void dropRuleItemConfiguration(String itemName, T currentRuleConfig);

    @Override
    RuleChangedItemType getType();
}

Import

import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;

I/O Contract

Inputs

Name Type Required Description
itemName String Yes Name of the rule item being changed or dropped
yamlContent String Yes YAML string content to deserialize into a rule item config
database ShardingSphereDatabase Yes Database to find current rule configuration from
currentRuleConfig T (RuleConfiguration) Yes Current rule config to apply changes to
toBeChangedItemConfig I Yes The new item configuration to apply

Outputs

Name Type Description
ruleItemConfig I Deserialized rule item configuration from YAML
ruleConfiguration T Found rule configuration from the database
ruleChangedItemType RuleChangedItemType Identifies which rule/item type this processor handles

Usage Examples

// Load processor via SPI
RuleItemConfigurationChangedProcessor processor =
    TypedSPILoader.getService(RuleItemConfigurationChangedProcessor.class, ruleChangedItemType);

// Swap YAML content to rule item config
Object itemConfig = processor.swapRuleItemConfiguration("t_order", yamlContent);

// Find current rule configuration
RuleConfiguration currentConfig = processor.findRuleConfiguration(database);

// Apply the change
processor.changeRuleItemConfiguration("t_order", currentConfig, itemConfig);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment