Injected objects in ScriptTaskListener | ScriptExecutionListener
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2016 04:55 PM
Background: We are in the process of embedding Activiti into a Grails web application. Grails sits on top off the Spring framework, so all Spring facilities are available and in play in the application. Activiti library dependencies are resolved through Maven distributions.
I have been attempting to use the ScriptTaskListener and ScriptExecutionListener from our embedded Activiti instance. Based on the various examples that are provided, it looks like the various script listeners should have a number of automatically injected objects available for use in the scripts, including:
* out
* task | execution (depending on if it is a Task or Execution listener)
* logger
I'm getting exceptions on all of these objects when I reference them inside of a script block like the following:
<activiti:taskListener event="assignment" class="org.activiti.engine.impl.bpmn.listener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[
logger.log("This is a log message in a workflow.");
out
rint "Hello there";
var processAssignee = task.assignee;
]]></activiti:string>
</activiti:field>
<activiti:field name="language" stringValue="groovy" />
<activiti:field name="resultVariable" stringValue="tester" />
</activiti:taskListener>
It's clear that some of these injected facilities are part of the Alfresco implementations that the Eclipse Design Tool really wants to put into play in the BPM definitions. These are not being brought in by the Maven dependencies. A quick review of the source code show some interesting and useful pieces being included in the input model, so it is worth my time to track this down.
So …
1. Are the Alfresco script listeners available from a Maven repo? A quick search came up empty.
2. Are these implementations encumbered in any way? Why are they separate from the core Activiti in the first place.
I have some plans to extend my Grails integration to include dependency injection support for all Grails artifacts within the scripts using its dynamic bean binding capability. It looks like I just need to reference my listener implementation to use it. Is that true?
I have been attempting to use the ScriptTaskListener and ScriptExecutionListener from our embedded Activiti instance. Based on the various examples that are provided, it looks like the various script listeners should have a number of automatically injected objects available for use in the scripts, including:
* out
* task | execution (depending on if it is a Task or Execution listener)
* logger
I'm getting exceptions on all of these objects when I reference them inside of a script block like the following:
<activiti:taskListener event="assignment" class="org.activiti.engine.impl.bpmn.listener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><
var processAssignee = task.assignee;
]]></activiti:string>
</activiti:field>
<activiti:field name="language" stringValue="groovy" />
<activiti:field name="resultVariable" stringValue="tester" />
</activiti:taskListener>
It's clear that some of these injected facilities are part of the Alfresco implementations that the Eclipse Design Tool really wants to put into play in the BPM definitions. These are not being brought in by the Maven dependencies. A quick review of the source code show some interesting and useful pieces being included in the input model, so it is worth my time to track this down.
So …
1. Are the Alfresco script listeners available from a Maven repo? A quick search came up empty.
2. Are these implementations encumbered in any way? Why are they separate from the core Activiti in the first place.
I have some plans to extend my Grails integration to include dependency injection support for all Grails artifacts within the scripts using its dynamic bean binding capability. It looks like I just need to reference my listener implementation to use it. Is that true?
Labels:
- Labels:
-
Archive
5 REPLIES 5

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2016 11:22 AM
We are using script task listeners in our processes.
We are using the Activiti 6 B2 project as configured in the demo that you can download.
We are using the javascript language.
I can do code like var assignee = task.getAssignee();
This works.
We are using the Activiti 6 B2 project as configured in the demo that you can download.
We are using the javascript language.
I can do code like var assignee = task.getAssignee();
This works.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2016 11:58 AM
Ah yes … I should have specified the Maven dependencies that we are using:
org.activiti:activiti-engine:5.21.0
org.activiti:activiti-spring:5.21.0
I'm thinking there are additional Maven dependencies that I need to include.
org.activiti:activiti-engine:5.21.0
org.activiti:activiti-spring:5.21.0
I'm thinking there are additional Maven dependencies that I need to include.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2016 04:46 AM
No, the things needed for executing scripts are in the engine maven dependency.
'task' and 'execution' should for sure be available, irregardless of where you run it.
Does something simple like printing out task.getName() not work?
'task' and 'execution' should for sure be available, irregardless of where you run it.
Does something simple like printing out task.getName() not work?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2016 12:26 PM
It looks like I was having a couple of different problems, the combination of which confused things. There were two issues:
* I was running against 5.18.0 which has some ScriptTaskListener issues that went away when I upgraded to 5.21.0
* The Eclipse Designer specifies the use of org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener as the script task listener when I update models using the gaphical BPMN editor. I have to manually change it back to org.activiti.engine.impl.bpmn.listener.ScriptTaskListener. It took me awhile to figure out that this was happening with any change to the model, not just a change to the TaskListener specification for that task. It makes sense, but the combination of errors was confusing.
In any case org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener is not shipped in the Maven dependencies – not surprising given the package name. I can build it myself from source, but I was wondering if there was a pre-existing Maven dependency for it.
The real issue is that I would like to use the Alfresco ScriptTaskListener implementation because of the extra objects that it injects - specifically the process variables. I'm going to provide a GrailsScriptTaskListener and GrailsScriptExecutionListener that will inject the Grails (Spring) application context and logger so that scripts have full access to the Grails scope.
* I was running against 5.18.0 which has some ScriptTaskListener issues that went away when I upgraded to 5.21.0
* The Eclipse Designer specifies the use of org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener as the script task listener when I update models using the gaphical BPMN editor. I have to manually change it back to org.activiti.engine.impl.bpmn.listener.ScriptTaskListener. It took me awhile to figure out that this was happening with any change to the model, not just a change to the TaskListener specification for that task. It makes sense, but the combination of errors was confusing.
In any case org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener is not shipped in the Maven dependencies – not surprising given the package name. I can build it myself from source, but I was wondering if there was a pre-existing Maven dependency for it.
The real issue is that I would like to use the Alfresco ScriptTaskListener implementation because of the extra objects that it injects - specifically the process variables. I'm going to provide a GrailsScriptTaskListener and GrailsScriptExecutionListener that will inject the Grails (Spring) application context and logger so that scripts have full access to the Grails scope.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2016 05:10 AM
> In any case org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener is not shipped in the Maven dependencies
No, and it only makes sense when using in Alfresco context.
I think the Eclipse thing is a bug, that shouldn't happen.
>The real issue is that I would like to use the Alfresco ScriptTaskListener implementation because of the extra objects that it injects -
> specifically the process variables
You can use the org.activiti.engine.impl.bpmn.listener.ScriptTaskListener for this. You can always access variables via execution.getVariable('someVar') if 'someVar' doesn't work for some reason.
No, and it only makes sense when using in Alfresco context.
I think the Eclipse thing is a bug, that shouldn't happen.
>The real issue is that I would like to use the Alfresco ScriptTaskListener implementation because of the extra objects that it injects -
> specifically the process variables
You can use the org.activiti.engine.impl.bpmn.listener.ScriptTaskListener for this. You can always access variables via execution.getVariable('someVar') if 'someVar' doesn't work for some reason.
