Search in sources :

Example 1 with ExtendedExpressionManager

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);
}
Also used : DataType(org.mule.runtime.api.metadata.DataType) ExtendedExpressionManager(org.mule.runtime.core.api.el.ExtendedExpressionManager)

Example 2 with ExtendedExpressionManager

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());
}
Also used : DefaultExpressionManager(org.mule.runtime.core.internal.el.DefaultExpressionManager) ExtendedExpressionManager(org.mule.runtime.core.api.el.ExtendedExpressionManager)

Example 3 with ExtendedExpressionManager

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);
}
Also used : ExtendedExpressionManager(org.mule.runtime.core.api.el.ExtendedExpressionManager)

Example 4 with ExtendedExpressionManager

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;
}
Also used : ExtendedExpressionManager(org.mule.runtime.core.api.el.ExtendedExpressionManager)

Example 5 with ExtendedExpressionManager

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)));
    }));
}
Also used : IntrospectionUtils.getSubtypeClasses(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.getSubtypeClasses) FunctionModel(org.mule.runtime.api.meta.model.function.FunctionModel) IntrospectionUtils.getParameterClasses(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.getParameterClasses) FunctionExecutor(org.mule.runtime.module.extension.internal.runtime.function.FunctionExecutor) MuleExtensionUtils.getClassLoader(org.mule.runtime.module.extension.internal.util.MuleExtensionUtils.getClassLoader) BindingContext(org.mule.runtime.api.el.BindingContext) StringToEnum(org.mule.runtime.core.internal.transformer.simple.StringToEnum) LifecycleUtils.initialiseIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.initialiseIfNeeded) DefaultExpressionModuleBuilder(org.mule.runtime.core.internal.el.DefaultExpressionModuleBuilder) HashSet(java.util.HashSet) MuleContext(org.mule.runtime.core.api.MuleContext) MuleException(org.mule.runtime.api.exception.MuleException) FunctionExecutorModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.FunctionExecutorModelProperty) BeanUtils.getName(org.mule.runtime.core.privileged.util.BeanUtils.getName) LifecycleUtils.stopIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.stopIfNeeded) LinkedList(java.util.LinkedList) Startable(org.mule.runtime.api.lifecycle.Startable) FunctionParameterDefaultValueResolverFactory(org.mule.runtime.module.extension.internal.runtime.function.FunctionParameterDefaultValueResolverFactory) DataType.fromFunction(org.mule.runtime.api.metadata.DataType.fromFunction) DefaultBindingContextBuilder(org.mule.runtime.core.internal.el.DefaultBindingContextBuilder) I18nMessageFactory.createStaticMessage(org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage) Set(java.util.Set) LifecycleUtils.startIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.startIfNeeded) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) Transformer(org.mule.runtime.core.api.transformer.Transformer) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) TypedValue(org.mule.runtime.api.metadata.TypedValue) List(java.util.List) Stream(java.util.stream.Stream) ExpressionModule(org.mule.runtime.api.el.ExpressionModule) Stoppable(org.mule.runtime.api.lifecycle.Stoppable) LegacyRegistryUtils.registerObject(org.mule.runtime.core.privileged.registry.LegacyRegistryUtils.registerObject) ModuleNamespace(org.mule.runtime.api.el.ModuleNamespace) ExtendedExpressionManager(org.mule.runtime.core.api.el.ExtendedExpressionManager) GlobalBindingContextProvider(org.mule.runtime.core.privileged.el.GlobalBindingContextProvider) FunctionParameterDefaultValueResolverFactory(org.mule.runtime.module.extension.internal.runtime.function.FunctionParameterDefaultValueResolverFactory) FunctionExecutor(org.mule.runtime.module.extension.internal.runtime.function.FunctionExecutor) ExtendedExpressionManager(org.mule.runtime.core.api.el.ExtendedExpressionManager) TypedValue(org.mule.runtime.api.metadata.TypedValue)

Aggregations

ExtendedExpressionManager (org.mule.runtime.core.api.el.ExtendedExpressionManager)6 BindingContext (org.mule.runtime.api.el.BindingContext)2 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Set (java.util.Set)1 Stream (java.util.stream.Stream)1 Component (org.mule.runtime.api.component.Component)1 ExpressionModule (org.mule.runtime.api.el.ExpressionModule)1 ModuleNamespace (org.mule.runtime.api.el.ModuleNamespace)1 MuleException (org.mule.runtime.api.exception.MuleException)1 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)1 I18nMessageFactory.createStaticMessage (org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage)1 Startable (org.mule.runtime.api.lifecycle.Startable)1 Stoppable (org.mule.runtime.api.lifecycle.Stoppable)1 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)1 FunctionModel (org.mule.runtime.api.meta.model.function.FunctionModel)1 DataType (org.mule.runtime.api.metadata.DataType)1 DataType.fromFunction (org.mule.runtime.api.metadata.DataType.fromFunction)1 TypedValue (org.mule.runtime.api.metadata.TypedValue)1