Accessing spring beans from activiti-rest
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2011 09:28 AM
How can I access my spring beans in the JUEL expressions for processes which are running in Activiti-REST (and accessible to the user using activiti-explorer).
I have already changed the activiti.cfg.xml to use SpringProcessEngineConfiguration insted of StandaloneProcessEngineConfiguration, but it seems my beans are still not accessible using an expression like ${myBean}.
I have tried defining my bean both in activiti.cfg.xml and web-application-context.xml, but it does not seem to make a difference.
I am using Activiti 5.4.
Thanks for your attention.
Joachim
I have already changed the activiti.cfg.xml to use SpringProcessEngineConfiguration insted of StandaloneProcessEngineConfiguration, but it seems my beans are still not accessible using an expression like ${myBean}.
I have tried defining my bean both in activiti.cfg.xml and web-application-context.xml, but it does not seem to make a difference.
I am using Activiti 5.4.
Thanks for your attention.
Joachim
Labels:
- Labels:
-
Archive
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2011 04:05 AM
Hi,
Currently, the rest-webapp uses the non-spring way of getting the process-engine (ProcessEngines.getProcessEngine(…)).
So the spring-context is loaded and only the processEngine bean is used.
If you want to use additional beans in activiti-rest (without checking out activiti code and building a spring-ized version of the activiti-rest) you can add the "beans" you want to expose in your expression in the configuration.
http://activiti.org/userguide/index.html#exposingConfigurationBeans -> this mentions all beans are exposed when using spring but when not using spring, just declare the ones you want, eg:
-> expression ${cool.invokeMethod('123')} will now work in rest
Currently, the rest-webapp uses the non-spring way of getting the process-engine (ProcessEngines.getProcessEngine(…)).
So the spring-context is loaded and only the processEngine bean is used.
If you want to use additional beans in activiti-rest (without checking out activiti code and building a spring-ized version of the activiti-rest) you can add the "beans" you want to expose in your expression in the configuration.
http://activiti.org/userguide/index.html#exposingConfigurationBeans -> this mentions all beans are exposed when using spring but when not using spring, just declare the ones you want, eg:
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<property name="jdbcUrl" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />
<property name="jdbcDriver" value="org.h2.Driver" />
<property name="jdbcUsername" value="sa" />
<property name="jdbcPassword" value="" />
<propery name="beans">
<map>
<entry><key>cool</key><value ref="coolService" /></entry>
</map>
</property>
-> expression ${cool.invokeMethod('123')} will now work in rest
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2011 04:19 AM
Thanks for the help Frank.
Though I am not sure that will do the trick as my bean didn't even get initialized when put in activiti.cfg.xml.
Anyway, I actually fixed it by patching the ActivitiWebScript and ActivitiStreamingWebScript classes to use a spring generated and injected process engine. It is working fine now. I will try to document what I did later today.
Kind regards,
Joachim
Though I am not sure that will do the trick as my bean didn't even get initialized when put in activiti.cfg.xml.
Anyway, I actually fixed it by patching the ActivitiWebScript and ActivitiStreamingWebScript classes to use a spring generated and injected process engine. It is working fine now. I will try to document what I did later today.
Kind regards,
Joachim
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2011 04:22 AM
Thanks!
