How to deploy Drools Flow and rules by my web application

一世执手 提交于 2019-12-21 02:59:09

问题


I've just now started my new project. My project manager said that Drools is the new technology and we will include drools flow and rules and will integrate our web application with it.

How does one integrate Drools flows and rules to within a web-application?


回答1:


It depends on what technologies you use. If, for example, you use Java+Maven+Spring, you first need to include Drools dependencies:

    <dependency>
        <groupId>org.drools</groupId>
        <artifactId>drools-core</artifactId>
        <version>${drools.version}</version>
    </dependency>
    <dependency>
        <groupId>org.drools</groupId>
        <artifactId>drools-compiler</artifactId>
        <version>${drools.version}</version>
    </dependency>
    <dependency>
        <groupId>org.drools</groupId>
        <artifactId>drools-spring</artifactId>
        <version>${drools.version}</version>
    </dependency>

Define the application context:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:drools="http://drools.org/schema/drools-spring"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
            http://drools.org/schema/drools-spring http://drools.org/schema/drools-spring.xsd">


    <drools:kbase id="kbase1">
        <drools:resources>
            <drools:resource source="classpath:Sample.drl" />
        </drools:resources>
    </drools:kbase>

    <drools:ksession id="ksession1" type="stateful" kbase="kbase1" />

</beans>

Then you can inject ksession1 as a bean.



来源:https://stackoverflow.com/questions/5141301/how-to-deploy-drools-flow-and-rules-by-my-web-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!