Function Mapper

JSP-EL allows function references inside expressions of the form <prefix>:<localName>(…). JSP-EL based expression managers delegate resolution of such function references to a function-mapper. In Java, the function-mapper is an implementation of the javax.servlet.jsp.el.FunctionMapper interface. It is the function-mapper’s responsibility to resolve a prefix and local-name to a static Java function (an instance of java.lang.reflect.Method) which the expression manager can call as part of expression evaluation.

The Expression Manager building block provides a function-mapper implementation which is an OSGi service deployed as part of the Expression Manager bundle. The implementation creates a registry of functions by querying the other bundles deployed in the same CRX container for any functions they are exporting for use inside expressions. The prefix and local-name supplied to this function-mapper must then be resolvable to one of the functions in this aggregated registry. Expression Manager supports two types of functions which bundles can export:
  • Remote Functions: These functions resolve to methods declared on the interfaces implemented by beans. Host bundles export the beans as OSGi services and also over Flex remoting. Remote functions can be called from both:
    • the server-side Expression Manager, since it is deployed in the same CRX container.

    • the client-side Expression Manager since such functions are exposed over Flex remoting.

    Remote functions use prefixes which start with the keyword "REMOTE_".

  • Local Functions: These functions are local to the runtime in which expressions are being evaluated. In Java, these functions correspond to static functions defined on Java classes. In Flex, these functions correspond to normal methods defined on ActionScript classes. The Expression Manager implementation assumes symmetrical local functions for which an implementation exists both in Java and in Flex.

    For example, there could be a logical 'str:substring(…)' function for which the Java implementation is a static 'substring' method defined on a 'com.adobe.exm.java.StringUtils' Java class. While the Flex implementation is a 'substr' method defined on a 'com.adobe.exm.flex.StringUtilities' ActionScript class.

Any prefix which does not start with the "REMOTE_" keyword is assumed to map to a local function. The Expresion Manager function-mapper can handle both types of functions and distinguishes between them based on whether the function prefix starts with the "REMOTE_" keyword. This function-mapper is not available as a public class which you can use inside Spring contexts. Instead, it is an OSGi service hosted by the Expression Manager bundle which must be imported into the custom Spring contexts of consuming bundles via BluePrint:
<bp:reference id="<mapper_id> " 
    interface="javax.servlet.jsp.el.FunctionMapper" 
filter="(exm.function.mapper.id=lc.exm.compositeFunctionMapper)"/>

The imported service can then be injected into the DefaultEXPEvaluator bean configured in the custom Spring context using <mapper_id> as a reference.

// Ethnio survey code removed