AnsweredAssumed Answered

Injected objects in ScriptTaskListener | ScriptExecutionListener

Question asked by rstevehole on Jun 22, 2016
Latest reply on Jun 29, 2016 by jbarrez
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">
            logger.log("This is a log message in a workflow.");
            out:print "Hello there";
            var processAssignee = task.assignee;
          <activiti:field name="language" stringValue="groovy" />
          <activiti:field name="resultVariable" stringValue="tester" />         

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?