Skip Headers
Oracle® Business Rules User's Guide
10g (10.1.3.1.0)

Part Number B28965-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

C Oracle Business Rules Frequently Asked Questions

This appendix contains frequently asked questions about Oracle Business Rules. Answers to each question are provided in each of the following categories:

C.1 Frequently Asked Questions About Rules Operations

This section addresses frequently asked questions relating to the semantics of Rules operations in Oracle Business Rules.

C.1.1 Why is the State of a Fact in a Rule Action Inconsistent with the Rule Condition?

The object was modified between the time the rule was activated and the time the rule was fired (executed), and the object was not re-asserted in the Rules Engine.

Objects (Java or RL) must be asserted as facts in the Rules Engine before they are used in rule evaluations. When an object that has been asserted as a fact is modified, either in the action of a rule or by something external to the Rules Engine (presumably by the application), the object must be re-asserted in the Rules Engine in order for the current object state to be reflected in the Rules Engine and thus in the rule evaluation. If this is not done, the application and Rules Engine are in an inconsistent state which can lead to unexpected behavior.

A Java bean may be written to support PropertyChangeListener so that the Rules Engine can automatically maintain a consistent state when a bean property us update. For more information, see Section 1.3.4.1, "Java Fact Type Definitions".

The one exception to this rule is for an object whose content is not being evaluated; that is, the Rules Engine does not contain a rule that tests or accesses any method or property of that object. One example of such a case is an object used to accumulate results from rule evaluations.


Note:

Suppose you have a rule that produces a sum from a collection of facts. Re-asserting the facts whose values are being summed yields an incorrect result in the fact containing the sum. Make sure you also re-assert the rule that produces the sum.

C.1.2 A Changed Java Object was Asserted as a Fact, but no Rules Fired. Why?

The object must be re-asserted in the Rules Engine. Therefore, the Rules Engine did not re-evaluate any rule conditions and did not activate any rules. For more information, refer to Section C.1.1.

C.1.3 What are the Differences Between Oracle Business Rules RL Language and Java?

See Appendix A in Oracle Business Rules Language Reference Guide.

C.1.4 How Do I Use Rules SDK to Include a null in an Expression

The Rules SDK automatically adds quotes for String values. To include a value without quotes, for example a null value without quotes in an expression, specify an advanced expression. The expression type FORM_LITERAL always surrounds string values with quotes. When you use the expression type FORM_ADVANCED, this does not surround the expression with quotes.

For example, the following Rules SDK code includes a null:

SimpleTest test = pattern.getSimpleTestTable().add();
test.getLeft().setForm(Expression.FORM_SINGLE_TERM);
test.getLeft().setSingleTermValue(attr);
test.setOperator(Util.TESTOP_NE);
test.getRight().setForm(Expression.FORM_ADVANCED);
test.getRight().getAdvancedExpression().append("null");

If you did not use the FORM_ADVANCED, you might see the following errors:

SEVERE: RUL-01815: Null values not allowed for key or value put ( LiteralValue, null )

java.lang.NullPointerException: RUL-01815: Null values not allowed for key or value put ( LiteralValue, null )

C.2 What JAR Files are Required for Working with Oracle Business Rules?

Oracle Business Rules support requires the JAR files listed in Table C-1. All paths are relative to $ORACLE_HOME.

Table C-1 Oracle Business Rules Required JAR Files

JAR File Description

rules/lib/rl.jar

The Oracle Business Rules Rules Engine library. This is the Java API used to instantiate and interact with the Rules Engine.

rules/lib/rl_dms.jar

Rules Engine Dynamic Monitoring Service (DMS) support. This file is required if DMS is enabled for a RuleSession.

rules/lib/rulesdk.jar

The Oracle Business Rules SDK. This is the Java API used to programatically author rules.

rules/lib/webdavrc.jar

The Oracle Business Rules SDK library for support of WebDAV repositories. This file is required when using the SDK with a WebDAV repository.

rules/lib/jr_dav.jar

The WebDAV client library. This file is required when using the SDK with a WebDAV repository.

jlib/oraclepki.jar

This file is required to support authentication with a repository such as a WebDAV repository.

jlib/ojpse.jar

This file is required to support authentication with a repository such as a WebDAV repository.

rules/lib/jsr94.jar

The standard JSR-94 library.

