class ContextDictionaryHolder { public static IDictionary s_contextDictionary = null; static { String aspireContext = ServletUtils.getWebApplicationContext(); if (aspireContext == null) aspireContext = ""; HashMap m = new HashMap(); m.put("aspirecontext",aspireContext); //Place other context related information into this dictionary ..... //Finally hold that in a dictionary s_contextDictionary = new MapDictionary(m); }//end of function }//end of class
satya - Mon Apr 09 2012 14:18:03 GMT-0400 (Eastern Daylight Time)
Another example
public class SQLQuoter
{
private static ITranslator sqlQuoteTranslator = null;
static
{
sqlQuoteTranslator = SQLArgSubstitutor.getQuoteTranslator();
if (sqlQuoteTranslator == null)
{
throw new RuntimeException("Cannot get Quote Translator object");
}
}
/*
* Take a string and quote the string
* depending on the database being used.
*/
public static String quote(String inS)
{
assert(sqlQuoteTranslator != null);
return sqlQuoteTranslator.translateString(inS);
}
}//eof-class