cancel
Showing results for 
Search instead for 
Did you mean: 

Access process payload in ELResolver

kaech
Champ in-the-making
Champ in-the-making
Hi,

I would like to implement an ELResolver whose behavior depends on the process payload.
Is there a way to access the process variables from within an ELResolver like it is possible in a JavaDelegate?

Thanks in advance.
7 REPLIES 7

frederikherema1
Star Contributor
Star Contributor
You should extend the org.activiti.engine.impl.el.ExpressionManager and use your custom version on your ProcessEngineConfiguration (property "expressionManager").

You have some methods on there to create a new ELResolver to use in an execution. The variable-scope is passed in (= execution, task, …), which yiou can get variables from to do whatever magic you want in your EL-resolver.

protected ELResolver createElResolver(VariableScope variableScope) {
    CompositeELResolver elResolver = new CompositeELResolver();
    elResolver.add(new VariableScopeElResolver(variableScope));
    elResolver.add(new ArrayELResolver());
    elResolver.add(new ListELResolver());
    elResolver.add(new MapELResolver());
    elResolver.add(new DynamicBeanPropertyELResolver(ItemInstance.class, "getFieldValue", "setFieldValue")); //TODO: needs verification
    elResolver.add(new BeanELResolver());
  
    // CUSTOM MAGIC EL-RESOLVER
    elResolver.add(new MagicResolver(variableScrope));
    return elResolver;
  }

kaech
Champ in-the-making
Champ in-the-making
That works, thank you.

casten2809
Champ in-the-making
Champ in-the-making
Hello,

First: Thanks for this SourceCode.

But I've an other Problem now.

If I use a ServiceTask with an "activiti:expression=${exampleBean.exampleMethode(exampleVariable)" in my *.bpmn20.xml-file and use an own ExpressionManager with an own ELResolver to find my properties (the exambleVariable), my own ExpressionManager won't get the "Beans" from the ProcessEngineConfigurationImpl.

Is it possible to get the Beans, that where define in the ProcessEngineConfigurationImpl, to my own ExpressionManager?

Casten

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Casten,

answer is yes.
To answer how, I should understand your implementation. But you can access beans from process engine configuration.
(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl#beans)

Refgards,
Martin

casten2809
Champ in-the-making
Champ in-the-making
Hi martin.grofcik,

thanks for your answer.

First I've tried your solution with the following statement:

<code>
<bean id="activiti.wop.processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">

   <property name="beans">
       <map>
    <entry key="exampleBean" value-ref="exampleBean"></entry>
       </map>
   </property>

   <property name="expressionManager" ref="express"/>

</bean>

<bean name="express" class="de.example.bpmactiviti.impl.BpmExpressionManager">
   <constructor-arg name="beans" ref="beans"/>
</bean>

<bean name="beans" factory-bean="activiti.wop.processEngineConfiguration" factory-method="getBeans"/>
</code>

But this solution doesn't work. Have I interpret your solution wrong?
And what were the right solution.

I've find another solution:

<code>
<bean id="activiti.wop.processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
…  
   <property name="expressionManager">
      <bean class="de.example.bpmactiviti.impl.BpmExpressionManager">
         <constructor-arg name="beans">
            <map>
               <entry key="initializeControlExpert" value-ref="initializeControlExpert"></entry>
            </map>
         </constructor-arg>
      </bean>
    </property>

</bean>
</code>

But I think this isn't a nice solution.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Casten,

From BpmExpressionManager point of view both solutions are the same. The difference is how beans are initialized and given to the BpmExpressionManager.
Did you get list of beans to BpmExpressionManager in the 1. solution (Why not?)

Regards
Martin

casten2809
Champ in-the-making
Champ in-the-making
Hi martin.grofcik,


No. I don't get some Beans for the BpmExpressionManager in the first solution.

As I have debbuged the source code I have seen, that as first the ExpressionManager will be set (org.activiti.spring.ProcessEngineFactoryBean) and after this the Beans are initialized (e.g. org.activiti.spring.SpringProcessEngineConfiguration).

I can't find out why this happened.


Regards

Casten
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.