rules/lib/jsr94_obr.jar

The Oracle Business Rules JSR-94 implementation.

lib/xml.jar

This file is required by the Rules SDK.

lib/xmlparserv2.jar

This file is required by the Rules SDK.

j2ee/home/lib/http_client.jar

This file is required when using a WebDAV repository.


C.3 How do I Deploy Rule Author on Non-Oracle Containers?

This section includes instructions for deploying Rule Author and the online help for Rule Author on non-Oracle containers.

This section covers the following:

C.3.1 Deploying Rule Author on WebSphere V6.1 (WAS V6.1)

To deploy Rule Author on WebSphere V6.1, first locate the OracleAS Companion CD installation disk supplied with Oracle Application Server. The OracleAS Companion CD Disk 2 includes two .ear files for each supported non-Oracle container. The .ear files for WebSphere should be located in the directory:

Disk2/rules/webapps/websphere/


Note:

Under WebSphere, Rule Author online help is not available.

It is recommended that your installation of WebSphere have administrative security configured. Please consult the WebSphere documentation on setting up administrative security.

As part of the installation of Rule Author, you must configure the appropriate user and group name for authentication and authorization. The following steps provide only an example of how to setup the user and password for WebSphere WAS V6.1 using the standalone custom registry. Production uses of Rule Author should have security configured by an expert. To see examples of more advanced approaches, such as database or LDAP, consult the appropriate IBM documentation.

Perform the following steps to deploy Oracle Business Rules Rule Author on WebSphere V6.1:

  1. Start the WebSphere server:

    % cd <websphere home>/profiles/AppSvr01/bin
    % ./startServer.sh server1
    
    
  2. Login to WebSphere administrative console using the URL,

    https://<host name>:9043/ibm/console/logon.jsp
    
    

    Note:

    If you enable global security, you have to log in to the admin console with the user name that belongs to the admin group.

    1. Click to expand the "Security" node on the navigation tree.

    2. Click the "Secure administration, applications, and infrastructure" node.

    3. In the "User account repository" group box, select "Standalone custom registry" from "Available realm definitions" and click "Set as current".

    4. Click Apply.

    5. Click the Save link in the "messages" box at the top of the page.

    6. On the server's file system, choose a directory that is only accessible by the operating system user that WebSphere is running as, and create a group file and user file within that directory. This creates two users, adminUser who belongs to the AdminGroup group with special privilege to log in to the admin console, and ruleUser1 who will be given permission to access the Rule Author application.

      The following shows an example of the contents of the group file groups.prop

      adminGroup:987:adminUser:AdminGroup
      ruleAdminGroup:567:ruleUser1:RuleAdminGroup
      
      

      Each line of the group file should contain the following:

      <group name>:<group id>:<user name 1>, .. , <user name N>:<display name>
      
      

      The following shows sample contents of user file users.prop:

      adminUser:welcome1:123:987:WebSphereAdmin
      ruleUser1:welcome1:456:567:RuleAdmin
      
      

      Each line of user file should contain the following:

      <name>:<password>:<unique user id>:<group name 1>,...,<group name
      N>:<display name> 
      
      

      This sets the passwords for both adminUser and ruleUser1 to welcome1.

    7. In the "User account repository" group box, select "Standalone custom registry" from "Available realm definitions" and click "Configure".

    8. Click the "Custom properties" link to set up two properties that specifies the location of the files:

      Name Value
      ----------------------------
      groupsFile <your path>/<group file name>
      usersFile <your path>/<user file name>
      
      
    9. When you finish configuring these 2 properties, click the "Standalone custom registry" link at the top to return to the previous page.

    10. Set the "Primary administrative user name" to "adminUser".

    11. Select the "Server identity that is stored in the repository" radio button.

    12. Type in the Server user ID ("adminUser") and server password ("welcome1") that were previously defined in the users.prop file into fields of the same name. Note that the user name and server password must be included in the user file and group file that you provided earlier (see Step d).

    13. Enter "com.ibm.websphere.security.FileRegistrySample" into "Custom registry class name" field (this should be the default value).

    14. Click "OK".

    15. Check the "Enable application security" box.

    16. Uncheck the "Use Java 2 security" box if it is checked. Under some circumstances, this box is checked automatically when checking the box in the previous step and must be unchecked.

    17. Click the "Apply" button.

    18. Click "Save" in the "messages" box at the top of the page.

  3. Click to expand the "Servers" node in the left column, then click "Application servers". Click the server you wish to deploy the Rule Author to.

  4. Stop and restart the server from the command line with the stopServer and startServer commands.

  5. Click Applications->Install New Application Node on the left navigation panel. You have to specify the path to the ruleauthor_websphere.ear and click "Next".

    Change the field "ApplicationName" from "Rule Author" (with a space) to "RuleAuthor" (with no space). Click "Next", and then "Next" for the next two screens. Finally, click "Finish".

    • Click on Environment in the left panel.

    • Click on Shared Libraries

    • Select the desired scope from the Scope menu.

    • Click "new"

    • Enter "Oracle XDK" for the name

    • Under Classpath, enter the absolute path to the files "xml.jar" and "xmlparserv2.jar", which are in the location of the deployed RuleAuthor.ear application. (find using find or search). Enter the paths one per line with no separator (for example, ":") between them.

    • Click the "OK" button

    • Click "Save"

  6. In the "Applications" area, click on "Enterpirse Applications", then click the RuleAuthor link.

    • Under the References heading, click on "Shared library references".

    • Select the checkbox for the "RuleAuthor" entry and click the "Reference shared libraries" button.

    • Select the "Oracle XDK" entry in the "Available" list and move it to the "Selected" list.

    • Click "OK".

    • Click "OK" on the next page.

  7. Click "Security role to user/group mapping".

  8. On the "Security role to user/group mapping" screen, check the checkbox in the "Select" column and then click the "Look up groups" button.

  9. Click the "Search" button to display the available groups, then move the user "group1" from the "Available" box to the "Selected" box. Click "OK".

  10. On the returned page, click "Save".

  11. Logout of the WebSphere console.

  12. Stop and then restart the WebSphere instance from the command line.

  13. Point your browser to the following URL (the default port is 9080):

    http://<host name>:<port>/ruleauthor

