Translation Drools6.2 Help Documentation-11. Integration with Spring

Source: Internet
Author: User
Tags documentation event listener


11. Integration with Spring

Important changes in 11.1.Drools 6.0

With the release of Drools 6.0, the integration of Drools and srping underwent a complete transformation. Here are some very important changes:

Drools the prefix recommended in spring from ' drools: ' Into ' Kie: '

6.0 new top-level tags:

Kie:kmodule

Kie:import (6.2 new)

Kie:releaseid (6.2 new)

The following label is no longer a valid top-level label:

Kie:kbase-kie:module Sub-Tags

Kie:ksession-kie:kbase Sub-Tags

Remove the following 5. X label

Drools:resources

Drools:resource

Drools:grid

Drools:grid-node

11.2. Integration with drools Expert (drools core engine)

In the following chapters we will explain the Kie namespace

11.2.1. Kiemodule

<kie:kmodule> defines the Kiebase collection and associated kiesession. This kmodule tag has a mandatory parameter "id".

Table 11.1. Example

Property

Describe

is required

Id

The Bean's ID is the name of the other bean reference. The spring ID semantics that apply to the standard.

Yes

A kmodule tag can contain only the following sub-nodes Kie:kbase

For more information on Kmodule, refer to drools Expert's kmodule.xml documentation.

11.2.2. kiebase

11.2.2.1<kie:base> attribute Parameters

Table 11.2. Example

Property

Describe

is required

Name

Name of the Kiebase

Yes

Packages

The resource bundle name, with "." Number separation

No

Includes

The name of the kbase being included. Consistent kbase resources will be included.

No

Default

The default Kbase

No

Default

A Boolean value (True/false). The default kbase, if not provided, is assumed to be false.

No

Scope

Prototype | Singleton If not provided, the default is singleton

No

Eventprocessingmode

The event-handling model. The valid options are stream, CLOUD

No

Equalsbehavior

The valid option is identity, equality

No

Declarativeagenda

Valid options are enabled, disabled, true, false

No

The 11.2.2.2kbase tag can only contain the next face label Kie:ksession

11.2.2.3.<kie:kbase> Example

A kmodule tag can contain multiple kbase elements (1..N)

Example 11.1. Kbase definition Examples

<kie:kmodule id= "Sample_module" >
<kie:kbase name= "Kbase1" packages= "Org.drools.spring.sample" >
...
</kie:kbase>
</kie:kmodule>

<bean id= "Kiepostprocessor"
class= "Org.kie.spring.KModuleBeanFactoryPostProcessor"/>

11.2.2.4Spring Bean scope (for kiebase and Kiessession)

When defining a kiebase or kiesession, you need to declare the scope of the bean. For example, to force spring to produce a new instance each time the request is made, you need to declare that the bean's scope property is ' prototype '. Similarly, if you want to return the same instance each time the request is made, you need to declare that the bean's scope property is ' singleton '.

11.2.3. Important Notes

In order to instantiate the Kmodule objects correctly (Kbase and ksession), A bean of type org.kie.spring.KModuleBeanFactoryPostProcessor or org.kie.spring.annotations.KModuleAnnotationPostProcessor needs to be forced to be defined.

Example 11.2. Standard kie-spring post processor bean definition

<bean id= "Kiepostprocessor"
class= "Org.kie.spring.KModuleBeanFactoryPostProcessor"/>

Example 11.3. kie-spring Post processor bean definition when using annotations

<bean id= "Kiepostprocessor"
class= "Org.kie.spring.annotations.KModuleAnnotationPostProcessor"/>

Note: When org.kie.spring.KModuleBeanFactoryPostProcessor or org.kie.spring.annotations.KModuleAnnotationPostProcessor are not defined, KIE-SPRI NG integration will not work.

11.2.4. kiesessions

The <kie:session> element is used to define kiesessions. This tag can also be used to define stateful (org.kie.api.runtime.KieSession) and Stateless (org.kie.api.runtime.StatelessKieSession) sessions.

11.2.4.1<kie:ksession> attribute Parameters

Table 11.3. Example

Property

Describe

is required

Name

Name of the Ksession

Yes

Type

There is a stateful (stateful) non-stateful (stateless) session. If this attribute is not defined, the default is stateful (Stateful)

No

Default

Whether this is the default ksession.

No

Scope

Prototype | Singleton, if not defined by default is singleton (singleton)

No

Clocktype

REALTIME or PSEUDO

No

Listeners-ref

Point to the Event Listener group (see section ' Defining a group of listeners ' 11.2.8.2 below).

No

Example 11.4. Defining ksession

<kie:kmodule id= "Sample-kmodule";
  <kie:kbase name= "Drl_kiesample3" packages= "Drl_kiesample3"
    <kie:ksession name= "Ksession1" type= "stateless"/>
    <kie: Ksession name= "Ksession2"/>
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.