Packaging Java rule sessions for Java EE

To package a Java™ or non-EJB rule session for Java EE, you use the rule session factory API to write an application that calls the ruleset. Then you edit the deployment descriptors and put the rule session JAR file and other files into the relevant archives.

Procedure

To package an application by using a POJO factory:

  1. Write a client application (a WAR file) by using JavaServer Pages (JSPs) and HTML files.

    Use the rule session factory API in your ruleset execution code (IlrPOJOSessionFactory).

  2. Edit the deployment descriptors to authorize access to the execution unit (XU) by adding a <resource-ref> element to either of these files:
    • To your web.xml file if you want to execute one ruleset per transaction scope.
    • To your ejb-jar.xml file if you want to execute two different rulesets in the same transaction scope.
       <resource-ref>
          <res-ref-name>eis/XUConnectionFactory</res-ref-name>
          <res-type>javax.resource.cci.ConnectionFactory</res-type>
          <res-auth>Application</res-auth>
          <res-sharing-scope>Unshareable</res-sharing-scope>
       </resource-ref>
    Important:

    Setting the res-sharing-scope value to Shareable might imply a sharing of the ruleset without consideration of the canonical ruleset path. You must set this value to UnShareable to isolate unexpected behavior related to the connection.

    In most cases, you must add this reference at the level of the application-server-specific descriptor.

    For example, to declare the <resource-ref> property for the XU in the weblogic.xml file:

    <reference-descriptor>
       <resource-description>
          <res-ref-name>eis/XUConnectionFactory</res-ref-name>
          <jndi-name>eis/XUConnectionFactory</jndi-name>
       </resource-description>
    </reference-descriptor>     

    To declare this reference in an EJB application in WebLogic, use the weblogic-ejb-jar.xml file, and add the following code:

    <resource-description>
       <res-ref-name>eis/XUConnectionFactory</res-ref-name>
       <jndi-name>eis/XUConnectionFactory</jndi-name>
    </resource-description>

    This segment of the descriptor binds the reference name used in the Rule Execution Server component to the real JNDI name eis/XUConnectionFactory. This is the name of the XU supplied at deployment time.

  3. Package the .class, .jsp, and .html files, and the deployment descriptors into the appropriate archive files.

    If you use only POJO factories, package the jrules-res-session-<appserver>.jar in your WEB-INF/lib directory. You can repackage as you want, but the goal is to grant access to the classes inside your servlet or JavaServer Pages. If your rules are written on Java classes, package them in the WAR file.