1 package org.myoodb.core; 25 26 import org.myoodb.*; 27 import org.myoodb.exception.*; 28 import org.myoodb.core.command.*; 29 30 public final class Database extends AbstractDatabase 31 { 32 public Database() 33 { 34 } 35 36 public MyOodbProxy createRoot(String className,String rootName,String sig,Object [] args) 37 { 38 try 39 { 40 MyOodbProxy result = null; 41 AbstractTransaction tx = MyOodbManager.getTheManager().getTransactionManager().currentTransaction(); 42 if (tx == null) 43 { 44 AbstractCommand command = new CreateCommand(className, rootName, sig, args); 45 MyOodbManager.getTheManager().getTransactionManager().processCommand(command, null, null); 46 result = (MyOodbProxy) command.getResult(); 47 } 48 else 49 { 50 result = tx.create(className, rootName, sig, args).getProxy(); 51 } 52 53 return result; 54 } 55 catch (RuntimeException e) 56 { 57 throw e; 58 } 59 catch (Exception e) 60 { 61 throw new InternalException("Caught during create root: " + e, e); 62 } 63 } 64 65 public MyOodbProxy createObject(String className,String sig,Object [] args) 66 { 67 try 68 { 69 MyOodbProxy result = null; 70 AbstractTransaction tx = MyOodbManager.getTheManager().getTransactionManager().currentTransaction(); 71 if (tx == null) 72 { 73 AbstractCommand command = new CreateCommand(className, null, sig, args); 74 MyOodbManager.getTheManager().getTransactionManager().processCommand(command, null, null); 75 result = (MyOodbProxy) command.getResult(); 76 } 77 else 78 { 79 result = tx.create(className, null, sig, args).getProxy(); 80 } 81 82 return result; 83 } 84 catch (RuntimeException e) 85 { 86 throw e; 87 } 88 catch (Exception e) 89 { 90 throw new InternalException("Caught during create object: " + e, e); 91 } 92 } 93 94 public void delete(MyOodbRemote obj) 95 { 96 try 97 { 98 AbstractTransaction tx = MyOodbManager.getTheManager().getTransactionManager().currentTransaction(); 99 if (tx == null) 100 { 101 AbstractCommand command = new DeleteCommand((MyOodbProxy)obj); 102 MyOodbManager.getTheManager().getTransactionManager().processCommand(command, null, null); 103 } 104 else 105 { 106 tx.delete(((MyOodbProxy)obj).getDatabaseHandle()); 107 } 108 } 109 catch (RuntimeException e) 110 { 111 throw e; 112 } 113 catch (Exception e) 114 { 115 throw new InternalException("Caught during delete: " + e, e); 116 } 117 } 118 119 public MyOodbProxy getRoot(String rootName) 120 { 121 try 122 { 123 MyOodbProxy result = null; 124 AbstractTransaction tx = MyOodbManager.getTheManager().getTransactionManager().currentTransaction(); 125 if (tx == null) 126 { 127 AbstractCommand command = new GetRootCommand(rootName); 128 MyOodbManager.getTheManager().getTransactionManager().processCommand(command, null, null); 129 result = (MyOodbProxy) command.getResult(); 130 } 131 else 132 { 133 result = tx.getRoot(rootName); 134 } 135 136 return result; 137 } 138 catch (RuntimeException e) 139 { 140 throw e; 141 } 142 catch (Exception e) 143 { 144 throw new InternalException("Caught during get root: " + e, e); 145 } 146 } 147 148 public MyOodbProxy getObject(org.myoodb.core.Identifier handle) 149 { 150 try 151 { 152 MyOodbProxy result = null; 153 AbstractTransaction tx = MyOodbManager.getTheManager().getTransactionManager().currentTransaction(); 154 if (tx == null) 155 { 156 AbstractCommand command = new GetObjectCommand(handle); 157 MyOodbManager.getTheManager().getTransactionManager().processCommand(command, null, null); 158 result = (MyOodbProxy) command.getResult(); 159 } 160 else 161 { 162 result = tx.getObject(handle); 163 } 164 165 return result; 166 } 167 catch (RuntimeException e) 168 { 169 throw e; 170 } 171 catch (Exception e) 172 { 173 throw new InternalException("Caught during get object: " + e, e); 174 } 175 } 176 177 public void setBean(org.myoodb.core.Identifier handle, MyOodbBean bean) 178 { 179 try 180 { 181 AbstractTransaction tx = MyOodbManager.getTheManager().getTransactionManager().currentTransaction(); 182 if (tx == null) 183 { 184 AbstractCommand command = new SetBeanCommand(handle, bean); 185 MyOodbManager.getTheManager().getTransactionManager().processCommand(command, null, null); 186 } 187 else 188 { 189 tx.setBean(handle, bean); 190 } 191 } 192 catch (RuntimeException e) 193 { 194 throw e; 195 } 196 catch (Exception e) 197 { 198 throw new InternalException("Caught during set bean: " + e, e); 199 } 200 } 201 202 public MyOodbBean getBean(org.myoodb.core.Identifier handle) 203 { 204 try 205 { 206 MyOodbBean result = null; 207 AbstractTransaction tx = MyOodbManager.getTheManager().getTransactionManager().currentTransaction(); 208 if (tx == null) 209 { 210 AbstractCommand command = new GetBeanCommand(handle); 211 MyOodbManager.getTheManager().getTransactionManager().processCommand(command, null, null); 212 result = (MyOodbBean) command.getResult(); 213 } 214 else 215 { 216 result = tx.getBean(handle); 217 } 218 219 return result; 220 } 221 catch (RuntimeException e) 222 { 223 throw e; 224 } 225 catch (Exception e) 226 { 227 throw new InternalException("Caught during get bean: " + e, e); 228 } 229 } 230 231 public void setXML(org.myoodb.core.Identifier handle, String xml) 232 { 233 try 234 { 235 AbstractTransaction tx = MyOodbManager.getTheManager().getTransactionManager().currentTransaction(); 236 if (tx == null) 237 { 238 AbstractCommand command = new SetXMLCommand(handle, xml); 239 MyOodbManager.getTheManager().getTransactionManager().processCommand(command, null, null); 240 } 241 else 242 { 243 tx.setXML(handle, xml); 244 } 245 } 246 catch (RuntimeException e) 247 { 248 throw e; 249 } 250 catch (Exception e) 251 { 252 throw new InternalException("Caught during set xml: " + e, e); 253 } 254 } 255 256 public String getXML(org.myoodb.core.Identifier handle) 257 { 258 try 259 { 260 String result = null; 261 AbstractTransaction tx = MyOodbManager.getTheManager().getTransactionManager().currentTransaction(); 262 if (tx == null) 263 { 264 AbstractCommand command = new GetXMLCommand(handle); 265 MyOodbManager.getTheManager().getTransactionManager().processCommand(command, null, null); 266 result = (String ) command.getResult(); 267 } 268 else 269 { 270 result = tx.getXML(handle); 271 } 272 273 return result; 274 } 275 catch (RuntimeException e) 276 { 277 throw e; 278 } 279 catch (Exception e) 280 { 281 throw new InternalException("Caught during get xml: " + e, e); 282 } 283 } 284 285 public Object invokeMethod(MyOodbRemote obj, String methodName, String sig, Object [] args, int accessLevel, int timeout) 286 { 287 try 288 { 289 Converter.LocalToProxy(args); 291 292 Object result = null; 293 AbstractTransaction tx = MyOodbManager.getTheManager().getTransactionManager().currentTransaction(); 294 if (tx == null) 295 { 296 AbstractCommand command = new InvokeMethodCommand((MyOodbProxy)obj, methodName, sig, args, accessLevel); 297 MyOodbManager.getTheManager().getTransactionManager().processCommand(command, null, null); 298 result = command.getResult(); 299 } 300 else 301 { 302 result = tx.invokeMethod(((MyOodbProxy) obj).getDatabaseHandle(), methodName, sig, args, accessLevel); 303 } 304 305 result = Converter.LocalToProxy(result); 307 308 return result; 309 } 310 catch (RuntimeException e) 311 { 312 throw e; 313 } 314 catch (Exception e) 315 { 316 throw new InternalException("Caught during invoke method: " + e, e); 317 } 318 } 319 320 public Object invokeMethod(MyOodbRemote obj, int methodIndex, Object [] args, int accessLevel, int timeout) 321 { 322 try 323 { 324 Converter.LocalToProxy(args); 326 327 Object result = null; 328 AbstractTransaction tx = MyOodbManager.getTheManager().getTransactionManager().currentTransaction(); 329 if (tx == null) 330 { 331 AbstractCommand command = new InvokeMethodCommand((MyOodbProxy)obj, methodIndex, args, accessLevel); 332 MyOodbManager.getTheManager().getTransactionManager().processCommand(command, null, null); 333 result = command.getResult(); 334 } 335 else 336 { 337 result = tx.invokeMethod(((MyOodbProxy) obj).getDatabaseHandle(), methodIndex, args, accessLevel); 338 } 339 340 result = Converter.LocalToProxy(result); 342 343 return result; 344 } 345 catch (RuntimeException e) 346 { 347 throw e; 348 } 349 catch (Exception e) 350 { 351 throw new InternalException("Caught during invoke method: " + e, e); 352 } 353 } 354 355 public void setCommunicationInterfacePassword(String oldPassword, String newPassword) 356 { 357 throw new PermissionException("Invalid invocation (must not be called from within the server)"); 358 } 359 } 360 | Popular Tags |