/** * Initialize and load our initial database from persistent storage. * * @param event The context initialization event */ public void contextInitialized(ServletContextEvent event) { log.info("Initializing memory database plug in from '" + pathname + "'"); // Remember our associated ServletContext this.context = event.getServletContext(); // Construct a new database and make it available database = new MemoryUserDatabase(); try { String path = calculatePath(); if (log.isDebugEnabled()) { log.debug(" Loading database from '" + path + "'"); } database.setPathname(path); database.open(); } catch (Exception e) { log.error("Opening memory database", e); throw new IllegalStateException("Cannot load database from '" + pathname + "': " + e); } context.setAttribute(DATABASE_KEY, database); }