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

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git


The following commit(s) were added to refs/heads/master by this push:
     new e608843  [SCB-2237] allow InjectProperties inject to spring bean 
instance (#2314)
e608843 is described below

commit e608843102a64c8c85a9b85ade840874023e9561
Author: wujimin <[email protected]>
AuthorDate: Sat Mar 27 14:09:51 2021 +0800

    [SCB-2237] allow InjectProperties inject to spring bean instance (#2314)
---
 .../servicecomb/core/CseApplicationListener.java   |   2 +
 .../org/apache/servicecomb/core/SCBEngine.java     |  12 ++-
 .../core/bootstrap/SCBEngineForTest.java           |   7 ++
 .../config/inject/InjectBeanPostProcessor.java     |  48 +++++++++
 .../servicecomb/config/priority/ConfigObject.java} |  82 ++++++++--------
 .../{inject => priority}/ConfigObjectFactory.java  |  88 ++++++++---------
 .../config/priority/ConfigObjectProperty.java}     |  81 ++++++++--------
 .../config/priority/PriorityProperty.java          |  86 ++++++++--------
 .../config/priority/PriorityPropertyFactory.java   |  73 ++++++++++++++
 .../config/priority/PriorityPropertyManager.java   | 108 +++++++--------------
 .../config/priority/PriorityPropertyType.java      |  79 +++++++++++++++
 .../config/inject/TestConfigObjectFactory.java     |  10 +-
 .../config/priority/TestPriorityProperty.java      |  16 +--
 .../config/priority/TestPriorityPropertyBase.java  |  20 +++-
 .../priority/TestPriorityPropertyFactory.java      |  42 ++++++++
 .../priority/TestPriorityPropertyManager.java      |  32 +-----
 .../inspector/internal/InspectorBootListener.java  |  24 +++--
 .../inspector/internal/InspectorConfig.java        |   8 +-
 .../inspector/internal/InspectorImpl.java          |  44 ++++-----
 .../org.apache.servicecomb.core.BootListener       |  18 ----
 .../internal/TestInspectorBootListener.java        |  66 ++++++-------
 .../inspector/internal/TestInspectorImpl.java      |  25 ++---
 .../src/main/resources/microservice.yaml           |  31 ++++++
 23 files changed, 597 insertions(+), 405 deletions(-)

diff --git 
a/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java 
b/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java
index 2cff295..4e50026 100644
--- a/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java
+++ b/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java
@@ -17,6 +17,7 @@
 
 package org.apache.servicecomb.core;
 
+import org.apache.servicecomb.config.priority.PriorityPropertyManager;
 import org.apache.servicecomb.core.filter.FilterChainsManager;
 import org.apache.servicecomb.foundation.common.utils.BeanUtils;
 import org.apache.servicecomb.foundation.vertx.client.http.HttpClients;
@@ -77,6 +78,7 @@ public class CseApplicationListener
 //        
SCBEngine.getInstance().setConsumerProviderManager(applicationContext.getBean(ConsumerProviderManager.class));
 //        
SCBEngine.getInstance().setTransportManager(applicationContext.getBean(TransportManager.class));
       scbEngine.setApplicationContext(applicationContext);
+      
scbEngine.setPriorityPropertyManager(applicationContext.getBean(PriorityPropertyManager.class));
       
scbEngine.setFilterChainsManager(applicationContext.getBean(FilterChainsManager.class));
       scbEngine.getConsumerProviderManager().getConsumerProviderList()
           
