Skip to content

Commit b5c2a25

Browse files
author
monsoon
committed
add confighelper and classutil
1 parent d02c1b0 commit b5c2a25

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package simple.xfj.framework.helper;
2+
3+
import simple.xfj.framework.constant.ConfigConstant;
4+
import simple.xfj.framework.util.PropsUtil;
5+
6+
import java.util.Properties;
7+
8+
/**
9+
* Created by asus on 2017/4/18.
10+
*/
11+
public final class ConfigHelper {
12+
13+
private static Properties properties;
14+
15+
static {
16+
try {
17+
properties = PropsUtil.loadProperties(ConfigConstant.CONFIG_FILENAME);
18+
}catch (Exception e){
19+
e.printStackTrace();
20+
}
21+
}
22+
23+
public static String getJdbcDriver(){
24+
return properties.getProperty(ConfigConstant.JDBC_DRIVER);
25+
}
26+
27+
public static String getJdbcUrl(){
28+
return properties.getProperty(ConfigConstant.JDBC_URL);
29+
}
30+
31+
public static String getJdbcUsername(){
32+
return properties.getProperty(ConfigConstant.JDBC_USERNAME);
33+
}
34+
35+
public static String getJdbcPassword(){
36+
return properties.getProperty(ConfigConstant.JDBC_PASSWORD);
37+
}
38+
39+
public static String getAPPBasePackage(){
40+
return properties.getProperty(ConfigConstant.APP_BASE_PACKAGE);
41+
}
42+
43+
public static String getAPPJspPath(){
44+
return properties.getProperty(ConfigConstant.APP_JSP_PATH,"/WEB-INF/view/");
45+
}
46+
47+
public static String getAPPAsset(){
48+
return properties.getProperty(ConfigConstant.APP_ASSET_PATH,"/asset/");
49+
}
50+
51+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package simple.xfj.framework.util;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
6+
import java.util.Set;
7+
8+
/**
9+
* Created by asus on 2017/4/18.
10+
*/
11+
public class ClassUtil {
12+
13+
private static final Logger LOGGER = LoggerFactory.getLogger(Class.class);
14+
15+
/**
16+
* 获取类加载器
17+
* @return
18+
*/
19+
public static ClassLoader getClassLoader(){
20+
return ClassUtil.getClassLoader();
21+
}
22+
23+
/**
24+
* 加载某个类
25+
* @param className
26+
* @param isInitialized
27+
* @return
28+
*/
29+
public static Class<?> loadClass(String className,boolean isInitialized){
30+
Class<?> clazz;
31+
try{
32+
clazz = Class.forName(className,isInitialized,getClassLoader());
33+
}catch (Exception e){
34+
LOGGER.error("load class failed",e);
35+
throw new RuntimeException(e);
36+
}
37+
return clazz;
38+
}
39+
40+
/**
41+
* 加载某个包下的所有类
42+
* @param packageName
43+
* @return
44+
*/
45+
public static Set<Class<?>> getClassSet(String packageName){
46+
47+
return null;
48+
}
49+
50+
51+
52+
53+
54+
55+
}

0 commit comments

Comments
 (0)