RuleFlowProcessFactory factory =
RuleFlowProcessFactory.createProcess("org.drools.process");
factory
// header
.name("My process").packageName("org.drools")
// nodes
.startNode(1).name("Start").done()
.actionNode(2).name("Action")
.action("java", "System.out.println(\"Hello World\");").done()
.endNode(3).name("End").done()
// connections
.connection(1, 2)
.connection(2, 3);
RuleFlowProcess process = factory.validate().getProcess();
Many thanks go out to salaboy for doing a large part of the work and adding the different factories to create the various types of nodes supported in RuleFlow. This also shows how easy it is to contribute to the Drools project if you want to: come join us at our #drools irc channel, describe what you want to do and we'll help you as much as possible and welcome contributions !
Kris

I wouldn't call this api fluent just because it's chainable. A fluent api should read more like english.
ReplyDeleteI believe a "connectedTo" operation to connect nodes during creation instead of an explicit connection(id,id) would help a lot. In the example it could/should replace done() - nodes with multiples in/out are probably a problem.
True, we didn't really try hard to make readable English sentences. But this api is still targeted towards normal java developers, so then the question would be: what would the people who use this api prefer?
ReplyDeleteRegarding the connections, we tried to find a simple solution that supports all use cases. But the good thing is we could support multiple ways. Could you give a more concrete example on how you would like it to work?
Thanks for sharing the best information and suggestions, I love your content, and they are very nice and very useful to us. If you are looking for the best Bing Search Api, then visit SERP House. I appreciate the work you have put into this.
ReplyDeleteI was just browsing through the internet looking for some information and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject. Bookmarked this page, will come back for more. verfahrensdokumentation
ReplyDelete