Rules engine integration interface (7) Rules engine calls Java classes

Rules engine calls Java classes

       Write a simple project through myEclipse, in which the method is to add two numbers and wait for the result, that is, result 1 = input value 1 + input value 2. There are three ways to implement a rule to call an external interface.


       1: Interface instance : Make a TestInterface.java interface class and Test.java implementation class in myEclipse, and write a double-type method in the Test.java implementation class. The method receives two parameters, and the two numbers are added together until result value.
       2: Java class object : Make a TestInterface.java interface class and Test.java implementation class in myEclipse, and write a double-type method in the Test.java implementation class. The method receives two parameters, and the two numbers are added together. Wait until the result value. At the same time, a double-type method is created in myEclipse for the Test.java implementation class. The method receives two parameters, and the two numbers are added together until the result value.
       3: External call interface object : Make a TestInterface.java interface class and Test.java implementation class in myEclipse, and write a double-type method in the Test.java implementation class. The method receives two parameters, and the two numbers are similar. Add and wait until the result value. At the same time, a double-type method is created in myEclipse for the Test.java implementation class. The method receives two parameters, and the two numbers are added together until the result value.

rule development

1. Import the jar package and
      put test.jar in the userlib directory under the installation tool. If the tool is open, you need to restart the tool.
2. The new rule package is related to the java class.
      Right-click the project "Object Library" - "New Rule Package", as shown below:

 

and named it "Related to java class", it shows as follows:


"The rule package related to the java class is created.

 

Define the variable
Click the object library, click the tab "Incoming Data", click, as shown in the figure below: the

 following form will pop up, the edit box corresponding to the name (English) is changed to "number1", and the type is set to double, as shown in the figure below:


 Display name ( Chinese) The corresponding edit box is changed to "input value 1", and the configuration is as follows:


After clicking OK, the display is as follows:


 According to the above method, configure the following variables, as shown in the figure:
 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326853650&siteId=291194637