If you have mapped the RuleAdministrator role in Step 2, you see the Rule Author login page when you attempt to click on any link on the page. If you have not correctly mapped the RuleAdministrator role, the application will go directly to the Repository Connection page.

Password-protected WebDAV Repository access using Oracle Wallet is currently non-functional on WebSphere. Password-protected access to a WebDAV repository only works using a directly-specified username and password.


Note:

To import an XML schema, first add the files xml.jar and xmlparserv2.jar (located in the installed Rule Author application directory) to the Java Fact classpath. The Java class files generated by the JAXB compiler from the XML schema depend on several classes provided by these JAR files. In non-Oracle containers, these classes are not on the Java Fact Classpath by default, so they must be added manually.

C.3.2 Deploying Rule Author on WebLogic Server

To deploy Oracle Business Rules Rule Author and the online help for Rule Author on WebLogic Server 9.1, you first need to locate the OracleAS Companion CD installation disk supplied with Oracle Application Server. The OracleAS Companion CD Disk 2 includes two .ear files for each supported non-Oracle container.

Perform the following steps to use the exploded ear file approach to deploy Oracle Business Rules Rule Author on WebLogic Server 9.1.


Note:

Locate the weblogic .ear files, ruleauthor_weblogic.ear and rulehelp_weblogic.ear on the OracleAS Companion CD Disk 2, in the directory,
Disk2/rules/webapps/weblogic/

  1. Make a directory named ruleauthor somewhere in <bea home>, where bea home is the WebLogic Server 9.1 home directory.

  2. Go to this directory and expand ruleauthor_weblogic.ear, located on the OracleAS Companion CD Disk 2, in the directory, as follows:

    % cd ruleauthor
    % jar xvf path/Disk2/rules/webapps/weblogic/ruleauthor_weblogic.ear
    
    
  3. Start WebLogic Server, as follows:

    % cd <bea home>/weblogic91/samples/domains/wl_server/bin
    % startWebLogic.cmd (for Windows)
    % ./startWebLogic.sh (for Unix)
    
    
  4. Point your browser to WebLogic Server Administration Console and log in. For example

    http://<hostname>:7001/console/login/LoginForm.jsp

  5. On the left panel, click "Deployments".

  6. On the left panel, click the "Lock & Edit" button.

  7. Click the "Install" button.

  8. Navigate the file browser until your find webapp directory. Select the radio button for this directory. Follow the instruction to deploy the application.

  9. On the left panel, click the "Activate Changes" button.

  10. On the left panel, click the "Lock & Edit" button.

  11. On the left panel, click "Security Realms".

  12. Click "myrealm".

  13. Click the "Users and Groups" tab.

  14. Click the "Groups" subtab

  15. Click the "New" button. Create a new group "rule-administrators".

  16. Click the "Users" subtab.

  17. Click the "New" button. Create a new user. Enter your choice of name. For example, enter ruleadmin and enter a password of the new user and then click "Save". Click the "Groups" tab. Using the shuttle, assign rule-administrators group to this user. Click "Save" when complete.

  18. Click the "Release Configuration" button.

  19. Go to the "Deployments" page and start the application.

  20. Log out of the console and close the browser.

  21. To test the application, open the browser and go to the URL

    http://<localhost>:7001/ruleauthor/

