protected void initializeExpressionManager() { if (processEngineConfiguration.getExpressionManager() == null && applicationContext != null) { processEngineConfiguration.setExpressionManager( new SpringExpressionManager(applicationContext, processEngineConfiguration.getBeans())); } }
@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); }
@Override public void init() { ProcessEngineConfigurationImpl configImpl = (ProcessEngineConfigurationImpl) getProcessEngineConfiguration(); configImpl.setExpressionManager(expressionManager); List<ResolverFactory> resolverFactories = configImpl.getResolverFactories(); if (resolverFactories == null) { resolverFactories = new ArrayList<ResolverFactory>(); resolverFactories.add(new VariableScopeResolverFactory()); resolverFactories.add(new BeansResolverFactory()); } configImpl.setScriptingEngines(new OsgiScriptingEngines(new ScriptBindingsFactory(resolverFactories))); super.init(); }
@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); }