Understanding the Expression Manager building block assets
The Expression Manager building block contains the following
services and components:
-
ExpressionEvaluator Service
-
Provides the capability to evaluate and validate expressions
at server-side.
-
ELToSwfGenerator Service
-
Provides the capability to generate a SWF file from a list
of expressions. The expressions are translated into ActionScript
classes before they are compiled into a SWF file.
-
Flex-expeval Component
-
Provides the capability to load a SWF file into a Flex application
and evaluate expressions contained in the SWF file.
For additional information about the services, see these resources:
ExpressionEvaluator service
The ExpressionEvaluator service is configured as a Spring
bean with id lc.exm.expEvaluator. It provides three APIs:
-
public HashMap<String, Serializable> evaluateExpressions(HashMap<String,
String> expressions, Serializable inputData)
-
This API is used to evaluate a set of expressions in a batch.
The API accepts a collection of expressions and input data required
to evaluate these expressions. It returns a collection of expression
results. The input expressions are provided as a map where each
expression is mapped against a unique key. The result of the API returns
a map containing the result of the expression, mapped to the key
of corresponding expressions. If the evaluation of any expression
fails, that expression is not added to the result set; however,
other expressions are evaluated and their values are added to the
result set.
-
public Serializable evaluateExpression(String expression,
Serializable inputData)
-
This API is used to evaluate a single expression. The API
expects an expression and the input data required to evaluate this
expression. It returns the computed value of the expression.
-
public void validateExpression(String expression)
-
This API is used to validate the syntax of an expression.
The API throws an exception if the expression syntax is invalid.
ELToSwfGenerator service
The ELToSwfGenerator service is configured as a Spring
bean with id lc.exm.elToSwfGeneratorService. It provides one API:
-
public byte[] generateSWF(Set<String>
expressionSet, String qualifiedClassName)
-
This API takes a set of expressions and the fully qualified
name of an ActionScript class as its parameters. The API translates
the expressions into ActionScript and generates an ActionScript
file with the qualifiedClassName. The generated ActionScript is
compiled into a SWF file and returned as a byte[].
Flex-expeval component
The Flex expression evaluator (Flex-expeval) component
exposes the following four APIs through the IExpressionEvaluationService
interface:
-
registerExpressionsUsingUrlLoader(expressionDefinitionId:String, swfUrl:String,
urlVars:Object=null, lazyLoad:Boolean=false)
-
This API is used to load the expression SWF file from the
specified URL. You can use urlVars to specify URL parameters. The
SWF file is registered with the specified expressionDefinitionId.
This ID must be passed when the expressions are evaluated.
-
registerExpressionsUsingBytesLoader(expressionDefinitionId:String,swfBytes:ByteArray,lazyLoad:Boolean=false)
-
This API is used to load a SWF file from the specified byte
array.
-
registerExpressionsUsingLoader(expressionDefinitionId:String,
expressionLoader:IExpressionLoader, lazyLoad:Boolean=false)
-
This API is used to load a SWF file using a custom loader.
The custom loader is required to implement IExpressionLoader.
-
evaluateExpression(expression:String,expressionDefinitionId:String,varsMap:Object,qualifiedClassName:String)
-
This API is used to evaluate an expression in a Flex client
application. The following parameters are passed:
-
expression:
The expression to be evaluated
-
expressionDefinitionId:
A unique id used to load the
expression SWF file into the Flex application
-
varsMap:
A map containing variables used in the expressions
-
qualifiedClassName:
Name of the ActionScript class
containing the expressions. This name is passed to the generateSWF
API when the SWF file is generated.