<?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 Re: Accessing Spring Beans from a ServiceTask in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/accessing-spring-beans-from-a-servicetask/m-p/85157#M57419</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Like Ronald already said in an earlier post. To inject Spring beans in a service task class, the service task class also must be a Spring bean.&lt;BR /&gt;So you have to configure a service task with an expression that points to a Spring bean. In the Spring config you can then inject the datasource property into the Spring bean.&lt;BR /&gt;You can find an example in the userguide.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;Ah, got it, sorry. In other words not hardwiring a Java class into the Service Task, but using an expression that resolves to a Spring Bean. Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Frank&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 May 2012 08:31:43 GMT</pubDate>
    <dc:creator>frank41</dc:creator>
    <dc:date>2012-05-02T08:31:43Z</dc:date>
    <item>
      <title>Accessing Spring Beans from a ServiceTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/accessing-spring-beans-from-a-servicetask/m-p/85151#M57413</link>
      <description>Hi all !I'd need to access Spring beans from a Java Service Task. I have tried with field injection&lt;IMG id="smileytongue" class="emoticon emoticon-smileytongue" src="https://migration33.stage.lithium.com/i/smilies/16x16_smiley-tongue.png" alt="Smiley Tongue" title="Smiley Tongue" /&gt;ublic class SpringServiceTask implements JavaDelegate {&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; private DataSource ds;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public void setDataSource(DataSource ds) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.ds= ds;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; public void execute(DelegateExecu</description>
      <pubDate>Sat, 28 Apr 2012 20:41:46 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/accessing-spring-beans-from-a-servicetask/m-p/85151#M57413</guid>
      <dc:creator>frank41</dc:creator>
      <dc:date>2012-04-28T20:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing Spring Beans from a ServiceTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/accessing-spring-beans-from-a-servicetask/m-p/85152#M57414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Your service task must be a spring bean as well then…&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Apr 2012 15:00:14 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/accessing-spring-beans-from-a-servicetask/m-p/85152#M57414</guid>
      <dc:creator>ronald_van_kuij</dc:creator>
      <dc:date>2012-04-29T15:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing Spring Beans from a ServiceTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/accessing-spring-beans-from-a-servicetask/m-p/85153#M57415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for your reply Ronald. Actually I have declared the Service Class in my applicationContext.xml&lt;/SPAN&gt;&lt;BR /&gt;&lt;CODE&gt;&amp;lt;bean id="springServiceTask" class="com.sample.SpringServiceTask"&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="ds" ref="dataSource"/&amp;gt;&lt;BR /&gt;&amp;lt;/bean&amp;gt;&lt;/CODE&gt;&lt;SPAN&gt;(sorry in the original message I've cut and paste another Service task declaration)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The matter, I guess, is that it does not get invoked through the Spring Context (but using a Singleton pattern)…..&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Apr 2012 15:44:35 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/accessing-spring-beans-from-a-servicetask/m-p/85153#M57415</guid>
      <dc:creator>frank41</dc:creator>
      <dc:date>2012-04-29T15:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing Spring Beans from a ServiceTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/accessing-spring-beans-from-a-servicetask/m-p/85154#M57416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How do you try to activate the bean? can you the code that call the bean?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;From the look of it the spring definition seems OK &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Make sure the datasource is defined correctly&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Apr 2012 08:31:34 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/accessing-spring-beans-from-a-servicetask/m-p/85154#M57416</guid>
      <dc:creator>nlitterat</dc:creator>
      <dc:date>2012-04-30T08:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing Spring Beans from a ServiceTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/accessing-spring-beans-from-a-servicetask/m-p/85155#M57417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;How do you try to activate the bean? can you the code that call the bean?&lt;BR /&gt;From the look of it the spring definition seems OK &lt;BR /&gt;Make sure the datasource is defined correctly&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;my ServiceTask are defined in the BPMN20 file as: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&amp;lt;serviceTask id="servicetask1" name="Service Task" activiti:class="com.sample.MyServiceTask"&amp;gt;&amp;lt;/serviceTask&amp;gt;&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;This is the Service Task implementation:&lt;/SPAN&gt;&lt;BR /&gt;&lt;CODE&gt;public class MyServiceTask implements JavaDelegate {&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; private DataSource dataSource;&lt;BR /&gt;&lt;BR /&gt; public void setDataSource(DataSource dataSource) {&lt;BR /&gt;&amp;nbsp; this.dataSource = dataSource;&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; public void execute(DelegateExecution execution) throws Exception {&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; System.out.println("Datasource is "+dataSource); // NULL!!&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;/CODE&gt;&lt;SPAN&gt;For example, here I'm using a Datasource which is injected using setter field injection. However it prints out null. (Same for other beans defined into applicationContext.xml)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Datasource is defined in applicationContext.xml&lt;/SPAN&gt;&lt;BR /&gt;&lt;CODE&gt;&amp;nbsp;&amp;nbsp; &amp;lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="url" value="jdbc:mysql://localhost:3306/activiti?autoReconnect=true" /&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="username" value="activiti" /&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="password" value="activiti" /&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="defaultAutoCommit" value="false" /&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;/bean&amp;gt;&lt;/CODE&gt;&lt;SPAN&gt;Last thing: I'm trying to execute this process from within the process-explorer application, so I'm using the applicationContext.xml inside it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope anybody can sort out which is the issue.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Frank&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Apr 2012 14:47:44 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/accessing-spring-beans-from-a-servicetask/m-p/85155#M57417</guid>
      <dc:creator>frank41</dc:creator>
      <dc:date>2012-04-30T14:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing Spring Beans from a ServiceTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/accessing-spring-beans-from-a-servicetask/m-p/85156#M57418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Like Ronald already said in an earlier post. To inject Spring beans in a service task class, the service task class also must be a Spring bean.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So you have to configure a service task with an expression that points to a Spring bean. In the Spring config you can then inject the datasource property into the Spring bean.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You can find an example in the userguide.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2012 07:51:14 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/accessing-spring-beans-from-a-servicetask/m-p/85156#M57418</guid>
      <dc:creator>trademak</dc:creator>
      <dc:date>2012-05-02T07:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing Spring Beans from a ServiceTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/accessing-spring-beans-from-a-servicetask/m-p/85157#M57419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Like Ronald already said in an earlier post. To inject Spring beans in a service task class, the service task class also must be a Spring bean.&lt;BR /&gt;So you have to configure a service task with an expression that points to a Spring bean. In the Spring config you can then inject the datasource property into the Spring bean.&lt;BR /&gt;You can find an example in the userguide.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;Ah, got it, sorry. In other words not hardwiring a Java class into the Service Task, but using an expression that resolves to a Spring Bean. Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Frank&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2012 08:31:43 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/accessing-spring-beans-from-a-servicetask/m-p/85157#M57419</guid>
      <dc:creator>frank41</dc:creator>
      <dc:date>2012-05-02T08:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing Spring Beans from a ServiceTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/accessing-spring-beans-from-a-servicetask/m-p/85158#M57420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Ah, got it, sorry. In other words not hardwiring a Java class into the Service Task, but using an expression that resolves to a Spring Bean. Thanks!&lt;BR /&gt;Frank&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes… &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2012 11:39:13 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/accessing-spring-beans-from-a-servicetask/m-p/85158#M57420</guid>
      <dc:creator>ronald_van_kuij</dc:creator>
      <dc:date>2012-05-02T11:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing Spring Beans from a ServiceTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/accessing-spring-beans-from-a-servicetask/m-p/85159#M57421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you please tell how you have achieved this.I'm also using the same&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jan 2017 10:10:06 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/accessing-spring-beans-from-a-servicetask/m-p/85159#M57421</guid>
      <dc:creator>itsmevkrishna</dc:creator>
      <dc:date>2017-01-19T10:10:06Z</dc:date>
    </item>
  </channel>
</rss>

