View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.shardingsphere.mode.spi;
19  
20  import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
21  import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
22  import org.apache.shardingsphere.infra.rule.event.rule.alter.AlterRuleItemEvent;
23  import org.apache.shardingsphere.infra.rule.event.rule.drop.DropRuleItemEvent;
24  import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
25  import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
26  
27  /**
28   * Rule item configuration changed processor.
29   *
30   * @param <T> type of rule configuration
31   * @param <I> type of rule item configuration
32   */
33  @SingletonSPI
34  public interface RuleItemConfigurationChangedProcessor<T extends RuleConfiguration, I> extends TypedSPI {
35      
36      /**
37       * Swap rule item configuration.
38       * 
39       * @param event alter rule item event
40       * @param yamlContent YAML content
41       * @return rule item configuration
42       */
43      I swapRuleItemConfiguration(AlterRuleItemEvent event, String yamlContent);
44      
45      /**
46       * Find rule configuration.
47       * 
48       * @param database database
49       * @return found rule configuration
50       */
51      T findRuleConfiguration(ShardingSphereDatabase database);
52      
53      /**
54       * Change rule item configuration.
55       * 
56       * @param event alter rule item event
57       * @param currentRuleConfig current rule configuration
58       * @param toBeChangedItemConfig to be changed item configuration
59       */
60      void changeRuleItemConfiguration(AlterRuleItemEvent event, T currentRuleConfig, I toBeChangedItemConfig);
61      
62      /**
63       * Drop rule item configuration.
64       * 
65       * @param event drop rule item event
66       * @param currentRuleConfig current rule configuration
67       */
68      void dropRuleItemConfiguration(DropRuleItemEvent event, T currentRuleConfig);
69  }