package at.knowcenter.wag.egov.egiz.cfg; import java.util.Properties; import at.gv.egiz.pdfas.api.sign.SignParameters; import at.gv.egiz.pdfas.utils.OgnlUtil; /** * Thread local holder for profile override values. * Don't use this class directly, use {@link SignParameters#setProfileOverrideValue(String, String)} * * @author exthex * */ public class OverridePropertyHolder { private static ThreadLocal propHolder = new ThreadLocal() { protected Object initialValue() { return new Properties();}; }; private static ThreadLocal ognlHolder = new ThreadLocal(); public static Properties getOverrideProps() { return (Properties) propHolder.get(); } public static void setOverrideProps(Properties props) { propHolder.set(props); } public static void setProperty(String key, String val) { getOverrideProps().setProperty(key, val); } public static String getProperty(String key) { String res = getOverrideProps().getProperty(key); if (res != null) { OgnlUtil ognl = getOgnl(); if (ognl != null && ognl.containsExpression(res)) { // evaluate expression res = ognl.compileMessage(res); } } return res; } public static void removeProperties() { propHolder.set(new Properties()); } public static void setOgnlUtil(OgnlUtil ognl) { ognlHolder.set(ognl); } private static OgnlUtil getOgnl() { return (OgnlUtil) ognlHolder.get(); } public static void removeOgnlUtil() { ognlHolder.set(null); } }