Browse Source

简化

pull/11/head
richie 5 years ago
parent
commit
ebfd8b381c
  1. 10
      src/main/java/com/fanruan/api/conf/BaseConfiguration.java
  2. 21
      src/main/java/com/fanruan/api/conf/ConfigContextKit.java
  3. 2
      src/test/java/com/fanruan/api/conf/BaseConfigurationTest.java

10
src/main/java/com/fanruan/api/conf/BaseConfiguration.java

@ -1,5 +1,6 @@
package com.fanruan.api.conf;
import com.fr.config.ConfigContext;
import com.fr.config.DefaultConfiguration;
/**
@ -9,4 +10,13 @@ import com.fr.config.DefaultConfiguration;
*/
public abstract class BaseConfiguration extends DefaultConfiguration {
/**
* 从配置对象池中创建或者获取配置对象实例
* @param clazz 配置实例类型
* @param <T> 类型
* @return 配置对象
*/
static <T extends BaseConfiguration> T getConfigInstance(final Class<T> clazz) {
return ConfigContext.getConfigInstance(clazz);
}
}

21
src/main/java/com/fanruan/api/conf/ConfigContextKit.java

@ -1,21 +0,0 @@
package com.fanruan.api.conf;
import com.fr.config.ConfigContext;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-16
*/
public class ConfigContextKit {
/**
* 从配置对象池中创建或者获取配置对象实例
* @param clazz 配置实例类型
* @param <T> 类型
* @return 配置对象
*/
public static <T extends BaseConfiguration> T getConfigInstance(final Class<T> clazz) {
return ConfigContext.getConfigInstance(clazz);
}
}

2
src/test/java/com/fanruan/api/conf/BaseConfigurationTest.java

@ -26,7 +26,7 @@ public class BaseConfigurationTest extends Prepare {
public static MyConf getInstance() {
if (instance == null) {
instance = ConfigContextKit.getConfigInstance(MyConf.class);
instance = getConfigInstance(MyConf.class);
}
return instance;
}

Loading…
Cancel
Save