Configure the parameters for the preprocessor and postprocessor to filter the request and response objects for your business requirements. You can specify the Java class name or custom JavaScript code
Java Preprocessor and Postprocessor |
---|
The preprocessor and postprocessor are Java classes that implement DataPreProcessor / DataPreProcessor2 and DataPostProcessor / DataPostProcessor2 interfaces. A developer can write custom code in the execute method of the preprocessor or postprocessor class. For a sample Java class code, refer to Java Sample Code for Preprocessor and Postprocessor. For various objects (session and request) and the methods with sample Java class code, refer to http://docs.kony.com/konylibrary/integration/MiddlewareAPI/index.html Note: You need the Note: For details on middleware APIs for preprocessor and postprocessor, |
JavaScript Preprocessor and Postprocessor |
Based on the interface, the preprocessors and postprocessors implement the following objects:
Kony Fabric supports modifying the result object as JSON object in JavaScript. Two new APIs, resultToJSON and jsonToResult in JavaScript.
You can use these objects and their corresponding methods directly in JavaScript code. |
Rules Preprocessor and Postprocessor |
You can use the Rules option to define you custom logic as a set of rules. This option makes defining pre and post processor custom logic closer to human language and is built using MVEL. Based on the interface, the preprocessors and postprocessors implement the following structure for rules: name: "<Name of the rule>" description: "<Description of the rule>" priority: <Priority of the rule> condition: "<Condition to evaluate>" actions: - "<Set of actions to execute>" For more details on How to write Rules, objects, use cases with sample rules, refer to Rules for Preprocessor and Postprocessor. |
The step allows you to further filter the data received from a service call.
JavaScript Code Validation for the Preprocessor: You can validate your JavaScript Code for the preprocessor before saving an operation. To validate the JavaScript code, click the Validate icon in the JavaScript code text box for the preprocessor.
The following are different scenarios that occur when you validate the JavaScript code for the Preprocessor:
Important: If you have validated the JavaScript code and found errors, the Console does not allow you to save the operation.
JavaScript Code Validation for the Postprocessor: You can validate your JavaScript Code for the postprocessor before saving an operation. To validate the JavaScript code, click the Validate icon in the JavaScript code text box for the postprocessor.
The following are different scenarios that occur when you validate the JavaScript code for Postprocessor:
Important: If you have validated the JavaScript code and found errors, the Console does not allow you to save the operation.
Under the Pass-through Cookies, specify a comma separated list of cookie names. When cookies names are present in the incoming client request, these cookies are sent to the backend target along with preprocessor request. A sample value looks like - cookie1, cookie2.
The service config and input map are being sent to the onException Implementation of postprocessor.
For example:
@OnException public Result executeWithAnnotation(@KonyContext Result result, @KonyContext DataControllerRequest request, @KonyContext DataControllerResponse response, @KonyContext(parameterName = ContextParams.INPUT) Map<String, Object> inputMap, @KonyContext(parameterName = ContextParams.CONFIGMAP) Map<String, Object> configMap, @KonyException Exception exception) throws Exception { Param config = new Param(); config.setName("className"); config.setValue((String)configMap.get("className")); result.setParam(config); return result; }
Note: In a Java service when an exception occurs, middleware calls the OnException method of the postprocessor if configured. Extended the ability to call onException even in the case of exception in preprocessor and postprocessor.
Note: You should not modify JVM timezone through custom code as modifying it can result in app server outage.
Copyright © 2019 Kony, Inc. All rights reserved. |