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
Configure application-managed tasks as described in the following topics:
InitialContext ic = new InitialContext(); TaskNameManager tnManager = ic.lookup ("java:comp/websphere/AppProfile/TaskNameManager");
try { tnManager.setTaskName("updateAccount"); } catch (IllegalTaskNameException e) { // task name reference not configured. Handle error. } // . . . rnManager.resetTaskName();