To deploy the help for Rule Author, follow Steps (1-7) to deploy rulehelp_weblogic.ear. To test the help page, click the help link on the Rule Author page.


Note:

To enable XML Fact Import and the use of WebDAV repository access, add the Oracle XDK classes to the container classpath. To do this, update startWebLogic.sh for the domain you are running by adding xml.jar and xmlparserv2.jar to the CLASSPATH environment variable path (on Windows, the name of the file you need to update is startWebLogic.cmd).

C.3.3 Deploying Rule Author on JBoss 4.0

To deploy Rule Author and the online help for Rule Author on JBoss, you first need to locate the OracleAS Companion CD installation disk supplied with Oracle Application Server. The OracleAS Companion CD Disk 2 includes two .ear files for each supported non-Oracle container.


Note 1:

If you wish to use the Rule Author XML Schema Import capability, you must add the locations of the files xml.jar and xmlparserv2.jar to the environment variable JBOSS_CLASSPATH in the environment from which you execute JBoss. These classes are available in ORACLE_HOME/lib.


Note 2:

Under JBoss, you cannot access WebDAV repositories due to XML parser incompatibilities.

Perform the following steps to deploy Rule Author on JBoss 4.0.


Note:

Locate the JBoss .ear files, ruleauthor_jboss.ear and rulehelp_jboss.ear on the OracleAS Companion CD Disk 2, in the directory,
Disk2/rules/webapps/jboss/

  1. Make sure you have JDK 1.5 installed in your environment. JBoss does not run well with JDK 1.4.

  2. Put ruleauthor_jboss.ear in the <jboss home>/server/default/deploy directory.

  3. Put the following jars in the <jboss home>/server/default/lib directory. They can be obtained by expanding the ruleauthor_jboss.ear file in a temporary directory.

    commons-el.jar
    jr_dav.jar
    jsp-el-api.jar
    oracle-el.jar
    regexp.jar
    rulesmvc.jar
    rulesdk.jar
    rl.jar
    share.jar
    uix2.jar
    webdavrc.jar
    xmlparserv2.jar
    xml.jar
    http_client.jar
    oraclepki.jar
    servlet.jar
    
    
  4. Edit <jboss home>/server/default/conf/login-config.xml to add the following section:

    <application-policy name = "ruleauthor">
       <authentication>
          <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
              flag = "required">
             <module-option name= "usersProperties">
                      props/ruleauthor-users.properties 
             </module-option>
             <module-option name="rolesProperties">
                      props/ruleauthor-roles.properties 
             </module-option>
          </login-module>
       </authentication>
    </application-policy>
    
    
  5. Add the users (ruleauthor-users.properties) and roles (ruleauthor-roles.properties) files to the following directory:

    <jboss home>/server/default/conf/props

    Example of contents of ruleauthor-users.properties file:

    ra=oraclerule

    Example of contents of ruleauthor-roles.properties file:

    ra=RuleAdministrator

    In this example, we create a user name ra that has a password oraclerule and belongs to role RuleAdministrator.

  6. Start JBoss using the following commands,

    %cd <jboss home>/bin
    %run.bat
    
    

    If successfully deployed, you should see output similar to the following:

    14:28:21,718 INFO [TomcatDeployer] deploy,ctxPath=/ruleauthor, warUrl=.../tmp/
    deploy/tmp20477ruleauthor_jboss.ear-contents/ruleauthor-exp.war/
    
    4:28:21,906 INFO  [EARDeployer] Started J2EE application: file:/C:/jboss-4.0.3SP1/server/default/deploy/ruleauthor_jboss.ear
    
    
  7. Point your browser to the site,

    http://<host>:8080/ruleauthor

    If you have mapped the RuleAdministator role as instructed in Steps 2 and 3, you see the Rule Author login page.

