We've created a branch to do drools-api, so that we don't break trunk
while we are moving around. As mentioned before while we are providing a
new api, we will keep the core/compiler apis as is so not to break
people's code, while they transition to the new api.
http://anonsvn.labs.jboss.com/labs/jbossrules/branches/drools-api-refacto...
http://fisheye.jboss.org/browse/JBossRules/branches/drools-api-refactor-2...
To help you get an idea of what the api now looks like, here is a brief
code snippet from a typical session creation:
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.addPackageFromDrl( reader );
Collection<KnowledgePackage> kpkgs =
kbuilder.getKnowledgePackages();
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( kpkgs );
StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
I'm going for the k prefix to indicate a knowlede variable.
builder/pkgBuilder = kbuilder
pkgs -> kpkgs
ruleBase -> kbase
session -> ksession.
Another decision we made is that we always return a generic collection
for things now, instead of arrays or lists. In general a Collection is
easier for the end user to work with, and it has toArray methods on it
anyway. We didn't use list, as list implies ordered semantics. So
whether it's kbuilder.KnowledgePackages() or kpackage.getRules() or
kpackage.getProcesses() it's always returning a Collection<Class>. I'm
open to other ideas, if people think this can be improved. I did think
about returning just Iterable, to make it even more generic, but figured
that people would want the size./isEmpty methods, we'll have to make the
other mutating methods throw an exception if someone tries to use them.
Don't forget everything is factory/provider based now, so I'd love
someone to start doing a spring set of providers in parallel so we can
make sure I've got it right. Anyone game?
Please do monitor and give feedback, I need to get this wrapped up this
week, so get the feedback to me asap. I'll post an update in a few days,
once the event and process stuff is migrated to the new knowledge api.
As always the Drools team can be found on IRC for real time chat:
http://www.jboss.org/drools/irc.html
Mark