I was looking at this example with the KieBase defined as follows:
<?xml version="1.0" encoding="UTF-8"?>
<kmodule
xmlns="http://jboss.org/kie/6.0.0/kmodule">
<kbase name="kbase1">
<ksession name="ksession1"/>
</kbase>
</kmodule>
I was expecting the drl file to be in src/main/resources/kbase1. I made this assumption because reading the book Mastering JBoss Drools 6, it was indicated that the kbase name is where the drl file should be placed. The sentence reads below:
'Notice that the name attribute of the KieBase is the same as the directory structure that we are using under /src/test/resources/ directory, where the rules are stored. '
However, in the example, the drl file in placed in the following directory: src/main/resources/namedkiesession.
Here is the file: HAL1.drl
package org.drools.example.api.namedkiesession
import org.drools.example.api.namedkiesession.Message
global java.io.PrintStream out
rule "rule 1" salience 10 when
m : Message( )
then
out.println( m.getName() + ": " + m.getText() );
end
rule "rule 2" when
Message( text == "Hello, HAL. Do you read me, HAL?" )
then
insert( new Message("HAL", "Dave. I read you." ) );
end
How does this work if the KieBase name is not where the actual drl file is stored? The full source code is here:
https://github.com/kiegroup/drools/blob/6.0.x/drools-examples-api/pom.xml