<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to add binding to Script task in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/how-to-add-binding-to-script-task/m-p/95440#M65469</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;We are considering embedding Activiti into an application, where we want to enable the use of the application-specific APIs in Activiti script tasks:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;// This is a groovy task&lt;BR /&gt;// The object "applicationSpecificApi" is injected into the script binding by us, similar to the object "execution"&lt;BR /&gt;def approvedAmount = execution.getVariable("amount");&lt;BR /&gt;def approvedBy&amp;nbsp; = execution.getVariable("user_id");&lt;BR /&gt;applicationSpecificApi.authorizeSpending (approvedAmount, approvedBy);&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;How do we add such a binding (a reference to either documentation or sample code should suffice)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Eirik&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 02 Feb 2012 21:03:47 GMT</pubDate>
    <dc:creator>elygre</dc:creator>
    <dc:date>2012-02-02T21:03:47Z</dc:date>
    <item>
      <title>How to add binding to Script task</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-add-binding-to-script-task/m-p/95440#M65469</link>
      <description>We are considering embedding Activiti into an application, where we want to enable the use of the application-specific APIs in Activiti script tasks:// This is a groovy task// The object "applicationSpecificApi" is injected into the script binding by us, similar to the object "execution"def approved</description>
      <pubDate>Thu, 02 Feb 2012 21:03:47 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-add-binding-to-script-task/m-p/95440#M65469</guid>
      <dc:creator>elygre</dc:creator>
      <dc:date>2012-02-02T21:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to add binding to Script task</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-add-binding-to-script-task/m-p/95441#M65470</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You would have to check how the ScriptTask is implemented. Somewhere in classes below, the task or execution is simply injected in a hashmap of objects that are available.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 08:48:25 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-add-binding-to-script-task/m-p/95441#M65470</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2012-02-03T08:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to add binding to Script task</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-add-binding-to-script-task/m-p/95442#M65471</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;For reference, in case other people have the same question. It looks like there are two mechanisms that are more or less accessible.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;First, the engine configuration has a list of "ResolverFactory", as shown in the code below (from ProcessEngineConfigurationImpl). By setting your own ResolverFactories, you can inject your own resolver:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;protected void initScriptingEngines() {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if (resolverFactories==null) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; resolverFactories = new ArrayList&amp;lt;ResolverFactory&amp;gt;();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; resolverFactories.add(new VariableScopeResolverFactory());&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; resolverFactories.add(new BeansResolverFactory());&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if (scriptingEngines==null) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; scriptingEngines = new ScriptingEngines(new ScriptBindingsFactory(resolverFactories));&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;}&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;Second, the "BeansResolverFactory" which is inserted by default in the code above, uses "Map&amp;lt;Object, Object&amp;gt; ProcessEngineConfigurationImpl.getBeans()" to look for beans to inject (presumably the same beans that are available in expressions), so you can just set beans to be injected here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;// While creating the engine&lt;BR /&gt;Map&amp;lt;Object, Object&amp;gt; beans = new HashMap&amp;lt;Object, Object&amp;gt;();&lt;BR /&gt;beans.put("myservice", new MyService());&lt;BR /&gt;((ProcessEngineConfigurationImpl)config).setBeans(beans);&lt;BR /&gt;&lt;BR /&gt;// In a script task&lt;BR /&gt;myservice.callMyFunction()&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;We ended up with the second solution, for now; it looks easy enough to change later, if required.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 12:41:21 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-add-binding-to-script-task/m-p/95442#M65471</guid>
      <dc:creator>elygre</dc:creator>
      <dc:date>2012-02-03T12:41:21Z</dc:date>
    </item>
  </channel>
</rss>

