1 |
| package org.drools.semantics.java; |
2 |
| |
3 |
| import org.drools.rule.Rule; |
4 |
| import org.drools.smf.Configuration; |
5 |
| import org.drools.smf.ConsequenceFactory; |
6 |
| import org.drools.smf.FactoryException; |
7 |
| import org.drools.spi.Consequence; |
8 |
| import org.drools.spi.RuleBaseContext; |
9 |
| |
10 |
| public class JavaBlockConsequenceFactory |
11 |
| implements |
12 |
| ConsequenceFactory |
13 |
| { |
14 |
82
| public Consequence newConsequence( Rule rule,
|
15 |
| RuleBaseContext context, |
16 |
| Configuration config) throws FactoryException |
17 |
| { |
18 |
82
| try
|
19 |
| { |
20 |
82
| Integer id = (Integer) context.get( "java-consequence-id" );
|
21 |
82
| if (id == null)
|
22 |
| { |
23 |
65
| id = new Integer( 0 );
|
24 |
| } |
25 |
82
| context.put("java-consequence-id", new Integer(id.intValue() + 1));
|
26 |
| |
27 |
82
| return new JavaBlockConsequence( rule,
|
28 |
| id.intValue(), |
29 |
| config.getText( ) ); |
30 |
| |
31 |
| } |
32 |
| catch ( Exception e ) |
33 |
| { |
34 |
0
| throw new FactoryException( e );
|
35 |
| } |
36 |
| } |
37 |
| } |