You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ji...@apache.org on 2022/01/16 15:50:23 UTC

[shardingsphere] branch master updated: Cache DataSourceProperties.standardProperties (#14812)

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

jianglongtao 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 42750ae  Cache DataSourceProperties.standardProperties (#14812)
42750ae is described below

commit 42750ae6de421377d487dff6d7924a0a71253282
Author: Liang Zhang <te...@163.com>
AuthorDate: Sun Jan 16 23:49:37 2022 +0800

    Cache DataSourceProperties.standardProperties (#14812)
    
    * Refactor DataSourceProperties
    
    * Cache DataSourceProperties.standardProperties
---
 .../datasource/props/DataSourceProperties.java     | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourceProperties.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourceProperties.java
index 1632966..8886760 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourceProperties.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourceProperties.java
@@ -41,17 +41,20 @@ public final class DataSourceProperties {
     @Getter(AccessLevel.NONE)
     private final Map<String, String> propertySynonyms;
     
+    private final Map<String, Object> standardProperties;
+    
     private final Map<String, Object> localProperties;
     
     private final Properties customPoolProps = new Properties();
     
-    public DataSourceProperties(final String dataSourceClassName, final Map<String, Object> localProperties) {
+    public DataSourceProperties(final String dataSourceClassName, final Map<String, Object> props) {
         this.dataSourceClassName = dataSourceClassName;
         propertySynonyms = DataSourcePoolMetaDataFactory.newInstance(dataSourceClassName).getPropertySynonyms();
-        this.localProperties = getLocalProperties(localProperties);
+        standardProperties = buildStandardProperties(props);
+        localProperties = buildLocalProperties(props);
     }
     
-    private Map<String, Object> getLocalProperties(final Map<String, Object> props) {
+    private Map<String, Object> buildLocalProperties(final Map<String, Object> props) {
         Map<String, Object> result = new LinkedHashMap<>(props);
         for (Entry<String, String> entry : propertySynonyms.entrySet()) {
             String standardPropertyName = entry.getKey();
@@ -64,18 +67,13 @@ public final class DataSourceProperties {
         return result;
     }
     
-    /**
-     * Get standard properties.
-     * 
-     * @return standard properties
-     */
-    public Map<String, Object> getStandardProperties() {
-        Map<String, Object> result = new LinkedHashMap<>(localProperties);
+    private Map<String, Object> buildStandardProperties(final Map<String, Object> props) {
+        Map<String, Object> result = new LinkedHashMap<>(props);
         for (Entry<String, String> entry : propertySynonyms.entrySet()) {
             String standardPropertyName = entry.getKey();
             String synonymsPropertyName = entry.getValue();
-            if (localProperties.containsKey(synonymsPropertyName)) {
-                result.put(standardPropertyName, localProperties.get(synonymsPropertyName));
+            if (props.containsKey(synonymsPropertyName)) {
+                result.put(standardPropertyName, props.get(synonymsPropertyName));
                 result.remove(synonymsPropertyName);
             }
         }