Development tools : Transaction editor : Defining formatters in transaction editor : Adding customized mapping engine : Configuring a customized Java script mapping engine
  
Configuring a customized Java script mapping engine
You can implement customized Java script mapping engines through the interface com.ibm.btt.base.mapper.engine.IJavaScriptEngine.
The interface IJavaScriptEngine requires the following methods.
eval
prepareJavaScript
getResultType
eval
public Object eval(String expression, Context inputContext, MapperContext mapperContext, Map<String, Object> contextData) throws Exception;
This method is invoked when evaluating the expression in the mapping. The returned value is the execution result of the expression.
Parameters
expression
The Java script in the mapping.
inputContext
The input context in the expression mapping.
mapperContext
Under Batch mode, the method that is provided in this parameter is used by the Java script of parameter expression. The variable name of the parameter mapperContext in the expression Java script is dse_fmt.
contextData
Retained parameter to provide more information about the mapping engine.
prepareJavaScript
public String preparaJavaScript(String script, Map<String, Object> contextData) throws Exception
Prepare the Java Script in the mapping.
For example, if Global Function is used in the mapping, Global Function must be explained to a format that is understandable to the current Java script engine. The original format of the Global Function is:
functs_BTTStringFunctions.concat('vip_', acctList$0$acct
For Rhino Java Script Engine, the Global Function is translated to the following format:
Packages.com.ibm.btt.utils.GlobalFunctions.concat('vip_', acctList$0$acctNo)
The translated format of the Global Function might be different depending on the target Java script engine, and must be processed accordingly.
Parameters
script
The Java script that needs to be prepared.
contextData
Retained parameter to provide more information about the mapping engine.
getResultType
public Class<?> getResultType(String expression);
Under Batch mode, this method is used to verify the returned value of Global Function. This method returns value only when there is one Global Function in the expression and the returned value of the Global Function is short, int, float, or long. Otherwise, this method returns null.
Parameter
expression
The expression that is checked.
isSupportTryCatchStatement
public boolean isSupportTryCatchStatement();
The try catch syntax is used to make sure that Batch mode and Normal mode have the same result even when errors occur. However, some Java script engine like MEVL Java script engine does not support this syntax. In this case, the returned value of this method must be false so that the mapping engine does not generate try catch sentences in the Java script.
Go up to
Adding customized mapping engine