cancel
Showing results for 
Search instead for 
Did you mean: 

Access to expressionManager from EngineServices?

tstephen
Champ on-the-rise
Champ on-the-rise
Hi,

Since the mail service task has the body of the mail injected as fields (named html and text) it is not possible to modify that body elsewhere in the process. There are several use cases for this including:

  • using a template stored externally in an ECM ; and
  • using different templates for different languages.
I thought a simple answer would be to allow two more fields (htmlVar and textVar) that will hold the name of a process variable that will be populated with the template. Note that I still want to be able to embed ${processVariable}s in these templates and have them replaced by the service task.

This is all working fine but I have not found an 'official' way to access the expression manager so for now I have to cast the EngineServices to the implementation class as shown below.


    public void execute(ActivityExecution execution) {
      …
      ProcessEngineConfigurationImpl svcs = (ProcessEngineConfigurationImpl) execution.getEngineServices();
      ExpressionManager em = svcs.getExpressionManager();


Obviously this is pretty dirty so I wondered how you feel about exposing the expressionManager on the EngineServices interface? Or is there some other way that would be better to get one?

cheers,
Tim
3 REPLIES 3

frederikherema1
Star Contributor
Star Contributor
The EngineServices exposes only public-facing API's. Expression-resolving is an internal thing (also uses a lot of org.activiti.*.impl.* classes), we don't want to expose this for the moment. Casting to a processEngineConfigurationImpl is fine, you can alternatively use Context.getProcessEngineConfiguration() (org.activiti.engine.impl.context.Context) - this is also an internal class, but at least you don't have to cast it. Be sure to ONLY use the org.activiti.engine.impl.context.Context class, when in the right context (so everywhere you get an EngineServices passed in is fine).

tstephen
Champ on-the-rise
Champ on-the-rise
Cheers Frederik, I used the Context.getProcessEngineConfiguration as suggested and submitted a pull request: https://github.com/Activiti/Activiti/pull/205

psc1952
Champ in-the-making
Champ in-the-making
How are the 'htmlVar' and/or 'textVar' variables assigned in the designer?