cancel
Showing results for 
Search instead for 
Did you mean: 

[Spring] Process scoped bean

bartek_andrzejc
Champ in-the-making
Champ in-the-making
Hey guys!

I'm reading Activiti in Action and I wanted to use process scoped bean because process variables are mapped to LinkedHashMaps. Unfortunatelly while deploying my application Spring told me, that there is no such scope "process". I'd like to know in what version of activiti process scoped beans were added. I'm using 5.12.

Thanks in advance.
5 REPLIES 5

jbarrez
Star Contributor
Star Contributor
This is an experimental feature in the activiti-spring module. It's not been maintained for a while, so i wouldnt count on it that it still works.

bartek_andrzejc
Champ in-the-making
Champ in-the-making
Thank you for your response. It's good to know that.

Am I correct about the fact, that complex types in proces variables are always mapped to LinkedHashMap<String, Object>?

jbarrez
Star Contributor
Star Contributor
No, not at all.

Java Objects are serialized as byte arrays.

johnm
Champ in-the-making
Champ in-the-making
mmm… I too have your book, and was happy to see the concept of process scoped beans mentioned, and get the above also.

When our app, starts up @PostConstruct gets called on our RunChecksServiceTask bean defined in activiti.cfg.xml,
i've implemented an empty @PostConstruct method, just so I can debug.

Later, when an instance of our process is created, and this task gets kicked off, I see that it's a different java instance then that which was constructed by Spring?

I'm totally confused, the scope of the RunChecksServiceTask is not specified in the activiti.cfg.xml( so it is a singleton). I would have thought that Activiti give back the same instance that was initalised when Spring started up?
<code>
<bean id="runChecksServiceTaskBean" class="path to our process package.RunChecksServiceTask">
       <property name="executor" ref="executor" />     
       <property name="sessionFactory" ref="workFlowSessionFactory" />
</bean>
</code>


in the process xml we have…..
<code>
    <serviceTask id="runChecksServiceTask" name="Run Checks" activiti:delegateExpression="${runChecksServiceTaskBean}"> </serviceTask>
</code>

I think I'm missing something fundamental here.. I'm looking for a Eureka moment. Using Spring 4.11, Activiti 5.14.
In your book you say use the process scoped concept used by sprinf-activity… but here you say 'No' to that. Can you advise what to do instead of scope="process" ? Thanks so much

jbarrez
Star Contributor
Star Contributor
No, process scoped beans are not supported. There is also not much use case for it, as a process variable does the same.

The one in delegateExpression will be singleton yes, but in case state is needed you can inject Expressions in it that can be resolved at runtime.