Recently too busy, today finally can spare time to update, a few Bo friends have been concerned, so I will certainly update.
A lot has been said, including how to create a rule project, how to write a rule set, how to install the RES service and the release rule package, but there are so many things that do not seem to know how to invoke or use the rule project we created in our app, so today, here we look together, How you can use the rule project in our own app.
In fact, there are two ways to publish a rule item, one to publish to a file system, one to publish to a folder, and another to publish to a database.
How do I invoke a rule in my own app? There are also two ways of creating a local client and then integrating it into our own application, using the IBM-provided API to invoke the rule set directly, the other is to publish the rule project as WebService, create a client invoker from the WSDL, and then integrate it into our own application.
The first way:
Open the rule Designer and look at the existing rules project:
There is just one rule project and the rule app package for that rule project (if you don't create a rule app package, check out the blog about res introduction, which is described in the article).
In the rule explorer right → new → other → Select the Ruleapp client project:
Click Next:
Select "Simple Old Java object" and click Next:
Enter the project name and click Next:
Select the corresponding Ruleapp and click Next:
Select the rule set archive and click Next to the Pojo property interface:
Here the interface name and implementation name is given automatically, without modification, the key is the following res configuration, click "Browse":
Click Create configuration:
Click "Create New Configuration Item":
Click Finish:
Click Next, then click Next to the Ruleapp Deployment page:
As you can see here, you can deploy Ruleapp to a file system or to a database, and we choose a folder that is deployed to the file system by default. Click Done. (Here you can configure the file path to a file under your application, so that you can directly deploy the rule app package to your app, and then port the generated client code to your app, you can invoke the rules in your app and complete the application integration of the rule application).
Click the Finish button:
Click the OK button, and then the default until complete.
The following is the directory structure of the client project:
You'll see for yourselves, huh?
Where the src file is generated by the call rules of the relevant interface file, can be opened to see, it is easy to read, and very human to provide us with a call Class (Main.java), open to look at:
As you can see, the execution of the rule is a method (Bean.executeagecheck (Personagecheck)) that passes our first parameter in the rule project, the interface calls the execution method, and returns an object containing the output parameters.
Next we test:
One rule in this rule set is this:
Let's test the results of this rule, and we'll change the code in Main.java:
We initialized two people, set their age to 18 and 17, respectively, and then execute the rule to get the information and output from the person who executed the rule. To view the results of the output:
The output conforms to the expected execution of the rule.
At this point, our rule call client has been completed.
Finally, on how to migrate the client code to your own project, do a little more, you simply copy the generated client project Res-data files and src folder to your project, the SRC directory in the relevant files will be error, cannot find the corresponding XOM class, You need to copy the XOM from the original rule project into your project, and finally bring in the Ilog related jar package, which is one of my integrated projects:
This article is here, and the next article will show you how to publish the rule to WebService for remote invocation.
If you are in the process of reading the omission or error, please put forward in the message, we share progress, welcome reprint, benefit others, but please specify the source!
Thank!
IBM Rules Engine (ODM) Primer Series II (3): Rule Engine Client Creation