9-Apr-12 (Created: 9-Apr-12) | More in 'CS-Java'

java/samplecode: Using static initialization

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

More on static initialization