首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 系统运维 >

系统管理类-SystemEnvironmentManager

2012-09-23 
系统管理类--SystemEnvironmentManagerpackage com.mypack.coreimport java.io.IOExceptionimport java.

系统管理类--SystemEnvironmentManager

package com.mypack.core;import java.io.IOException;import java.util.Properties;import javax.annotation.PostConstruct;import org.springframework.core.io.Resource;import org.springframework.util.Assert;/** *  * 系统管理类 *  * @author Administrator *  */public class SystemEnvironmentManager {private static Properties systemEnvironmentConfigProperties = new Properties();private Resource resource;@PostConstructpublic void init() {Assert.notNull(resource, "parameter resource is not null");readSystemEnvironmentConfigProperties();}private void readSystemEnvironmentConfigProperties() {try {systemEnvironmentConfigProperties.load(resource.getInputStream());} catch (IOException e) {throw new RuntimeException(e.getMessage(), e);}}public static String getProperty(String code) {if (code == null) {throw new IllegalArgumentException("parameter code is not null");}return systemEnvironmentConfigProperties.getProperty(code);}public Resource getResource() {return resource;}public void setResource(Resource resource) {this.resource = resource;}}


<bean id="systemEnvironmentManager"class="com.mypack.core.SystemEnvironmentManager"><property name="resource"value="classpath:system_environment_config.properties"></property></bean>

热点排行