To deploy the help for Rule Author, drop the rulehelp_jboss.ear to the deploy directory. To test the help page, click the help link on the Rule Author page.

C.4 How Does a RuleSession Handle Concurrency and Synchronization?

Method calls on an Oracle Business Rules RuleSession object are thread-safe such that calls by multiple threads do not cause exceptions at the RuleSession level. However, there are no exclusivity or transactional guarantees on the execution of methods. The lowest-level run method in the Rules Engine is synchronized, so two threads with a shared RuleSession cannot both simultaneously execute run. One call to run must wait for the other to finish.

RL Functions are not synchronized by default. Like Java methods, RL functions can execute concurrently and it is the programmer's responsibility to use synchronized blocks to protect access to shared data (for instance, a HashMap containing results data).

Any set of actions that a user wishes to be executed as in a transaction-like form must synchronize around the shared object. Users should not synchronize around a RuleSession object because exceptions thrown when calling RuleSession methods may require the RuleSession object to be discarded.

For most uses of a RuleSession object in Oracle Business Rules, each thread or servlet instance should create and use a local RuleSession object. This usage pattern is roughly analogous to using a JDBC connection in this manner.

The following examples demonstrate how to use a shared RuleSession object.

For the case where Thread-1 includes the following:

ruleSession.callFunctionWithArgument("assert", singleFact1);
ruleSession.callFunctionWithArgument("assert", singleFact2);

and Thread-2 includes the following:

ruleSession.callFunction("run");
ruleSession.callFunction("clear");

In this case, the execution of the two threads might proceed as shown in Example C-1.

Example C-1 Using a Shared RuleSession Object in Oracle Business Rules

Thread-1:  ruleSession.callFunctionWithArgument("assert", singleFact1);
Thread-2:  ruleSession.callFunction("run");
Thread-2:  ruleSession.callFunction("clear"); 
Thread-1:  ruleSession.callFunctionWithArgument("assert", singleFact2); 

In Example C-1, the two facts Thread-1 asserted are never both in the RuleSession during a call to run. Notice also that only one thread calls the run method. We do not recommend a design where multiple threads can call run on a shared RuleSession. This usage pattern can create extremely hard to find bugs and there is no gain in performance.

All accesses to a shared RuleSession object must be synchronized to ensure the intended behavior. However, a RuleSession instance may throw an exception and not be recoverable, so do not use this object as the synchronization object. Instead, use another shared object as the synchronization point.

One can envision a shared server process producer-consumer model for RuleSession use. In this model, multiple threads assert facts to a shared RuleSession and one thread periodically calls run, reads any results, and outputs them. This ensures that thread conflicts cannot occur, because the two code segments must be executed serially and cannot be intermingled. For example, the code with shared objects, producer code, and consumer code in Example C-2, Example C-3, and Example C-4.

Example C-2 RuleSession Shared Objects

RuleSession ruleSession;
Object ruleSessionLock = new Object();

Example C-3 RuleSession Producer Code

