Search code examples
drools

Physical packages and package declaration in DROOLS


What is the use of physical packages and package declaration in Drools.

For eg,

I have a rule, Myrule.drl in the physical package com.mycompany

As I understand the package declaration in drools doesn't depend on the actual physical package the file lies in.

So I can give in Myrule.drl as

package com.sample;

rule "my rule" when then end

Can somebody help me to understand what is the relation between the physical package/folder that the drl file lies and the package declaration in drl file?


Solution

  • Your understanding is correct. There is no relation between the package declaration in your DRL and the place where the DRL file is. All the Java classes generated by either the RHS of the rules or the type declarations are going to be placed by Drools' Compiler in the package defined in the DRL file where they are. This allow you to have rules or declare types with same name but in different packages.

    Hope it helps,