1 21 package com.db4o; 22 23 import com.db4o.config.*; 24 import com.db4o.ext.*; 25 import com.db4o.foundation.*; 26 import com.db4o.inside.*; 27 28 class Sessions extends Collection4{ 29 31 void forEach(Visitor4 visitor){ 32 synchronized(Global4.lock){ 33 Iterator4 i = iterator(); 34 while(i.moveNext()){ 35 visitor.visit(i.current()); 36 } 37 } 38 } 39 40 ObjectContainer open(Configuration config,String databaseFileName) { 41 42 synchronized(Global4.lock){ 43 ObjectContainer oc = null; 44 Session newSession = new Session(databaseFileName); 45 46 Session oldSession = (Session) get(newSession); 47 if (oldSession != null) { 48 oc = oldSession.subSequentOpen(); 49 if (oc == null) { 50 remove(oldSession); 51 } 52 return oc; 53 } 54 55 if (Deploy.debug) { 56 System.out.println("db4o Debug is ON"); 57 if (!Deploy.flush) { 58 System.out.println("Debug option set NOT to flush file."); 59 } 60 try{ 61 oc = new YapRandomAccessFile(config,newSession); 62 }catch(Exception e){ 63 e.printStackTrace(); 64 } 65 } else { 66 try { 67 oc = new YapRandomAccessFile(config,newSession); 68 } catch (DatabaseFileLockedException e) { 69 throw e; 70 } catch (ObjectNotStorableException e) { 71 throw e; 72 } catch (Throwable t) { 73 Messages.logErr(Db4o.i_config, 4, databaseFileName, t); 74 return null; 75 } 76 } 77 newSession.i_stream = (YapStream) oc; 78 add(newSession); 79 Platform4.postOpen(oc); 80 Messages.logMsg(Db4o.i_config, 5, databaseFileName); 81 return oc; 82 } 83 } 84 85 public Object remove(Object obj){ 86 synchronized(Global4.lock){ 87 return super.remove(obj); 88 } 89 } 90 91 } 92 | Popular Tags |