public String addFacts(FactTypeA fa, FactTypeB fb, FactTypeC fc){
   String status = "";
   synchronized(ruleSessionLock){
     try {
       ruleSession.callFunctionWithArgument("assert", fa);
       ruleSession.callFunctionWithArgument("assert", fb);
       status = "success";
     } catch (Exception e) { 
       // a method that creates a new RuleSession loads it with rules
       initializeRuleSession(); 
       status = "failure";
     }
     return status;
}

Example C-4 RuleSession Consumer Code

public List exec(){
  synchronized(ruleSessionLock){
    try {
      ruleSession.callFunction("run");
      List results = (List)ruleSession.callFunction("getResults");
      ruleSession.callFunction("clearResults");
      return results;
    }  catch (Exception e) { 
      // a method that creates a new RuleSession loads it with rules
      initializeRuleSession();
      return null;
    }
  }
}


Note:

When multiple threads are sharing a RuleSession object, it is not recommended that more than one of the threads calls the run method.

C.5 How Do I Improve Oracle Business Rules Runtime Performance?

When trying to increase the performance of an application that uses a RuleSession object, you should try to minimize the number of times that you open the Repository and generate the RL code. Thus, you should avoid opening and reading a Repository for each RuleSession instance you create; this practice should allow the program to perform well in most cases.

You can share the String object containing generated RL code, so that all application instances can use it for loading the rules into a private RuleSession object.

If your application requires additional performance tuning, you can use a pooling mechanism to share a set of RuleSession objects. In this case, a common pool would hold RuleSession objects and a thread could obtain an object from the pool, use the object for a series of operations, and then return the object to the pool. RuleSession objects which throw an exception should not be reused. If an exception was thrown by the RuleSession, the pool would need to discard this instance and replace it with a new RuleSession instance.

Note the following issues when using pooled RuleSession objects:

Depending on the computation requirements of your application, the performance improvements from pooling may be very small. The computational cost of creating a new RuleSession object and loading RL code is unlikely to be a performance bottleneck. You should monitor performance to see if it is within the acceptable range before attempting to increase performance using RuleSession object pooling.

The Oracle Java Object Cache provides a mechanism for very simple pooling. However, you will need to add an extra layer that can call reset() and check for exceptions that require RuleSession objects to be discarded and re-created.


See Also:

Java Object Cache in the Oracle Containers for J2EE Services Guide

C.6 How Do I Correctly Use an RL Language Cross Product?

When working with cross products of facts, there are cases where the runtime behavior of RL Language may produce surprising results.

Consider the RL Language code in Example C-5.

Example C-5 Cross Product Using Fact F

class F {int i; }; 
rule r1 { 
  if (fact F F1 && fact F F2) { 
    println("Results: " + F1.i + ", " + F2.i); 
}} 
assert(new F(i:1)); 
assert(new F(i:2)); 
run(); 

How many lines print in the Example C-5 output? The answer is 4 lines because fact F1 and fact F2 can be the same instance and are compared in each operand.

Thus, Example C-5 gives the following output:

Results: 2, 2 
Results: 2, 1 
Results: 1, 2 
Results: 1, 1 

Using the same example with a third F, for example ( assert(new F(i:3)); ) then nine lines are printed and if, at the same time, a third term && fact F F3 is added then 27 lines are printed.

If you are attempting to find all combinations and orders of distinct facts, you need an additional term to in the test, as shown in Example C-6.

Example C-6 Find All Combinations of Fact F

rule r1 { 
  if (fact F F1 && fact F F2 && F1 != F2) { 
    println("Results: " + F1.i + ", " + F2.i); 
}} 


The code in Example C-6 gives the following output:

Results: 2, 1 
Results: 1, 2 

The simplest, although not the fastest way to find all combinations of facts, regardless of their order, is to use the code shown in Example C-7.

Example C-7 Finding Combinations of Fact F

rule r1 { 
  if (fact F F1 && fact F F2 && id(F1) < id(F2)) { 
    println("Results: " + F1.i + ", " + F2.i); 
  }
}

Because the function id() shown in Example C-7 takes longer to execute in a test pattern than a direct comparison, the fastest method is to test on a unique value in each object. For example, you could add an integer value property "oid" to your class that is assigned a unique value for each instance of the class.

Example C-8 shows the same rule using the oid value.

Example C-8 Fast Complete Comparison

rule r1 { 
  if (fact F F1 && fact F F2 && F1.oid < F2.oid) { 
    println("Results: " + F1.i + ", " + F2.i); 
  }
}

This problem may also arise if you attempt to remove all duplicate facts from the Oracle Rules Engine, using a function as shown Example C-9.

Example C-9 Retracting Duplicate Facts Incorrect Sample

rule rRemoveDups { 
  if (fact F F1 && fact F F2 && F1.i == F2.i) { 
     retract(F2); 
  } 
} 

However, this rule removes all facts of type F, not just the duplicates because F1 and F2 may be the same fact instance. Example C-10 shows the correct version of this rule.

Example C-10 Retracting Duplicate Facts Corrected Sample

rule rRemoveDups { 
  if (fact F F1 && fact F F2 && F1 != F2 && F1.i == F2.i) { 
     retract(F2); 
  } 
}

C.7 How Do I Access a Rule in a Dictionary Using a URL?

Rule Author can take a dictionary and a rule name in a URL and access a rule directly from the URL. After a user logs in to Rule Author either through the Rule Author login page using Oracle Single Sign-On, Rule Author allows the user to display a ruleset or rule page with a URL.

The format of the URL is as follows, with parameter descriptions in Table C-2.

http://<host_name>:<port_number>/ruleauthor/event=dlConnect& 
<repos_prop 1>=<repos_value val> ..... &
Dict=<dict_name>&Version=<version> &
RuleSet=<ruleset_name> &
rule=<rule_name>

For example, the following URL allows you to view a rule, checkCredit in ruleset rs2 with a single URL:

http://localhost:8888/ruleauthor/ConnectRepos.uix?event=dlConnect&ReposType=File&oracle.rules.sdk.store.jar.path=C:\jartest\test1.jar&Dict=c233&Version=v1&RuleSet=rs2&rule=checkCredit

Table C-2 URL Parameters for Accessing a Rule Using a URL

URL Component Description

host_name

Specifies the host where the Rule Author application is running.

port_number

Specifies the port number where the Rule Author application is running.

repos_prop i

Denotes the repository connection property i defined by the Oracle Business Rules SDK. Consult the Javadoc for additional details.

For file type repository, see oracle.rules.sdk.store.jar.Constants.java.

For WebDAV, see oracle.rules.sdk.store.webdav.Constants.java.

repos_value val

Denotes repository connection value val for property i

dict_version

Specifies the dictionary name

ruleset_name

Optional - specifies the ruleset name. If you do not provide either a <ruleset_name> or a <rule_name>, the ruleset summary page is shown.

rule_name

Optional - specifies the rule name. If a <ruleset_name> is set, but <rule_name> is not given, the ruleset page is shown.


C.8 How Do I Use a Property Change Listener in Oracle Business Rules?

The Oracle Rules Engine supports the Java PropertyChangeListener design pattern. This allows an instance of a Java fact that uses the PropertyChangeSupport class to automatically notify the Oracle Rules Engine when property values have changed. Java facts are not required to implement this pattern to be used by Oracle Rules Engine.

Normally, changes made to values of a property of a Java object that has previously been asserted to the Oracle Rules Engine requires that the object be re-asserted in order for rules to be reevaluated with the new property value. For properties that fire PropertyChangeEvents, changing the value of those properties both changes the value and re-asserts the fact to the Oracle Rules Engine.

To implement the PropertyChangeListener design pattern in a class, do the following:

  1. Import this package in the class:

    import java.beans.PropertyChangeSupport;
    
    
  2. Add a private member variable to the class:

    private PropertyChangeSupport m_pcs = null;
    
  3. In the constructor, create a new Property Change Support object:

    m_pcs = new PropertyChangeSupport(this);
    
    
  4. Then for each setter, add the call to firePropertyChange:

    public void setName( String name ){
       String oldVal =  m_name;
       m_name = name;
       m_pcs.firePropertyChange( "name", oldVal, m_name );
    }
    
    
  5. Implement addPropertyChangeListener method (delegate to m_pcs):

    public void addPropertyChangeListener(PropertyChangeListener pcl){     m_pcs.addPropertyChangeListener( pcl );}
    
    
  6. Implement removePropertyChangeListener method (delegate to m_pcs):

    public removePropertyChangeListener(PropertyChangeListener pcl){
       m_pcs.removePropertyChangeListener( pcl );
    }
    
    
    

When deciding whether to design your application to always explicitly re-assert modified objects or implement the PropertyChangeListener design pattern, consider the following items:

C.9 How Do I Modify the Single Sign-On Timeout for Oracle Application Server?

If you find that the default Oracle Single Sign-On timeout specified for your applications, including Rule Author is too low for your installation, you can change the value specified for this timeout.

Perform the following steps to change the Single Sign-On timeout:

  1. In Application Server Control, go to the Cluster Topology page.

  2. In the Administration area, click Java SSO Configuration.

  3. In the Properties area, change the value in the Session Timeout (secs) text box to the desired timeout value.

  4. Click Apply.

C.10 Does Oracle Business Rules Provide High Availability?

If you need to run a rules application as a highly available application, you should refer to the Oracle Application Server High Availability Guide for information on Oracle Business Rules and high availability.