Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-266

Customize how drools checks if an object is already asserted in its working memory

    XMLWordPrintable

Details

    Description

      If two objects A and B are asserted, where A != B, but A.eqals(B) is true, then drools adds both of them to working memory, creating two fact handles. Behaviour is based on using org.drools.util.IdentityMap as identityMap in Reteoo workingMemoryImpl

      My request is to add another behaviour and customizable which to use.
      Drools should assert an object B, if there is not already an object A in working memory where A.equals(B) is true. (Basically this behaviour is achieved by using HashMap instead of IdentityMap)

      Customization should be possible via setting properties on workingMemory creation. In JSR94 it would be a property for createRuleSession:

      HashMap properties = new HashMap();
      properties.put("org.drools.objectequality", "equals");
      //properties.put("org.drools.objectequality", "identity"); //default value
      StatefulRuleSession session = (StatefulRuleSession)ruleRuntime.createRuleSession(executionSetName, properties, RuleRuntime.STATEFUL_SESSION_TYPE);

      • Currently, properties are used to set global variables. So "org.drools.objectequality" would yield unknown global error.

      Attachments

        Activity

          People

            etirelli Edson Tirelli
            work_registries John Doe (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: