欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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"));

 

相关标签: Seam