Seam中使用Properties配置信息
程序员文章站
2024-03-12 20:27:38
...
/**
* 此類用于讀取XXX Project 中的配置信息
* @author zzz
*
*/
@Name("XxxPropertiesFactory")
@Scope(ScopeType.APPLICATION)
public class XxxProperties {
private static Properties prop;
static{
synchronized(XxxProperties.class){
prop= new Properties();
InputStream is = XxxProperties.class.getResourceAsStream("/xxx.properties");
if(is == null){
throw new RuntimeException("can not found the file xxx.properties");
}
try {
prop.load(is);
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
@Factory(value="xxxProperties",autoCreate=true,scope=ScopeType.APPLICATION)
public Properties getXxxProperties(){
return prop;
}
public static XxxProperties instance(){
return (XxxProperties) Component.getInstance(XxxProperties.class,ScopeType.APPLICATION);
}
}
Properties properties = XxxProperties.instance().getXxxProperties(); initFirstResult = Integer.valueOf(properties.getProperty("xxx.employee.page.size"));
上一篇: Apache Hive数据导入
下一篇: 一段很有意思的代码