| Samples > Rule Execution Server Integration > How to Generate a Rule Service Bean |
How to Generate a Rule Service Bean |
PREVIOUS NEXT |
This sample shows how to use a new RuleApp code execution generator to create a rule service bean. A set of generators is provided to create execution code, with the necessary configuration parameters and resources in a new Java project. These generators can be extended to add other facilities.
Key features include:
This sample extends the Rule Studio API, and the required sample plug-ins are delivered as pre-deployed. If you have not already done so, you must install the plug-in samples extension site in Eclipse before importing the sample project files and running the sample.
To install the plug-in samples extension site:
<InstallDir>/studio/samples/eclipse.
To check that the Ruleservice Sample feature is enabled:
<InstallDir>/studio/samples/eclipse and check that Ruleservice Sample 1.0.0. is listed.
To import the sample project files:
ILOG Rule Studio Samples and Tutorials.
samples > architecture > ruleservice.
You start by generating the loanruleservice project, then you deploy and execute your RuleApp in a Java EE environment.
To generate the loanruleservice project:
Other tree item and select Ruleservice sample template with velocity facility then click Next.
loanruleservice then click Next.
ruleservice-ruleapp then click Next.
loanvalidation-rules then click Next.
borrower parameter then click Change.
loan parameter then click Change.
Loan result = new loan.Loan(loan.DateUtil.makeDate(2005,java.util.Calendar.JUNE, 1),
72, 100000, 0.7d);return result;
The loanruleservice project is generated and appears in the Rule Explorer. You are now ready to deploy and then execute your RuleApp in a Java EE environment.
To deploy your RuleApp in a Java EE environment:
loanruleservice project in the Rule Explorer.
src directory, you should see the generated source files for the EJB and the web application.
jboss40 folder and click the build.xml target.
build.xml target again.
Now the application is ready to execute.
To execute the Java EE Archive:
http://localhost:8080/loan.
The sample is located in <InstallDir>/studio/samples/architecture/ruleservice.
The Velocity templates (.vm) are located in <InstallDir>/studio/samples/eclipse/plugins/ilog.rules.studio.samples.ruleservice_1.0.0/templates/velocity.
Layout:
Application.vm: Generates the EAR deployment descriptor jboss40/decriptor/application.xml.
Bean.vm: Generates src/<Ruleappname>/ejb/<Projectname>Bean.java. This class contains one method for each ruleset of the RuleApp to run.
build.vm: Generates the jboss40/build.xml Ant build file which invokes the xdoclet, runs the remote Java client and packages the EAR.
buildproperties.vm: Generates the jboss40/build.properties file used by the jboss40/build.xml Ant script to set specific properties.
Exception.vm: Generates the Java class file src/<Ruleappname>/<Projectname>Exception.java. that contains the ruleexecution exception class.
jndijboss40properties.vm: Generates the jboss40/jndi.properties file that is used by the Java remote client to connect to the server.
ParamClient.vm : Generates the Java class file src/<Ruleappname>/client/ParamClient.java that is used to initialize input parameters.
RemoteClient.vm: Generates the Java class file src/<Ruleappname>/client/RemoteJavaClient.java that is used to invoke the Java client remotely.
Result.vm: Generates the Java class file src/<Ruleappname>/ejb/<RuleProject>Result.java that contains the result for the rule project.
Web.vm : Generates the jboss40/decriptor/web.xml Web application descriptor.
WebContent/css: Directory containing the CSS file for the web application.
WebContent/images: Directory containing the image files for the web application.
WebContent/*.jsp: JSP Files for the web application.
These classes are used to generate samples source files:
ilog.rules.studio.samples.ruleservice:
RuleserviceGenerator: This class manages templates for a Ruleservice project for RuleApps. This template generates a Java EE project for RuleApps with a bean class that executes a RuleApp on Java EE environment.
ilog.rules.studio.samples.ruleservice.ui:
To display the source code of the ruleservice Eclipse plug-in:
External Plug-ins and Fragments and click Next.
ilog.rules.studio.samples.ruleservice plug-in (be careful not to select ilog.rules.studio.samples.ruleservice.source), then click Add.
A rule service is a software component that encapsulates runtime rule processing elements. The component provides a ready-to-run business rule application. A rule service simplifies the process of integrating business rules with popular application platforms. Java programming is only required if you want to customize the rule service component.
A rule service component is invoked using a programming language or a communication protocol. The following graphic shows a high level view of a rule service and the function it performs.
A rule service component is a stateless Enterprise Java Bean (EJB). It contains one or more extracted rulesets, Java classes and interface source files, and an Ant script file and other resource files to enable the rule engine to execute a ruleset on a specified platform.
The rule service generates descriptors for JBoss. The use of XDoclet enables support for other application server platforms.
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |