How the Expression Manager building block works

The Expression Manager building block can be divided into two modules: server-side expression evaluation and client-side expression evaluation. This diagram depicts the overall architecture of this module:

View full size graphic
Expression Management Architecture

Server-side expression evaluation

The server-side expression evaluation module provides the capability to evaluate expressions on the server side.

The Expression Evaluator service is the core of the server-side expression evaluation module. It provides APIs for expression evaluation and validation. Expressions can be evaluated in single or batch mode. This component acts as a wrapper to the expression evaluation library (JSP EL). The actual expression evaluation task is delegated to the expression library.

An expression evaluation service requires an instance of Variable Resolver to retrieve values of variables referenced inside expressions. Typically an expression requires a Function Mapper to resolve function references inside expressions to actual functions which can be called by the expression evaluation service. For use-cases where the values of variables used in expressions are drawn from properties of Data Dictionary instances, the Data Dictionary building block provides a variable-resolver implementation which can be used by applications.

  • Variable Resolver: used to retrieve the value of variables used in expressions by expression evaluation library.

  • Function Mapper: used to resolve function references in expressions to actual invoke-able functions.

Client-side expression evaluation using Flex

The client-side expression evaluation module provides the capability to evaluate expressions in a Flex client application, without a server roundtrip. The Flex Expression Manager can interpret and evaluate JSP-EL compliant-expressions on the client-side. The IExpressionManager interface (com.adobe.solutions.exm.runtime.IExpressionManager) is the entry point into client-side expression evaluation. Consuming applications are expected to pass a JSP-EL compliant expression. Applications can also pass a target variable to an IExpressionManager instance using assignTo() or one of the manage*() methods. Applications retrieve an IComputedExpression instance to obtain the resultant evaluation of the expression. If a target variable is provided to the Expression Manager, the variable is automatically set and updated, when the expression recomputes, with result of expression evaluation. The client-side expression manager requires a variable resolver and a function mapper to resolve variable references and function calls inside expressions

The IComputedExpression instance returned by Expression Manager to calling applications serves as a live container for the result of expression evaluation. The container is live in the sense it contains a bindable value property (the result of expression evaluation) which auto-updates whenever an expression-recomputation event occurs. Examples of such events include a value-change for a variable which is used inside the expression, or an asynchronous remote function call returning successfully. The IComputedExpression instance also dispatches an event (an instance of com.adobe.solutions.exm.runtime.ComputationErrorEvent) named computationErrorEvent. The event is dispatched whenever an error occurs during evaluation of the expression such as if an asynchronous remote function calls errors out. The error property of the event contains the error which occurred during evaluation.

Applications can use an IComputedExpression instance one of two ways:
  • For simple use-cases where the expression is evaluated once, applications can read the value property of the IComputedExpression instance immediately. This mechanism does not work for expressions containing remote function calls which are asynchronous by nature. The value property read initially from the IComputedExpression instance is a garbage value. The value is auto-updated to the correct value when the remote function call returns successfully later.

  • For longer-running use-cases applications can bind to the value property of the IComputedExpression instance using standard Flex binding. For example, a user interface field is bound to the result of expression evaluation. Applications listen to events of type "computationErrorEvent" on the IComputedExpression instance for detecting errors during expression evaluation. That binding is the only mechanism which works for expressions containing remote function calls which are asynchronous by nature.

The com.adobe.solutions.exm.runtime.impl.ExpressionManagerImpl class is the default implementation of the IExpressionManager interface. Applications are expected to create an instance of this class, configure it with a variable resolver and function mapper, and use it for expression evaluation.

// Ethnio survey code removed