1 |
| package org.drools.semantics.java; |
2 |
| |
3 |
| import java.io.IOException; |
4 |
| |
5 |
| import org.codehaus.janino.Java.CompileException; |
6 |
| import org.codehaus.janino.Parser.ParseException; |
7 |
| import org.codehaus.janino.Scanner.ScanException; |
8 |
| import org.drools.rule.RuleSet; |
9 |
| import org.drools.smf.Configuration; |
10 |
| import org.drools.smf.FactoryException; |
11 |
| import org.drools.smf.FunctionsFactory; |
12 |
| import org.drools.spi.Functions; |
13 |
| import org.drools.spi.RuleBaseContext; |
14 |
| |
15 |
| public class JavaFunctionsFactory |
16 |
| implements |
17 |
| FunctionsFactory |
18 |
| { |
19 |
| |
20 |
0
| public Functions newFunctions(RuleSet ruleSet,
|
21 |
| RuleBaseContext context, |
22 |
| Configuration config) throws FactoryException |
23 |
| { |
24 |
0
| try
|
25 |
| { |
26 |
0
| Integer id = (Integer) context.get( "java-functions-id" );
|
27 |
0
| if ( id == null )
|
28 |
| { |
29 |
0
| id = new Integer( 0 );
|
30 |
| } |
31 |
0
| context.put( "java-functions-id",
|
32 |
| new Integer( id.intValue( ) + 1 ) ); |
33 |
| |
34 |
0
| return new JavaFunctions( ruleSet,
|
35 |
| id.intValue( ), |
36 |
| config.getText( ) ); |
37 |
| } |
38 |
| catch ( Exception e ) |
39 |
| { |
40 |
0
| throw new FactoryException( e );
|
41 |
| } |
42 |
| |
43 |
| } |
44 |
| } |