`
q_wong
  • 浏览: 105544 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Seam中使用Properties配置信息

阅读更多
/**
 * 此類用于讀取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"));

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics