forked from fanruan/finekit
richie
5 years ago
5 changed files with 99 additions and 0 deletions
@ -0,0 +1,12 @@
|
||||
package com.fanruan.api.conf; |
||||
|
||||
import com.fr.config.DefaultConfiguration; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-08-16 |
||||
*/ |
||||
public abstract class BaseConfiguration extends DefaultConfiguration { |
||||
|
||||
} |
@ -0,0 +1,12 @@
|
||||
package com.fanruan.api.conf; |
||||
|
||||
import com.fr.config.utils.UniqueKey; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-08-16 |
||||
* 需要存入fine_conf_entity配置库中的属性对象,需要继承此抽象类 |
||||
*/ |
||||
public abstract class BaseUniqueKey extends UniqueKey { |
||||
} |
@ -0,0 +1,21 @@
|
||||
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); |
||||
} |
||||
} |
@ -0,0 +1,10 @@
|
||||
package com.fanruan.api.security; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-08-16 |
||||
* 文本加密解密相关的工具类 |
||||
*/ |
||||
public class SecurityKit { |
||||
} |
@ -0,0 +1,44 @@
|
||||
package com.fanruan.api.conf; |
||||
|
||||
import com.fanruan.api.Prepare; |
||||
import com.fr.config.holder.Conf; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-08-16 |
||||
*/ |
||||
public class BaseConfigurationTest extends Prepare { |
||||
|
||||
@Test |
||||
public void testGet() { |
||||
MyConf conf = MyConf.getInstance(); |
||||
Assert.assertEquals(10, conf.getCount()); |
||||
conf.setCount(100); |
||||
Assert.assertEquals(100, conf.getCount()); |
||||
} |
||||
|
||||
private static class MyConf extends BaseConfiguration { |
||||
|
||||
private static volatile MyConf instance = null; |
||||
|
||||
public static MyConf getInstance() { |
||||
if (instance == null) { |
||||
instance = ConfigContextKit.getConfigInstance(MyConf.class); |
||||
} |
||||
return instance; |
||||
} |
||||
|
||||
private Conf<Integer> count = HolderKit.simple(10); |
||||
|
||||
public int getCount() { |
||||
return count.get(); |
||||
} |
||||
|
||||
public void setCount(int count) { |
||||
this.count.set(count); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue