Java Sample Code for Preprocessor and Postprocessor - Objects

Sample ObjectServicePreProcessor

The following is a sample ObjectServicePreProcessor:

 public class SamplePreProcessor implements ObjectServicePreProcessor {
@Override
public void execute(FabricRequestManager requestManager, FabricResponseManager responseManager, 
FabricRequestChain requestChain) throws Exception {
PayloadHandler requestPayloadHandler = requestManager.getPayloadHandler();

JsonObject object = requestPayloadHandler.getPayloadAsJson().getAsJsonObject();
object.addProperty("Kony", "Hello World!");


requestPayloadHandler.updatePayloadAsJson(object);
requestChain.execute();
}
}

Sample ObjectServicePostProcessor

The following is a sample ObjectServicePostProcessor:

 public class SamplePostProcessor implements ObjectServicePostProcessor {
@Override
public void execute(FabricRequestManager requestManager, FabricResponseManager responseManager)
throws Exception {
PayloadHandler responsePayloadHandler = responseManager.getPayloadHandler();

JsonObject responseAsPayload = responsePayloadHandler.getPayloadAsJson().getAsJsonObject();
responseAsPayload.addProperty("Kony", "Hello World!");

responsePayloadHandler.updatePayloadAsJson(responseAsPayload);
}
}
Copyright © 2020 Temenos AG. All rights reserved.