1 |
| package org.drools.semantics.annotation.smf; |
2 |
| |
3 |
| import org.drools.rule.Rule; |
4 |
| import org.drools.rule.RuleSet; |
5 |
| import org.drools.semantics.annotation.model.AnnonatedPojoRuleBuilder; |
6 |
| import org.drools.semantics.base.BaseRuleFactory; |
7 |
| import org.drools.smf.Configuration; |
8 |
| import org.drools.smf.FactoryException; |
9 |
| import org.drools.spi.RuleBaseContext; |
10 |
| |
11 |
| public class SMFAnnotationRuleFactory extends BaseRuleFactory |
12 |
| { |
13 |
| private AnnonatedPojoRuleBuilder builder = new AnnonatedPojoRuleBuilder( ); |
14 |
| |
15 |
3
| public Rule newRule( RuleSet ruleSet, RuleBaseContext context, Configuration config )
|
16 |
| throws FactoryException |
17 |
| { |
18 |
| |
19 |
3
| Rule rule = super.newRule( ruleSet, context, config );
|
20 |
3
| String className = config.getAttribute( "class" );
|
21 |
3
| try
|
22 |
| { |
23 |
3
| Object pojo = Class.forName( className ).newInstance( );
|
24 |
2
| builder.buildRule( rule, pojo );
|
25 |
| } |
26 |
| catch (Exception e) |
27 |
| { |
28 |
1
| throw new FactoryException( e );
|
29 |
| } |
30 |
2
| return rule;
|
31 |
| } |
32 |
| } |