0

Objective:

I am trying to integrate Drools 6.0 with my application using Drools-Spring integration features.

Issues faced:

  1. I need to define the knowledge bases in a spring context XML and make the package names to be dynamically passed into the knowledge bases using Spring Expression Language when the Spring container is created at the start-up. But, the package names are not being injected into the knowledge base when it is created by Drools framework.

  2. If I define the package names and hard-code them into the "packages" property of the kbase tag, it works.

  3. Could you please let me know if there is a way to make the package names being passed dynamically passed into the "packages" property of the kbase tag. This is because my client application would supply the packages names when the knowledge bases are setup and I am trying not to hard-code these.

XML Configuration:

<bean id="packageRepository" class="test.PackageRepository">
 <property name="packages" value="packageA,packageB"/>
</bean>

<kie:kmodule id="kmodule">
  <kie:kbase name="testKnowledgeBase" packages="#{packageRepository.packages}"/>
</kie:kmodule>
sunsin1985
  • 2,437
  • 5
  • 22
  • 27
  • What do you expect from specific package names in the DRL files? The only reason (AFAIK) to have certain package names is to simplify imports of Java classes from the same package, i.e., omitting the import altogether. – laune May 02 '14 at 17:06
  • As per the Drools documentation, we need to supply a package name which is basically a folder name when we create an instance of KnowledgeBase. A KnowledgeBase would then be used to create KnowledgeSessions to execute the DRL files only in the package (folder) name from which the KnowledgeBase was created. I am trying to make this packageName supplied to the KnowledgeBase dynamic based on a configuration. – sunsin1985 May 02 '14 at 17:29

0 Answers0