This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hello, I was wondering what the code at line 4 does? Does static mean that this code is always executed when an instance is made? public class ServiceLocator { private InitialContext ic;//1 private Map cache; //2 private static ServiceLocator me;//3 static {//4 try { me = new ServiceLocator(); } catch(ServiceLocatorException se) { System.err.println(se); se.printStackTrace(System.err); } }
private ServiceLocator() throws ServiceLocatorException { try { ic = new InitialContext(); cache = Collections.synchronizedMap(new HashMap()); } catch (NamingException ne) { throw new ServiceLocatorException(ne); } catch (Exception e) { throw new ServiceLocatorException(e); } }
static public ServiceLocator getInstance() { return me; }