Custom Module | Qntrl | Bridge | Online Help | Build your own module according to your needs in Qntrl

Custom Module


Early Access  

Custom Module is not enabled for all users. If you’d like to try it out, please email our support team for early access.

The predefined modules in a Bridge may help you reach a DB/App server/AD and accomplish your tasks. However, to meet some specific demands, Qntrl lets you create your own module (in Java) according to your requirements. Just like other Bridge modules, the custom-built module can be executed in Messages.

 Environmental Set-up 

  1. Click the settings gear iconat the left pane.

  2. Navigate to Advanced >> Bridge, then choose Custom Module.

  1. 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.

  2. To integrate the SDK into your project, you need to add all the downloaded jars files to the reference libraries section.

  3. 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.     


Create a Custom Module   

  1. In Qntrl, in the Custom Module page, click the New Custom Module button.

  2. Fill in the required details.

    1. Module Name: Provide a unique name to identify the module.

    2. Type: Select the application type used to write your custom module.

      1. JAR

      2. REST API Service

      3. SOAP Service

    3. DescriptionProvide a few details that describe the purpose of the module.

    4.  Main Class NameThe class name along with the package name in your Java package (e.g.: packageName.className).

    5. Attachments: Attach the zip file that comprises your JAR, created using the SDK interface.

  3. Click Save


How to Execute a Custom Module 

Step 1: Associate the Custom Module with the Bridge

To execute a custom module, it must first be associated with the bridge. Upon association, the custom module JAR will be uploaded to the target bridge. To associate the created custom module with the bridge:
  1. Click the settings gear icon at the top-right corner of the header bar.
  2. Navigate to Advanced >> Bridge, then choose Bridge.
  3. In the Bridge list page, click on the name of the bridge to which the custom module needs to be associated. 
  4. The selected bridge details will be displayed. Under the Modules tab, click the Associate Modules button, and from the displayed list of modules select the name of the custom module you wish to associate with the bridge.
  5. Click Save.

      


Step 2 : Execute the Custom Module 

To execute the custom module in the Bridge, the Message module is utilized. To accomplish this:
  1. Navigate to(settings) >> Advanced >> Bridge, then select Messages.
  2. In the Message list page that loads, click the New Message button.

  3. 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.

  1. 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.


Types of Custom Module  

1.  Jar 

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 {
@Override
 public 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);
}
}


2.  Rest API Services 

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:

  1. Upon deployment on the Bridge server, REST API endpoints will be retrieved using the RestController and RequestDetails annotations.

  2. 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.

  3. 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.

 

Implementation:

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

    1.  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:

  1. 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.

  2. 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.

  1. For Module:
    1. Endpoint: rest/{module_name}/_global_info
    2. Returns all the paths along with the method details in the module.
  2. For Controller:
    1. Endpoint: rest/{module_name}/{controller_path}/_global_info
    2. Returns all the paths along with the method details present in the particular controller.

   

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());
    @Override
    public void serviceStarted(Endpoint endpoint) {
        LOGGER.log(Level.INFO, "service {0} - {1} is started", new Object[]{endpoint.getName(), endpoint.getUrlPattern()});
    }
    @Override
    public List<Endpoint> getEndpoints() {
        return Arrays.asList(
                new Endpoint("SampleSoapService", SampleSoapService.class.getName(), "/soap/sample")
        );
    }
 
    @Override
    public void serviceStopped(Endpoint endpoint) {
        LOGGER.log(Level.INFO, "service {0} - {1} is stopped", new Object[]{endpoint.getName(), endpoint.getUrlPattern()});
    }
    @Override
    public void moduleUnregistered() {
        LOGGER.log(Level.INFO, "sample soap service module got removed");
    }
}

SampleSoapService.java

import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public class SampleSoapService {
    @WebMethod(operationName = "SayHello")
    public String sayHello(String name) {
        return "Hello " + name + "..!";
    }
}


Accessing Soap Service:
After compiling these classes, create a JAR file and zip it. Upload the zip file to the custom module in Qntrl. You can then access it in the Bridge using the URL http[s]://{your_domain}/soap/sample?wsdl, where you will see the WSDL of this SOAP service.

View / Edit properties of a Custom Module   

To update a custom module,
  1. Navigate to(settings) >> Advanced >> Bridge, then select Custom Module.
  2. On the module list page, click the name of the module.
  3. The details of the selected custom module will be displayed. You can view and edit the properties of fields (Module Name, Description, Main Class Name, etc.) here. 

 

  1. In the Attachment field, you can add or remove JAR files. The added JAR file will become Active.

      Limitations:
  1.       A maximum of three zip files can be attached.
  2.       Only one JAR file will be active.
  3.       When one file gets active, other JAR files become inactive and the active JAR file will automatically get deployed.
  1. Under the Associated Bridge(s) tab, the bridge we associated while creating the module will be displayed. If you activate a new JAR file and update the module, the JAR will be deployed to this bridge by default.
If the newly added JAR file is not deployed to the bridge by default, you can forcefully deploy and update by clicking on the Deploy button.
  1. After making the required modifications, click Save


Delete a Custom Module   

To remove a custom module from Bridge,
  1. Navigate to(settings) >> Advanced >> Bridge, then select Custom Module.

  2. Hover over the name of the module you want to delete, click the action menu, and select the Delete.

  3. Confirm the Delete action.

 



    • Related Articles

    • Custom Function: Create_Job

      This custom function can be used to create a new card in any board. It can also be configured to carry forward necessary field values from the former card to the latter. Business Scenario Helen is the head of Procurement Management in her ...
    • Custom Function: Computing_Field_Values

      This custom function can be used to add two values and save the return value in a custom field. The sum will be dynamically updated in the custom field after this function is executed. Business Scenario Helen is the head of Procurement Management at ...
    • Custom Function: Create_Ticket_in_Zoho_Desk

      Zoho Desk is customer service software which allows you to address customer concerns. This custom function can be used to post a card as a ticket in Zoho Desk. Prerequisites Sign up for Zoho Desk and create a department. The ticket will be created in ...
    • Card custom views

      Cards are grouped and displayed under different views. Users can use Qntrl's default views or also create their own custom views. Default Views There are five default views supported by Qntrl. To use the default view: Navigate to Boards and select a ...
    • Manage Custom Functions

      Custom functions allow users to develop and execute user-defined functions using Deluge. You can execute simple program snippets to automate processes, or integrate with third-party or Zoho applications. Business Uses for Custom Functions Use Custom ...

    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.