[Version 5.0.2 and later]Using the TaskNameManager interface

Why and when to perform this task

You can declaratively configure container managed tasks for J2EE web components, application clients, and Enterprise Java Beans (EJBs). On rare occasions, you might find it necessary to programatically set the current task name. Application profiling supports this requirement with a simple interface that enables both overriding of the current task associated with the thread of execution, and resetting of the current task with the original task.

Application profiling does not support queries of the task that is in operation at run time. Instead, applications interact with logical task names that are declaratively configured as application managed tasks. Logical references enable the actual task name to be changed without having to recompile applications.

Wherever possible, avoid setting tasks programmatically. The declarative method results in more portable function that can be easily adjusted without requiring redevelopment and recompilation.

Steps for this task

  1. Configure application-managed tasks.
    Application profiling requires that a task name reference be declared for any task that is to be set programmatically. Task name references introduce a level of indirection so that the actual task set at run time can be adjusted by reassembly without requiring recoding or recompilation. Any attempt to set a task name that is undeclared as a task reference results in the raising of an exception.

    Configure application-managed tasks as described in the following topics:

  2. Perform a JNDI lookup on the TaskNameManager interface:
    InitialContext ic = new InitialContext();
    TaskNameManager tnManager = ic.lookup
    ("java:comp/websphere/AppProfile/TaskNameManager");
    
    The TaskNameManager interface is not bound into the namespace if the application profiling service is disabled.
  3. Set the task name:
    try {
    tnManager.setTaskName("updateAccount");
    }
    catch (IllegalTaskNameException e) {
    // task name reference not configured. Handle error.
    }
    // . . .
    rnManager.resetTaskName();
    Resetting the task name undoes the effects of any setTaskName() method operations and reestablishes whatever task name was current when the component began execution. If the setTaskName() method has not been called, the resetTaskName() method has no effect.

Related tasks
Configuring application-managed tasks for web components
Configuring container managed tasks for application clients
Configuring container managed tasks for Enterprise Java Beans
Related reference
TaskNameManager interface



Searchable topic ID:   tapp_usetasknamemanager
Last updated: Jun 21, 2007 8:07:48 PM CDT    WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/appprofile/tasks/tapp_usetasknamemanager.html

Library | Support | Terms of Use | Feedback