001/* 002 * JKNIV, whinstone one contract to access your database. 003 * 004 * Copyright (C) 2017, the original author or authors. 005 * 006 * This library is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 2.1 of the License. 010 * 011 * This library is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with this library; if not, write to the Free Software Foundation, Inc., 018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 019 */ 020package net.sf.jkniv.whinstone.transaction; 021 022import net.sf.jkniv.sqlegance.transaction.TransactionType; 023 024public interface Transactional 025{ 026 /* 027 //Transaction getTransaction(); 028 /** 029 * A call to the TransactionManager.suspend method temporarily suspends the transaction 030 * that is currently associated with the calling thread. If the thread is not associated 031 * with any transaction, a null object reference is returned; otherwise, a valid Transaction 032 * object is returned. The Transaction object can later be passed to the resume method to 033 * reinstate the transaction context association with the calling thread. 034 * @return 035 * 036 Transaction suspend(); 037 038 /** 039 * The TransactionManager.resume method re-associates the specified transaction context with 040 * the calling thread. If the transaction specified is a valid transaction, the transaction 041 * context is associated with the calling thread; otherwise, the thread is associated with 042 * no transaction. 043 * 044 * If TransactionManager.resume is invoked when the calling thread is already associated with 045 * another transaction, the transaction manager throws the IllegalStateException exception. 046 * 047 * @param transaction 048 * 049 * 050 void resume(Transaction transaction); 051 //void setRollbackOnly(); 052 */ 053 054 /** 055 * The TransactionManager.begin method starts a global transaction and associates 056 * the transaction context with the calling thread. 057 * 058 * If the TransactionManager implementation does not support nested transactions, 059 * the TransactionManager.begin method throws the NotSupportedException when the 060 * calling thread is already associated with a transaction. 061 * 062 * The TransactionManager.getTransaction method returns the Transaction object that 063 * represents the transaction context currently associated with the calling thread. 064 * This Transaction object can be used to perform various operations on the target transaction. 065 * Examples of Transaction object operations are resource enlistment and synchronization registration. 066 * @throws TransactionException TODO doc me when some error occurs 067 */ 068 public void begin(); 069 070 /*** 071 * The TransactionManager.commit method completes the transaction currently associated 072 * with the calling thread. After the commit method returns, the calling thread is not 073 * associated with a transaction. If the commit method is called when the thread is not 074 * associated with any transaction context, the TransactionManager throws an exception. 075 * In some implementations, the commit operation is restricted to the transaction originator only. 076 * If the calling thread is not allowed to commit the transaction, the TransactionManager throws an exception. 077 * @throws TransactionException TODO doc me when some error occurs 078 */ 079 void commit(); 080 081 /** 082 * The TransactionManager.rollback method rolls back the transaction associated with the current thread. 083 * After the rollback method completes, the thread is associated with no transaction. 084 * @throws TransactionException TODO doc me when some error occurs 085 */ 086 void rollback(); 087 088 TransactionStatus getStatus(); 089 090 /** 091 * Type of transactions supported by the repository 092 * @return type of transaction 093 */ 094 TransactionType geTransactionType(); 095 096 /* 097 * Modify the timeout value that is associated with transactions started 098 * by the current thread with the begin method. 099 * 100 * <p> If an application has not called this method, the transaction 101 * service uses some default value for the transaction timeout. 102 * 103 * @param seconds The value of the timeout in seconds. If the value is zero, 104 * the transaction service restores the default value. If the value 105 * is negative a SystemException is thrown. 106 * 107 * @exception TransactionException Thrown if the transaction manager 108 * encounters an unexpected error condition. 109 * 110 void setTransactionTimeout(int seconds) throws TransactionException; 111 */ 112}