use of org.mule.runtime.api.el.BindingContext in project mule by mulesoft.
the class DefaultExpressionManagerTestCase method simpleCustomVariable.
@Test
@Description("Verifies that custom variables are considered.")
public void simpleCustomVariable() {
Object object = new Object();
BindingContext context = builder().addBinding(MY_VAR, new TypedValue(object, OBJECT)).build();
assertThat(expressionManager.evaluate("#[myVar]", context).getValue(), equalTo(object));
}
use of org.mule.runtime.api.el.BindingContext in project mule by mulesoft.
the class DefaultExpressionModuleBuilderTestCase method shouldBeAddedToBindingContext.
@Test
public void shouldBeAddedToBindingContext() {
BindingContext.Builder bindingContextBuilder = BindingContext.builder();
ExpressionModule.Builder builder = ExpressionModule.builder(namespace);
builder.addBinding("id", typedValue);
ExpressionModule module = builder.build();
bindingContextBuilder.addModule(module);
BindingContext bindingContext = bindingContextBuilder.build();
assertThat(bindingContext.modules(), hasSize(1));
assertThat(bindingContext.modules(), hasItem(module));
}
use of org.mule.runtime.api.el.BindingContext in project mule by mulesoft.
the class ExtensionActivator method registerExpressionFunctions.
private void registerExpressionFunctions(ExtensionModel extensionModel) {
if (extensionModel.getFunctionModels().isEmpty()) {
return;
}
ExpressionModule.Builder moduleBuilder = new DefaultExpressionModuleBuilder(new ModuleNamespace(extensionModel.getXmlDslModel().getPrefix()));
registerExpressionFunctions(extensionModel.getFunctionModels().stream(), moduleBuilder);
try {
final BindingContext bindingContext = new DefaultBindingContextBuilder().addModule(moduleBuilder.build()).build();
registerObject(muleContext, extensionModel.getName() + "GlobalBindingContextProvider", (GlobalBindingContextProvider) () -> bindingContext);
} catch (Exception e) {
throw new MuleRuntimeException(createStaticMessage(e.getMessage()), e);
}
}
Aggregations