[rules-users] Overriding default evaluators

Barry Kaplan groups1 at memelet.com
Thu Mar 11 11:17:18 EST 2010


That may be how its supposed to work, but it does not.
PackageBuilderConfiguration#buildEvaluatorRegistry selects properties from
'chainedProperties' from the two collections of properties -- the drools
default and the scala extensions -- into a single map. It then adds the
evaluators from that combined map, which is now intermingled so the add
order is undefined.

My workaround was, after the registry is first created but before any drls
are parsed (hack alert):

  def registerScalaEvaluators(kbuilder: KnowledgeBuilder) {
    val kbuilderConfig =
kbuilder.asInstanceOf[KnowledgeBuilderImpl].getPackageBuilder.getPackageBuilderConfiguration
    val chainedProperties = kbuilderConfig.getChainedProperties
    val evaluatorRegistry = kbuilderConfig.getEvaluatorRegistry

    val scalaEntries = new java.util.HashMap[String, String]
    chainedProperties.mapStartsWith(scalaEntries,
EvaluatorOption.PROPERTY_NAME+"scala_", true)
    for (className <- scalaEntries.values) {
      evaluatorRegistry.addEvaluatorDefinition(className)
    }
  }





-- 
View this message in context: http://n3.nabble.com/Overriding-default-evaluators-tp441342p442360.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list