| | |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.json.JSONArray; |
| | | import org.json.JSONObject; |
| | | import org.springframework.context.EnvironmentAware; |
| | | import org.springframework.core.env.Environment; |
| | | |
| | | import com.matrix.core.tools.PropertiesUtil; |
| | | |
| | | /** |
| | | * 配置管理器 |
| | | * |
| | | * |
| | | * @author hancong03@baidu.com |
| | | * |
| | | */ |
| | | public final class ConfigManager { |
| | | public final class ConfigManager implements EnvironmentAware { |
| | | |
| | | private Environment env; |
| | | private final String rootPath; |
| | | private final String originalPath; |
| | | private final String contextPath; |
| | |
| | | private final static String SCRAWL_FILE_NAME = "scrawl"; |
| | | // 远程图片抓取filename定义 |
| | | private final static String REMOTE_FILE_NAME = "remote"; |
| | | |
| | | |
| | | private final static String FILES_TORAGE_PATH ="file_storage_path"; |
| | | |
| | | @Override |
| | | public void setEnvironment(Environment environment) { |
| | | env = environment; |
| | | |
| | | |
| | | } |
| | | |
| | | /* |
| | | * 通过一个给定的路径构建一个配置管理器, 该管理器要求地址路径所在目录下必须存在config.properties文件 |
| | |
| | | |
| | | /** |
| | | * 配置管理器构造工厂 |
| | | * |
| | | * |
| | | * @param rootPath |
| | | * 服务器根路径 |
| | | * @param contextPath |
| | |
| | | } |
| | | |
| | | conf.put("savePath", savePath); |
| | | conf.put("rootPath", PropertiesUtil.getString(this.FILES_TORAGE_PATH)); |
| | | |
| | | String fileStoragePath = env.getProperty(FILES_TORAGE_PATH); |
| | | conf.put("rootPath",fileStoragePath); |
| | | |
| | | return conf; |
| | | |