<?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 ServiceTask creating lots of new beans in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/servicetask-creating-lots-of-new-beans/m-p/211914#M165044</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am calling a lot of expressions in ServiceTasks and also checking for conditions in the flow, the bean is declared in the following way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;lt;bean id="core" class="org.springframework.jndi.JndiObjectFactoryBean"&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="jndiName" value="java:global/platform-core/platform-core-ejb/Core"/&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="cache" value="true"/&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/bean&amp;gt;&lt;BR /&gt;&amp;lt;/beans&amp;gt;&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;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;!–break–&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;However in the stateless bean I have a printLn(String) in the @PostConstruct annotated method and it gets called after every expression evaluation, which makes me believe it creates a new stateless bean instance for each call. How can I make activiti cache the bean and reuse it? Or at least make sure that it uses an object pool?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 18 Nov 2015 10:57:57 GMT</pubDate>
    <dc:creator>halfsoft</dc:creator>
    <dc:date>2015-11-18T10:57:57Z</dc:date>
    <item>
      <title>ServiceTask creating lots of new beans</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/servicetask-creating-lots-of-new-beans/m-p/211914#M165044</link>
      <description>I am calling a lot of expressions in ServiceTasks and also checking for conditions in the flow, the bean is declared in the following way:&amp;lt;bean id="core" class="org.springframework.jndi.JndiObjectFactoryBean"&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="jndiName" value="java:global/platform-core/platform-core-e</description>
      <pubDate>Wed, 18 Nov 2015 10:57:57 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/servicetask-creating-lots-of-new-beans/m-p/211914#M165044</guid>
      <dc:creator>halfsoft</dc:creator>
      <dc:date>2015-11-18T10:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: ServiceTask creating lots of new beans</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/servicetask-creating-lots-of-new-beans/m-p/211915#M165045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;did you try to set explicitly scope="singleton" for your JndiObjectFactoryBean ? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the cache = true is the default behaviour of the JndiObjectFactoryBean and if you are sure cache is on and this FactoryBean is singleton then it should work,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if not, just turn on the debugger and check the instances when fetching the bean.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Nov 2015 14:45:24 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/servicetask-creating-lots-of-new-beans/m-p/211915#M165045</guid>
      <dc:creator>vasile_dirla</dc:creator>
      <dc:date>2015-11-18T14:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: ServiceTask creating lots of new beans</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/servicetask-creating-lots-of-new-beans/m-p/211916#M165046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If the bean is Singleton then having 100 different process instances call the same methods is a not a good idea(most of them will time out while waiting for somebody else to finish his call of the method).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It is the same with the Statefull, if I set the JndiObjectFactoryBean to cache the object - i get the same object, but this leads to the same exception. If statefull and cache off It will throw "method not found" exceptions (something with the proxy gets broken).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If stateless - works, but every call to the bean is creating a new object and injecting everything necessary in it, which is slow.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Using JndiObjectFactoryBean:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Singleton - cache on - only one global object, timeout exception when several threads try to call the same method&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Singleton - cache of - only one global object, timeout exception when several threads try to call the same method&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Statefull - cache on - only one global object, timeout exception when several threads try to call the same method&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Statefull - cache off - many objects, method not found exception&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Stateless - cache on - huge amount of objects get created, works&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Stateless - cache off - not tested, but i think the result will be like "Stageful no cache"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Using the class name directly (&amp;lt;bean id="core" class="com.packageName.Core"&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The object does not get created as a bean at all, so nothing gets injected(i need to manually find the references to the helper beans by using JNDI), also only one object is created and reused so no pooling at all.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What is the recommended way to call methods in EJB's when there is also high concurrency?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Nov 2015 16:17:11 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/servicetask-creating-lots-of-new-beans/m-p/211916#M165046</guid>
      <dc:creator>halfsoft</dc:creator>
      <dc:date>2015-11-18T16:17:11Z</dc:date>
    </item>
  </channel>
</rss>

