I'm in the process of doing the final changes to drools-api. Having done
the spring work, not yet committed, I liked their resource framework, so
decided to copy this for Drools. So we now have:
KnowledgeBuilder.add( Resource, KnowledgeType, ResourceConfiguration );
Where we support the following Resource sources:
FileSystemResource, ClassPathResource, UrlResource ByteArrayResource,
ReaderResource, EncodedResource and InputStreamResource
In use it'll look like:
kbuilder.add( ResourceFactory.newClassPathResource( "somefile.drl",
classLoader ), KnowledgeType.DRL )
I do not yet do knowledge type inference from the .ext - I think I'll
leave that till after 5.0, if I do it at all.
So kbuilder.addResource( URL, ...) and kbuilder.addResource( Reader, ...
) from M3 no longer exist and are as above.
What I'm adding now is the ability to provide an xml file that is a
configuration of resources to load. The term Configuration is
overloaded, and we use this more to provide the directives for
knowledgebuilder and knowledgebase. So I was thinking Composition and
Part - for Knowledge Composition and Knowledge Part, from
dictionary.com
on "composition":
"the act of combining parts or elements to form a whole."
"the composition of “aircraft” from “air” and “craft.”
My reasoning for this is a composition will contain rules, processes,
decision tables, dsls etc. "The KnowlegeBase is a composition of
Knowlege Parts".
The XML would look like:
<composition>
<part resource="classpath://........" type="DRL">
<part resource="file://........">
<decisiontable-configuration type="XLS" worksheet-name="blah"
/>
</part>
</composition>
I have not added a resource type attribute, as we will assume it must
start with protocol. classpath will use ClassPathResource, file will use
FileSystemResource and anything will be a UrlResource. This would be a
special KnowlegeType. I may later make the type optional, once we can
infer the type from the .ext.
kbuilder.addResource( ResourceFactory.newFileResource(
"/data/my-knowledge.xml" ), KnowledgeType.COMPOSITION );
What do people think?
Mark