Search in sources :

Example 1 with CommandContextFunctionMapper

use of org.camunda.bpm.engine.impl.el.CommandContextFunctionMapper in project camunda-bpm-platform by camunda.

the class ProcessEngineConfigurationImpl method initExpressionManager.

protected void initExpressionManager() {
    if (expressionManager == null) {
        expressionManager = new ExpressionManager(beans);
    }
    // add function mapper for command context (eg currentUser(), currentUserGroups())
    expressionManager.addFunctionMapper(new CommandContextFunctionMapper());
    // add function mapper for date time (eg now(), dateTime())
    expressionManager.addFunctionMapper(new DateTimeFunctionMapper());
}
Also used : ExpressionManager(org.camunda.bpm.engine.impl.el.ExpressionManager) DateTimeFunctionMapper(org.camunda.bpm.engine.impl.el.DateTimeFunctionMapper) CommandContextFunctionMapper(org.camunda.bpm.engine.impl.el.CommandContextFunctionMapper)

Example 2 with CommandContextFunctionMapper

use of org.camunda.bpm.engine.impl.el.CommandContextFunctionMapper in project camunda-bpm-platform by camunda.

the class CustomExpressionManagerTest method testBuiltinFunctionMapperRegistration.

@Test
public void testBuiltinFunctionMapperRegistration() {
    // given a process engine configuration with a custom function mapper
    ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration().setJdbcUrl("jdbc:h2:mem:camunda" + getClass().getSimpleName());
    CustomExpressionManager customExpressionManager = new CustomExpressionManager();
    Assert.assertTrue(customExpressionManager.getFunctionMappers().isEmpty());
    config.setExpressionManager(customExpressionManager);
    // when the engine is initialized
    engine = config.buildProcessEngine();
    // then two default function mappers should be registered
    Assert.assertSame(customExpressionManager, config.getExpressionManager());
    Assert.assertEquals(2, customExpressionManager.getFunctionMappers().size());
    boolean commandContextMapperFound = false;
    boolean dateTimeMapperFound = false;
    for (FunctionMapper functionMapper : customExpressionManager.getFunctionMappers()) {
        if (functionMapper instanceof CommandContextFunctionMapper) {
            commandContextMapperFound = true;
        }
        if (functionMapper instanceof DateTimeFunctionMapper) {
            dateTimeMapperFound = true;
        }
    }
    Assert.assertTrue(commandContextMapperFound && dateTimeMapperFound);
}
Also used : DateTimeFunctionMapper(org.camunda.bpm.engine.impl.el.DateTimeFunctionMapper) CommandContextFunctionMapper(org.camunda.bpm.engine.impl.el.CommandContextFunctionMapper) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) CommandContextFunctionMapper(org.camunda.bpm.engine.impl.el.CommandContextFunctionMapper) FunctionMapper(org.camunda.bpm.engine.impl.javax.el.FunctionMapper) DateTimeFunctionMapper(org.camunda.bpm.engine.impl.el.DateTimeFunctionMapper) Test(org.junit.Test)

Aggregations

CommandContextFunctionMapper (org.camunda.bpm.engine.impl.el.CommandContextFunctionMapper)2 DateTimeFunctionMapper (org.camunda.bpm.engine.impl.el.DateTimeFunctionMapper)2 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 ExpressionManager (org.camunda.bpm.engine.impl.el.ExpressionManager)1 FunctionMapper (org.camunda.bpm.engine.impl.javax.el.FunctionMapper)1 Test (org.junit.Test)1