首页>代码>SpringBoot开发非常美观的java博客系统(包含后台管理功能)>/mblog/mblog-base/src/main/java/mblog/base/context/AppContext.java
/*
+--------------------------------------------------------------------------
|   Mblog [#RELEASE_VERSION#]
|   ========================================
|   Copyright (c) 2014, 2015 mtons. All Rights Reserved
|   http://www.mtons.com
|
+---------------------------------------------------------------------------
*/
package mblog.base.context;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.context.ServletContextAware;

import javax.servlet.ServletContext;

/**
 * @author langhsu
 * 
 */
@Component
public class AppContext implements ServletContextAware {
	
	/*
	 * 文件存储-根目录
	 */
	@Value("${site.store.root}")
	String root = "/data/mblog";
	
	/*
	 * 文件存储-原文件目录
	 */
	String origDir = "/store/orig";
	
	/*
	 * 文件存储-压缩目录
	 */
	String thumbsDir = "/store/thumbs";

	/*
	 * 文件存储-头像目录
	 */
	String avaDir = "/store/ava";
	
	/*
	 * 文件存储-临时文件目录
	 */
	String tempDir = "/store/temp";

	/*
	 * 系统配置信息
	 * - 在 StartupListener 类中加载
	 */
	public Map<String, String> config;

	/**
	 * 容器全局变量
	 */
	private ServletContext servletContext;

	public String getRoot() {
		return root;
	}

	public void setRoot(String root) {
		this.root = root;
	}

	public String getOrigDir() {
		return origDir;
	}

	public void setOrigDir(String origDir) {
		this.origDir = origDir;
	}

	public String getThumbsDir() {
		return thumbsDir;
	}

	public void setThumbsDir(String thumbsDir) {
		this.thumbsDir = thumbsDir;
	}

	public String getTempDir() {
		return tempDir;
	}

	public void setTempDir(String tempDir) {
		this.tempDir = tempDir;
	}

	public String getAvaDir() {
		return avaDir;
	}

	public void setAvaDir(String avaDir) {
		this.avaDir = avaDir;
	}

	public Map<String, String> getConfig() {
		return config;
	}

	public void setConfig(Map<String, String> config) {
		this.config = config;
		//同步更新容器全局变量
		Iterator<Map.Entry<String, String>> iter = config.entrySet().iterator();
		while (iter.hasNext()){
			Map.Entry<String, String> e = iter.next();
			servletContext.setAttribute(e.getKey(), e.getValue());
		}
	}

	@Override
	public void setServletContext(ServletContext servletContext) {
		this.servletContext = servletContext;
	}

	public ServletContext getServletContext() {
		return servletContext;
	}
}
最近下载更多
032932  LV1 2月22日
srmess  LV4 2024年12月30日
Duangi  LV1 2024年12月23日
zolscy  LV24 2024年12月18日
xianyu091012  LV5 2024年11月19日
12347658  LV1 2024年11月13日
xunxia  LV7 2024年10月10日
微信网友_7005760998215680  LV6 2024年10月2日
Cloong  LV1 2024年8月22日
murphy  LV7 2024年7月2日
最近浏览更多
15578157792  LV7 4月26日
vincemokea  LV4 4月24日
暂无贡献等级
暂无贡献等级
哪里的完整版  LV8 4月1日
2022102154  LV1 3月27日
wjlsyq  LV1 3月20日
benben2020 3月19日
暂无贡献等级
发答案法国 3月6日
暂无贡献等级
orang801  LV2 3月4日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友