1 |
| package org.drools.semantics.annotation.spring; |
2 |
| |
3 |
| import java.util.Set; |
4 |
| |
5 |
| import org.drools.rule.Rule; |
6 |
| import org.drools.rule.RuleSet; |
7 |
| import org.springframework.beans.factory.FactoryBean; |
8 |
| import org.springframework.beans.factory.InitializingBean; |
9 |
| |
10 |
| public class SpringAnnotationRuleSetFactory implements FactoryBean, InitializingBean |
11 |
| { |
12 |
| private String name; |
13 |
| private Set<Rule> rules; |
14 |
| |
15 |
2
| public void setName( String name )
|
16 |
| { |
17 |
2
| this.name = name;
|
18 |
| } |
19 |
| |
20 |
2
| public void setRules( Set<Rule> rules )
|
21 |
| { |
22 |
2
| this.rules = rules;
|
23 |
| } |
24 |
| |
25 |
3
| public void afterPropertiesSet( ) throws Exception
|
26 |
| { |
27 |
3
| if (name == null)
|
28 |
| { |
29 |
1
| throw new IllegalArgumentException( "RuleSet property 'name' must be specified." );
|
30 |
| } |
31 |
| } |
32 |
| |
33 |
2
| public Object getObject( ) throws Exception
|
34 |
| { |
35 |
2
| RuleSet ruleSet = new RuleSet( name );
|
36 |
2
| for (Rule rule : rules)
|
37 |
| { |
38 |
4
| ruleSet.addRule( rule );
|
39 |
| } |
40 |
2
| return ruleSet;
|
41 |
| } |
42 |
| |
43 |
1
| public Class getObjectType( )
|
44 |
| { |
45 |
1
| return RuleSet.class;
|
46 |
| } |
47 |
| |
48 |
1
| public boolean isSingleton( )
|
49 |
| { |
50 |
1
| return false;
|
51 |
| } |
52 |
| } |