drools introduction
TRANSCRIPT
- L A K S H M I P R A T Y U S H A K U P P A
DROOLS
1
2
CONTEXT
• Java enterprise level application can be split into three parts −• User Interface• Service layer• Business layer
• Drool is a standard way to handle the business layer.• It is a collection of tools that separates logic and
data within business processes.
3
WHAT IS DROOLS ?
• Drools is a Business Logic integration Platform (BLiP).• It is written in Java.• It is an open source project that is backed by
JBoss and Red Hat, Inc.
4
ADVANTAGES
• Declarative Programming• Rules are written in less complex language.
• Speed and Scalability• One can add new rules without having to modify the
existing rules and these are very quickly processed.• Centralization of Knowledge• By using Rules, you create a repository of knowledge (a
knowledge base) which is executable. • Tool Integration• Tools such as Eclipse provide ways to edit and manage
rules and get immediate feedback, validation, and content assistance.
5
KNOWLEDGE BASE
• Interface that manages a collection of rules, processes, and internal type.• The main purpose of Knowledge Base is to store
and reuse them because their creation is expensive.• Knowledge Base provides methods for creating
knowledge sessions.
6
KNOWLEDGE SESSIONS
• It is the main interface for interacting with the Drools Engine. • The knowledge session can be of two types:• Stateless Knowledge Session• Stateful Knowledge Session.
7
STATELESS KNOWLEDGE SESSION• It is a stateless session that forms the simplest use case,
not utilizing inference.• It can be called like a function, passing it some data and
then receiving some results back.• Examples:• Validation• Is this person eligible for a mortgage?
• Calculation• Compute a mortgage premium.
• Routing and Filtering• Filter incoming messages, such as emails, into folders.• Send incoming messages to a destination
8
STATEFUL KNOWLEDGE SESSION
• Stateful sessions are longer lived and allow iterative changes over time. • Some common use cases for Stateful sessions
include:• Monitoring• Stock market monitoring and analysis for semi-automatic buying.
• Diagnostics• Fault finding, medical diagnostics
• Logistics• Parcel tracking and delivery provisioning
9
KNOWLEDGE BUILDER
• The interface is responsible for building a KnowledgePackage from knowledge definitions (rules, processes, types).
10
EXAMPLE
The objects that the rule file accesses should be added to the session.
A kmodule.xml file defining in a declaratively way the KieBases and KieSessions that can be created from it.
11
RULE FILE