Implementation:Apache Shardingsphere DatabaseRuleNodePath Search
| Knowledge Sources | |
|---|---|
| Domains | Mode_Management, Registry_Path |
| Last Updated | 2026-02-10 00:00 GMT |
Overview
DatabaseRuleNodePath represents a node path for database rules and provides factory methods for creating search criteria and path matching utilities.
Description
DatabaseRuleNodePath is a final class annotated with @NodePathEntity that models the hierarchical path structure ${database}/rules/${ruleType}/${databaseRuleItem}. It composes a DatabaseMetaDataNodePath for the database segment and a DatabaseRuleItem for the rule item segment. The class provides static methods to create NodePathSearchCriteria for rule type searches and rule item name searches, as well as path matching checks for rule type, named rule item, and unique rule item paths.
Usage
Use this class when you need to construct or match registry paths for database-level rule configurations. The search criteria factory methods are used by event handlers and persistence services to locate rule nodes in the registry hierarchy.
Code Reference
Source Location
- Repository: Apache_Shardingsphere
- File: DatabaseRuleNodePath.java
- Lines: 1-108
Signature
@NodePathEntity("${database}/rules/${ruleType}/${databaseRuleItem}")
@Getter
public final class DatabaseRuleNodePath implements NodePath {
public DatabaseRuleNodePath(final String databaseName, final String ruleType,
final DatabaseRuleItem databaseRuleItem)
public static NodePathSearchCriteria createRuleTypeSearchCriteria(final String databaseName)
public static NodePathSearchCriteria createRuleItemNameSearchCriteria(
final String databaseName, final String ruleType, final String ruleItemType)
public static boolean isRuleTypePath(final String databaseName, final String path)
public static boolean isNamedRuleItemPath(
final String databaseName, final String ruleType, final String ruleItemType, final String path)
public static boolean isUniqueRuleItemPath(
final String databaseName, final String ruleType, final String ruleItemType, final String path)
}
Import
import org.apache.shardingsphere.mode.node.path.type.database.metadata.rule.DatabaseRuleNodePath;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| databaseName | String | Yes | Name of the database in the path |
| ruleType | String | Yes | Type of the rule (e.g., "sharding", "encrypt") |
| databaseRuleItem | DatabaseRuleItem | No | Rule item segment; null for rule-type-level searches |
| path | String | Yes | Full path to match against for boolean checks |
Outputs
| Name | Type | Description |
|---|---|---|
| searchCriteria | NodePathSearchCriteria | Search criteria for locating rule nodes |
| isMatch | boolean | Whether the given path matches the expected rule path pattern |
Usage Examples
// Create search criteria for all rule types in a database
NodePathSearchCriteria criteria = DatabaseRuleNodePath.createRuleTypeSearchCriteria("my_db");
// Check if a path is a rule type path
boolean isRule = DatabaseRuleNodePath.isRuleTypePath("my_db", "/metadata/my_db/rules/sharding");
// Check if a path matches a named rule item
boolean isNamed = DatabaseRuleNodePath.isNamedRuleItemPath("my_db", "sharding", "tables", path);