1 3 4 package webapp; 5 6 import org.apache.log4j.Category; 7 import song.SongServices; 8 import org.ozoneDB.*; 9 10 16 17 public class WebApp { 18 19 private static ExternalDatabase db = null; 20 21 24 private static Category logger = Category.getInstance(WebApp.class.getName()); 25 26 30 public static void init() { 31 32 35 try { 36 logger.info("init()"); 37 39 db = ExternalDatabase.openDatabase( "ozonedb:remote://localhost:3333" ); 41 42 if (db == null){ 43 logger.warn("init(): db == null -- something went wrong."); 44 } 45 46 logger.info( "Connected ..." ); 47 db.reloadClasses(); 48 49 SongServices.init(db); 50 } catch (Exception e){ 51 logger.error("init() failed", e); 52 } 53 } 54 55 59 public static void term() { 60 62 logger.info("term()"); 63 64 SongServices.term(); 65 66 try { 67 db.close(); 68 } catch (Exception e){ 69 e.printStackTrace(); 70 } 71 db = null; 72 } 73 74 78 public static OzoneInterface database(){ 79 return db; 80 } 81 82 83 } 84 85 86 | Popular Tags |