Docs Menu
User Guide / Service / Java

Java Service

Java Service is needed when there exists a need to create a API that is difficult to build in the API setup. A Java Service can be called directly from the API. A Java service can invoke a Java application. It uses a JAR file from the library and inside this JAR file, multiple classes are stored that use Java Library for execution. There are two main reasons for using a Java Service.

1. Implement Custom Algorithms

Sometimes the programming logic is a bit complex and there is a need for creating a custom logic that is not possible or not supported in the API. In that case, a customized Java Service is created by writing a suitable Java code and then calling the same through a API.

2. Communicate with Java Library

Communicating directly with the Java Library through a API is not supported by the Syncloop platform. So as to implement the communication with Java Library or use any existing Java Code is implemented by writing Java Service and calling the same in the API.

To create a Java Service on the Syncloop Platform Right-Click on the Package Folder then select NewπŸ‘ͺ Services πŸ‘ͺ Java

Root Properties

Note:

i) A Java Service cannot invoke or call any other Java Service.
ii) A Java Service cannot invoke or call any other API.

Code Window

A code window is a window where actual Java code is written. A Java Service will be created with a default code already written. After writing the code if the code is saved by clicking on the save button the syntax of the Java Code is correct.

Root Properties

The above Java Service code format will remain the same and should not be changed.

The various windows available on Syncloop API Development Platform are the same as are for the API. The input/output parameters support all those data types that are also available in the API. Here these variables are given as input to the Java Code where they are processed and output is derived from the Java service code and stored in the output parameters of the API.

To get the data in the Java Service code DataPipeline Object is used. This object is the main object for getting the data from the input parameters and saving the output in the output parameters. These input and output parameters can be mapped while calling this Java Service in the API. In addition to that the DataPipleline object has many other methods and properties for handling various data types and variable arrays.

Example for getting input parameters

dataPipline.getString(β€œ ”); // This recommended
dataPipline.getAsString(β€œ ”);
like that we can implement it for other datatypes. To implement the object for arrays the method that is used is
dataPipline.get(β€œ ”);

Example for putting output parameters

dataPipline.putString(β€œ ”); // This recommended
dataPipline.putAsString(β€œ ”);
like that we can implement it for other datatypes. To implement the object for arrays the method that is used is
dataPipline.put(β€œ, );

Mapping the parameters

When the Java Service is called into the API the input and output parameters of the Java Services can be mapped with the input and output parameters of the API. This can enable the usage of various methods defined in Java Service to be used in the API. This also enables a developer to efficiently use the Java library by a flow service indirectly through a Java Service.

To know more about how Java Service can be called in the API watch the video shown below.