use of org.mule.runtime.core.api.el.ExtendedExpressionManager in project mule by mulesoft.
the class TypeSafeValueResolverWrapperTestCase method doSetUp.
@Override
protected void doSetUp() throws Exception {
muleContext = spy(muleContext);
ExtendedExpressionManager expressionManager = spy(muleContext.getExpressionManager());
when(staticValueResolver.isDynamic()).thenReturn(false);
when(staticValueResolver.resolve(any(ValueResolvingContext.class))).thenReturn("123");
when(dynamicValueResolver.isDynamic()).thenReturn(true);
when(dynamicValueResolver.resolve(any(ValueResolvingContext.class))).thenReturn("123");
when(muleContext.getExpressionManager()).thenReturn(expressionManager);
dynamicResolver = new TypeSafeValueResolverWrapper<>(dynamicValueResolver, Integer.class);
dynamicResolver.setTransformationService(transformationService);
initialiseIfNeeded(dynamicResolver, muleContext);
staticResolver = new TypeSafeValueResolverWrapper<>(staticValueResolver, Integer.class);
staticResolver.setTransformationService(transformationService);
initialiseIfNeeded(staticResolver, muleContext);
when(transformationService.transform(eq("123"), any(DataType.class), any(DataType.class))).thenReturn(123);
}
use of org.mule.runtime.core.api.el.ExtendedExpressionManager in project mule by mulesoft.
the class DefaultExpressionManagerFactoryBean method getObject.
@Override
public ExtendedExpressionManager getObject() throws Exception {
DefaultExpressionManager delegate = new DefaultExpressionManager();
muleContext.getInjector().inject(delegate);
return (ExtendedExpressionManager) createClassLoaderInjectorInvocationHandler(delegate, muleContext.getExecutionClassLoader());
}
use of org.mule.runtime.core.api.el.ExtendedExpressionManager in project mule by mulesoft.
the class RaiseErrorProcessor method initialise.
@Override
public void initialise() throws InitialisationException {
errorType = muleContext.getErrorTypeRepository().lookupErrorType(buildFromStringRepresentation(typeId)).get();
ExtendedExpressionManager expressionManager = muleContext.getExpressionManager();
descriptionEvaluator.initialize(expressionManager);
}
use of org.mule.runtime.core.api.el.ExtendedExpressionManager in project mule by mulesoft.
the class MessageEnricher method enrich.
protected PrivilegedEvent enrich(final PrivilegedEvent event, PrivilegedEvent eventToEnrich) throws MuleException {
final ExtendedExpressionManager expressionManager = muleContext.getExpressionManager();
if (event != null) {
for (EnrichExpressionPair pair : enrichExpressionPairs) {
eventToEnrich = enrich(eventToEnrich, event, pair.getSource(), pair.getTarget(), expressionManager);
}
}
setCurrentEvent(eventToEnrich);
return eventToEnrich;
}
use of org.mule.runtime.core.api.el.ExtendedExpressionManager in project mule by mulesoft.
the class ExtensionActivator method registerExpressionFunctions.
private void registerExpressionFunctions(Stream<FunctionModel> functions, ExpressionModule.Builder module) {
final FunctionParameterDefaultValueResolverFactory valueResolverFactory = (defaultValue, type) -> context -> {
ExtendedExpressionManager em = muleContext.getExpressionManager();
String value = String.valueOf(defaultValue);
return em.isExpression(value) ? em.evaluate(value, type, context) : new TypedValue<>(defaultValue, type);
};
functions.forEach(function -> function.getModelProperty(FunctionExecutorModelProperty.class).ifPresent(mp -> {
FunctionExecutor executor = mp.getExecutorFactory().createExecutor(function, valueResolverFactory);
lifecycleAwareElements.add(executor);
module.addBinding(function.getName(), new TypedValue<>(executor, fromFunction(executor)));
}));
}
Aggregations