TaskNameManager 接口
TaskNameManager 是应用程序概要分析功能的程序化接口。因为在极少数的情况下,可能必须以编程方式设置当前任务名,所以 TaskNameManager 接口支持覆盖与执行线程相关联的当前任务并支持将当前任务复位为原始任务。
应用程序概要分析使您能够根据 WebSphere Application Server 运行时环境来标识特定的工作单元。运行时可定制其对此工作单元确切需求的支持。访问意向是当前唯一利用应用程序概要分析功能的运行时组件。例如,您可配置一个事务装入一个实体 Bean,带有强大更新锁定,并配置另一个事务装入同一实体 Bean,但是没有锁定。
应用程序概要分析引入了两个概念以实现此功能:任务和概要文件。
任务是工作单元的可配置名称。在这种情况下,工作单元表示事务或 ActivitySession。
概要文件只是任务到实体 Bean 上所配置的一组访问意向策略的映射。当 Bean 上的调用(通过 finder 方法、容器管理的关系 (CMR) 获取方法 (getter) 或动态查询)需要从后端系统检索数据时,与请求关联的说动工作单元任务用于确定事务的确切需求。相同的 Bean 在任务到概要文件映射的上下文中以不同的方式装入和运行。每个概要文件为开发者提供重新配置应用程序访问意向的机会。
除了在选择了 5.x 兼容性方式属性的服务器上执行的 J2EE 1.3 应用程序之外,为容器管理的事务或容器管理的 ActivitySession 配置的 Enterprise JavaBeans 内不能使用此接口,这是因为工作单元只能在启动工作单元的时刻与任务相关联。因此,设置任务名的调用必须在工作单元开始前启动。不能在工作单元开始后对其命名。将会忽略容器管理的工作单元执行期间对此接口的调用。
TaskNameManager 接口可用于使用下列 Java 命名和目录接口 (JNDI) 查询技术的所有 J2EE 组件:
java:comp/websphere/AppProfile/TaskNameManager
package com.ibm.websphere.appprofile;
/**
* The TaskNameManager is the programmatic interface
* to the application profiling function. Using this interface,
* programmers can set the current task name on the
* thread of execution. The task name must have been
* configured in the deployment descriptors as a task
* reference associated with a task. The set task
* name's scope is the duration of the method
* invocation in the EJB and Web components and for
* the duration of the client process, or until the
* resetTaskName() method is invoked.
*/
public interface TaskNameManager {
/**
* Set the thread's current task name to the specified
* parameter. The task name must have been configured as
* a task reference with a corresponding task or the
* IllegalTaskName exception is thrown.
*/
public void setTaskName(String taskName) throws IllegalTaskNameException;
/**
* Sets the thread's task name to the value that was set
* at, or imported into, the beginning of the method
* invocation (for EJB and Web components) or process
* (for J2EE clients).
*/
public void resetTaskName();
}