<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Human Task API and Data Structures Proposal
</h3>
<span style="margin-bottom: 10px;">
    modified by <a href="https://community.jboss.org/people/salaboy21">Mauricio Salatino</a> in <i>jBPM</i> - <a href="https://community.jboss.org/docs/DOC-18641">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><h1><div class="toc" style="border: 1px dashed black; padding: 10px;"><ul><li>
<a class="jive-link-anchor-small" href="#Introduction">Introduction</a>
</li>
<ul><ul><li>
<a class="jive-link-anchor-small" href="#Generic_Service_Infrastructure">Generic Service Infrastructure</a>
</li>
</ul></ul><li>
<a class="jive-link-anchor-small" href="#Task_Def_Service">Task Def Service</a>
</li>
<ul><ul><li>
<a class="jive-link-anchor-small" href="#Task_Def_Structure">Task Def Structure</a>
</li>
</ul></ul><ul><li>
<a class="jive-link-anchor-small" href="#Task_Presentation_Service">Task Presentation Service</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#Task_Assignments_Service">Task Assignments Service</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#Task_Delegation_Service">Task Delegation Service</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#Task_Notification_Service_">Task Notification Service </a>
</li>
</ul><li>
<a class="jive-link-anchor-small" href="#Task_Instance_Service">Task Instance Service</a>
</li>
<ul><ul><li>
<a class="jive-link-anchor-small" href="#Human_Task_LifeCycle_Manager">Human Task LifeCycle Manager</a>
</li>
<ul><li>
<a class="jive-link-anchor-small" href="#Task_LifeCycle_Events">Task LifeCycle Events</a>
</li>
</ul><li>
<a class="jive-link-anchor-small" href="#Transaction_Strategies">Transaction Strategies</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#Task_Instance_Structure">Task Instance Structure</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#Task_Query_Service">Task Query Service</a>
</li>
</ul></ul><ul><li>
<a class="jive-link-anchor-small" href="#Task_Admin_Service">Task Admin Service</a>
</li>
<li>
<a class="jive-link-anchor-small" href="#Task_Attachment_and_Comment_Services_">Task Attachment and Comment Services </a>
</li>
<li>
<a class="jive-link-anchor-small" href="#_Task_Events_Callbacks_Listeners_Service"> Task Events, Callbacks,&#160; Listeners Service</a>
</li>
</ul></ul></div></h1><h1 id="Introduction">Introduction</h1><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Based on the previous document for reviewing the architecture and APIs exposed by the Human Task module I've came up with this first schetck of proposal for changes.</p><p>I've decided for this stage to show a more modular approach that the one provided by the current implementation. </p><p>This modular approach will let us scale if more functionality is required without the need of chainging the interfaces of the already existing services. It will also allow us to </p><p>provide different implementations for each of the modules which will give us a lot of flexibility to integrate with different technologies. For example provide an Attachments Service</p><p>which uses a Content Repository and keep the comments in a database. We will be able to mix and match based on the scenario requirement.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The main focus of this proposal is to decouple all the logical services provided by the Human Task module and enable different implementations to cohexist under the same set of APIs.</p><p>This document describe also the Data Structures and Interfaces that will be exposed to the end User. All the other internal mechanisms and classes will be hidden.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The figure shows the logical organization of the proposed services. The services are logically grouped Task Definition Services and Task Instances Services.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>All the services will be created using CDI beans, which will allow us to expose them via Switchyard / Camel&#160; (<a class="jive-link-external-small" href="https://docs.jboss.org/author/display/SWITCHYARD/Bean+Services">https://docs.jboss.org/author/display/SWITCHYARD/Bean+Services</a>)etc. In other words, these services will be completely agnostic of the</p><p>transports that different applications under different scenarios can use to interact with them. Using CDI will enable us to define different profiles and configurations for the module</p><p>depending on the scenario that we want to use it. Meaning that if you don't need a service, you just don't use it and you don't need to suffer the footprint of that unused service.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The following repository contains some experiments towards the direction described in this wiki page:</p><p><a class="jive-link-external-small" href="https://github.com/Salaboy/human-task-poc-proposal">https://github.com/Salaboy/human-task-poc-proposal</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The following sections explain the scope of the proposed services:</p><p><a href="https://community.jboss.org/servlet/JiveServlet/showImage/102-18641-6-18930/TaskServices.png"><span> https://community.jboss.org/servlet/JiveServlet/downloadImage/102-18641-6-18930/446-600/TaskServices.png </span></a></p><h3 id="Generic_Service_Infrastructure">Generic Service Infrastructure</h3><p>Each service architecture will vary depending on the implementation. </p><p>For most of the services a simple implementation will do the work:</p><p><a href="https://community.jboss.org/servlet/JiveServlet/showImage/18935/TaskServicesArchitecture.png"><span> https://community.jboss.org/servlet/JiveServlet/downloadImage/18935/TaskServicesArchitecture.png </span></a></p><p>No matter the services implementation, they should be as stateless as possible. Storing all the information in a Database or Repository.</p><p>There are some cases where Services implementation can provide a stateful context, but those implementations should specify why and how</p><p>they will keep the correlation between different requests. This should be stated using qualifiers as well as a different CDI scope.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1 id="Task_Def_Service">Task Def Service</h1><p>A Task Definition is a structure that contains a reusable structure to define a Human Interaction. By reusable I mean, a Task that can be executed multiple times and</p><p>that shares static information, such as Assignments, Delegation options, Deadlines, Notifications, etc. If all this information can be shared we can reduce the definition time</p><p>just providing the users to select on of the provided definitions, instead of defining all this information every time that a task is required.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The task service def service will deal with static Human Task Definitions. These definitions can be generated by the userTasks from a business processes or via the</p><p>provided APIs by third parties applications. We will be able to deploy new task definitions to the service, list all the available definitions based on different criterias, etc. </p><p>A set of more specific services will be provided to store and manage additional information about Task Definitions.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">// DEFINE ONCE, REUSE EVERYWHERE</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; TaskDef taskDef = <font color="navy"><b>new</b></font> TaskDef(<font color="red">"myTaskDef"</font>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; PeopleAssignments peopleAssignments = <font color="navy"><b>new</b></font> PeopleAssignments();
&#160;&#160;&#160;&#160;&#160;&#160;&#160; List&lt;OrganizationalEntity&gt; potentialOwners = <font color="navy"><b>new</b></font> ArrayList&lt;OrganizationalEntity&gt;();
&#160;&#160;&#160;&#160;&#160;&#160;&#160; potentialOwners.add(salaboy);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; peopleAssignments.setPotentialOwners(potentialOwners);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; taskDef.setPeopleAssignments(peopleAssignments);
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">//Deploy Definition </font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; taskDefService.deployTaskDef(taskDef);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">// list</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; taskDefService.getAllTaskDef(<font color="red">"*"</font>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">// getById</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; taskDefService.getTaskDefById(<font color="red">"myTaskDef"</font>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">// unregister</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">//taskDefService.undeployTaskDef("myTaskDef");</font>
&#160;
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Service Interface:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="jive-link-external-small" href="https://github.com/Salaboy/human-task-poc-proposal/blob/master/human-task-core-cdi-experiment/src/main/java/org/jboss/human/interactions/api/TaskDefService.java">https://github.com/Salaboy/human-task-poc-proposal/blob/master/human-task-core-cdi-experiment/src/main/java/org/jboss/human/interactions/api/TaskDefService.java</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h3 id="Task_Def_Structure">Task Def Structure</h3><p>TBD</p><h3></h3><h2 id="Task_Presentation_Service">Task Presentation Service</h2><p>The task presentation service will allow us to provide more information about how a task will be presented to the users. This will include the I18N options for all the texts</p><p>related to a task such as Subject, Description, Goals, etc. Decoupling this logic and structures in a different service will allow us to only query this information when it's needed and</p><p>not everytime that we want to interact with a task. Because this is not a core service, we can choose to not use it and disable it if our implementation doesn't require such presentation information.</p><p>This service will allow us to define common presentation elements that can be shared among different task definitions.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">&#160; TaskPresentationService taskPresentationService = container.instance().select(TaskPresentationService.class).get();
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">//Internally it will use taskDef.getTaskDef(id).getPresentationElements()</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; List&lt;PresentationElement&gt; presentationElements = taskPresentationService.getPresentationElements(taskId);
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2 id="Task_Assignments_Service">Task Assignments Service</h2><p>The task Assignment service will be in charge of hosting information about task assignments. This information will describe the potentialOwners, excludedOwners, StakeHolders, BusinessAdmins, etc.</p><p>All this information will be related with a task definition and not with a task instance. In other words this is about static definitions (doing on modeling time) of the task and not about the </p><p>assignments that will be defined at runtime when a Task Instance is created. Having this information decoupled will allow us to define different strategies for validating, querying and interacting with </p><p>an external identity service. When a Task instance is created, using this information plus the runtime context and the defined strategies the concrete assigments will be applied to the Task instance.</p><p>Instead of store and duplicate assignment information per task , we can reuse the assignments from previously defined tasks.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2 id="Task_Delegation_Service">Task Delegation Service</h2><p>This service will host different delegation schemas that can be used by the task definitions. Depending on the business scenario were the human interactions will be defined, this service will host common patterns that can be reused by Task Definitions. Instead of store and duplicate delegation/escalation information per task , we can reuse the delegationescalation information from previously defined tasks.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2 id="Task_Notification_Service_">Task Notification Service </h2><p>The service expose an interface that allows us to define templates for notifications that can be used on Task Deadlines, Lifecycle Events, Callbacks.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1 id="Task_Instance_Service">Task Instance Service</h1><p>Once we have a Task Definiton deployed we can start creating instances of a specific Task Definition Type. The instance will use the static information provided </p><p>by the task definition to create the new Task Instance. The information about assignments, deadlines and escalations/delegations will be defined inside the Task Definition (which support </p><p>expressions) . When a new instance is created all the expressions are resolved and the task will only contain the relevant data for execution. If at runtime more information about the Task Definition is required, the Task Instance Service can use the Task Definition Service internally to get generic information. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The Task Instance Service will expose the life cycle methods to interact with a Task Instance, such as: start, complete, forward, claim, release, etc (WS-HT defined methods). </p><p>Internally, the Task Instance Service will contain the core logic to represent the task life cycle. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Having this Service decoupled from the rest will allow us to improve that logic and have a well defined boundary of the module capabilties and responsabilities. Because we are working</p><p>to provide a pluggable life cycle mechanism, different Task Instances Services implementation can be provided. Using CDI decorators and qualifiers the API usage will be extremely improved </p><p>and it will easily allow us to run the component in any environment (From standalone to EE with major changes).</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Sync and Async Services should be modeled using CDI qualifiers instead of different interfaces.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">// Lifecycle methods for task instances only!!!! </font>
&#160;&#160;&#160;&#160;&#160;&#160; TaskInstanceService taskInstanceService = taskServiceEntryPoint.getTaskInstanceService();
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; Map&lt;String, Object&gt; params = <font color="navy"><b>new</b></font> HashMap&lt;String, Object&gt;();
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">// Instantiate </font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>long</b></font> taskId = taskInstanceService.newTask(<font color="red">"myTaskDef"</font>, params);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">// Interact</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; taskInstanceService.start(taskId, <font color="red">"salaboy"</font>);
&#160;
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Service Interface:</p><p><a class="jive-link-external-small" href="https://github.com/Salaboy/human-task-poc-proposal/blob/master/human-task-core-cdi-experiment/src/main/java/org/jboss/human/interactions/api/TaskInstanceService.java">https://github.com/Salaboy/human-task-poc-proposal/blob/master/human-task-core-cdi-experiment/src/main/java/org/jboss/human/interactions/api/TaskInstanceService.java</a></p><h3></h3><p><br/><a href="https://community.jboss.org/servlet/JiveServlet/showImage/18933/TaskServiceIntanceService.png"><span> https://community.jboss.org/servlet/JiveServlet/downloadImage/18933/TaskServiceIntanceService.png </span></a></p><p>As you can see the TaskInstanceService has a couple of important services that will be injected at runtime. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h3 id="Human_Task_LifeCycle_Manager">Human Task LifeCycle Manager</h3><p>The lifeCycleManager will be in charge of defining the lifecycle of each Task Instance. This Manager will be pluggable to allow us to provide different implementations for different needs.</p><p>The MVEL Lifecycle Manager reuse the logic that is now contained inside the jbpm-human-task-core module, which loads an MVEL file which contains all the possible states for a TaskInstance. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>MVELLifecycleManager simple implementation: </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="jive-link-external-small" href="https://github.com/Salaboy/human-task-poc-proposal/blob/master/human-task-core-cdi-experiment/src/main/java/org/jboss/human/interactions/internals/lifecycle/MVELLifecycleManager.java">https://github.com/Salaboy/human-task-poc-proposal/blob/master/human-task-core-cdi-experiment/src/main/java/org/jboss/human/interactions/internals/lifecycle/MVELLifecycleManager.java</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Different LifecycleManagers can be provided and the implementation can be decided at configuration time using one simple CDI Qualifier. </p><p>For Example:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">@Inject @Mvel
<font color="navy"><b>private</b></font> LifecycleManager lifeCycleManager;
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h4 id="Task_LifeCycle_Events">Task LifeCycle Events</h4><p>No matter the LifecycleManager implementation, all of them will require to inform the outside world about the lifecycle events, allowing us to caputure those events for different usages. </p><p>We will be able to Log those events, use those events as callbacks mechanisms, make inferences about them, etc.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>SEAM3 provides a CDI extension that allows us to get a PersistenceContext and define transactions in SE environments:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a class="jive-link-external-small" href="http://docs.jboss.org/seam/3/persistence/latest/reference/en-US/html_single/">http://docs.jboss.org/seam/3/persistence/latest/reference/en-US/html_single/</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This is what we are doing today manually, they provide a declarative way of defining our transaction policies and the persistence context propagation.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h3 id="Transaction_Strategies">Transaction Strategies</h3><p>Depending on the Scenario is how the transactions strategies will need to be configured.</p><p>Based on CDI qualifiers and interceptors we will be able to provide different implementations that will be selected based on the environment. </p><p>Transactions are usually handled as Aspects, which in CDI can be defined using Interceptors. We will be able to select different Interceptors </p><p>depending on the environment that we want to run our application. These interceptors will be selected based on quilifiers and they will&#160; be injected into the relevant</p><p>classes.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h3 id="Task_Instance_Structure">Task Instance Structure</h3><p>The task instance structure will contain only the information required by a Task to run. All the information that belongs to the task definition will not be copied to the </p><p>Task Instance structure.&#160; </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h3 id="Task_Query_Service">Task Query Service</h3><p>The task query service provides a set of methods to query Task Instances. Because each task contains a lot of information, a separate service was created to provide a flexible mechanism</p><p>to retrive task instance information. Internally it can use multiple service to retrieve the information.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Service Interface:</p><p><a class="jive-link-external-small" href="https://github.com/Salaboy/human-task-poc-proposal/blob/master/human-task-core-cdi-experiment/src/main/java/org/jboss/human/interactions/api/TaskQueryService.java">https://github.com/Salaboy/human-task-poc-proposal/blob/master/human-task-core-cdi-experiment/src/main/java/org/jboss/human/interactions/api/TaskQueryService.java</a></p><h2 id="Task_Admin_Service">Task Admin Service</h2><p>The task admin service provides some Administration APIs to do clean ups and keep the storage as free as possible of unneeded data. </p><p>Service Interface:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Service Interface:<br/><a class="jive-link-external-small" href="https://github.com/Salaboy/human-task-poc-proposal/blob/master/human-task-core-cdi-experiment/src/main/java/org/jboss/human/interactions/api/TaskAdminService.java">https://github.com/Salaboy/human-task-poc-proposal/blob/master/human-task-core-cdi-experiment/src/main/java/org/jboss/human/interactions/api/TaskAdminService.java</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2 id="Task_Attachment_and_Comment_Services_">Task Attachment and Comment Services </h2><p>Both services are decoupled to allow fine grained control on how the attachments are handled and stored. Depending on the context on the task and the architecture we the Human Interactions will happen is how we will want to handle attachments. Providing a decoupled interface for these services will allow us to gradually support different ways to store this information that is related with a specific task instance.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">&#160;&#160;&#160;&#160;&#160;&#160; TaskAttachmentService taskAttachmentService = container.instance().select(TaskAttachmentService.class).get();
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; taskAttachmentService.addAttachment(taskId, attachment);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; List&lt;Attachment&gt; attachs = taskAttachmentService.getAttachments(taskId);
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; TaskCommentService taskCommentService = container.instance().select(TaskCommentService.class).get();
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; taskCommentService.addComment(taskId, comment);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; List&lt;Comment&gt; comments = taskCommentService.getComments(taskId);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; taskCommentService.removeComment(commentId);
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2 id="_Task_Events_Callbacks_Listeners_Service"> Task Events, Callbacks,&#160; Listeners Service</h2><p>This service will expose a set of APIs that will allow external applications to register interest and callback functions to a Task Instance or a group of Task Instances (could be also by Task Definition). </p><p>When a third party application creates a task inside the human task module, it will automatically becomes the owner of the task. If the application is interested in being notified about the Task Lifecycle or just a small set of events, the application will need to register a callback function or identifier which enables the component to contact back the application. This callbacks and listeners information should be (once again) agnostic to the transport. This information will represent a logic description about how to contact a third party application if it is needed, but several implementations can be plugged to achieve the desired behavior on runtime. We can leverage the Events features of CDI for listeners and callbacks.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Having this service as a decoupled module will allow us to: </p><ul><li>Provide different strategies for different environments</li><li>Allow external components to be notified (pull) or to poll the task events notifications and execute the callbacks for us. Meaning that we expose the information<br/>about what needs to happen but not how it will happen. Reducing the complexity of the component and leveraging already implemented features from frameworks like Switchard / Camel.</li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2></h2></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Comment by <a href="https://community.jboss.org/docs/DOC-18641">going to Community</a></p>

        <p style="margin: 0;">Create a new document in jBPM at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2034">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>