1 9 package org.ozoneDB.odmg; 10 11 import java.io.*; 12 import org.odmg.*; 13 import org.ozoneDB.DxLib.*; 14 15 16 23 public class OzoneODMG extends ODMG { 24 25 29 private transient DxSet dbs; 30 31 32 public OzoneODMG() { 33 if (org.ozoneDB.core.Env.currentEnv() != null) { 34 throw new ODMGRuntimeException( "Method must not be called from inside an ozone database object." ); 35 } 36 dbs = new DxHashSet(); 37 } 38 39 40 45 public synchronized Database newDatabase() { 46 if (org.ozoneDB.core.Env.currentEnv() != null) { 47 throw new ODMGRuntimeException( "Method must not be called from inside an ozone database object." ); 48 } 49 Database db = new OzoneODMGDatabase( this ); 50 return db; 51 } 52 53 54 58 protected synchronized void databaseOpened( Database db ) { 59 if (dbs.count() > 0) { 64 throw new ODMGRuntimeException( "More than one open databases per factory are not allowed." ); 65 } 66 67 dbs.add( db ); 68 } 69 70 71 protected synchronized void databaseClosed( Database db ) { 72 dbs.remove( db ); 73 } 74 75 76 81 public Database getDatabase( Object obj ) { 82 if (org.ozoneDB.core.Env.currentEnv() != null) { 83 throw new ODMGRuntimeException( "Method must not be called from inside an ozone database object." ); 84 } 85 86 DxIterator it = dbs.iterator(); 87 while (it.next() != null) { 88 OzoneODMGDatabase db = (OzoneODMGDatabase)it.object(); 89 if (db.containsObject( obj )) { 90 return db; 91 } 92 } 93 return null; 94 } 95 96 97 103 public Transaction newTransaction() { 104 if (org.ozoneDB.core.Env.currentEnv() != null) { 105 throw new ODMGRuntimeException( "Method must not be called from inside an ozone database object." ); 106 } 107 return new OzoneODMGTransaction( dbs ); 108 } 109 110 111 116 public Transaction currentTransaction() { 117 if (org.ozoneDB.core.Env.currentEnv() != null) { 118 throw new ODMGRuntimeException( "Method must not be called from inside an ozone database object." ); 119 } 120 return OzoneODMGTransaction.current(); 121 } 122 123 124 129 public String getObjectId( Object obj ) { 130 if (org.ozoneDB.core.Env.currentEnv() != null) { 131 throw new ODMGRuntimeException( "Method must not be called from inside an ozone database object." ); 132 } 133 134 throw new RuntimeException ( "Method not implemented yet." ); 135 } 136 137 138 143 public OQLQuery newOQLQuery() { 144 throw new RuntimeException ( "newOQLQuery(): ozone does not implement OQL." ); 145 } 146 147 148 153 public DList newDList() { 154 if (org.ozoneDB.core.Env.currentEnv() != null) { 155 throw new ODMGRuntimeException( "Method must not be called from inside an ozone database object." ); 156 } 157 return new OzoneODMGDList(); 158 } 159 160 161 166 public DBag newDBag() { 167 if (org.ozoneDB.core.Env.currentEnv() != null) { 168 throw new ODMGRuntimeException( "Method must not be called from inside an ozone database object." ); 169 } 170 return new OzoneODMGDBag(); 171 } 172 173 174 179 public DSet newDSet() { 180 if (org.ozoneDB.core.Env.currentEnv() != null) { 181 throw new ODMGRuntimeException( "Method must not be called from inside an ozone database object." ); 182 } 183 return new OzoneODMGDSet(); 184 } 185 186 187 192 public DArray newDArray() { 193 if (org.ozoneDB.core.Env.currentEnv() != null) { 194 throw new ODMGRuntimeException( "Method must not be called from inside an ozone database object." ); 195 } 196 return new OzoneODMGDArray(); 197 } 198 199 200 205 public DMap newDMap() { 206 throw new RuntimeException ( "Method not implemented yet" ); 207 } 208 209 } 210 | Popular Tags |