This is an automated email from the ASF dual-hosted git repository. yaohaishi pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-docs.git
commit 9cdef4ceb457d31e985a0cc8c2fb4bb8d0646a9f Author: pengliang <[email protected]> AuthorDate: Tue May 28 16:55:41 2019 +0800 injectDocumentModification --- java-chassis-reference/en_US/config/inject-config.md | 9 +++++++-- java-chassis-reference/zh_CN/config/inject-config.md | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/java-chassis-reference/en_US/config/inject-config.md b/java-chassis-reference/en_US/config/inject-config.md index b44c547..56702e3 100644 --- a/java-chassis-reference/en_US/config/inject-config.md +++ b/java-chassis-reference/en_US/config/inject-config.md @@ -63,7 +63,7 @@ We can execute injection with the following sample code: Inject configuration properties into objects without `InjectProperties` and `InjectProperty` annotations: ```Java -ConfigNoAnnotation config = new ConfigObjectFactory().create(ConfigNoAnnotation.class); +ConfigNoAnnotation config = priorityPropertyManager.createConfigObject(ConfigNoAnnotation.class); ``` Inject configuration properties into objects annotated with `InjectProperties` and `InjectProperty`: @@ -79,7 +79,7 @@ Inject configuration properties into objects annotated with `InjectProperties` a 2. root.l1-2 ```Java -ConfigWithAnnotation config = new ConfigObjectFactory().create(ConfigWithAnnotation.class, +ConfigWithAnnotation config = priorityPropertyManager.createConfigObject(ConfigWithAnnotation.class, "key", "k", "low-list", Arrays.asList("low-1", "low-2"), "high-list", Arrays.asList("high-1", "high-2"), @@ -87,5 +87,10 @@ ConfigWithAnnotation config = new ConfigObjectFactory().create(ConfigWithAnnotat ); ``` +Last displayed empty object and empty cache +```Java +priorityPropertyManager.unregisterConfigObject(config) +``` + ## Reference resources Refer to the sample code: https://github.com/apache/servicecomb-java-chassis/blob/master/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/inject/TestConfigObjectFactory.java diff --git a/java-chassis-reference/zh_CN/config/inject-config.md b/java-chassis-reference/zh_CN/config/inject-config.md index 4dfa330..d9217b7 100644 --- a/java-chassis-reference/zh_CN/config/inject-config.md +++ b/java-chassis-reference/zh_CN/config/inject-config.md @@ -59,7 +59,7 @@ public class ConfigNoAnnotation { 将配置属性注入到无`@InjectProperties`和`@InjectProperty`注解的对象上: ```Java -ConfigNoAnnotation config = new ConfigObjectFactory().create(ConfigNoAnnotation.class); +ConfigNoAnnotation config = priorityPropertyManager.createConfigObject(ConfigNoAnnotation.class); ``` 将配置属性注入到有`@InjectProperties`和`@InjectProperty`注解的对象上: @@ -75,7 +75,7 @@ ConfigNoAnnotation config = new ConfigObjectFactory().create(ConfigNoAnnotation. 2. root.l1-2 ```Java -ConfigWithAnnotation config = new ConfigObjectFactory().create(ConfigWithAnnotation.class, +ConfigWithAnnotation config = priorityPropertyManager.createConfigObject(ConfigWithAnnotation.class, "key", "k", "low-list", Arrays.asList("low-1", "low-2"), "high-list", Arrays.asList("high-1", "high-2"), @@ -83,5 +83,10 @@ ConfigWithAnnotation config = new ConfigObjectFactory().create(ConfigWithAnnotat ); ``` +最后不管是有无注解的属性注入,都要显示的回收对象 +```Java +priorityPropertyManager.unregisterConfigObject(config) +``` + ## 参考 示例代码请参考: https://github.com/apache/servicecomb-java-chassis/blob/master/foundations/foundation-config/src/test/java/org/apache/servicecomb/config/inject/TestConfigObjectFactory.java
