68699

How can we share individual rules between .drl files in JBoss Rules?

Question:

We are using <a href="http://www.jboss.org/drools/" rel="nofollow">JBoss Rules</a> (a.k.a. Drools) and have several <em>.drl</em> files that each contain several rules. Is there a way to avoid duplication between files, so that we can define common rules that are available to more than one <em>.drl</em> file?

Unfortunately, there does not seem to be any kind of <em>include</em> or module facility.

Answer1:

There is no way of including rules from another .drl file from within a .drl file.

You can however add two .drl files to the same ruleBase and they will work as if they were in the same file.

PackageBuilder builder = new PackageBuilder(); builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "common.drl" ) ) ); builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "rules1.drl" ) ) ); RuleBase ruleBase = RuleBaseFactory.newRuleBase(); ruleBase.addPackage( builder.getPackage() );

Recommend

  • Multiple boolean conditions in a rule in drools?
  • Open Source based Rules Engines in Java or Python [closed]
  • Retrieve drools working memory from Optaplanner solution
  • Are Drools global variables session-bound?
  • Refetch events when switching fullcalendar views
  • Best practice for condensing code? [closed]
  • Ignoring unknown parameters: point.colour.1
  • How can I create doxygen docs from boost::python docstrings?
  • One html form, several interrelated django forms - how to save?
  • How to pass method result as parameter to base class constructor in C++?
  • How do databases sort Chinese characters?
  • web shop (shopping cart) on google app engine
  • How to validate a year I enter in textbox using jquery rule?
  • Laravel at least one field is required
  • Less Conflicting Session Manager for Zope 2
  • NHibernate manually control fetching
  • Is there some graphical way to create my own configuration file on SonarLint?
  • Does Mobilefirst provide a provision to access web services directly?
  • htaccess add www if not subdomain, if subdomain remove www
  • How do I exclude a dependency in provided scope when running in Maven test scope?
  • Is there a perl module to validate passwords stored in “{crypt}hashedpassword” “{ssha}hashedpassword
  • Sencha Touch 2.0 Controller refs attribute not working?
  • Yii2: Config params vs. const/define
  • Meteor helpers not available in Angular template
  • Ajax Loaded meta Tags
  • When to use `image` and when to use `Matrix` in Emgu CV?
  • Installing Hadoop, Java Exception about illegal characters at index 7?
  • What is the “return” in scheme?
  • Different response to non-authenticated users and AJAX calls
  • Which linear programming package should I use for high numbers of constraints and “warm starts” [clo
  • Why is the timeout on a windows udp receive socket always 500ms longer than set by SO_RCVTIMEO?
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Buffer size for converting unsigned long to string
  • KeystoneJS: Relationships in Admin UI not updating
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • using HTMLImports.whenReady not working in chrome
  • Hits per day in Google Big Query
  • coudnt use logback because of log4j
  • How to get Windows thread pool to call class member function?