Early Access
Click the settings gear iconat the left pane.
Navigate to Advanced >> Bridge, then choose Custom Module.
To set up a custom module implementation, it is necessary to have the Custom Module SDK installed in your development environment. The SDK requires Java (compatible with version 8) to be configured. You can obtain the SDK by clicking the Download SDK button located at the top right corner. This SDK includes a collection of libraries that facilitate the creation of custom modules.
To integrate the SDK into your project, you need to add all the downloaded jars files to the reference libraries section.
Once the custom module implementation is ready, compile the project and create it as a JAR file. Once created, compress the created Jar file into a zip file. This zip file is used while creating a custom module.
Refer to the Types of Custom Module section for the sample Java classes.
Note:
Your main class in custom module implementation is expected to extend the interface according to the custom module type(JAR, REST API Sevice, SOAP Service).
If the custom module has to return a response, it should be a JSON Object.
In Qntrl, in the Custom Module page, click the New Custom Module button.
Fill in the required details.
Module Name: Provide a unique name to identify the module.
Type: Select the application type used to write your custom module.
JAR
REST API Service
SOAP Service
Description: Provide a few details that describe the purpose of the module.
Main Class Name: The class name along with the package name in your Java package (e.g.: packageName.className).
Attachments: Attach the zip file that comprises your JAR, created using the SDK interface.
Click Save.
In the Message list page that loads, click the New Message button.
In the New Message window, enter the following details.
Name: Enter a unique name for the message.
Bridge: Select the bridge you would like to execute from the dropdown list.
Module: The created custom module will be displayed in the dropdown list. Select the custom module to execute it through this message.
Type: Select the message type:
Synchronous - Executes tasks in the same request and provides a response
Asynchronous - Executes tasks in the background.
Request Data: The instructions to be executed by the bridge need to be given here in JSON format. Based on the custom module chosen, the request data format will vary.
Note: The request data format is not predetermined and will vary according to the implementation of the custom module.
Response: If the type is 'Synchronous', the response to the request will be displayed under this tab.
Once all the details are filled, click Execute.
Upon successful message execution, you can view the response (for synchronous type messages), and a server call entry in the message list of your bridge agent.
Your main class in custom module is expected to extend the JarModule interface and override the request method.
Sample Java class//$Id$package zylker;import org.json.JSONObject;import com.zoho.qntrl.bridge.sdk.module.jar.JarModule;public class SupplyMonitor extends JarModule {@Overridepublic void request(JSONObject arg0) throws Exception {int byteCount = arg0.getInt("byteCount");int units = arg0.getInt("units");JSONObject result = new JSONObject();result.put("load", byteCount * units);response(result);}}
Support for REST API services in custom modules allows end users to develop their own REST API modules in their preferred format. Upon deployment, these REST API endpoints will be published on the Bridge server.
Deployment on the Bridge Server:
Upon deployment on the Bridge server, REST API endpoints will be retrieved using the RestController and RequestDetails annotations.
URL Construction: URLs are constructed as rest/{module_name}/{controller_path}/{request_path}.
Module Name: Retrieved from the main class's getModuleBasePath() function.
Controller Path: Path fetched from the RestController annotation.
Request Path: Path retrieved from the RestController annotation.
URL Method: Retrieved from the RequestDetails annotation.
REST Module Configuration File:
Method and path details are added to the rest_modules.xml file, which is loaded during server start.
If a new version is updated in Qntrl, URLs in the configuration file are deleted and replaced with URLs fetched from the new version.
Upon module deletion in Qntrl, the module's details are removed from the configuration file.
REST API Service Classes
Classes and their purposes for implementing the REST API Service are detailed below:
Configuration Class:
Contains the module's base path and the authenticator's class instance.
Implements
com.zoho.qntrl.bridge.sdk.module.rest.RestServiceModule
Override Methods
➤ getModuleBasePath()
Should return the module's base path used to construct the REST API Url.
➤ getServiceAuthenticatorClassInstance()
Should return the authenticator's class instance.
Authenticator Class:
Users must implement their authentication methodology.
Implements
com.zoho.qntrl.bridge.sdk.module.rest.RestServiceAuthenticator
Override Methods
authenticate(HttpServletRequest, HttpServletResponse)
Request and response instances of the triggered API's are passed as arguments. If the request is authenticated and valid, the respective method implementation will be called; otherwise, it returns the error message as "User is not authorized".
Controller Class
Users can implement their action implementations. Annotations and their purposes are detailed below:
i. RESTContoller: Marks the class as a REST API controller, which can also be mentioned as an entity. In the future, for OAuth 2, scope will be mapped in the controller.
Type - Class Annotation
Fields
basePath - Maps the controller with the base path; it should not have the same base path. It provides provision to retrieve the global metadata of the controller using the URL. No validation is done. If the same base path is used, it will be added to the rest module configuration file, and whichever returns first will be executed.
ii. RequestDetails: Identifies the method to invoke for the URL. The URL's method and path will be retrieved using it.
Type - Method Annotation
Fields
method - The request method name should be provided (mandatory).
path - The path URL should be mentioned. It's not mandatory as the base path will be provided in the controller, and for basic CRUD operations, it's enough.
Generating ZIP File
To generate a ZIP file:
Generate the class files along with the parameter names stored with it. The parameter name will be used to fetch the value from the request's parameter or header.
Create a JAR file using those class files and then ZIP the JAR file.
Global Info
Users can retrieve the global information of the module and controller using the following endpoints.
3. SOAP Services
Support for SOAP services within Custom Modules allows end users to create their own SOAP service custom modules in their desired format. Upon deployment, these SOAP service endpoints will be made available on the Bridge server.
Deployment on the Bridge Server:
Upon deployment in the Bridge server, SOAP service endpoints are retrieved from the main class getEndpoint() method.
Endpoint URLs must begin with /soap.
SOAP Module Configuration File:
Configuration details of SOAP modules are stored in the soap_modules.xml file, which is loaded during server startup.
If a new version is updated in Qntrl, existing URLs related to the module in the configuration file will be deleted and replaced with the endpoints retrieved from the new version.
Upon module deletion in Qntrl, corresponding module details are removed from the configuration file.
Implementation:
To create a SOAP service module, you need to implement the SoapServiceModule interface in the main class. Below is an example of the main class and a SOAP endpoint.
SampleSoapServiceModule.java
import com.zoho.qntrl.bridge.sdk.module.soap.Endpoint;import com.zoho.qntrl.bridge.sdk.module.soap.SoapServiceModule;import java.util.Arrays;import java.util.List;import java.util.logging.Level;import java.util.logging.Logger;public class SampleSoapServiceModule implements SoapServiceModule {private static final Logger LOGGER = Logger.getLogger(SampleSoapServiceModule.class.getName());@Overridepublic void serviceStarted(Endpoint endpoint) {LOGGER.log(Level.INFO, "service {0} - {1} is started", new Object[]{endpoint.getName(), endpoint.getUrlPattern()});}@Overridepublic List<Endpoint> getEndpoints() {return Arrays.asList(new Endpoint("SampleSoapService", SampleSoapService.class.getName(), "/soap/sample"));}@Overridepublic void serviceStopped(Endpoint endpoint) {LOGGER.log(Level.INFO, "service {0} - {1} is stopped", new Object[]{endpoint.getName(), endpoint.getUrlPattern()});}@Overridepublic void moduleUnregistered() {LOGGER.log(Level.INFO, "sample soap service module got removed");}}
SampleSoapService.java
import javax.jws.WebMethod;import javax.jws.WebService;@WebServicepublic class SampleSoapService {@WebMethod(operationName = "SayHello")public String sayHello(String name) {return "Hello " + name + "..!";}}
In the Attachment field, you can add or remove JAR files. The added JAR file will become Active.
After making the required modifications, click Save.
Navigate to(settings) >> Advanced >> Bridge, then select Custom Module.
Hover over the name of the module you want to delete, click the action menu, and select the Delete.
Confirm the Delete action.
You are currently viewing the help articles of Qntrl 3.0. If you are still using our older version and require guidance with it, Click here.