.addAll(applicationContext.getBeansOfType(ConsumerProvider.class).values());
diff --git a/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java 
b/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java
index 5c6d3d5..7e05dfa 100644
--- a/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java
+++ b/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java
@@ -118,7 +118,7 @@ public class SCBEngine {
 
   private ExecutorManager executorManager = new ExecutorManager();
 
-  private PriorityPropertyManager priorityPropertyManager = new 
PriorityPropertyManager();
+  private PriorityPropertyManager priorityPropertyManager;
 
   protected List<BootUpInformationCollector> bootUpInformationCollectors = 
SPIServiceUtils
       .getSortedService(BootUpInformationCollector.class);
@@ -206,6 +206,11 @@ public class SCBEngine {
     return priorityPropertyManager;
   }
 
+  public SCBEngine setPriorityPropertyManager(PriorityPropertyManager 
priorityPropertyManager) {
+    this.priorityPropertyManager = priorityPropertyManager;
+    return this;
+  }
+
   public EventBus getEventBus() {
     return eventBus;
   }
@@ -451,7 +456,10 @@ public class SCBEngine {
 
     //Step 5: destroy config center source
     ConfigUtil.destroyConfigCenterConfigurationSource();
-    priorityPropertyManager.close();
+    // only be null for some test cases
+    if (priorityPropertyManager != null) {
+      priorityPropertyManager.close();
+    }
 
     //Step 6: Stop vertx to prevent blocking exit
     // delete the following one line when every refactor is done.
diff --git 
a/core/src/main/java/org/apache/servicecomb/core/bootstrap/SCBEngineForTest.java
 
b/core/src/main/java/org/apache/servicecomb/core/bootstrap/SCBEngineForTest.java
index 61034a5..71b5af2 100644
--- 
a/core/src/main/java/org/apache/servicecomb/core/bootstrap/SCBEngineForTest.java
+++ 
b/core/src/main/java/org/apache/servicecomb/core/bootstrap/SCBEngineForTest.java
@@ -22,6 +22,9 @@ import static 
org.apache.servicecomb.core.executor.ExecutorManager.EXECUTOR_GROU
 import java.util.Arrays;
 import java.util.List;
 
+import org.apache.servicecomb.config.priority.ConfigObjectFactory;
+import org.apache.servicecomb.config.priority.PriorityPropertyFactory;
+import org.apache.servicecomb.config.priority.PriorityPropertyManager;
 import org.apache.servicecomb.core.SCBEngine;
 import org.apache.servicecomb.core.executor.GroupExecutor;
 import org.apache.servicecomb.core.filter.Filter;
@@ -43,6 +46,10 @@ public class SCBEngineForTest extends SCBEngine {
     );
     setFilterChainsManager(new FilterChainsManager()
         .addFilters(filters));
+
+    PriorityPropertyFactory propertyFactory = new PriorityPropertyFactory();
+    ConfigObjectFactory configObjectFactory = new 
ConfigObjectFactory(propertyFactory);
+    setPriorityPropertyManager(new 
PriorityPropertyManager(configObjectFactory));
   }
 
   @Override
diff --git 
a/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/inject/InjectBeanPostProcessor.java
 
b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/inject/InjectBeanPostProcessor.java
new file mode 100644
index 0000000..a520250
--- /dev/null
+++ 
b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/inject/InjectBeanPostProcessor.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.config.inject;
+
+import java.util.Collections;
+
+import org.apache.servicecomb.config.priority.PriorityPropertyManager;
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.stereotype.Component;
+
+@Component
+public class InjectBeanPostProcessor implements BeanPostProcessor {
+  private final PriorityPropertyManager priorityPropertyManager;
+
+  public InjectBeanPostProcessor(PriorityPropertyManager 
priorityPropertyManager) {
+    this.priorityPropertyManager = priorityPropertyManager;
+  }
+
+  @Override
+  public Object postProcessAfterInitialization(Object bean, String beanName) 
throws BeansException {
+    Class<?> beanCls = BeanUtils.getImplClassFromBean(bean);
+    InjectProperties injectProperties = 
beanCls.getAnnotation(InjectProperties.class);
+    if (injectProperties == null) {
+      return bean;
+    }
+
+    priorityPropertyManager.createConfigObject(bean, Collections.emptyMap());
+
+    return bean;
+  }
+}
diff --git 
a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyBase.java
 
b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/ConfigObject.java
similarity index 58%
copy from 
foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyBase.java
copy to 
foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/ConfigObject.java
index 841c8a9..19e75c1 100644
--- 
a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyBase.java
+++ 
b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/ConfigObject.java
@@ -1,43 +1,39 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicecomb.config.priority;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
-import org.junit.After;
-import org.junit.Before;
-
-public class TestPriorityPropertyBase {
-  protected PriorityPropertyManager priorityPropertyManager;
-
-  @Before
-  public void setup() {
-    // avoid write too many logs
-    Logger.getRootLogger().setLevel(Level.OFF);
-
-    ArchaiusUtils.resetConfig();
-    priorityPropertyManager = new PriorityPropertyManager();
-
-    Logger.getRootLogger().setLevel(Level.INFO);
-  }
-
-  @After
-  public void teardown() {
-    ArchaiusUtils.resetConfig();
-  }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.config.priority;
+
+import java.util.List;
+
+public class ConfigObject<T> {
+  private final T instance;
+
+  private final List<ConfigObjectProperty> properties;
+
+  public ConfigObject(T instance, List<ConfigObjectProperty> properties) {
+    this.instance = instance;
+    this.properties = properties;
+  }
+
+  public T getInstance() {
+    return instance;
+  }
+
+  public List<ConfigObjectProperty> getProperties() {
+    return properties;
+  }
+}
diff --git 
a/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/inject/ConfigObjectFactory.java
 
b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/ConfigObjectFactory.java
similarity index 74%
rename from 
foundations/foundation-config/src/main/java/org/apache/servicecomb/config/inject/ConfigObjectFactory.java
rename to 
foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/ConfigObjectFactory.java
index 44fcb57..66fbf79 100644
--- 
a/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/inject/ConfigObjectFactory.java
+++ 
b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/ConfigObjectFactory.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.servicecomb.config.inject;
+package org.apache.servicecomb.config.priority;
 
 import static 
org.apache.servicecomb.foundation.common.utils.LambdaMetafactoryUtils.createObjectSetter;
 
@@ -23,10 +23,12 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.servicecomb.config.priority.PriorityProperty;
-import org.apache.servicecomb.config.priority.PriorityPropertyManager;
+import org.apache.servicecomb.config.inject.InjectProperties;
+import org.apache.servicecomb.config.inject.InjectProperty;
+import org.apache.servicecomb.config.inject.PlaceholderResolver;
 import org.apache.servicecomb.foundation.common.utils.JsonUtils;
 import org.apache.servicecomb.foundation.common.utils.bean.Setter;
+import org.springframework.stereotype.Component;
 
 import com.fasterxml.jackson.databind.BeanDescription;
 import com.fasterxml.jackson.databind.JavaType;
@@ -40,55 +42,49 @@ import com.fasterxml.jackson.databind.type.TypeFactory;
  * ${} or ${not-exist-key} is valid key in archaius<br>
  * so this wrapper mechanism will not throw exception even can not find value 
by placeholder
  */
+@Component
 public class ConfigObjectFactory {
-  private PriorityPropertyManager priorityPropertyManager;
+  private final PriorityPropertyFactory propertyFactory;
 
-  private Class<?> cls;
-
-  private Map<String, Object> parameters;
-
-  private Object instance;
-
-  private String prefix = "";
-
-  private List<PriorityProperty<?>> priorityProperties = new ArrayList<>();
+  public ConfigObjectFactory(PriorityPropertyFactory propertyFactory) {
+    this.propertyFactory = propertyFactory;
+  }
 
-  @SuppressWarnings("unchecked")
-  public <T> T create(PriorityPropertyManager priorityPropertyManager, 
Class<T> cls, Map<String, Object> parameters) {
-    this.priorityPropertyManager = priorityPropertyManager;
-    this.cls = cls;
-    this.parameters = parameters;
+  public PriorityPropertyFactory getPropertyFactory() {
+    return propertyFactory;
+  }
 
+  public <T> ConfigObject<T> create(Class<T> cls, Map<String, Object> 
parameters) {
     try {
-      instance = cls.newInstance();
+      return create(cls.newInstance(), parameters);
     } catch (Throwable e) {
       throw new IllegalStateException("create config object failed, class=" + 
cls.getName(), e);
     }
-
-    initPrefix();
-    doCreate();
-
-    return (T) instance;
   }
 
-  public List<PriorityProperty<?>> getPriorityProperties() {
-    return priorityProperties;
+  public <T> ConfigObject<T> create(T instance, Map<String, Object> 
parameters) {
+    String prefix = initPrefix(instance.getClass());
+    List<ConfigObjectProperty> properties = createProperties(instance, prefix, 
parameters);
+
+    return new ConfigObject<>(instance, properties);
   }
 
-  private void initPrefix() {
+  private String initPrefix(Class<?> cls) {
     InjectProperties injectProperties = 
cls.getAnnotation(InjectProperties.class);
     if (injectProperties == null) {
-      return;
+      return "";
     }
 
     String prefix = injectProperties.prefix();
-    if (!prefix.isEmpty()) {
-      this.prefix = prefix + ".";
+    if (prefix.isEmpty()) {
+      return "";
     }
+    return prefix + ".";
   }
 
-  private void doCreate() {
-    JavaType javaType = TypeFactory.defaultInstance().constructType(cls);
+  public List<ConfigObjectProperty> createProperties(Object instance, String 
prefix, Map<String, Object> parameters) {
+    List<ConfigObjectProperty> properties = new ArrayList<>();
+    JavaType javaType = 
TypeFactory.defaultInstance().constructType(instance.getClass());
     BeanDescription beanDescription = 
JsonUtils.OBJ_MAPPER.getSerializationConfig().introspect(javaType);
     for (BeanPropertyDefinition propertyDefinition : 
beanDescription.findProperties()) {
       if (propertyDefinition.getField() == null) {
@@ -100,14 +96,16 @@ public class ConfigObjectFactory {
       }
 
       Setter<Object, Object> setter = createObjectSetter(propertyDefinition);
-      PriorityProperty<?> priorityProperty = 
createPriorityProperty(propertyDefinition.getField().getAnnotated());
-      priorityProperty.setCallback((value, target) -> setter.set(target, 
value), instance);
-      priorityProperties.add(priorityProperty);
+      PriorityProperty<?> priorityProperty = 
createPriorityProperty(propertyDefinition.getField().getAnnotated(),
+          prefix, parameters);
+      setter.set(instance, priorityProperty.getValue());
+      properties.add(new ConfigObjectProperty(setter, priorityProperty));
     }
+    return properties;
   }
 
-  private PriorityProperty<?> createPriorityProperty(Field field) {
-    String[] keys = collectPropertyKeys(field);
+  private PriorityProperty<?> createPriorityProperty(Field field, String 
prefix, Map<String, Object> parameters) {
+    String[] keys = collectPropertyKeys(field, prefix, parameters);
 
     Class<?> fieldCls = field.getType();
     switch (fieldCls.getName()) {
@@ -147,7 +145,7 @@ public class ConfigObjectFactory {
       }
     }
 
-    return priorityPropertyManager.newPriorityProperty(String.class, null, 
defaultValue, keys);
+    return propertyFactory.getOrCreate(String.class, null, defaultValue, keys);
   }
 
   private PriorityProperty<?> createDoubleProperty(Field field, String[] keys, 
Double defaultValue) {
@@ -158,7 +156,7 @@ public class ConfigObjectFactory {
       }
     }
 
-    return priorityPropertyManager.newPriorityProperty(Double.class, null, 
defaultValue, keys);
+    return propertyFactory.getOrCreate(Double.class, null, defaultValue, keys);
   }
 
   private PriorityProperty<?> createFloatProperty(Field field, String[] keys, 
Float defaultValue) {
@@ -169,7 +167,7 @@ public class ConfigObjectFactory {
       }
     }
 
-    return priorityPropertyManager.newPriorityProperty(Float.class, null, 
defaultValue, keys);
+    return propertyFactory.getOrCreate(Float.class, null, defaultValue, keys);
   }
 
   private PriorityProperty<?> createBooleanProperty(Field field, String[] 
keys, Boolean defaultValue) {
@@ -180,7 +178,7 @@ public class ConfigObjectFactory {
       }
     }
 
-    return priorityPropertyManager.newPriorityProperty(Boolean.class, null, 
defaultValue, keys);
+    return propertyFactory.getOrCreate(Boolean.class, null, defaultValue, 
keys);
   }
 
   private PriorityProperty<?> createLongProperty(Field field, String[] keys, 
Long defaultValue) {
@@ -191,7 +189,7 @@ public class ConfigObjectFactory {
       }
     }
 
-    return priorityPropertyManager.newPriorityProperty(Long.class, null, 
defaultValue, keys);
+    return propertyFactory.getOrCreate(Long.class, null, defaultValue, keys);
   }
 
   private PriorityProperty<?> createIntProperty(Field field, String[] keys, 
Integer defaultValue) {
@@ -202,10 +200,10 @@ public class ConfigObjectFactory {
       }
     }
 
-    return priorityPropertyManager.newPriorityProperty(Integer.class, null, 
defaultValue, keys);
+    return propertyFactory.getOrCreate(Integer.class, null, defaultValue, 
keys);
   }
 
-  private String[] collectPropertyKeys(Field field) {
+  private String[] collectPropertyKeys(Field field, String prefix, Map<String, 
Object> parameters) {
     String propertyPrefix = prefix;
     String[] keys = new String[] {field.getName()};
 
@@ -225,6 +223,6 @@ public class ConfigObjectFactory {
       finalKeys.addAll(resolvedKeys);
     }
 
-    return finalKeys.toArray(new String[finalKeys.size()]);
+    return finalKeys.toArray(new String[0]);
   }
 }
\ No newline at end of file
diff --git 
a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyBase.java
 
b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/ConfigObjectProperty.java
similarity index 58%
copy from 
foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyBase.java
copy to 
foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/ConfigObjectProperty.java
index 841c8a9..7231999 100644
--- 
a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyBase.java
+++ 
b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/ConfigObjectProperty.java
@@ -1,43 +1,38 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.servicecomb.config.priority;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
-import org.junit.After;
-import org.junit.Before;
-
-public class TestPriorityPropertyBase {
-  protected PriorityPropertyManager priorityPropertyManager;
-
-  @Before
-  public void setup() {
-    // avoid write too many logs
-    Logger.getRootLogger().setLevel(Level.OFF);
-
-    ArchaiusUtils.resetConfig();
-    priorityPropertyManager = new PriorityPropertyManager();
-
-    Logger.getRootLogger().setLevel(Level.INFO);
-  }
-
-  @After
-  public void teardown() {
-    ArchaiusUtils.resetConfig();
-  }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.config.priority;
+
+import org.apache.servicecomb.foundation.common.utils.bean.Setter;
+
+/**
+ * do not reference config object instance, otherwise gc for weak hash map 
will failed
+ */
+public class ConfigObjectProperty {
+  private final Setter<Object, Object> setter;
+
+  private final PriorityProperty<?> property;
+
+  public ConfigObjectProperty(Setter<Object, Object> setter, 
PriorityProperty<?> property) {
+    this.setter = setter;
+    this.property = property;
+  }
+
+  public void updateValue(Object instance) {
+    setter.set(instance, property.getValue());
+  }
+}
diff --git 
a/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/PriorityProperty.java
 
b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/PriorityProperty.java
index a07f8c3..faad071 100644
--- 
a/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/PriorityProperty.java
+++ 
b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/PriorityProperty.java
@@ -19,7 +19,6 @@ package org.apache.servicecomb.config.priority;
 import java.lang.reflect.Type;
 import java.util.Arrays;
 import java.util.Objects;
-import java.util.function.BiConsumer;
 import java.util.function.Function;
 
 import org.slf4j.Logger;
@@ -35,42 +34,31 @@ import com.netflix.config.DynamicProperty;
 public class PriorityProperty<T> {
   private static final Logger LOGGER = 
LoggerFactory.getLogger(PriorityProperty.class);
 
-  // priorityKeys[0] has the highest priority
-  private final String[] priorityKeys;
+  private final PriorityPropertyType<T> propertyType;
 
   private final String joinedPriorityKeys;
 
-  // when got invalid value will try next level
-  // null always be a invalid value
-  private final T invalidValue;
+  private final Function<DynamicProperty, T> internalValueReader;
 
-  // when got invalid value by lowest level, will use defaultValue
-  private final T defaultValue;
-
-  private DynamicProperty[] properties;
+  private final DynamicProperty[] properties;
 
   private T finalValue;
 
-  private Function<DynamicProperty, T> internalValueReader;
-
-  private BiConsumer<T, Object> callback = (t, u) -> {
-  };
-
-  @SuppressWarnings("unchecked")
-  PriorityProperty(Type type, T invalidValue, T defaultValue, String... 
priorityKeys) {
-    internalValueReader = collectReader(type);
-
-    this.priorityKeys = priorityKeys;
-    this.joinedPriorityKeys = Arrays.toString(priorityKeys);
-    this.invalidValue = invalidValue;
-    this.defaultValue = defaultValue;
+  public PriorityProperty(PriorityPropertyType<T> propertyType) {
+    this.propertyType = propertyType;
+    this.joinedPriorityKeys = Arrays.toString(propertyType.getPriorityKeys());
+    this.internalValueReader = collectReader(propertyType.getType());
+    this.properties = createProperties(propertyType.getPriorityKeys());
+    initValue();
+  }
 
-    properties = new DynamicProperty[priorityKeys.length];
+  private DynamicProperty[] createProperties(String[] priorityKeys) {
+    DynamicProperty[] properties = new DynamicProperty[priorityKeys.length];
     for (int idx = 0; idx < priorityKeys.length; idx++) {
       String key = priorityKeys[idx].trim();
       properties[idx] = DynamicProperty.getInstance(key);
     }
-    updateFinalValue(true);
+    return properties;
   }
 
   private Function<DynamicProperty, T> collectReader(Type type) {
@@ -132,29 +120,47 @@ public class PriorityProperty<T> {
   }
 
   public String[] getPriorityKeys() {
-    return priorityKeys;
+    return propertyType.getPriorityKeys();
   }
 
   public T getDefaultValue() {
-    return defaultValue;
+    return propertyType.getDefaultValue();
   }
 
   public DynamicProperty[] getProperties() {
     return properties;
   }
 
-  synchronized void updateFinalValue(boolean init) {
-    updateFinalValue(init, this);
+  void initValue() {
+    String effectiveKey = doUpdateFinalValue();
+    LOGGER.debug("config inited, \"{}\" set to {}, effective key is \"{}\".",
+        joinedPriorityKeys, finalValue, effectiveKey);
   }
 
-  synchronized void updateFinalValue(boolean init, Object target) {
+  synchronized boolean updateValue() {
+    T lastValue = finalValue;
+    String effectiveKey = doUpdateFinalValue();
+    if (effectiveKey != null) {
+      LOGGER.debug("config changed, \"{}\" changed from {} to {}, effective 
key is \"{}\".",
+          joinedPriorityKeys, lastValue, finalValue, effectiveKey);
+      return true;
+    }
+
+    return false;
+  }
+
+  /**
+   *
+   * @return if value changed, return effectiveKey, otherwise null
+   */
+  private String doUpdateFinalValue() {
     T lastValue = finalValue;
 
     String effectiveKey = "default value";
-    T value = defaultValue;
+    T value = propertyType.getDefaultValue();
     for (DynamicProperty property : properties) {
       T propValue = internalValueReader.apply(property);
-      if (propValue == null || propValue.equals(invalidValue)) {
+      if (propValue == null || 
propValue.equals(propertyType.getInvalidValue())) {
         continue;
       }
 
@@ -164,26 +170,14 @@ public class PriorityProperty<T> {
     }
 
     if (Objects.equals(lastValue, value)) {
-      return;
+      return null;
     }
 
-    if (init) {
-      LOGGER.debug("config inited, \"{}\" set to {}, effective key is \"{}\".",
-          joinedPriorityKeys, value, effectiveKey);
-    } else {
-      LOGGER.debug("config changed, \"{}\" changed from {} to {}, effective 
key is \"{}\".",
-          joinedPriorityKeys, finalValue, value, effectiveKey);
-    }
     finalValue = value;
-    callback.accept(finalValue, target);
+    return effectiveKey;
   }
 
   public T getValue() {
     return finalValue;
   }
-
-  public void setCallback(BiConsumer<T, Object> callback, Object target) {
-    this.callback = callback;
-    callback.accept(finalValue, target);
-  }
 }
diff --git 
a/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/PriorityPropertyFactory.java
 
b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/PriorityPropertyFactory.java
new file mode 100644
index 0000000..f3ec2a7
--- /dev/null
+++ 
b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/PriorityPropertyFactory.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.config.priority;
+
+import java.lang.reflect.Type;
+import java.util.Map;
+import java.util.stream.Stream;
+
+import javax.annotation.PreDestroy;
+
+import org.apache.commons.configuration.AbstractConfiguration;
+import org.apache.commons.configuration.event.ConfigurationEvent;
+import org.apache.commons.configuration.event.ConfigurationListener;
+import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx;
+import org.springframework.stereotype.Component;
+
+import com.netflix.config.ConfigurationManager;
+
+@Component
+public class PriorityPropertyFactory {
+  private final AbstractConfiguration configuration;
+
+  private final ConfigurationListener configurationListener = 
this::configurationListener;
+
+  // same to com.netflix.config.DynamicProperty.ALL_PROPS
+  // the set is finite
+  // will not cause OOM exception
+  private final Map<PriorityPropertyType<?>, PriorityProperty<?>> properties = 
new ConcurrentHashMapEx<>();
+
+  public PriorityPropertyFactory() {
+    this.configuration = ConfigurationManager.getConfigInstance();
+    this.configuration.addConfigurationListener(configurationListener);
+  }
+
+  @PreDestroy
+  public void onDestroy() {
+    this.configuration.removeConfigurationListener(configurationListener);
+  }
+
+  public Stream<PriorityProperty<?>> getProperties() {
+    return properties.values().stream();
+  }
+
+  private void configurationListener(ConfigurationEvent event) {
+    if (event.isBeforeUpdate()) {
+      return;
+    }
+
+    // just update all properties, it's very fast, no need to do any optimize
+    getProperties().forEach(PriorityProperty::updateValue);
+  }
+
+  @SuppressWarnings("unchecked")
+  public <T> PriorityProperty<T> getOrCreate(Type type, T invalidValue, T 
defaultValue, String... priorityKeys) {
+    PriorityPropertyType<T> propertyType = new PriorityPropertyType<>(type, 
invalidValue, defaultValue, priorityKeys);
+    return (PriorityProperty<T>) properties.computeIfAbsent(propertyType, 
PriorityProperty::new);
+  }
+}
diff --git 
a/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/PriorityPropertyManager.java
 
b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/PriorityPropertyManager.java
index dd84f5a..7cf6eaf 100644
--- 
a/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/PriorityPropertyManager.java
+++ 
b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/PriorityPropertyManager.java
@@ -16,47 +16,46 @@
  */
 package org.apache.servicecomb.config.priority;
 
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
+import static java.util.Collections.synchronizedMap;
+
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
+import java.util.Map.Entry;
 import java.util.WeakHashMap;
 
+import org.apache.commons.configuration.AbstractConfiguration;
 import org.apache.commons.configuration.event.ConfigurationEvent;
 import org.apache.commons.configuration.event.ConfigurationListener;
-import org.apache.servicecomb.config.inject.ConfigObjectFactory;
-import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx;
+import org.springframework.stereotype.Component;
 
 import com.netflix.config.ConfigurationManager;
-import com.netflix.config.DynamicPropertyFactory;
 
+@Component
 public class PriorityPropertyManager {
-  private ConfigurationListener configurationListener = 
this::configurationListener;
+  private final AbstractConfiguration configuration;
+
+  private final ConfigurationListener configurationListener = 
this::configurationListener;
 
-  private Set<PriorityProperty<?>> priorityPropertySet =
-      Collections.newSetFromMap(Collections.synchronizedMap(new 
WeakHashMap<>()));
+  private final ConfigObjectFactory configObjectFactory;
 
-  private Map<Object, List<PriorityProperty<?>>> configObjectMap =
-      Collections.synchronizedMap(new WeakHashMap<>());
+  // key is config object instance
+  // value is properties of the config object instance
+  private final Map<Object, List<ConfigObjectProperty>> configObjectMap = 
synchronizedMap(new WeakHashMap<>());
 
-  // will be reset to null after register or unregister
-  // and build when configuration changed
-  private Map<Object, Map<String, List<PriorityProperty<?>>>> keyCache;
+  public PriorityPropertyManager(ConfigObjectFactory configObjectFactory) {
+    this.configuration = ConfigurationManager.getConfigInstance();
+    this.configuration.addConfigurationListener(configurationListener);
 
-  public PriorityPropertyManager() {
-    // make sure create a DynamicPropertyFactory instance
-    // otherwise will cause wrong order of configurationListeners
-    DynamicPropertyFactory.getInstance();
+    this.configObjectFactory = configObjectFactory;
+  }
 
-    
ConfigurationManager.getConfigInstance().addConfigurationListener(configurationListener);
+  public PriorityPropertyFactory getPropertyFactory() {
+    return configObjectFactory.getPropertyFactory();
   }
 
   public void close() {
-    
ConfigurationManager.getConfigInstance().removeConfigurationListener(configurationListener);
+    configuration.removeConfigurationListener(configurationListener);
   }
 
   public synchronized void configurationListener(ConfigurationEvent event) {
@@ -64,52 +63,17 @@ public class PriorityPropertyManager {
       return;
     }
 
-    if (keyCache == null) {
-      keyCache = new ConcurrentHashMapEx<>();
-      updateCache(new Object(), priorityPropertySet);
-      configObjectMap.forEach((k, v) -> updateCache(k, v));
-    }
-
-    if (event.getPropertyName() != null) {
-      keyCache.forEach((k, v) -> v.getOrDefault(event.getPropertyName(), 
Collections.emptyList()).stream()
-          .forEach(p -> p.updateFinalValue(false, k)));
-      return;
-    }
-
-    // event like add configuration source, need to make a global refresh
-    keyCache.forEach(
-        (k, v) -> v.values().stream().flatMap(Collection::stream).forEach(
-            p -> p.updateFinalValue(false, k)));
-  }
-
-  private void updateCache(Object target, Collection<PriorityProperty<?>> 
properties) {
-    Map<String, List<PriorityProperty<?>>> targetMap = 
keyCache.computeIfAbsent(target, k -> new HashMap<>());
-    for (PriorityProperty<?> priorityProperty : properties) {
-      for (String key : priorityProperty.getPriorityKeys()) {
-        targetMap.computeIfAbsent(key, k -> new 
ArrayList<>()).add(priorityProperty);
-      }
-      priorityProperty.updateFinalValue(false, target);
+    // just update all properties, it's very fast, no need to do any optimize
+    for (Entry<Object, List<ConfigObjectProperty>> entry : 
configObjectMap.entrySet()) {
+      Object instance = entry.getKey();
+      entry.getValue().forEach(configObjectProperty -> 
configObjectProperty.updateValue(instance));
     }
   }
 
-  public Set<PriorityProperty<?>> getPriorityPropertySet() {
-    return priorityPropertySet;
-  }
-
-  public Map<Object, List<PriorityProperty<?>>> getConfigObjectMap() {
+  public Map<Object, List<ConfigObjectProperty>> getConfigObjectMap() {
     return configObjectMap;
   }
 
-  private synchronized void registerPriorityProperty(PriorityProperty<?> 
property) {
-    priorityPropertySet.add(property);
-    keyCache = null;
-  }
-
-  private synchronized void registerConfigObject(Object configObject, 
List<PriorityProperty<?>> properties) {
-    configObjectMap.put(configObject, properties);
-    keyCache = null;
-  }
-
   public <T> T createConfigObject(Class<T> cls, Object... kvs) {
     Map<String, Object> parameters = new HashMap<>();
     for (int idx = 0; idx < kvs.length; idx += 2) {
@@ -120,21 +84,17 @@ public class PriorityPropertyManager {
   }
 
   public <T> T createConfigObject(Class<T> cls, Map<String, Object> 
parameters) {
-    ConfigObjectFactory factory = new ConfigObjectFactory();
-    T configObject = factory.create(this, cls, parameters);
-    registerConfigObject(configObject, factory.getPriorityProperties());
-    return configObject;
+    ConfigObject<T> configObject = configObjectFactory.create(cls, parameters);
+    return saveConfigObject(configObject);
   }
 
-  public <T> PriorityProperty<T> newPriorityProperty(Type cls, T invalidValue, 
T defaultValue,
-      String... priorityKeys) {
-    return new PriorityProperty<>(cls, invalidValue, defaultValue, 
priorityKeys);
+  public <T> T createConfigObject(T instance, Map<String, Object> parameters) {
+    ConfigObject<T> configObject = configObjectFactory.create(instance, 
parameters);
+    return saveConfigObject(configObject);
   }
 
-  public <T> PriorityProperty<T> createPriorityProperty(Type cls, T 
invalidValue, T defaultValue,
-      String... priorityKeys) {
-    PriorityProperty<T> priorityProperty = new PriorityProperty<>(cls, 
invalidValue, defaultValue, priorityKeys);
-    registerPriorityProperty(priorityProperty);
-    return priorityProperty;
+  private <T> T saveConfigObject(ConfigObject<T> configObject) {
+    configObjectMap.put(configObject.getInstance(), 
configObject.getProperties());
+    return configObject.getInstance();
   }
 }
diff --git 
a/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/PriorityPropertyType.java
 
b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/PriorityPropertyType.java
new file mode 100644
index 0000000..843bbd8
--- /dev/null
+++ 
b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/priority/PriorityPropertyType.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.config.priority;
+
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.Objects;
+
+public class PriorityPropertyType<T> {
+  private final Type type;
+
+  // when got invalid value will try next level
+  // null always be a invalid value
+  private final T invalidValue;
+
+  // when got invalid value by lowest level, will use defaultValue
+  private final T defaultValue;
+
+  // priorityKeys[0] has the highest priority
+  private final String[] priorityKeys;
+
+  public PriorityPropertyType(Type type, T invalidValue, T defaultValue, 
String... priorityKeys) {
+    this.type = type;
+    this.invalidValue = invalidValue;
+    this.defaultValue = defaultValue;
+    this.priorityKeys = priorityKeys;
+  }
+
+  public Type getType() {
+    return type;
+  }
+
+  public T getInvalidValue() {
+    return invalidValue;
+  }
+
+  public T getDefaultValue() {
+    return defaultValue;
+  }
+
+  public String[] getPriorityKeys() {
+    return priorityKeys;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+    PriorityPropertyType<?> that = (PriorityPropertyType<?>) o;
+    return type.equals(that.type) && Objects.equals(invalidValue, 
that.invalidValue) && Objects
+        .equals(defaultValue, that.defaultValue) && 
Arrays.equals(priorityKeys, that.priorityKeys);
+  }
+
+  @Override
+  public int hashCode() {
+    int result = Objects.hash(type, invalidValue, defaultValue);
+    result = 31 * result + Arrays.hashCode(priorityKeys);
+    return result;
+  }
+}
diff --git 
a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/inject/TestConfigObjectFactory.java
 
b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/inject/TestConfigObjectFactory.java
index 92cd17f..8ca76c6 100644
--- 
a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/inject/TestConfigObjectFactory.java
+++ 
b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/inject/TestConfigObjectFactory.java
@@ -21,7 +21,7 @@ import java.util.Arrays;
 import org.apache.servicecomb.config.priority.TestPriorityPropertyBase;
 import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
 import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class TestConfigObjectFactory extends TestPriorityPropertyBase {
   public static class ConfigNoAnnotation {
@@ -189,7 +189,6 @@ public class TestConfigObjectFactory extends 
TestPriorityPropertyBase {
     Assert.assertFalse(config.isBooleanValue1());
     Assert.assertNull(config.booleanValueObj);
     Assert.assertNull(config.getBooleanValueObj1());
-
   }
 
   @Test
@@ -251,7 +250,6 @@ public class TestConfigObjectFactory extends 
TestPriorityPropertyBase {
     Assert.assertTrue(config.isBooleanValue1());
     Assert.assertTrue(config.booleanValueObj);
     Assert.assertTrue(config.getBooleanValueObj1());
-
   }
 
   @Test
@@ -313,7 +311,6 @@ public class TestConfigObjectFactory extends 
TestPriorityPropertyBase {
     Assert.assertTrue(config.isBooleanValue1());
     Assert.assertTrue(config.booleanValueObj);
     Assert.assertTrue(config.getBooleanValueObj1());
-
   }
 
   @InjectProperties(prefix = "root")
@@ -359,7 +356,6 @@ public class TestConfigObjectFactory extends 
TestPriorityPropertyBase {
     Assert.assertEquals(3, config.floatDef, 0);
     Assert.assertEquals(4, config.doubleDef, 0);
     Assert.assertTrue(config.booleanDef);
-
   }
 
   @Test
@@ -385,7 +381,6 @@ public class TestConfigObjectFactory extends 
TestPriorityPropertyBase {
 
     ArchaiusUtils.setProperty("root.low-1.a.high-1.b", Long.MAX_VALUE - 3);
     Assert.assertEquals(Long.MAX_VALUE - 3, config.longValue);
-
   }
 
   @Test
@@ -400,7 +395,6 @@ public class TestConfigObjectFactory extends 
TestPriorityPropertyBase {
 
     ArchaiusUtils.setProperty("root.l1-1", String.valueOf(2f));
     Assert.assertEquals(2f, config.floatValue, 0);
-
   }
 
   @Test
@@ -411,7 +405,6 @@ public class TestConfigObjectFactory extends 
TestPriorityPropertyBase {
 
     ArchaiusUtils.setProperty("root.k.value", "1");
     Assert.assertEquals(1, config.intValue);
-
   }
 
   @Test
@@ -429,6 +422,5 @@ public class TestConfigObjectFactory extends 
TestPriorityPropertyBase {
 
     ArchaiusUtils.setProperty("override.low", null);
     Assert.assertNull(config.strValue);
-
   }
 }
diff --git 
a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityProperty.java
 
b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityProperty.java
index 43356ed..9f4db63 100644
--- 
a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityProperty.java
+++ 
b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityProperty.java
@@ -21,7 +21,7 @@ import java.util.Collections;
 import org.apache.commons.configuration.MapConfiguration;
 import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
 import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import com.netflix.config.ConcurrentCompositeConfiguration;
 import com.netflix.config.DynamicPropertyFactory;
@@ -37,7 +37,7 @@ public class TestPriorityProperty extends 
TestPriorityPropertyBase {
 
   @Test
   public void testLong() {
-    PriorityProperty<Long> config = 
priorityPropertyManager.createPriorityProperty(Long.class, -1L, -2L, keys);
+    PriorityProperty<Long> config = propertyFactory.getOrCreate(Long.class, 
-1L, -2L, keys);
     Assert.assertEquals(-2L, (long) config.getValue());
 
     ArchaiusUtils.setProperty(low, 1L);
@@ -65,7 +65,7 @@ public class TestPriorityProperty extends 
TestPriorityPropertyBase {
 
   @Test
   public void testInt() {
-    PriorityProperty<Integer> config = 
priorityPropertyManager.createPriorityProperty(Integer.class, -1, -2, keys);
+    PriorityProperty<Integer> config = 
propertyFactory.getOrCreate(Integer.class, -1, -2, keys);
     Assert.assertEquals(-2L, (int) config.getValue());
 
     ArchaiusUtils.setProperty(low, 1);
@@ -93,7 +93,7 @@ public class TestPriorityProperty extends 
TestPriorityPropertyBase {
 
   @Test
   public void testString() {
-    PriorityProperty<String> config = 
priorityPropertyManager.createPriorityProperty(String.class, null, "def", keys);
+    PriorityProperty<String> config = 
propertyFactory.getOrCreate(String.class, null, "def", keys);
     Assert.assertEquals("def", config.getValue());
 
     ArchaiusUtils.setProperty(low, 1);
@@ -121,7 +121,7 @@ public class TestPriorityProperty extends 
TestPriorityPropertyBase {
 
   @Test
   public void testBoolean() {
-    PriorityProperty<Boolean> config = 
priorityPropertyManager.createPriorityProperty(Boolean.class, null, false, 
keys);
+    PriorityProperty<Boolean> config = 
propertyFactory.getOrCreate(Boolean.class, null, false, keys);
     Assert.assertFalse(config.getValue());
 
     ArchaiusUtils.setProperty(low, true);
@@ -149,7 +149,7 @@ public class TestPriorityProperty extends 
TestPriorityPropertyBase {
 
   @Test
   public void testDouble() {
-    PriorityProperty<Double> config = 
priorityPropertyManager.createPriorityProperty(Double.class, null, -2.0, keys);
+    PriorityProperty<Double> config = 
propertyFactory.getOrCreate(Double.class, null, -2.0, keys);
     Assert.assertEquals(-2, config.getValue(), 0);
 
     ArchaiusUtils.setProperty(low, 1);
@@ -177,7 +177,7 @@ public class TestPriorityProperty extends 
TestPriorityPropertyBase {
 
   @Test
   public void testFloat() {
-    PriorityProperty<Float> config = 
priorityPropertyManager.createPriorityProperty(Float.class, null, -2.0f, keys);
+    PriorityProperty<Float> config = propertyFactory.getOrCreate(Float.class, 
null, -2.0f, keys);
     Assert.assertEquals(-2, config.getValue(), 0);
 
     ArchaiusUtils.setProperty(low, 1);
@@ -205,7 +205,7 @@ public class TestPriorityProperty extends 
TestPriorityPropertyBase {
 
   @Test
   public void globalRefresh() {
-    PriorityProperty<String> property = 
priorityPropertyManager.createPriorityProperty(String.class, null, null, keys);
+    PriorityProperty<String> property = 
propertyFactory.getOrCreate(String.class, null, null, keys);
 
     Assert.assertNull(property.getValue());
 
diff --git 
a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyBase.java
 
b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyBase.java
index 841c8a9..d590767 100644
--- 
a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyBase.java
+++ 
b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyBase.java
@@ -19,24 +19,34 @@ package org.apache.servicecomb.config.priority;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+
+import com.netflix.config.DynamicPropertyFactory;
 
 public class TestPriorityPropertyBase {
   protected PriorityPropertyManager priorityPropertyManager;
 
-  @Before
+  protected PriorityPropertyFactory propertyFactory;
+
+  @BeforeEach
   public void setup() {
     // avoid write too many logs
     Logger.getRootLogger().setLevel(Level.OFF);
 
     ArchaiusUtils.resetConfig();
-    priorityPropertyManager = new PriorityPropertyManager();
+
+    // make sure create a DynamicPropertyFactory instance
+    // otherwise will cause wrong order of configurationListeners
+    DynamicPropertyFactory.getInstance();
+
+    propertyFactory = new PriorityPropertyFactory();
+    priorityPropertyManager = new PriorityPropertyManager(new 
ConfigObjectFactory(propertyFactory));
 
     Logger.getRootLogger().setLevel(Level.INFO);
   }
 
-  @After
+  @AfterEach
   public void teardown() {
     ArchaiusUtils.resetConfig();
   }
diff --git 
a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyFactory.java
 
b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyFactory.java
new file mode 100644
index 0000000..9024d70
--- /dev/null
+++ 
b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyFactory.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.config.priority;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.jupiter.api.Test;
+
+class TestPriorityPropertyFactory extends TestPriorityPropertyBase {
+  @Test
+  void should_not_create_multiple_instances_for_same_parameter() {
+    PriorityProperty<Integer> p1 = propertyFactory.getOrCreate(int.class, 
null, 0, "high", "low");
+    PriorityProperty<Integer> p2 = propertyFactory.getOrCreate(int.class, 
null, 0, "high", "low");
+
+    assertThat(p1).isSameAs(p2);
+    assertThat(propertyFactory.getProperties().count()).isEqualTo(1);
+  }
+
+  @Test
+  void should_create_different_instances_for_different_parameter() {
+    PriorityProperty<Integer> p1 = propertyFactory.getOrCreate(int.class, 
null, 0, "high", "low");
+    PriorityProperty<Long> p2 = propertyFactory.getOrCreate(long.class, null, 
0L, "high", "low");
+
+    assertThat(p1).isNotSameAs(p2);
+    assertThat(propertyFactory.getProperties().count()).isEqualTo(2);
+  }
+}
\ No newline at end of file
diff --git 
a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyManager.java
 
b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyManager.java
index bccf97f..35402ae 100644
--- 
a/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyManager.java
+++ 
b/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/priority/TestPriorityPropertyManager.java
@@ -17,21 +17,16 @@
 
 package org.apache.servicecomb.config.priority;
 
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
 import org.apache.servicecomb.config.ConfigUtil;
 import org.apache.servicecomb.config.inject.InjectProperties;
 import org.apache.servicecomb.config.inject.InjectProperty;
 import org.apache.servicecomb.config.inject.TestConfigObjectFactory;
-import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
-import org.junit.After;
 import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import com.netflix.config.DynamicProperty;
 
-public class TestPriorityPropertyManager {
+public class TestPriorityPropertyManager extends TestPriorityPropertyBase {
   String high = "ms.schema.op";
 
   String middle = "ms.schema";
@@ -46,27 +41,11 @@ public class TestPriorityPropertyManager {
     public String strValue;
   }
 
-  @Before
-  public void setup() {
-    // avoid write too many logs
-    Logger.getRootLogger().setLevel(Level.OFF);
-
-    ArchaiusUtils.resetConfig();
-
-    Logger.getRootLogger().setLevel(Level.INFO);
-  }
-
-  @After
-  public void teardown() {
-    ArchaiusUtils.resetConfig();
-  }
-
   private void waitKeyForGC(PriorityPropertyManager priorityPropertyManager) {
     long maxTime = 10000;
     long currentTime = System.currentTimeMillis();
     while (System.currentTimeMillis() - currentTime < maxTime) {
-      if (priorityPropertyManager.getPriorityPropertySet().isEmpty()
-          && priorityPropertyManager.getConfigObjectMap().isEmpty()) {
+      if (priorityPropertyManager.getConfigObjectMap().isEmpty()) {
         break;
       }
       System.runFinalization();
@@ -84,21 +63,18 @@ public class TestPriorityPropertyManager {
   public void testConfigurationsAreGCCollected() {
     long timeBegin = System.currentTimeMillis();
 
-    PriorityPropertyManager priorityPropertyManager = new 
PriorityPropertyManager();
     for (int i = 0; i < 100; i++) {
       for (int j = 0; j < 100; j++) {
         TestConfigObjectFactory.ConfigWithAnnotation configConfigObject = 
priorityPropertyManager.createConfigObject(
             TestConfigObjectFactory.ConfigWithAnnotation.class);
         Assert.assertEquals("abc", configConfigObject.strDef);
-        PriorityProperty<Long> configPriorityProperty = 
priorityPropertyManager.
-            createPriorityProperty(Long.class, -1L, -2L, keys);
+        PriorityProperty<Long> configPriorityProperty = 
propertyFactory.getOrCreate(Long.class, -1L, -2L, keys);
         Assert.assertEquals(-2L, (long) configPriorityProperty.getValue());
       }
     }
 
     waitKeyForGC(priorityPropertyManager);
 
-    
Assert.assertTrue(priorityPropertyManager.getPriorityPropertySet().isEmpty());
     Assert.assertTrue(priorityPropertyManager.getConfigObjectMap().isEmpty());
     for (DynamicProperty property : 
ConfigUtil.getAllDynamicProperties().values()) {
       Assert.assertTrue(ConfigUtil.getCallbacks(property).isEmpty());
diff --git 
a/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorBootListener.java
 
b/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorBootListener.java
index 36e465e..7bd08a6 100644
--- 
a/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorBootListener.java
+++ 
b/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorBootListener.java
@@ -16,14 +16,26 @@
  */
 package org.apache.servicecomb.inspector.internal;
 
+import org.apache.servicecomb.config.priority.PriorityPropertyFactory;
 import org.apache.servicecomb.core.BootListener;
 import org.apache.servicecomb.registry.RegistrationManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
+@Component
 public class InspectorBootListener implements BootListener {
   private static final Logger LOGGER = 
LoggerFactory.getLogger(InspectorBootListener.class);
 
+  private final InspectorConfig inspectorConfig;
+
+  private final PriorityPropertyFactory propertyFactory;
+
+  public InspectorBootListener(InspectorConfig inspectorConfig, 
PriorityPropertyFactory propertyFactory) {
+    this.inspectorConfig = inspectorConfig;
+    this.propertyFactory = propertyFactory;
+  }
+
   @Override
   public int getOrder() {
     return Short.MAX_VALUE;
@@ -31,18 +43,18 @@ public class InspectorBootListener implements BootListener {
 
   @Override
   public void onAfterTransport(BootEvent event) {
-    InspectorConfig inspectorConfig = 
event.getScbEngine().getPriorityPropertyManager()
-        .createConfigObject(InspectorConfig.class);
     if (!inspectorConfig.isEnabled()) {
       LOGGER.info("inspector is not enabled.");
       return;
     }
-
     LOGGER.info("inspector is enabled.");
+
     // will not register this schemas to service registry
-    InspectorImpl inspector = new InspectorImpl(event.getScbEngine(), 
inspectorConfig,
-        RegistrationManager.INSTANCE.getMicroservice().getSchemaMap());
-    
inspector.setPriorityPropertyManager(event.getScbEngine().getPriorityPropertyManager());
+    InspectorImpl inspector = new InspectorImpl()
+        .setInspectorConfig(inspectorConfig)
+        .setPropertyFactory(propertyFactory)
+        
.setSchemas(RegistrationManager.INSTANCE.getMicroservice().getSchemaMap())
+        .correctBasePathForOnlineTest(event.getScbEngine());
     
event.getScbEngine().getProducerProviderManager().registerSchema("inspector", 
inspector);
   }
 }
diff --git 
a/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorConfig.java
 
b/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorConfig.java
index 70683fc..2103608 100644
--- 
a/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorConfig.java
+++ 
b/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorConfig.java
@@ -18,7 +18,9 @@ package org.apache.servicecomb.inspector.internal;
 
 import org.apache.servicecomb.config.inject.InjectProperties;
 import org.apache.servicecomb.config.inject.InjectProperty;
+import org.springframework.stereotype.Component;
 
+@Component
 @InjectProperties(prefix = "servicecomb.inspector")
 public class InspectorConfig {
   @InjectProperty(keys = "enabled", defaultValue = "true")
@@ -31,15 +33,17 @@ public class InspectorConfig {
     return enabled;
   }
 
-  public void setEnabled(boolean enabled) {
+  public InspectorConfig setEnabled(boolean enabled) {
     this.enabled = enabled;
+    return this;
   }
 
   public String getAsciidoctorCss() {
     return asciidoctorCss;
   }
 
-  public void setAsciidoctorCss(String asciidoctorCss) {
+  public InspectorConfig setAsciidoctorCss(String asciidoctorCss) {
     this.asciidoctorCss = asciidoctorCss;
+    return this;
   }
 }
diff --git 
a/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorImpl.java
 
b/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorImpl.java
index 046f46e..d41e08f 100644
--- 
a/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorImpl.java
+++ 
b/inspector/src/main/java/org/apache/servicecomb/inspector/internal/InspectorImpl.java
@@ -27,7 +27,6 @@ import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Comparator;
-import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -48,7 +47,7 @@ import 
org.apache.servicecomb.common.rest.resource.ClassPathStaticResourceHandle
 import org.apache.servicecomb.common.rest.resource.StaticResourceHandler;
 import org.apache.servicecomb.config.ConfigUtil;
 import org.apache.servicecomb.config.priority.PriorityProperty;
-import org.apache.servicecomb.config.priority.PriorityPropertyManager;
+import org.apache.servicecomb.config.priority.PriorityPropertyFactory;
 import org.apache.servicecomb.core.Const;
 import org.apache.servicecomb.core.SCBEngine;
 import org.apache.servicecomb.core.Transport;
@@ -89,32 +88,29 @@ public class InspectorImpl {
 
   private static final DateTimeFormatter FORMATTER = 
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 
-  private final SCBEngine scbEngine;
+  private final StaticResourceHandler resourceHandler = new 
ClassPathStaticResourceHandler();
 
   private InspectorConfig inspectorConfig;
 
   private Map<String, String> schemas;
 
-  private volatile Asciidoctor asciidoctor;
-
-  private StaticResourceHandler resourceHandler = new 
ClassPathStaticResourceHandler();
+  private PriorityPropertyFactory propertyFactory;
 
-  private PriorityPropertyManager priorityPropertyManager;
+  private volatile Asciidoctor asciidoctor;
 
-  public InspectorImpl(SCBEngine scbEngine, InspectorConfig inspectorConfig, 
Map<String, String> schemas) {
-    this.scbEngine = scbEngine;
+  public InspectorImpl setInspectorConfig(InspectorConfig inspectorConfig) {
     this.inspectorConfig = inspectorConfig;
-    this.schemas = new LinkedHashMap<>(schemas);
-
-    correctBasePathForOnlineTest();
+    return this;
   }
 
-  public SCBEngine getScbEngine() {
-    return scbEngine;
+  public InspectorImpl setPropertyFactory(PriorityPropertyFactory 
propertyFactory) {
+    this.propertyFactory = propertyFactory;
+    return this;
   }
 
-  public InspectorConfig getInspectorConfig() {
-    return inspectorConfig;
+  public InspectorImpl setSchemas(Map<String, String> schemas) {
+    this.schemas = schemas;
+    return this;
   }
 
   // when work in servlet mode, should concat url prefix
@@ -122,17 +118,17 @@ public class InspectorImpl {
   //
   // ServiceComb consumer has not this problem
   // ServiceComb consumer not care for producer deploy with or without servlet
-  private void correctBasePathForOnlineTest() {
+  public InspectorImpl correctBasePathForOnlineTest(SCBEngine scbEngine) {
     Transport restTransport = 
scbEngine.getTransportManager().findTransport(Const.RESTFUL);
     if (restTransport == null ||
         !restTransport.getClass().getName()
             
.equals("org.apache.servicecomb.transport.rest.servlet.ServletRestTransport")) {
-      return;
+      return this;
     }
 
     String urlPrefix = 
ClassLoaderScopeContext.getClassLoaderScopeProperty(DefinitionConst.URL_PREFIX);
     if (StringUtils.isEmpty(urlPrefix)) {
-      return;
+      return this;
     }
 
     for (Entry<String, String> entry : schemas.entrySet()) {
@@ -145,10 +141,7 @@ public class InspectorImpl {
 
       entry.setValue(SwaggerUtils.swaggerToString(swagger));
     }
-  }
-
-  public void setPriorityPropertyManager(PriorityPropertyManager 
priorityPropertyManager) {
-    this.priorityPropertyManager = priorityPropertyManager;
+    return this;
   }
 
   @Path("/schemas")
@@ -311,11 +304,8 @@ public class InspectorImpl {
   @GET
   public List<PriorityPropertyView> priorityProperties() {
     List<PriorityPropertyView> views = new ArrayList<>();
-    priorityPropertyManager.getConfigObjectMap().values().stream()
-        .flatMap(Collection::stream)
+    propertyFactory.getProperties()
         .forEach(p -> views.add(createPriorityPropertyView(p)));
-    priorityPropertyManager.getPriorityPropertySet().forEach(p ->
-        views.add(createPriorityPropertyView(p)));
     return views;
   }
 
diff --git 
a/inspector/src/main/resources/META-INF/services/org.apache.servicecomb.core.BootListener
 
b/inspector/src/main/resources/META-INF/services/org.apache.servicecomb.core.BootListener
deleted file mode 100644
index 65ec1a6..0000000
--- 
a/inspector/src/main/resources/META-INF/services/org.apache.servicecomb.core.BootListener
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.servicecomb.inspector.internal.InspectorBootListener
diff --git 
a/inspector/src/test/java/org/apache/servicecomb/inspector/internal/TestInspectorBootListener.java
 
b/inspector/src/test/java/org/apache/servicecomb/inspector/internal/TestInspectorBootListener.java
index 5bf1d73..713c203 100644
--- 
a/inspector/src/test/java/org/apache/servicecomb/inspector/internal/TestInspectorBootListener.java
+++ 
b/inspector/src/test/java/org/apache/servicecomb/inspector/internal/TestInspectorBootListener.java
@@ -16,45 +16,28 @@
  */
 package org.apache.servicecomb.inspector.internal;
 
-import org.apache.servicecomb.config.ConfigUtil;
-import org.apache.servicecomb.config.priority.PriorityPropertyManager;
 import org.apache.servicecomb.core.BootListener.BootEvent;
 import org.apache.servicecomb.core.BootListener.EventType;
 import org.apache.servicecomb.core.SCBEngine;
 import org.apache.servicecomb.core.bootstrap.SCBBootstrap;
-import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
+import org.apache.servicecomb.core.definition.MicroserviceMeta;
+import org.apache.servicecomb.core.definition.SchemaMeta;
+import org.apache.servicecomb.core.provider.producer.ProducerProviderManager;
+import org.apache.servicecomb.foundation.common.Holder;
 import org.apache.servicecomb.foundation.test.scaffolding.log.LogCollector;
-import org.junit.AfterClass;
 import org.junit.Assert;
-import org.junit.BeforeClass;
 import org.junit.Test;
 
 public class TestInspectorBootListener {
-  static PriorityPropertyManager priorityPropertyManager;
-
-  static InspectorConfig inspectorConfig;
-
-  @BeforeClass
-  public static void setup() {
-    ConfigUtil.installDynamicConfig();
-    priorityPropertyManager = new PriorityPropertyManager();
-    inspectorConfig = 
priorityPropertyManager.createConfigObject(InspectorConfig.class);
-  }
-
-  @AfterClass
-  public static void teardown() {
-    ArchaiusUtils.resetConfig();
-  }
-
   @Test
   public void getOrder() {
-    Assert.assertEquals(Short.MAX_VALUE, new 
InspectorBootListener().getOrder());
+    Assert.assertEquals(Short.MAX_VALUE, new InspectorBootListener(null, 
null).getOrder());
   }
 
   @Test
   public void filterEvent() {
     BootEvent event = new BootEvent();
-    InspectorBootListener listener = new InspectorBootListener();
+    InspectorBootListener listener = new InspectorBootListener(new 
InspectorConfig(), null);
 
     try (LogCollector logCollector = new LogCollector()) {
       for (EventType eventType : EventType.values()) {
@@ -69,24 +52,39 @@ public class TestInspectorBootListener {
   }
 
   @Test
-  public void diabled() {
-    ArchaiusUtils.setProperty("servicecomb.inspector.enabled", false);
-
+  public void disabled() {
     SCBEngine scbEngine = SCBBootstrap.createSCBEngineForTest();
-    scbEngine.getTransportManager().clearTransportBeforeInit();
-    scbEngine.run();
+    scbEngine.setProducerMicroserviceMeta(new MicroserviceMeta(scbEngine, 
"ms", false));
+
+    InspectorConfig inspectorConfig = new InspectorConfig()
+        .setEnabled(false);
+    new InspectorBootListener(inspectorConfig, null)
+        .onAfterTransport(new BootEvent(scbEngine, EventType.AFTER_TRANSPORT));
+
     
Assert.assertNull(scbEngine.getProducerMicroserviceMeta().findSchemaMeta("inspector"));
-    scbEngine.destroy();
   }
 
   @Test
   public void enabled() {
-    ArchaiusUtils.setProperty("servicecomb.inspector.enabled", true);
+    Holder<Object> holder = new Holder<>();
 
     SCBEngine scbEngine = SCBBootstrap.createSCBEngineForTest();
-    scbEngine.getTransportManager().clearTransportBeforeInit();
-    scbEngine.run();
-    
Assert.assertNotNull(scbEngine.getProducerMicroserviceMeta().findSchemaMeta("inspector"));
-    scbEngine.destroy();
+    scbEngine.setProducerMicroserviceMeta(new MicroserviceMeta(scbEngine, 
"ms", false));
+    scbEngine.setProducerProviderManager(new 
ProducerProviderManager(scbEngine) {
+      @Override
+      public SchemaMeta registerSchema(String schemaId, Object instance) {
+        if ("inspector".equals(schemaId)) {
+          holder.value = instance;
+        }
+        return null;
+      }
+    });
+
+    InspectorConfig inspectorConfig = new InspectorConfig()
+        .setEnabled(true);
+    new InspectorBootListener(inspectorConfig, null)
+        .onAfterTransport(new BootEvent(scbEngine, EventType.AFTER_TRANSPORT));
+
+    Assert.assertNotNull(holder.value);
   }
 }
diff --git 
a/inspector/src/test/java/org/apache/servicecomb/inspector/internal/TestInspectorImpl.java
 
b/inspector/src/test/java/org/apache/servicecomb/inspector/internal/TestInspectorImpl.java
index 9280442..d8411bb 100644
--- 
a/inspector/src/test/java/org/apache/servicecomb/inspector/internal/TestInspectorImpl.java
+++ 
b/inspector/src/test/java/org/apache/servicecomb/inspector/internal/TestInspectorImpl.java
@@ -37,12 +37,10 @@ import javax.ws.rs.core.Response.Status;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.servicecomb.config.ConfigUtil;
-import org.apache.servicecomb.config.priority.PriorityProperty;
-import org.apache.servicecomb.config.priority.PriorityPropertyManager;
+import org.apache.servicecomb.config.priority.PriorityPropertyFactory;
 import org.apache.servicecomb.core.SCBEngine;
 import org.apache.servicecomb.core.Transport;
 import org.apache.servicecomb.core.bootstrap.SCBBootstrap;
-import org.apache.servicecomb.core.definition.CoreMetaUtils;
 import org.apache.servicecomb.foundation.common.utils.ClassLoaderScopeContext;
 import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
 import 
org.apache.servicecomb.foundation.test.scaffolding.exception.RuntimeExceptionWithoutStackTrace;
@@ -53,7 +51,6 @@ import 
org.apache.servicecomb.inspector.internal.swagger.SchemaFormat;
 import org.apache.servicecomb.registry.RegistrationManager;
 import org.apache.servicecomb.registry.api.registry.Microservice;
 import org.apache.servicecomb.registry.definition.DefinitionConst;
-import org.apache.servicecomb.swagger.engine.SwaggerProducer;
 import org.apache.servicecomb.swagger.invocation.Response;
 import org.apache.servicecomb.swagger.invocation.exception.CommonExceptionData;
 import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
@@ -97,10 +94,11 @@ public class TestInspectorImpl {
     }
 
     scbEngine.run();
-    SwaggerProducer producer = CoreMetaUtils
-        
.getSwaggerProducer(scbEngine.getProducerMicroserviceMeta().findSchemaMeta("inspector"));
-    InspectorImpl inspector = (InspectorImpl) producer.getProducerInstance();
-    return new InspectorImpl(scbEngine, inspector.getInspectorConfig(), new 
LinkedHashMap<>(schemas));
+    InspectorImpl inspector = new InspectorImpl()
+        
.setInspectorConfig(scbEngine.getPriorityPropertyManager().createConfigObject(InspectorConfig.class))
+        .setSchemas(schemas);
+    inspector.correctBasePathForOnlineTest(scbEngine);
+    return inspector;
   }
 
   @AfterClass
@@ -264,6 +262,7 @@ public class TestInspectorImpl {
     }
   }
 
+  // create AsciiDoctor, cost seconds
   @Test
   public void getSchemaContentById_view_html() throws IOException {
     testViewHtmlById("schema1");
@@ -350,20 +349,16 @@ public class TestInspectorImpl {
 
   @Test
   public void priorityProperties() {
-    PriorityPropertyManager priorityPropertyManager = new 
PriorityPropertyManager();
-    inspector.setPriorityPropertyManager(priorityPropertyManager);
+    PriorityPropertyFactory propertyFactory = new PriorityPropertyFactory();
+    inspector.setPropertyFactory(propertyFactory);
 
-    PriorityProperty<?> priorityProperty = priorityPropertyManager
-        .createPriorityProperty(int.class, 0, 0, "high", "low");
+    propertyFactory.getOrCreate(int.class, 0, 0, "high", "low");
 
     List<PriorityPropertyView> views = inspector.priorityProperties();
     Assert.assertEquals(1, views.size());
     Assert.assertThat(
         
views.get(0).getDynamicProperties().stream().map(DynamicPropertyView::getKey).collect(Collectors.toList()),
         Matchers.contains("high", "low"));
-
-    priorityPropertyManager.close();
-    inspector.setPriorityPropertyManager(null);
   }
 
   @Test
diff --git 
a/service-registry/registry-lightweight/src/main/resources/microservice.yaml 
b/service-registry/registry-lightweight/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..f5c48df
--- /dev/null
+++ b/service-registry/registry-lightweight/src/main/resources/microservice.yaml
@@ -0,0 +1,31 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+servicecomb-config-order: -1000
+servicecomb:
+  filter-chains:
+    consumer:
+      policies:
+        scb-discovery: simple-load-balance, scb-consumer-transport
+    producer:
+      policies:
+        scb-discovery: scb-producer-transport, schedule, producer-operation
+  handler:
+    chain:
+      Consumer:
+        service:
+          scb-discovery: simpleLB
\ No newline at end of file

Reply via email to