ExecutionContext (Java EE 5)

Java EE API


javax.resource.spi.work Class ExecutionContext

java.lang.Object
  extended by javax.resource.spi.work.ExecutionContext

public class ExecutionContext
extends Object


此类模拟执行上下文(事务、安全等等),Work 实例必须使用这些上下文执行。提供此类的目的是为了便于轻松创建 ExecutionContext 实例:只需扩展此类并只重写感兴趣的那些方法。

最好使 ExecutionContext 是类而不是接口的原因如下:

  • 资源适配器不需要实现此类。只需要实现上下文信息(如事务等)。
  • ExecutionContext 类发展时,不必更改资源适配器代码。例如,将来可能会向 ExecutionContext 类添加更多的上下文类型,但不会强制更改资源适配器实现。
英文文档:

This class models an execution context (transaction, security, etc) with which the Work instance must be executed. This class is provided as a convenience for easily creating ExecutionContext instances by extending this class and overriding only those methods of interest.

Some reasons why it is better for ExecutionContext to be a class rather than an interface:

  • There is no need for a resource adapter to implement this class. It only needs to implement the context information like transaction, etc.
  • The resource adapter code does not have to change when the ExecutionContext class evolves. For example, more context types could be added to the ExecutionContext class (in the future) without forcing resource adapter implementations to change.

Version:
1.0
Author:
Ram Jeyaraman

Constructor Summary
 
Method Summary
 long
 Xid
 void
 void
 
Methods inherited from class java.lang.Object
 

Constructor Detail

public ExecutionContext()
英文文档:

ExecutionContext

public ExecutionContext()
Method Detail

public void setXid(Xid xid)
设置事务上下文。
xid 事务上下文。
英文文档:

setXid

public void setXid(Xid xid)
set a transaction context.

Parameters:
xid - transaction context.

public Xid getXid()
英文文档:

getXid

public Xid getXid()

public void setTransactionTimeout(long timeout) throws NotSupportedException
设置导入事务的事务超时值。
timeout 事务超时值(以秒为单位)。只接受正的非 0 值。其他值都是非法的,将被拒绝并抛出 NotSupportedException
ThrowsNotSupportedException: 抛出该异常指示非法的超时值。
英文文档:

setTransactionTimeout

public void setTransactionTimeout(long timeout)
                           throws NotSupportedException
Set the transaction timeout value for a imported transaction.

Parameters:
timeout - transaction timeout value in seconds. Only positive non-zero values are accepted. Other values are illegal and are rejected with a NotSupportedException.
Throws:
NotSupportedException - thrown to indicate an illegal timeout value.

public long getTransactionTimeout()
获取导入事务的事务超时值。
return 指定的事务超时值(以秒为单位)。未指定超时值或者指定了非法的超时值时,返回值 -1 (WorkManager.UNKNOWN);此类事务将不会进行常规超时处理。
英文文档:

getTransactionTimeout

public long getTransactionTimeout()
Get the transaction timeout value for a imported transaction.

Returns:
the specified transaction timeout value in seconds. When no timeout value or an illegal timeout value had been specified, a value of -1 (WorkManager.UNKNOWN) is returned; such a transaction is excluded from regular timeout processing.


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!