OneStopTesting.com - Testing EBooks, Tutorials, Articles, Jobs, Training Institutes etc.
OneStopGate.com - Gate EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopMBA.com - MBA EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopIAS.com - IAS EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopSAP.com - SAP EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopGRE.com - of GRE EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
Main Classes of the Drools API | Articles | Recent Articles | News Article | Interesting Articles | Technology Articles | Articles On Education | Articles On Corporate | Company Articles | College Articles | Articles on Recession
Home » Articles » Main Classes of the Drools API
Main Classes of the Drools API
Article Posted On Date : Friday, May 22, 2009
Main Classes of the Drools API
Advertisements
HTML clipboard Main Classes of the Drools API At first, Drools was rules oriented. The API was hard to understand, poorly documented, and didn't cover things like event processing properly. In time, Drools became knowledge oriented and much easier to use and implement in projects. Before seeing Drools in action, get to know the main classes of the Drools API (you will recognize these classes later in a real example that will transform the spaghetti code from the introduction): org.drools.builder.KnowledgeBuilder � Transforms a source file into a KnowledgePackage of rule and process definitions that a KnowledgeBase can consume. (Later, you will see how to create a source file, like a .drl or .xls file.) org.drools.KnowledgeBase � A repository of all the application's knowledge definitions; contains rules, processes, functions, type models. org.drools.agent.KnowledgeAgent � Provides automatic loading, caching, and re-loading of resources, and is configured from a properties file. org.drools.runtime.StatefulKnowledgeSession � The most common way to interact with a rule engine. A StatefulKnowledgeSession allows the application to establish an iterative conversation with the engine, where the reasoning process may be triggered multiple times for the same set of data. After the application finishes using the session, though, it must call the dispose() method in order to free the resources and used memory. org.drools.runtime.StatelessKnowledgeSession � A convenience API that wraps a StatefulKonwledgeSession . It removes the need to call dispose() . Stateless sessions do not support iterative insertions and fireAllRules from Java code. The act of calling execute(...) is a single shot method that will internally instantiate a StatefullKnowledgeSession , add all the user data and execute user commands, call fireAllRules , and then call dispose() . These interfaces are sustained by a set of factory classes:
org.drools.builder.KnowledgeBuilderFactory � This factory is used to build the knowledge base definitions that are held collectively in KnowledgePackages . The KnowledgePackage also provides the role of "namespacing." You can supply an optional KnowlegeBuilderConfiguration , which is itself created from this factory. The KnowledgeBuilderConfiguration allows you to set the ClassLoader to be used along with other settings like the default dialect and compiler, as well as many other options. org.drools.io.ResourceFactory � A convenience factory to provide resource implementations for the desired IO resource. org.drools.KnowledgeBaseFactory � This factory will create and return a KnowledgeBase instance. An optional KnowledgeBaseConfiguration can be provided. The KnowlegeBaseConfiguration is also itself created from this factory. org.drools.agent.KnowledgeAgentFactory � The KnowlegeAgent is created by the KnowlegeAgentFactory . The KnowlegeAgent provides automatic loading, caching, and re-loading of resources, and is configured from a properties file. The KnowledgeAgent can update or rebuild this KnowlegeBase as the resources it uses change. The configuration given to the factory determines the strategy for this, but it is typically pull based using regular polling. The above descriptions are available in the official Javadoc for Drools 5 (see bottom of that page for download information).
Amazon.in Widgets