Hi,<br><br>I am adding the ability to execute WorkItems as function calls in Actions defined in Drools Guvnor.<br><br>The intent is not to duplicate the invocation of Rules and WorkItems from within a process using Task nodes, but a simple means for non-jBPM users to call functions defined as WorkItems from rules.<br>

<br>At present, my prototype adds DRL to the RHS of a rule along these lines:-<br><br><span style="font-family: courier new,monospace;">...</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">when</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">  WorkItemManager wim = drools.getWorkingMemory().getWorkItemManager();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  SessionConfiguration sessionConfiguration = (SessionConfiguration) kcontext.getKnowledgeRuntime().getSessionConfiguration();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">  Map handlers = sessionConfiguration.getWorkItemHandlers();<br><br style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">  WorkItemHandler wihMyStringTask = handlers.get( &quot;MyStringTask&quot; );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">  if( wihMyStringTask != null ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    WorkItemImpl wiMyStringTask = new WorkItemImpl();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    wiMyStringTask.getParameters().put( &quot;Param1-string&quot;, &quot;hello&quot; );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    wihMyStringTask.executeWorkItem( wiMyStringTask, wim );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br>Parameters are defined as literals or bound to facts\fields in the UI. <br><br>I&#39;m not convinced of the value of Result parameters for this use-case, as execution of the Work Item has no context, however it is possible they will end up in Working Memory and can be re-bound for use in other rules.<br>
<br>My concerns are that the WorkItem does not have an ID, a State or a ProcessInstanceID and I am concerned WorkItem implementations may break when signalling back to the ProcessManager (or other internal jBPM plumbing I&#39;ve not come to yet). Can anybody with a greater insight of jBPM&#39;s internals comment (or am I heading towards a train wreck of biblical proportions)?<br>
<br>Cheers,<br><br>Mike<br><br>