|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.transaction Interface TransactionManager
public interface TransactionManager
TransactionManager 接口定义帮助应用服务器管理事务邦定的方法。
The TransactionManager interface defines the methods that allow an application server to manage transaction boundaries.
Method Summary | |
---|---|
void |
begin()
Create a new transaction and associate it with the current thread. |
void |
commit()
Complete the transaction associated with the current thread. |
int |
getStatus()
Obtain the status of the transaction associated with the current thread. |
Transaction |
getTransaction()
Get the transaction object that represents the transaction context of the calling thread. |
void |
resume(Transaction tobj)
Resume the transaction context association of the calling thread with the transaction represented by the supplied Transaction object. |
void |
rollback()
Roll back the transaction associated with the current thread. |
void |
setRollbackOnly()
Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction. |
void |
setTransactionTimeout(int seconds)
Modify the timeout value that is associated with transactions started by the current thread with the begin method. |
Transaction |
suspend()
Suspend the transaction currently associated with the calling thread and return a Transaction object that represents the transaction context being suspended. |
Method Detail |
---|
public void
begin() throws NotSupportedException, SystemException
创建一个新事务,并将其与当前线程关联。
Throws | NotSupportedException: 如果线程已经与事务关联,但 TransactionManager 实现不支持嵌套的事务。 |
Throws | SystemException: 如果事务管理器遇到不可预料的错误情况,则抛出该异常。 |
begin
void begin() throws NotSupportedException, SystemException
- Create a new transaction and associate it with the current thread.
- Throws:
NotSupportedException
- Thrown if the thread is already associated with a transaction and the Transaction Manager implementation does not support nested transactions.SystemException
- Thrown if the transaction manager encounters an unexpected error condition.
public void
commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException
完成与当前线程关联的事务。完成此方法时,线程不再与事务关联。
Throws | RollbackException: 抛出该异常指示事务已经回滚,而不是提交。 |
Throws | HeuristicMixedException: 抛出该异常指示做出了启发式决策,提交了一部分相关更新,同时回滚了另一部分。 |
Throws | HeuristicRollbackException: 抛出该异常指示做出了启发式决策,回滚了所有相关更新。 |
Throws | SecurityException: 抛出该异常指示不允许线程提交事务。 |
Throws | IllegalStateException: 如果当前线程不与事务关联,则抛出该异常。 |
Throws | SystemException: 如果事务管理器遇到不可预料的错误情况,则抛出该异常。 |
commit
void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException
- Complete the transaction associated with the current thread. When this
method completes, the thread is no longer associated with a transaction.
- Throws:
RollbackException
- Thrown to indicate that the transaction has been rolled back rather than committed.HeuristicMixedException
- Thrown to indicate that a heuristic decision was made and that some relevant updates have been committed while others have been rolled back.HeuristicRollbackException
- Thrown to indicate that a heuristic decision was made and that all relevant updates have been rolled back.SecurityException
- Thrown to indicate that the thread is not allowed to commit the transaction.IllegalStateException
- Thrown if the current thread is not associated with a transaction.SystemException
- Thrown if the transaction manager encounters an unexpected error condition.
public int
getStatus() throws SystemException
获取与当前线程关联的事务状态。
return | 事务状态。如果没有任何事务与当前线程关联,则此方法返回 Status.NoTransaction 值。 |
Throws | SystemException: 如果事务管理器遇到不可预料的错误情况,则抛出该异常。 |
getStatus
int getStatus() throws SystemException
- Obtain the status of the transaction associated with the current thread.
- Returns:
- The transaction status. If no transaction is associated with the current thread, this method returns the Status.NoTransaction value.
- Throws:
SystemException
- Thrown if the transaction manager encounters an unexpected error condition.
public Transaction
getTransaction() throws SystemException
获取表示调用线程的事务上下文的事务对象。
return |
表示与调用线程关联的事务的 Transaction 对象。 |
Throws | SystemException: 如果事务管理器遇到不可预料的错误情况,则抛出该异常。 |
getTransaction
Transaction getTransaction() throws SystemException
- Get the transaction object that represents the transaction
context of the calling thread.
- Returns:
- the
Transaction
object representing the transaction associated with the calling thread. - Throws:
SystemException
- Thrown if the transaction manager encounters an unexpected error condition.
public void
resume(Transaction tobj) throws InvalidTransactionException, IllegalStateException, SystemException
恢复调用线程与所提供的 Transaction 对象表示的事务的事务上下文关联。当此方法返回时,调用线程与指定的事务上下文关联。
tobj |
表示要恢复的事务的 Transaction 对象。 |
Throws | InvalidTransactionException: 如果参数事务对象包含一个无效的事务,则抛出此异常。 |
Throws | IllegalStateException: 如果线程已与另一个事务关联,则抛出该异常。 |
Throws | SystemException: 如果事务管理器遇到不可预料的错误情况,则抛出该异常。 |
resume
void resume(Transaction tobj) throws InvalidTransactionException, IllegalStateException, SystemException
- Resume the transaction context association of the calling thread
with the transaction represented by the supplied Transaction object.
When this method returns, the calling thread is associated with the
transaction context specified.
- Parameters:
tobj
- TheTransaction
object that represents the transaction to be resumed.- Throws:
InvalidTransactionException
- Thrown if the parameter transaction object contains an invalid transaction.IllegalStateException
- Thrown if the thread is already associated with another transaction.SystemException
- Thrown if the transaction manager encounters an unexpected error condition.
public void
rollback() throws IllegalStateException, SecurityException, SystemException
回滚与当前线程关联的事务。完成此方法时,线程不再与事务关联。
Throws | SecurityException: 抛出该异常指示不允许线程回滚事务。 |
Throws | IllegalStateException: 如果当前线程不与事务关联,则抛出该异常。 |
Throws | SystemException: 如果事务管理器遇到不可预料的错误情况,则抛出该异常。 |
rollback
void rollback() throws IllegalStateException, SecurityException, SystemException
- Roll back the transaction associated with the current thread. When this
method completes, the thread is no longer associated with a
transaction.
- Throws:
SecurityException
- Thrown to indicate that the thread is not allowed to roll back the transaction.IllegalStateException
- Thrown if the current thread is not associated with a transaction.SystemException
- Thrown if the transaction manager encounters an unexpected error condition.
public void
setRollbackOnly() throws IllegalStateException, SystemException
修改与当前线程关联的事务,从而使事务的唯一可能结果为回滚事务。
Throws | IllegalStateException: 如果当前线程不与事务关联,则抛出该异常。 |
Throws | SystemException: 如果事务管理器遇到不可预料的错误情况,则抛出该异常。 |
setRollbackOnly
void setRollbackOnly() throws IllegalStateException, SystemException
- Modify the transaction associated with the current thread such that
the only possible outcome of the transaction is to roll back the
transaction.
- Throws:
IllegalStateException
- Thrown if the current thread is not associated with a transaction.SystemException
- Thrown if the transaction manager encounters an unexpected error condition.
public void
setTransactionTimeout(int seconds) throws SystemException
修改与事务关联的超时值,这些事务由当前线程通过 begin 方法启动。
如果应用程序没有调用此方法,则事务服务对事务超时使用某个默认值。
seconds | 超时值(以秒为单位)。如果值为 0,则事务服务恢复默认值。如果值为负,则抛出 SystemException。 |
Throws | SystemException: 如果事务管理器遇到不可预料的错误情况,则抛出该异常。 |
setTransactionTimeout
void setTransactionTimeout(int seconds) throws SystemException
- Modify the timeout value that is associated with transactions started
by the current thread with the begin method.
If an application has not called this method, the transaction service uses some default value for the transaction timeout.
- Parameters:
seconds
- The value of the timeout in seconds. If the value is zero, the transaction service restores the default value. If the value is negative a SystemException is thrown.- Throws:
SystemException
- Thrown if the transaction manager encounters an unexpected error condition.
public Transaction
suspend() throws SystemException
将当前与调用线程关联的事务挂起,并返回一个表示被挂起的事务上下文的 Transaction 对象。如果调用线程没有与事务关联,则该方法返回一个 null 对象引用。当此方法返回时,调用线程未与任何事务关联。
return | 表示被挂起事务的 Transaction 对象。 |
Throws | SystemException: 如果事务管理器遇到不可预料的错误情况,则抛出该异常。 |
suspend
Transaction suspend() throws SystemException
- Suspend the transaction currently associated with the calling
thread and return a Transaction object that represents the
transaction context being suspended. If the calling thread is
not associated with a transaction, the method returns a null
object reference. When this method returns, the calling thread
is not associated with a transaction.
- Returns:
- Transaction object representing the suspended transaction.
- Throws:
SystemException
- Thrown if the transaction manager encounters an unexpected error condition.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!