首页>代码>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;
	}
}
最近下载更多
Luck_ZDM  LV11 4月12日
CaoCaii  LV6 3月24日
lichengai  LV7 2月26日
try8023  LV18 1月16日
空中飞尘  LV13 2023年12月13日
2410068425  LV23 2023年11月29日
lili535353  LV1 2023年11月29日
xiaokang1  LV9 2023年11月11日
Seaskye  LV14 2023年11月4日
1298281706  LV1 2023年10月29日
最近浏览更多
860421  LV3 前天
chirsbey2 4月17日
暂无贡献等级
Luck_ZDM  LV11 4月12日
玖零定制问题修复  LV34 4月4日
zolscy  LV12 4月2日
ZYY12123 4月1日
暂无贡献等级
CaoCaii  LV6 3月24日
jc121140  LV3 3月22日
vluobo  LV1 3月19日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友