Custom Handlers for Multiple Opcode Support
The BRM REST Services Manager enables you to call multiple BRM opcodes within custom flows, providing flexibility for advanced request and response processing using the Mapper Framework.
About the Handler Architecture
The handler architecture includes the following components:
-
A handler package that provides a RequestHandler base class for request and response mapping.
-
Custom handlers that extend RequestHandler to support additional preprocessing, postprocessing, or custom flist handling.
-
ExtendedHandlerRegistry.java, which registers custom handlers with the BRM REST Services Manager API. The ExtendedHandlerRegistry SDK Package is located at com.oracle.communications.oms.brm.mapper.extension.utils.
Creating and Registering Custom Handlers
To create custom handlers and register them:
-
Create your custom handler class in the BRM REST Services Manager SDK. You can use the default SDK package com.oracle.communications.oms.brm.mapper.extension.handler or create your own package.
Note:
Refer to the handler using its fully qualified class name regardless of the package used.
-
Extend RequestHandler and override the following methods to meet with your business requirements:
- PreProcessing: Allows you to perform processing before the opcode call.
- customizeInputFlist: Allows you to customize the flist created by the mapper.
- customizeResponseJson: Allows you to customize the response JSON.
- PostProcessing: Allows you to perform processing after the opcode call.
Note:
Refer to the class com.oracle.communications.oms.brm.mapper.extension.handler.ExtendedRequestHandler.java in the SDK package to create the custom Handler.
-
Implement the required configureBuilder method and ensure TransformationUtil is attached for proper mapping.
For example,public static Builder configureBuilder(RequestHandler.Builder builder) { return (Builder) builder .withTransformationUtil(new TransformationUtil()) }To call multiple opcodes in transactions, add the below mentioned details, open a transaction, and pass the context:public static Builder configureBuilder(RequestHandler.Builder builder) { return (Builder) builder .withTransformationUtil(new TransformationUtil()) .withPortalContext(context) .withTransactionUtility(new TransactionUtil()); } -
Register your custom handler using ExtendedHandlerRegistry.java, located in the SDK package com.oracle.communications.oms.brm.mapper.extension.utils. Map the custom handler to the first segment of the URI path by specifying the fully qualified class name. For example:
-
URI Segment: Register using the first segment of the URI path. For example:
http://host:port/brm/productInventory/v5/product/
where,-
productInventory is the first segment.
-
-
Custom Handler: Fully qualified class name of your custom handler, such as com.example.CustomProductHandler.
For example:
@Override public void registerHandlers(HandlerRegistry registry) { registry.registerHandler("productInventory", "com.example.CustomProductHandler"); } -
Note:
-
In this example, CustomProductHandler is the name of the custom handler in the com.example package.
-
When a request is received, the framework uses URI mapping to resolve the appropriate handler.