cancel
Showing results for 
Search instead for 
Did you mean: 

what objects are available to your process

kethur
Champ in-the-making
Champ in-the-making
Hi,

One of the examples i was looking at the Activiti in Action book, it has this snippet of code where it uses the objects task and task.eventName.  the object task is not defined anywhere in the bpm process or in the spring config.  Could you please explain how this is working.  How can i know which are the default objects availble to your workflow that I can use as below.


      <userTask id="bradHasADrinkTask" activiti:assignee="Brad">
         <extensionElements>
            <activiti:taskListener expression="${gossipUserTask.gossipTask(task, task.eventName)}" event="assignment" />
            <activiti:taskListener expression="${gossipUserTask.gossipTask(task, task.eventName)}" event="create" />
            <activiti:taskListener expression="${execution.setVariable('readyDrinking', true)}" event="complete"/>
         </extensionElements>
      </userTask>

Thanks,
Raj
1 REPLY 1

jbarrez
Star Contributor
Star Contributor
These are just injected by default into the expression manager. Normally, they are documented in the user guide.

If you want to check the code, start with the ExpressionManager. There, a collection of resolvers for the expression are defined:


  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());
    return elResolver;
  }

The one you mention here, is the VariableScopeElResolver:


public Object getValue(ELContext context, Object base, Object property)  {
   
    if (base == null) {
      String variable = (String) property; // according to javadoc, can only be a String
     
      if( (EXECUTION_KEY.equals(property) && variableScope instanceof ExecutionEntity)
              || (TASK_KEY.equals(property) && variableScope instanceof TaskEntity) ) {
        context.setPropertyResolved(true);
        return variableScope;
      } else if (EXECUTION_KEY.equals(property) && variableScope instanceof TaskEntity) {
        context.setPropertyResolved(true);
        return ((TaskEntity) variableScope).getExecution();
      } else if(LOGGED_IN_USER_KEY.equals(property)){
        context.setPropertyResolved(true);
        return Authentication.getAuthenticatedUserId();
      } else {
        if (variableScope.hasVariable(variable)) {
          context.setPropertyResolved(true); // if not set, the next elResolver in the CompositeElResolver will be called
          return variableScope.getVariable(variable);
        }       
      }
    }