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.proxy.backend.config.yaml;
19  
20  import lombok.Getter;
21  import lombok.Setter;
22  import org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration;
23  import org.apache.shardingsphere.globalclock.yaml.config.YamlGlobalClockRuleConfiguration;
24  import org.apache.shardingsphere.infra.util.yaml.YamlConfiguration;
25  import org.apache.shardingsphere.infra.yaml.config.pojo.mode.YamlModeConfiguration;
26  import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
27  import org.apache.shardingsphere.parser.yaml.config.YamlSQLParserRuleConfiguration;
28  import org.apache.shardingsphere.sqlfederation.yaml.config.YamlSQLFederationRuleConfiguration;
29  import org.apache.shardingsphere.sqltranslator.yaml.config.YamlSQLTranslatorRuleConfiguration;
30  import org.apache.shardingsphere.transaction.yaml.config.YamlTransactionRuleConfiguration;
31  
32  import java.util.Collection;
33  import java.util.HashMap;
34  import java.util.LinkedList;
35  import java.util.Map;
36  import java.util.Properties;
37  
38  /**
39   * YAML server configuration for ShardingSphere-Proxy.
40   */
41  @Getter
42  @Setter
43  public final class YamlProxyServerConfiguration implements YamlConfiguration {
44      
45      private YamlModeConfiguration mode;
46      
47      private YamlAuthorityRuleConfiguration authority;
48      
49      private YamlTransactionRuleConfiguration transaction;
50      
51      private YamlSQLParserRuleConfiguration sqlParser;
52      
53      private YamlSQLTranslatorRuleConfiguration sqlTranslator;
54      
55      private YamlGlobalClockRuleConfiguration globalClock;
56      
57      private YamlSQLFederationRuleConfiguration sqlFederation;
58      
59      private Map<String, YamlProxyDataSourceConfiguration> dataSources = new HashMap<>();
60      
61      private Collection<YamlRuleConfiguration> rules = new LinkedList<>();
62      
63      private Properties props = new Properties();
64      
65      private Collection<String> labels;
66      
67      /**
68       * Set rules if the param rules is not null.
69       *
70       * @param rules the rules to set
71       */
72      public void setRules(final Collection<YamlRuleConfiguration> rules) {
73          if (null != rules) {
74              this.rules = rules;
75          }
76      }
77      
78      /**
79       * Set props if the param props is not null.
80       *
81       * @param props the props to set
82       */
83      public void setProps(final Properties props) {
84          if (null != props) {
85              this.props = props;
86          }
87      }
88  }