PropertyAction.java 1.08 KB
Newer Older
Kim Gyeongeun committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
package jp.agentec.sinaburocast.action.common;

import jp.agentec.sinaburocast.common.util.PropertyUtil;

import org.apache.log4j.Logger;
import org.seasar.struts.annotation.Execute;
import org.seasar.struts.util.ResponseUtil;

/**
 * プロパティファイルのリロードを行う。
 * 
 * 
 * @author tsukada
 *
 */
public class PropertyAction {
	private final Logger logger = Logger.getLogger(getClass());
	
	public String file;
	
	public String key;
	
	@Execute(validator=false,  urlPattern = "reload/{file}")
	public String reload() {
		try {
			PropertyUtil.reloadProperty(file);
			ResponseUtil.write("OK");
		} catch (Exception e) {
			logger.error("reload property [" + file + "] failed.", e);
			ResponseUtil.write("NG " + e.toString());
		}
		return null;
	}
	
	@Execute(validator=false,  urlPattern = "show/{file}/{key}")
	public String show() {
		try {
			ResponseUtil.write(PropertyUtil.getProperty(file, key, false));
		} catch (Exception e) {
			logger.error("show property [" + file + " : " + key + " ] failed.", e);
			ResponseUtil.write("NG " + e.toString());
		}
		return null;
	}

}