1 2 12 package com.versant.core.jdo; 13 14 import com.versant.core.server.QueryResultWrapper; 15 import com.versant.core.server.CompiledQuery; 16 17 import javax.jdo.Transaction; 18 import javax.jdo.PersistenceManager; 19 import javax.jdo.Query; 20 import javax.jdo.PersistenceManagerFactory; 21 import javax.jdo.Extent; 22 import javax.jdo.spi.PersistenceCapable; 23 24 import javax.transaction.Synchronization ; 25 import javax.transaction.xa.XAException ; 26 import javax.transaction.xa.XAResource ; 27 import javax.transaction.xa.Xid ; 28 29 import java.sql.Connection ; 30 import java.util.Collection ; 31 import java.util.List ; 32 33 34 35 import com.versant.core.common.BindingSupportImpl; 36 import com.versant.core.common.OID; 37 import com.versant.core.common.State; 38 import com.versant.core.common.*; 39 import com.versant.core.storagemanager.ExecuteQueryReturn; 40 41 48 public final class SynchronizedPMProxy extends PMProxy { 49 50 private VersantPersistenceManagerImp realPM; 51 52 public SynchronizedPMProxy(VersantPersistenceManagerImp realPM) { 53 this.realPM = realPM; 54 } 55 56 public synchronized QueryResultWrapper executeQuery(CompiledQuery cq, Object [] params) { 57 return realPM.getStorageManager().executeQuery(realPM, null, cq, params); 58 } 59 60 public QueryResultContainer getNextQueryResult(QueryResultWrapper aQrs, int skipAmount) { 61 return realPM.getStorageManager().fetchNextQueryResult(realPM, 62 ((ExecuteQueryReturn)aQrs).getRunningQuery(), skipAmount); 63 } 64 65 public synchronized void flushIfDepOn(int[] bits) { 66 realPM.flushIfDepOn(bits); 67 } 68 69 public synchronized void processLocalCacheReferenceQueue() { 70 realPM.processLocalCacheReferenceQueue(); 71 } 72 73 public synchronized void addToCache(StatesReturned container) { 74 realPM.addToCache(container); 75 } 76 77 public synchronized void closeQuery(QueryResultWrapper qrw) { 78 realPM.getStorageManager().closeQuery(((ExecuteQueryReturn)qrw).getRunningQuery()); 79 } 80 81 public synchronized QueryResultContainer getAbsolute(QueryResultWrapper qrsIF, int index, int fetchAmount) { 82 return realPM.getStorageManager().fetchRandomAccessQueryResult(realPM, 83 ((ExecuteQueryReturn)qrsIF).getRunningQuery(), index, 84 fetchAmount); 85 } 86 87 public synchronized int getResultCount(QueryResultWrapper qrsIF) { 88 return realPM.getStorageManager().getRandomAccessQueryCount(realPM, 89 ((ExecuteQueryReturn)qrsIF).getRunningQuery()); 90 } 91 92 public synchronized QueryResultContainer getAllQueryResults(CompiledQuery cq, 93 Object [] params) { 94 return realPM.getStorageManager().executeQueryAll(realPM, null, cq, params); 95 } 96 97 public synchronized void setMasterOnDetail(PersistenceCapable detail, int managedFieldNo, 98 PersistenceCapable master, boolean removeFromCurrentMaster) { 99 realPM.setMasterOnDetail(detail, managedFieldNo, master, removeFromCurrentMaster); 100 } 101 102 public synchronized Object getObjectField(PersistenceCapable pc, int fieldNo) { 103 return realPM.getObjectField(pc, fieldNo); 104 } 105 106 public synchronized int getQueryRowCount(CompiledQuery cq, Object [] params) { 107 return realPM.getStorageManager().executeQueryCount(null, cq, params); 108 } 109 110 public synchronized Object getOptimisticLockingValue(Object o) { 111 checkClosed(); 112 return realPM.getOptimisticLockingValue(o); 113 } 114 115 public synchronized void setPmCacheRefType(Object pc, int type) { 116 checkClosed(); 117 realPM.setPmCacheRefType(pc, type); 118 } 119 120 public synchronized void setPmCacheRefType(Object [] pcs, int type) { 121 checkClosed(); 122 realPM.setPmCacheRefType(pcs, type); 123 } 124 125 public synchronized void setPmCacheRefType(Collection col, int type) { 126 checkClosed(); 127 realPM.setPmCacheRefType(col, type); 128 } 129 130 public synchronized void setPmCacheRefType(int type) { 131 checkClosed(); 132 realPM.setPmCacheRefType(type); 133 } 134 135 public synchronized int getPmCacheRefType() { 136 checkClosed(); 137 return realPM.getPmCacheRefType(); 138 } 139 140 145 public synchronized boolean isInterceptDfgFieldAccess() { 146 return realPM.isInterceptDfgFieldAccess(); 147 } 148 149 public synchronized void setInterceptDfgFieldAccess(boolean interceptDfgFieldAccess) { 150 realPM.setInterceptDfgFieldAccess(interceptDfgFieldAccess); 151 } 152 153 public synchronized VersantPersistenceManagerImp getRealPM() { 154 checkClosed(); 155 return realPM; 156 } 157 158 VersantPersistenceManagerImp getRealPMNoCheck() { 159 return realPM; 160 } 161 162 public synchronized void resetPM() { 163 realPM = null; 164 } 165 166 public synchronized boolean isRealPMNull() { 167 return realPM == null; 168 } 169 170 public synchronized List versantAllDirtyInstances() { 171 checkClosed(); 172 return realPM.versantAllDirtyInstances(); 173 } 174 175 private void checkClosed() { 176 if (realPM == null) { 177 throw BindingSupportImpl.getInstance().invalidOperation( 178 "The pm is closed"); 179 } 180 } 181 182 public synchronized boolean isDirty() { 183 checkClosed(); 184 return realPM.isDirty(); 185 } 186 187 public synchronized void cancelQueryExecution() { 188 checkClosed(); 189 realPM.cancelQueryExecution(); 190 } 191 192 public synchronized Object getObjectByIDString(String value, boolean toValidate) { 193 checkClosed(); 194 return realPM.getObjectByIDString(value, toValidate); 195 } 196 197 public synchronized void loadFetchGroup(Object pc, String name) { 198 checkClosed(); 199 realPM.loadFetchGroup(pc, name); 200 } 201 202 public synchronized void flush() { 203 checkClosed(); 204 realPM.flush(); 205 } 206 207 public synchronized void flush(boolean retainState) { 208 checkClosed(); 209 realPM.flush(retainState); 210 } 211 212 public synchronized void makeTransientRecursive(Object pc) { 213 checkClosed(); 214 realPM.makeTransientRecursive(pc); 215 } 216 217 public synchronized Connection getJdbcConnection(String datastore) { 218 checkClosed(); 219 return realPM.getJdbcConnection(datastore); 220 } 221 222 public synchronized String getConnectionURL(String dataStore) { 223 checkClosed(); 224 return realPM.getConnectionURL(dataStore); 225 } 226 227 public synchronized String getConnectionDriverName(String dataStore) { 228 checkClosed(); 229 return realPM.getConnectionDriverName(dataStore); 230 } 231 232 public synchronized boolean isClosed() { 233 return realPM == null; 234 } 235 236 public synchronized void close() { 237 if (realPM == null) { 238 return; 239 } 240 realPM.close(); 241 } 242 243 public synchronized Transaction currentTransaction() { 244 checkClosed(); 245 return this; 246 } 247 248 public synchronized void evict(Object o) { 249 checkClosed(); 250 realPM.evict(o); 251 } 252 253 public synchronized void evictAll(Object [] objects) { 254 checkClosed(); 255 realPM.evictAll(objects); 256 } 257 258 public synchronized void evictAll(Collection collection) { 259 checkClosed(); 260 realPM.evictAll(collection); 261 } 262 263 public synchronized void evictAll() { 264 checkClosed(); 265 realPM.evictAll(); 266 } 267 268 public synchronized void refresh(Object o) { 269 checkClosed(); 270 realPM.refresh(o); 271 } 272 273 public synchronized void refreshAll(Object [] objects) { 274 checkClosed(); 275 realPM.refreshAll(objects); 276 } 277 278 public synchronized void refreshAll(Collection collection) { 279 checkClosed(); 280 realPM.refreshAll(collection); 281 } 282 283 public synchronized void refreshAll() { 284 checkClosed(); 285 realPM.refreshAll(); 286 } 287 288 public synchronized Query newQuery() { 289 checkClosed(); 290 return realPM.newQuery(); 291 } 292 293 public synchronized Query newQuery(Object o) { 294 checkClosed(); 295 return realPM.newQuery(o); 296 } 297 298 public synchronized Query newQuery(String s, Object o) { 299 checkClosed(); 300 return realPM.newQuery(s, o); 301 } 302 303 public synchronized Query newQuery(Class aClass) { 304 checkClosed(); 305 return realPM.newQuery(aClass); 306 } 307 308 public synchronized Query newQuery(Extent extent) { 309 checkClosed(); 310 return realPM.newQuery(extent); 311 } 312 313 public synchronized Query newQuery(Class aClass, Collection collection) { 314 checkClosed(); 315 return realPM.newQuery(aClass, collection); 316 } 317 318 public synchronized Query newQuery(Class aClass, String s) { 319 checkClosed(); 320 return realPM.newQuery(aClass, s); 321 } 322 323 public synchronized Query newQuery(Class aClass, Collection collection, String s) { 324 checkClosed(); 325 return realPM.newQuery(aClass, collection, s); 326 } 327 328 public synchronized Query newQuery(Extent extent, String s) { 329 checkClosed(); 330 return realPM.newQuery(extent, s); 331 } 332 333 public synchronized Extent getExtent(Class aClass, boolean b) { 334 checkClosed(); 335 return realPM.getExtent(aClass, b); 336 } 337 338 public synchronized Object getObjectById(Object o, boolean b) { 339 checkClosed(); 340 return realPM.getObjectById(o, b); 341 } 342 343 public synchronized Object getObjectId(Object o) { 344 checkClosed(); 345 return realPM.getObjectId(o); 346 } 347 348 public synchronized Object getTransactionalObjectId(Object o) { 349 checkClosed(); 350 return realPM.getTransactionalObjectId(o); 351 } 352 353 public synchronized Object newObjectIdInstance(Class aClass, String s) { 354 checkClosed(); 355 return realPM.newObjectIdInstance(aClass, s); 356 } 357 358 public synchronized void makePersistent(Object o) { 359 checkClosed(); 360 realPM.makePersistent(o); 361 } 362 363 public synchronized void makePersistentAll(Object [] objects) { 364 checkClosed(); 365 realPM.makePersistentAll(objects); 366 } 367 368 public synchronized void makePersistentAll(Collection collection) { 369 checkClosed(); 370 realPM.makePersistentAll(collection); 371 } 372 373 public synchronized void deletePersistent(Object o) { 374 checkClosed(); 375 realPM.deletePersistent(o); 376 } 377 378 public synchronized void deletePersistentAll(Object [] objects) { 379 checkClosed(); 380 realPM.deletePersistentAll(objects); 381 } 382 383 public synchronized void deletePersistentAll(Collection collection) { 384 checkClosed(); 385 realPM.deletePersistentAll(collection); 386 } 387 388 public synchronized void makeTransient(Object o) { 389 checkClosed(); 390 realPM.makeTransient(o); 391 } 392 393 public synchronized void makeTransientAll(Object [] objects) { 394 checkClosed(); 395 realPM.makeTransientAll(objects); 396 } 397 398 public synchronized void makeTransientAll(Collection collection) { 399 checkClosed(); 400 realPM.makeTransientAll(collection); 401 } 402 403 public synchronized void makeTransactional(Object o) { 404 checkClosed(); 405 realPM.makeTransactional(o); 406 } 407 408 public synchronized void makeTransactionalAll(Object [] objects) { 409 checkClosed(); 410 realPM.makeTransactionalAll(objects); 411 } 412 413 public synchronized void makeTransactionalAll(Collection collection) { 414 checkClosed(); 415 realPM.makeTransactionalAll(collection); 416 } 417 418 public synchronized void makeNontransactional(Object o) { 419 checkClosed(); 420 realPM.makeNontransactional(o); 421 } 422 423 public synchronized void makeNontransactionalAll(Object [] objects) { 424 checkClosed(); 425 realPM.makeNontransactionalAll(objects); 426 } 427 428 public synchronized void makeNontransactionalAll(Collection collection) { 429 checkClosed(); 430 realPM.makeNontransactionalAll(collection); 431 } 432 433 public synchronized void retrieve(Object o) { 434 checkClosed(); 435 realPM.retrieve(o); 436 } 437 438 public synchronized void retrieveAll(Collection pcs, boolean DFGOnly) { 439 checkClosed(); 440 realPM.retrieveAll(pcs, DFGOnly); 441 } 442 443 public synchronized void retrieveAll(Object [] pcs, boolean DFGOnly) { 444 checkClosed(); 445 realPM.retrieveAll(pcs, DFGOnly); 446 } 447 448 public synchronized void retrieveAll(Collection collection) { 449 checkClosed(); 450 realPM.retrieveAll(collection); 451 } 452 453 public synchronized void retrieveAll(Object [] objects) { 454 checkClosed(); 455 realPM.retrieveAll(objects); 456 } 457 458 public synchronized void setUserObject(Object o) { 459 checkClosed(); 460 realPM.setUserObject(o); 461 } 462 463 public synchronized Object getUserObject() { 464 checkClosed(); 465 return realPM.getUserObject(); 466 } 467 468 public synchronized PersistenceManagerFactory getPersistenceManagerFactory() { 469 checkClosed(); 470 return realPM.getPersistenceManagerFactory(); 471 } 472 473 public synchronized Class getObjectIdClass(Class aClass) { 474 checkClosed(); 475 return realPM.getObjectIdClass(aClass); 476 } 477 478 public synchronized void setMultithreaded(boolean b) { 479 checkClosed(); 480 realPM.setMultithreaded(b); 481 } 482 483 public synchronized boolean getMultithreaded() { 484 checkClosed(); 485 return realPM.getMultithreaded(); 486 } 487 488 public synchronized void setIgnoreCache(boolean b) { 489 checkClosed(); 490 realPM.setIgnoreCache(b); 491 } 492 493 public synchronized boolean getIgnoreCache() { 494 checkClosed(); 495 return realPM.getIgnoreCache(); 496 } 497 498 499 public synchronized void commit(Xid xid, boolean b) throws XAException { 500 checkClosed(); 501 realPM.commit(xid, b); 502 } 503 504 public synchronized void end(Xid xid, int i) throws XAException { 505 checkClosed(); 506 realPM.end(xid, i); 507 } 508 509 public synchronized void forget(Xid xid) throws XAException { 510 checkClosed(); 511 realPM.forget(xid); 512 } 513 514 public synchronized int getTransactionTimeout() throws XAException { 515 checkClosed(); 516 return realPM.getTransactionTimeout(); 517 } 518 519 public synchronized boolean isSameRM(XAResource xaResource) throws XAException { 520 if (realPM == null) return false; 521 return realPM.isSameRM(xaResource); 522 } 523 524 public synchronized int prepare(Xid xid) throws XAException { 525 checkClosed(); 526 return realPM.prepare(xid); 527 } 528 529 public synchronized Xid [] recover(int i) throws XAException { 530 checkClosed(); 531 return realPM.recover(i); 532 } 533 534 public synchronized void rollback(Xid xid) throws XAException { 535 checkClosed(); 536 realPM.rollback(xid); 537 } 538 539 public synchronized boolean setTransactionTimeout(int i) throws XAException { 540 checkClosed(); 541 return realPM.setTransactionTimeout(i); 542 } 543 544 public synchronized void start(Xid xid, int i) throws XAException { 545 checkClosed(); 546 realPM.start(xid, i); 547 } 548 549 public synchronized void afterCompletion(int i) { 550 checkClosed(); 551 realPM.afterCompletion(i); 552 } 553 554 public synchronized void beforeCompletion() { 555 checkClosed(); 556 realPM.beforeCompletion(); 557 } 558 559 560 public synchronized OID getInternalOID(final PersistenceCapable pc) { 561 checkClosed(); 562 return realPM.getInternalOID(pc); 563 } 564 565 public synchronized PCStateMan getInternalSM(final PersistenceCapable pc) { 566 checkClosed(); 567 return realPM.getInternalSM(pc); 568 } 569 570 public synchronized PCStateMan getInternalSM(OID oid) { 571 checkClosed(); 572 return realPM.getInternalSM(oid); 573 } 574 575 public synchronized State getInternaleState(PersistenceCapable pc) { 576 checkClosed(); 577 return realPM.getInternaleState(pc); 578 } 579 580 public synchronized void addTxStateObject(PCStateMan stateObject) { 581 checkClosed(); 582 realPM.addTxStateObject(stateObject); 583 } 584 585 public synchronized void removeTxStateObject(PCStateMan stateObject) { 586 checkClosed(); 587 realPM.removeTxStateObject(stateObject); 588 } 589 590 public synchronized boolean isOptimistic() { 591 checkClosed(); 592 return realPM.getOptimistic(); 593 } 594 595 public synchronized boolean isRetainValues() { 596 checkClosed(); 597 return realPM.getRetainValues(); 598 } 599 600 public synchronized boolean isRestoreValues() { 601 checkClosed(); 602 return realPM.getRestoreValues(); 603 } 604 605 public synchronized boolean isActive() { 606 checkClosed(); 607 return realPM.isActive(); 608 } 609 610 public synchronized void begin() { 611 checkClosed(); 612 realPM.begin(); 613 } 614 615 public synchronized void commit() { 616 checkClosed(); 617 realPM.commit(); 618 } 619 620 public synchronized boolean getNontransactionalRead() { 621 checkClosed(); 622 return realPM.getNontransactionalRead(); 623 } 624 625 public synchronized boolean getNontransactionalWrite() { 626 checkClosed(); 627 return realPM.getNontransactionalWrite(); 628 } 629 630 public synchronized boolean getOptimistic() { 631 checkClosed(); 632 return realPM.getOptimistic(); 633 } 634 635 public synchronized PersistenceManager getPersistenceManager() { 636 checkClosed(); 637 return this; 638 } 639 640 public synchronized boolean getRestoreValues() { 641 checkClosed(); 642 return realPM.getRestoreValues(); 643 } 644 645 public synchronized boolean getRetainValues() { 646 checkClosed(); 647 return realPM.getRetainValues(); 648 } 649 650 651 public synchronized Synchronization getSynchronization() { 652 checkClosed(); 653 return realPM.getSynchronization(); 654 } 655 656 657 public synchronized void rollback() { 658 checkClosed(); 659 realPM.rollback(); 660 } 661 662 public synchronized void setNontransactionalRead(boolean b) { 663 checkClosed(); 664 realPM.setNontransactionalRead(b); 665 } 666 667 public synchronized void setNontransactionalWrite(boolean b) { 668 checkClosed(); 669 realPM.setNontransactionalWrite(b); 670 } 671 672 public synchronized void setOptimistic(boolean b) { 673 checkClosed(); 674 realPM.setOptimistic(b); 675 } 676 677 public synchronized void setRestoreValues(boolean b) { 678 checkClosed(); 679 realPM.setRestoreValues(b); 680 } 681 682 public synchronized void setRetainValues(boolean b) { 683 checkClosed(); 684 realPM.setRetainValues(b); 685 } 686 687 688 public synchronized void setSynchronization(Synchronization synchronization) { 689 checkClosed(); 690 realPM.setSynchronization(synchronization); 691 } 692 693 694 public synchronized void setDatastoreTxLocking(int mode) { 695 checkClosed(); 696 realPM.setDatastoreTxLocking(mode); 697 } 698 699 public synchronized int getDatastoreTxLocking() { 700 checkClosed(); 701 return realPM.getDatastoreTxLocking(); 702 } 703 704 public synchronized void setRetainConnectionInOptTx(boolean on) { 705 checkClosed(); 706 realPM.setRetainConnectionInOptTx(on); 707 } 708 709 public synchronized Object getObjectByIdFromCache(Object oid) { 710 checkClosed(); 711 return realPM.getObjectByIdFromCache(oid); 712 } 713 714 public synchronized boolean isHollow(Object pc) { 715 checkClosed(); 716 return realPM.isHollow(pc); 717 } 718 719 public synchronized boolean hasIdentity(Object pc) { 720 checkClosed(); 721 return realPM.hasIdentity(pc); 722 } 723 724 public synchronized Object newObjectIdInstance(Class pcClass, String str, 725 boolean resolved) { 726 checkClosed(); 727 return realPM.newObjectIdInstance(pcClass, str, resolved); 728 } 729 730 public synchronized Object getObjectByIDString(String value, boolean toValidate, 731 boolean resolved) { 732 checkClosed(); 733 return realPM.getObjectByIDString(value, toValidate, resolved); 734 } 735 736 public synchronized void logEvent(int level, String description, int ms) { 737 checkClosed(); 738 realPM.logEvent(level, description, ms); 739 } 740 741 public synchronized Query versantNewNamedQuery(Class cls, String queryName) { 742 checkClosed(); 743 return realPM.versantNewNamedQuery(cls, queryName); 744 } 745 746 public synchronized boolean isCheckModelConsistencyOnCommit() { 747 checkClosed(); 748 return realPM.isCheckModelConsistencyOnCommit(); 749 } 750 751 public synchronized void setCheckModelConsistencyOnCommit(boolean on) { 752 checkClosed(); 753 realPM.setCheckModelConsistencyOnCommit(on); 754 } 755 756 public synchronized void checkModelConsistency() { 757 checkClosed(); 758 realPM.checkModelConsistency(); 759 } 760 761 public synchronized int getObjectsById(Object [] oids, int length, Object [] data, 762 int stateFieldNo, int classMetaDataIndex) { 763 checkClosed(); 764 return realPM.getObjectsById(oids, length, data, stateFieldNo, 765 classMetaDataIndex); 766 } 767 768 public synchronized Collection versantDetachCopy(Collection pcs, String fetchGroup) { 769 checkClosed(); 770 return realPM.versantDetachCopy(pcs, fetchGroup); 771 } 772 773 public synchronized Collection versantAttachCopy(Collection detached, 774 boolean makeTransactional) { 775 checkClosed(); 776 return realPM.versantAttachCopy(detached, makeTransactional); 777 } 778 779 public synchronized Collection versantAttachCopy(Collection detached, 780 boolean makeTransactional, boolean shallow) { 781 return realPM.versantAttachCopy(detached, makeTransactional, shallow); 782 } 783 784 public synchronized void evictFromL2CacheAfterCommit(Object o) { 785 checkClosed(); 786 realPM.evictFromL2CacheAfterCommit(o); 787 } 788 789 public synchronized void evictAllFromL2CacheAfterCommit(Object [] a) { 790 checkClosed(); 791 realPM.evictAllFromL2CacheAfterCommit(a); 792 } 793 794 public synchronized void evictAllFromL2CacheAfterCommit(Collection c) { 795 checkClosed(); 796 realPM.evictAllFromL2CacheAfterCommit(c); 797 } 798 799 public synchronized void evictAllFromL2CacheAfterCommit(Class cls, 800 boolean includeSubclasses) { 801 checkClosed(); 802 realPM.evictAllFromL2CacheAfterCommit(cls, includeSubclasses); 803 } 804 805 public synchronized void evictAllFromL2CacheAfterCommit() { 806 checkClosed(); 807 realPM.evictAllFromL2CacheAfterCommit(); 808 } 809 810 public void addLifecycleListener(LifecycleListener listener, 811 Class [] classes) { 812 checkClosed(); 813 realPM.addLifecycleListener(listener, classes); 814 } 815 816 public void removeLifecycleListener(LifecycleListener listener) { 817 checkClosed(); 818 realPM.removeLifecycleListener(listener); 819 } 820 821 822 823 } 824 | Popular Tags |