Is it possible to have several DSL resources files in a knowledge base on BRMS 5.x?
Environment
JBoss Enterprise BRMS 5.x
Issue
How can we load multiple DSL resources files in my knowledge base on BRMS 5.x?
Resolution
It's possible to have multiple domain-specific language (DSL) files within a set of Rules and load them on your current Knowledge Base.
In order to manage this issue, JBoss Enterprise BRMS provides the org.drools.builder.KnowledgeBuilder interface, which is able to add additional resources on a Knowledge Base such as DSL and DSLR files as well. Example:
public static final void main(String[] args) {
try {
// creates a KnowledgeBuilder class
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
// adding multiple DSL resources
kbuilder.add(ResourceFactory.newClassPathResource(<DSL_FILE_1>), ResourceType.DSL);
kbuilder.add(ResourceFactory.newClassPathResource(<DSLR_FILE_1>), ResourceType.DSLR);
// load up the knowledge base within all resources
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
....
} catch (Throwable t) {
t.printStackTrace();
}
}
Furthermore for additional information regarding the DSL Editor , please consult the DSL Editor Section from Drools_Tools_Reference_Guide.
Finally, you can also check the brms5_multiple_dsl_files_sample.tar attachment for a more complete and detailed sample implementation.
Attachments
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments