1 23 24 package org.objectweb.speedo.jca; 25 26 import org.objectweb.util.monolog.api.BasicLevel; 27 import org.objectweb.util.monolog.api.Logger; 28 import org.objectweb.speedo.api.Debug; 29 import org.objectweb.speedo.api.SpeedoProperties; 30 31 import java.util.Collection ; 32 33 import javax.naming.Context ; 34 import javax.naming.InitialContext ; 35 import javax.resource.ResourceException ; 36 import javax.resource.cci.Connection ; 37 import javax.resource.cci.ConnectionMetaData ; 38 import javax.resource.cci.Interaction ; 39 import javax.resource.cci.LocalTransaction ; 40 import javax.resource.cci.ResultSetInfo ; 41 import javax.transaction.Synchronization ; 42 import javax.transaction.UserTransaction ; 43 import javax.jdo.datastore.JDOConnection; 44 import javax.jdo.datastore.Sequence; 45 import javax.jdo.listener.InstanceLifecycleListener; 46 import javax.jdo.FetchPlan; 47 import javax.jdo.PersistenceManager; 48 import javax.jdo.JDOException; 49 import javax.jdo.Transaction; 50 import javax.jdo.Query; 51 import javax.jdo.Extent; 52 import javax.jdo.PersistenceManagerFactory; 53 54 57 public class JdoConnection 58 implements Connection , ConnectionMetaData , PersistenceManager, Transaction { 59 60 private final static String NO_ACTIVE_CONNECTION = 61 "The JDO connection should be active!!"; 62 63 66 private Logger logger; 67 70 private final static String EISPRODUCTNAME = "JDO Connector"; 71 75 private JdoConnectionFactory connectionFactory; 76 79 private JdoManagedConnection managedConnection = null; 80 83 private LocalTransaction localTransaction = null; 84 85 88 private UserTransaction userTransaction = null; 89 90 96 JdoConnection(Logger el, JdoConnectionFactory fcf) { 97 logger = el; 98 connectionFactory = fcf; 99 } 100 101 105 void initialize(JdoManagedConnection mc) { 106 managedConnection = mc; 107 } 108 109 111 114 public Interaction createInteraction() throws ResourceException { 115 throw new ResourceException ("JDO Connector: no support for Interaction."); 116 } 117 118 public LocalTransaction getLocalTransaction() throws ResourceException { 119 if (managedConnection == null) { 120 throw new ResourceException ("JDO Connector: cannot get a LocalTransaction with no associated ManagedConnection."); 121 } 122 localTransaction = managedConnection; 123 return managedConnection; 124 } 125 126 129 public ConnectionMetaData getMetaData() throws ResourceException { 130 return this; 131 } 132 133 136 public ResultSetInfo getResultSetInfo() throws ResourceException { 137 throw new ResourceException ("JDO Connector: no support for ResultSet."); 138 } 139 140 144 public void close() { 145 if (Debug.ON) 146 logger.log(BasicLevel.DEBUG, "Closes Connection: " + this); 147 if (managedConnection == null) { 148 return; 150 } 151 if (localTransaction != null) { 152 if (!managedConnection.localTransactionTerminated()) { 153 throw new JDOException("JDO Connector: cannot close connection while a LocalTransaction is still active."); 154 } 155 } 156 try { 157 managedConnection.dissociateConnection(this); 158 } catch (ResourceException e) { 159 throw new JDOException("JDO Connector: problem while closing a connection.", e); 160 } finally { 161 localTransaction = null; 162 managedConnection = null; 163 } 164 } 165 166 169 public void setAutoCommit(boolean b) throws ResourceException { 170 throw new ResourceException ("No sense for a JDO connector."); 171 } 172 173 176 public boolean getAutoCommit() throws ResourceException { 177 throw new ResourceException ("No sense for a JDO connector."); 178 } 179 180 182 186 public String getEISProductName() throws ResourceException { 187 return EISPRODUCTNAME; 188 } 189 190 194 public String getEISProductVersion() throws ResourceException { 195 return connectionFactory.getAdapterVersion(); 196 } 197 198 202 public String getUserName() throws ResourceException { 203 return ""; 204 } 205 206 209 public boolean isClosed() { 210 return managedConnection == null; 211 } 212 213 public Transaction currentTransaction() { 214 if (managedConnection == null) { 215 throw new JDOException(NO_ACTIVE_CONNECTION); 216 } 217 if (connectionFactory.getTransactionMode() != SpeedoProperties.TRANSACTION_BMODE_NORMAL) { 219 if(connectionFactory.getTransactionMode() == SpeedoProperties.TRANSACTION_BMODE_UT) { 220 try { 221 if (userTransaction == null) { 222 Context ic = new InitialContext (); 223 userTransaction = (UserTransaction ) ic.lookup("javax.transaction.UserTransaction"); 224 } 225 logger.log(BasicLevel.DEBUG, "UserTransaction is used."); 226 } catch (Exception e) { 227 throw new JDOException("Error with JTA UserTransaction", e); 228 } 229 } 230 return this; 231 } else { 232 return managedConnection.getProxyManager().currentTransaction(); 233 } 234 } 235 236 public void evict(Object o) { 237 if (managedConnection == null) { 238 throw new JDOException(NO_ACTIVE_CONNECTION); 239 } 240 managedConnection.getProxyManager().evict(o); 241 } 242 243 public void evictAll(Object [] objects) { 244 if (managedConnection == null) { 245 throw new JDOException(NO_ACTIVE_CONNECTION); 246 } 247 managedConnection.getProxyManager().evictAll(objects); 248 } 249 250 public void evictAll(Collection collection) { 251 if (managedConnection == null) { 252 throw new JDOException(NO_ACTIVE_CONNECTION); 253 } 254 managedConnection.getProxyManager().evictAll(collection); 255 } 256 257 public void evictAll() { 258 if (managedConnection == null) { 259 throw new JDOException(NO_ACTIVE_CONNECTION); 260 } 261 managedConnection.getProxyManager().evictAll(); 262 } 263 264 public void refresh(Object o) { 265 if (managedConnection == null) { 266 throw new JDOException(NO_ACTIVE_CONNECTION); 267 } 268 managedConnection.getProxyManager().refresh(o); 269 } 270 271 public void refreshAll(Object [] objects) { 272 if (managedConnection == null) { 273 throw new JDOException(NO_ACTIVE_CONNECTION); 274 } 275 managedConnection.getProxyManager().refreshAll(objects); 276 } 277 278 public void refreshAll(Collection collection) { 279 if (managedConnection == null) { 280 throw new JDOException(NO_ACTIVE_CONNECTION); 281 } 282 managedConnection.getProxyManager().refreshAll(collection); 283 } 284 285 public void refreshAll() { 286 if (managedConnection == null) { 287 throw new JDOException(NO_ACTIVE_CONNECTION); 288 } 289 managedConnection.getProxyManager().refreshAll(); 290 } 291 292 public Query newQuery() { 293 if (managedConnection == null) { 294 throw new JDOException(NO_ACTIVE_CONNECTION); 295 } 296 return managedConnection.getProxyManager().newQuery(); 297 } 298 299 public Query newQuery(String q) { 300 if (managedConnection == null) { 301 throw new JDOException(NO_ACTIVE_CONNECTION); 302 } 303 return managedConnection.getProxyManager().newQuery(q); 304 } 305 306 public Query newQuery(Object o) { 307 if (managedConnection == null) { 308 throw new JDOException(NO_ACTIVE_CONNECTION); 309 } 310 return managedConnection.getProxyManager().newQuery(o); 311 } 312 313 public Query newQuery(String s, Object o) { 314 if (managedConnection == null) { 315 throw new JDOException(NO_ACTIVE_CONNECTION); 316 } 317 return managedConnection.getProxyManager().newQuery(s, o); 318 } 319 320 public Query newQuery(Class aClass) { 321 if (managedConnection == null) { 322 throw new JDOException(NO_ACTIVE_CONNECTION); 323 } 324 return managedConnection.getProxyManager().newQuery(aClass); 325 } 326 327 public Query newQuery(Extent extent) { 328 if (managedConnection == null) { 329 throw new JDOException(NO_ACTIVE_CONNECTION); 330 } 331 return managedConnection.getProxyManager().newQuery(extent); 332 } 333 334 public Query newQuery(Class aClass, Collection collection) { 335 if (managedConnection == null) { 336 throw new JDOException(NO_ACTIVE_CONNECTION); 337 } 338 return managedConnection.getProxyManager().newQuery(aClass, collection); 339 } 340 341 public Query newQuery(Class aClass, String s) { 342 if (managedConnection == null) { 343 throw new JDOException(NO_ACTIVE_CONNECTION); 344 } 345 return managedConnection.getProxyManager().newQuery(aClass, s); 346 } 347 348 public Query newQuery(Class aClass, Collection collection, String s) { 349 if (managedConnection == null) { 350 throw new JDOException(NO_ACTIVE_CONNECTION); 351 } 352 return managedConnection.getProxyManager().newQuery(aClass, collection, s); 353 } 354 355 public Query newQuery(Extent extent, String s) { 356 if (managedConnection == null) { 357 throw new JDOException(NO_ACTIVE_CONNECTION); 358 } 359 return managedConnection.getProxyManager().newQuery(extent, s); 360 } 361 362 public Extent getExtent(Class aClass, boolean b) { 363 if (managedConnection == null) { 364 throw new JDOException(NO_ACTIVE_CONNECTION); 365 } 366 return managedConnection.getProxyManager().getExtent(aClass, b); 367 } 368 369 public Object getObjectById(Object o, boolean b) { 370 if (managedConnection == null) { 371 throw new JDOException(NO_ACTIVE_CONNECTION); 372 } 373 return managedConnection.getProxyManager().getObjectById(o, b); 374 } 375 376 public Collection getObjectsById(Collection arg0, boolean arg1) { 377 if (managedConnection == null) { 378 throw new JDOException(NO_ACTIVE_CONNECTION); 379 } 380 return managedConnection.getProxyManager().getObjectsById(arg0, arg1); 381 } 382 public Collection getObjectsById(Collection arg0) { 383 if (managedConnection == null) { 384 throw new JDOException(NO_ACTIVE_CONNECTION); 385 } 386 return managedConnection.getProxyManager().getObjectsById(arg0); 387 } 388 public Object [] getObjectsById(Object [] arg0, boolean arg1) { 389 if (managedConnection == null) { 390 throw new JDOException(NO_ACTIVE_CONNECTION); 391 } 392 return managedConnection.getProxyManager().getObjectsById(arg0, arg1); 393 } 394 public Object [] getObjectsById(Object [] arg0) { 395 if (managedConnection == null) { 396 throw new JDOException(NO_ACTIVE_CONNECTION); 397 } 398 return managedConnection.getProxyManager().getObjectsById(arg0); 399 } 400 public Sequence getSequence(String arg0) { 401 if (managedConnection == null) { 402 throw new JDOException(NO_ACTIVE_CONNECTION); 403 } 404 return managedConnection.getProxyManager().getSequence(arg0); 405 } 406 public Object getUserObject(Object arg0) { 407 if (managedConnection == null) { 408 throw new JDOException(NO_ACTIVE_CONNECTION); 409 } 410 return managedConnection.getProxyManager().getUserObject(arg0); 411 } 412 public Object newInstance(Class arg0) { 413 if (managedConnection == null) { 414 throw new JDOException(NO_ACTIVE_CONNECTION); 415 } 416 return managedConnection.getProxyManager().newInstance(arg0); 417 } 418 public Object putUserObject(Object arg0, Object arg1) { 419 if (managedConnection == null) { 420 throw new JDOException(NO_ACTIVE_CONNECTION); 421 } 422 return managedConnection.getProxyManager().putUserObject(arg0, arg1); 423 } 424 public Object removeUserObject(Object arg0) { 425 if (managedConnection == null) { 426 throw new JDOException(NO_ACTIVE_CONNECTION); 427 } 428 return managedConnection.getProxyManager().removeUserObject(arg0); 429 } 430 public Object getObjectId(Object o) { 431 if (managedConnection == null) { 432 throw new JDOException(NO_ACTIVE_CONNECTION); 433 } 434 return managedConnection.getProxyManager().getObjectId(o); 435 } 436 437 public Object getObjectById(Class clazz, Object o) { 438 if (managedConnection == null) { 439 throw new JDOException(NO_ACTIVE_CONNECTION); 440 } 441 return managedConnection.getProxyManager().getObjectById(clazz, o); 442 } 443 public Object getObjectById(Object o) { 444 if (managedConnection == null) { 445 throw new JDOException(NO_ACTIVE_CONNECTION); 446 } 447 return managedConnection.getProxyManager().getObjectById(o); 448 } 449 public Object getTransactionalObjectId(Object o) { 450 if (managedConnection == null) { 451 throw new JDOException(NO_ACTIVE_CONNECTION); 452 } 453 return managedConnection.getProxyManager().getTransactionalObjectId(o); 454 } 455 456 public Object newObjectIdInstance(Class aClass, Object s) { 457 if (managedConnection == null) { 458 throw new JDOException(NO_ACTIVE_CONNECTION); 459 } 460 return managedConnection.getProxyManager().newObjectIdInstance(aClass, s); 461 } 462 463 public void makePersistent(Object o) { 464 if (managedConnection == null) { 465 throw new JDOException(NO_ACTIVE_CONNECTION); 466 } 467 managedConnection.getProxyManager().makePersistent(o); 468 } 469 470 public void makePersistentAll(Object [] objects) { 471 if (managedConnection == null) { 472 throw new JDOException(NO_ACTIVE_CONNECTION); 473 } 474 managedConnection.getProxyManager().makePersistentAll(objects); 475 } 476 477 public void makePersistentAll(Collection collection) { 478 if (managedConnection == null) { 479 throw new JDOException(NO_ACTIVE_CONNECTION); 480 } 481 managedConnection.getProxyManager().makePersistentAll(collection); 482 } 483 484 public void deletePersistent(Object o) { 485 if (managedConnection == null) { 486 throw new JDOException(NO_ACTIVE_CONNECTION); 487 } 488 managedConnection.getProxyManager().deletePersistent(o); 489 } 490 491 public void deletePersistentAll(Object [] objects) { 492 if (managedConnection == null) { 493 throw new JDOException(NO_ACTIVE_CONNECTION); 494 } 495 managedConnection.getProxyManager().deletePersistentAll(objects); 496 } 497 498 public void deletePersistentAll(Collection collection) { 499 if (managedConnection == null) { 500 throw new JDOException(NO_ACTIVE_CONNECTION); 501 } 502 managedConnection.getProxyManager().deletePersistentAll(collection); 503 } 504 505 public void makeTransient(Object o) { 506 if (managedConnection == null) { 507 throw new JDOException(NO_ACTIVE_CONNECTION); 508 } 509 managedConnection.getProxyManager().makeTransient(o); 510 } 511 512 public void makeTransientAll(Object [] objects) { 513 if (managedConnection == null) { 514 throw new JDOException(NO_ACTIVE_CONNECTION); 515 } 516 managedConnection.getProxyManager().makeTransientAll(objects); 517 } 518 519 public void makeTransientAll(Collection collection) { 520 if (managedConnection == null) { 521 throw new JDOException(NO_ACTIVE_CONNECTION); 522 } 523 managedConnection.getProxyManager().makeTransientAll(collection); 524 } 525 526 public void makeTransactional(Object o) { 527 if (managedConnection == null) { 528 throw new JDOException(NO_ACTIVE_CONNECTION); 529 } 530 managedConnection.getProxyManager().makeTransactional(o); 531 } 532 533 public void makeTransactionalAll(Object [] objects) { 534 if (managedConnection == null) { 535 throw new JDOException(NO_ACTIVE_CONNECTION); 536 } 537 managedConnection.getProxyManager().makeTransactionalAll(objects); 538 } 539 540 public void makeTransactionalAll(Collection collection) { 541 if (managedConnection == null) { 542 throw new JDOException(NO_ACTIVE_CONNECTION); 543 } 544 managedConnection.getProxyManager().makeTransactionalAll(collection); 545 } 546 547 public void makeNontransactional(Object o) { 548 if (managedConnection == null) { 549 throw new JDOException(NO_ACTIVE_CONNECTION); 550 } 551 managedConnection.getProxyManager().makeNontransactional(o); 552 } 553 554 public void makeNontransactionalAll(Object [] objects) { 555 if (managedConnection == null) { 556 throw new JDOException(NO_ACTIVE_CONNECTION); 557 } 558 makeNontransactionalAll(objects); 559 } 560 561 public void makeNontransactionalAll(Collection collection) { 562 if (managedConnection == null) { 563 throw new JDOException(NO_ACTIVE_CONNECTION); 564 } 565 managedConnection.getProxyManager().makeNontransactionalAll(collection); 566 } 567 568 public void retrieve(Object o) { 569 if (managedConnection == null) { 570 throw new JDOException(NO_ACTIVE_CONNECTION); 571 } 572 managedConnection.getProxyManager().retrieve(o); 573 } 574 575 public void retrieveAll(Collection collection) { 576 if (managedConnection == null) { 577 throw new JDOException(NO_ACTIVE_CONNECTION); 578 } 579 managedConnection.getProxyManager().retrieveAll(collection); 580 } 581 582 public void retrieveAll(Object [] objects) { 583 if (managedConnection == null) { 584 throw new JDOException(NO_ACTIVE_CONNECTION); 585 } 586 managedConnection.getProxyManager().retrieveAll(objects); 587 } 588 589 public void retrieveAll(Collection collection, boolean b) { 590 if (managedConnection == null) { 591 throw new JDOException(NO_ACTIVE_CONNECTION); 592 } 593 managedConnection.getProxyManager().retrieveAll(collection, b); 594 } 595 596 public void retrieveAll(Object [] objects, boolean b) { 597 if (managedConnection == null) { 598 throw new JDOException(NO_ACTIVE_CONNECTION); 599 } 600 managedConnection.getProxyManager().retrieveAll(objects, b); 601 } 602 603 public void setUserObject(Object o) { 604 if (managedConnection == null) { 605 throw new JDOException(NO_ACTIVE_CONNECTION); 606 } 607 managedConnection.getProxyManager().setUserObject(o); 608 } 609 610 public Object getUserObject() { 611 if (managedConnection == null) { 612 throw new JDOException(NO_ACTIVE_CONNECTION); 613 } 614 return managedConnection.getProxyManager().getUserObject(); 615 } 616 617 public PersistenceManagerFactory getPersistenceManagerFactory() { 618 if (managedConnection == null) { 619 throw new JDOException(NO_ACTIVE_CONNECTION); 620 } 621 return managedConnection.getProxyManager().getPersistenceManagerFactory(); 622 } 623 624 public Class getObjectIdClass(Class aClass) { 625 if (managedConnection == null) { 626 throw new JDOException(NO_ACTIVE_CONNECTION); 627 } 628 return managedConnection.getProxyManager().getObjectIdClass(aClass); 629 } 630 631 public void setMultithreaded(boolean b) { 632 if (managedConnection == null) { 633 throw new JDOException(NO_ACTIVE_CONNECTION); 634 } 635 managedConnection.getProxyManager().setMultithreaded(b); 636 } 637 638 public boolean getMultithreaded() { 639 if (managedConnection == null) { 640 throw new JDOException(NO_ACTIVE_CONNECTION); 641 } 642 return managedConnection.getProxyManager().getMultithreaded(); 643 } 644 645 public void setIgnoreCache(boolean b) { 646 if (managedConnection == null) { 647 throw new JDOException(NO_ACTIVE_CONNECTION); 648 } 649 managedConnection.getProxyManager().setIgnoreCache(b); 650 } 651 652 public boolean getIgnoreCache() { 653 if (managedConnection == null) { 654 throw new JDOException(NO_ACTIVE_CONNECTION); 655 } 656 return managedConnection.getProxyManager().getIgnoreCache(); 657 } 658 659 public void addInstanceLifecycleListener(InstanceLifecycleListener arg0, Class [] arg1) { 660 if (managedConnection == null) { 661 throw new JDOException(NO_ACTIVE_CONNECTION); 662 } 663 managedConnection.getProxyManager().addInstanceLifecycleListener(arg0, arg1); 664 } 665 public Object attachCopy(Object arg0, boolean arg1) { 666 if (managedConnection == null) { 667 throw new JDOException(NO_ACTIVE_CONNECTION); 668 } 669 return managedConnection.getProxyManager().attachCopy(arg0, arg1); 670 } 671 public Collection attachCopyAll(Collection arg0, boolean arg1) { 672 if (managedConnection == null) { 673 throw new JDOException(NO_ACTIVE_CONNECTION); 674 } 675 return managedConnection.getProxyManager().attachCopyAll(arg0, arg1); 676 } 677 public Object [] attachCopyAll(Object [] arg0, boolean arg1) { 678 if (managedConnection == null) { 679 throw new JDOException(NO_ACTIVE_CONNECTION); 680 } 681 return managedConnection.getProxyManager().attachCopyAll(arg0, arg1); 682 } 683 public Object detachCopy(Object arg0) { 684 if (managedConnection == null) { 685 throw new JDOException(NO_ACTIVE_CONNECTION); 686 } 687 return managedConnection.getProxyManager().detachCopy(arg0); 688 } 689 public Collection detachCopyAll(Collection arg0) { 690 if (managedConnection == null) { 691 throw new JDOException(NO_ACTIVE_CONNECTION); 692 } 693 return managedConnection.getProxyManager().detachCopyAll(arg0); 694 } 695 public Object [] detachCopyAll(Object [] arg0) { 696 if (managedConnection == null) { 697 throw new JDOException(NO_ACTIVE_CONNECTION); 698 } 699 return managedConnection.getProxyManager().detachCopyAll(arg0); 700 } 701 public void flush() { 702 if (managedConnection == null) { 703 throw new JDOException(NO_ACTIVE_CONNECTION); 704 } 705 managedConnection.getProxyManager().flush(); 706 } 707 public void checkConsistency() { 708 if (managedConnection == null) { 709 throw new JDOException(NO_ACTIVE_CONNECTION); 710 } 711 managedConnection.getProxyManager().checkConsistency(); 712 } 713 public JDOConnection getDataStoreConnection() { 714 if (managedConnection == null) { 715 throw new JDOException(NO_ACTIVE_CONNECTION); 716 } 717 return managedConnection.getProxyManager().getDataStoreConnection(); 718 } 719 public Extent getExtent(Class arg0) { 720 if (managedConnection == null) { 721 throw new JDOException(NO_ACTIVE_CONNECTION); 722 } 723 return managedConnection.getProxyManager().getExtent(arg0); 724 } 725 public FetchPlan getFetchPlan() { 726 if (managedConnection == null) { 727 throw new JDOException(NO_ACTIVE_CONNECTION); 728 } 729 return managedConnection.getProxyManager().getFetchPlan(); 730 } 731 public Query newNamedQuery(Class arg0, String arg1) { 732 if (managedConnection == null) { 733 throw new JDOException(NO_ACTIVE_CONNECTION); 734 } 735 return managedConnection.getProxyManager().newNamedQuery(arg0, arg1); 736 } 737 public void refreshAll(JDOException arg0) { 738 if (managedConnection == null) { 739 throw new JDOException(NO_ACTIVE_CONNECTION); 740 } 741 managedConnection.getProxyManager().refreshAll(arg0); 742 } 743 public void removeInstanceLifecycleListener(InstanceLifecycleListener arg0) { 744 if (managedConnection == null) { 745 throw new JDOException(NO_ACTIVE_CONNECTION); 746 } 747 managedConnection.getProxyManager().removeInstanceLifecycleListener(arg0); 748 } 749 750 754 public void begin() { 755 if (connectionFactory.getTransactionMode() == SpeedoProperties.TRANSACTION_BMODE_UT) { 756 try { 757 userTransaction.begin(); 758 } catch(Exception e) { 759 throw new JDOException("Error with JTA UserTransaction.begin().", e); 760 } 761 } else { 762 logger.log(BasicLevel.INFO, "Nothing is done on begin. The property ignoreJDOTransaction is activated."); 764 } 765 } 766 767 public void commit() { 768 if (connectionFactory.getTransactionMode() == SpeedoProperties.TRANSACTION_BMODE_UT) { 769 try { 770 userTransaction.commit(); 771 logger.log(BasicLevel.DEBUG, "UserTransaction commit."); 772 } catch(Exception e) { 773 throw new JDOException("Error with JTA UserTransaction.commit().", e); 774 } 775 } else { 776 logger.log(BasicLevel.INFO, "Nothing is done on commit. The property ignoreJDOTransaction is activated."); 778 } 779 } 780 781 public void rollback() { 782 if (connectionFactory.getTransactionMode() == SpeedoProperties.TRANSACTION_BMODE_UT) { 783 try { 784 userTransaction.rollback(); 785 } catch(Exception e) { 786 throw new JDOException("Error with JTA UserTransaction.rollback().", e); 787 } 788 } else { 789 logger.log(BasicLevel.INFO, "Nothing is done on rollback. The property ignoreJDOTransaction is activated."); 791 } 792 } 793 794 public boolean isActive() { 795 if (managedConnection == null) { 797 throw new JDOException(NO_ACTIVE_CONNECTION); 798 } 799 return managedConnection.getProxyManager().currentTransaction().isActive(); 800 } 801 802 public boolean getRollbackOnly() { 803 if (managedConnection == null) { 805 throw new JDOException(NO_ACTIVE_CONNECTION); 806 } 807 return managedConnection.getProxyManager().currentTransaction().getRollbackOnly(); 808 } 809 810 public void setRollbackOnly() { 811 if (managedConnection == null) { 813 throw new JDOException(NO_ACTIVE_CONNECTION); 814 } 815 managedConnection.getProxyManager().currentTransaction().setRollbackOnly(); 816 817 } 818 819 820 public void setNontransactionalRead(boolean nontransactionalRead) { 821 if (managedConnection == null) { 823 throw new JDOException(NO_ACTIVE_CONNECTION); 824 } 825 managedConnection.getProxyManager().currentTransaction().setNontransactionalRead(nontransactionalRead); 826 } 827 828 829 public boolean getNontransactionalRead() { 830 if (managedConnection == null) { 832 throw new JDOException(NO_ACTIVE_CONNECTION); 833 } 834 return managedConnection.getProxyManager().currentTransaction().getNontransactionalRead(); 835 836 } 837 838 839 public void setNontransactionalWrite(boolean nontransactionalWrite) { 840 if (managedConnection == null) { 842 throw new JDOException(NO_ACTIVE_CONNECTION); 843 } 844 managedConnection.getProxyManager().currentTransaction().setNontransactionalWrite(nontransactionalWrite); 845 846 } 847 848 849 public boolean getNontransactionalWrite() { 850 if (managedConnection == null) { 852 throw new JDOException(NO_ACTIVE_CONNECTION); 853 } 854 return managedConnection.getProxyManager().currentTransaction().getNontransactionalWrite(); 855 } 856 857 858 public void setRetainValues(boolean retainValues) { 859 if (managedConnection == null) { 861 throw new JDOException(NO_ACTIVE_CONNECTION); 862 } 863 managedConnection.getProxyManager().currentTransaction().setRetainValues(retainValues); 864 865 } 866 867 868 public boolean getRetainValues() { 869 if (managedConnection == null) { 871 throw new JDOException(NO_ACTIVE_CONNECTION); 872 } 873 return managedConnection.getProxyManager().currentTransaction().getRetainValues(); 874 } 875 876 877 public void setRestoreValues(boolean restoreValues) { 878 if (managedConnection == null) { 880 throw new JDOException(NO_ACTIVE_CONNECTION); 881 } 882 managedConnection.getProxyManager().currentTransaction().setRestoreValues(restoreValues); 883 } 884 885 886 public boolean getRestoreValues() { 887 if (managedConnection == null) { 889 throw new JDOException(NO_ACTIVE_CONNECTION); 890 } 891 return managedConnection.getProxyManager().currentTransaction().getRestoreValues(); 892 } 893 894 895 public void setOptimistic(boolean optimistic) { 896 if (managedConnection == null) { 898 throw new JDOException(NO_ACTIVE_CONNECTION); 899 } 900 managedConnection.getProxyManager().currentTransaction().setOptimistic(optimistic); 901 } 902 903 904 public boolean getOptimistic() { 905 if (managedConnection == null) { 907 throw new JDOException(NO_ACTIVE_CONNECTION); 908 } 909 return managedConnection.getProxyManager().currentTransaction().getOptimistic(); 910 } 911 912 913 public void setSynchronization(Synchronization sync) { 914 if (managedConnection == null) { 916 throw new JDOException(NO_ACTIVE_CONNECTION); 917 } 918 managedConnection.getProxyManager().currentTransaction().setSynchronization(sync); 919 } 920 921 922 public Synchronization getSynchronization() { 923 if (managedConnection == null) { 925 throw new JDOException(NO_ACTIVE_CONNECTION); 926 } 927 return managedConnection.getProxyManager().currentTransaction().getSynchronization(); 928 } 929 930 931 public PersistenceManager getPersistenceManager() { 932 if (managedConnection == null) { 934 throw new JDOException(NO_ACTIVE_CONNECTION); 935 } 936 return managedConnection.getProxyManager().currentTransaction().getPersistenceManager(); 937 } 938 } 939 | Popular Tags |