Tasks are named units of work. They are the mechanism by which the run time environment determines which access intent policies to apply when an entity bean's data is loaded from the back end system.
Application profiles enable developers to configure an entity bean with multiple access intent policies; if there are n instances of profiles in a given application, each bean can be configured with as many as n access intent policies.
A task is a unit of work that is given a name by a developer. A task is assigned to any thread executing within a J2EE component, then propagated implicitly across all IIOP requests. The WebSphere Application Server run time environment queries the task at the invocation of any entity bean, and establishes the appropriate access intent policy with which an entity instance is associated. A task typically corresponds to the execution of a concrete and high-level job within the application.
If an entity bean is loaded in a unit of work that is not associated with a task, or is associated with a task that is unassociated with an application profile, the default bean-level access intent or the method-level access intent configuration is applied. If a unit of work is associated with a task that is configured with an application profile, the bean-level access intent configuration within the appropriate application profile is applied.
For example, consider a school district application that calls through a session bean in order to interact with student records. One method on the session bean allows administrators to modify the students' records; another method supports student requests to view their own records. Without application profiling, the two tasks would operate anonymously and the run time environment would be unable to distinguish work operating on behalf of one task or the other. To optimize the application, a developer can configure one of the methods on the session bean with the task "updateRecords" and the other method on the session bean with the task "readRecords". When registered with an application profile that has the student bean configured with the appropriate locking access intent, the "updateRecords" task is assured that it is not unnecessarily blocking transactions that need to only read the records.
Tasks can be configured to be managed by the container or to be programmatically established by the application. Container managed tasks can be configured on servlets, Java Server Pages (JSPs), application clients, and the methods of Enterprise Java Beans (EJBs). Application managed tasks are configured on all J2EE components.