-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
DecisionTableFactory.java
41 lines (31 loc) · 1.42 KB
/
DecisionTableFactory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package org.drools.compiler.compiler;
import java.io.InputStream;
import org.kie.internal.builder.DecisionTableConfiguration;
import org.kie.internal.utils.ServiceRegistryImpl;
public class DecisionTableFactory {
private static final String PROVIDER_CLASS = "org.drools.decisiontable.DecisionTableProviderImpl";
private static DecisionTableProvider provider;
public static String loadFromInputStream(InputStream is, DecisionTableConfiguration configuration) {
return getDecisionTableProvider().loadFromInputStream( is, configuration );
}
public static synchronized void setDecisionTableProvider(DecisionTableProvider provider) {
DecisionTableFactory.provider = provider;
}
public static synchronized DecisionTableProvider getDecisionTableProvider() {
if ( provider == null ) {
loadProvider();
}
return provider;
}
private static void loadProvider() {
ServiceRegistryImpl.getInstance().addDefault( DecisionTableProvider.class, PROVIDER_CLASS );
setDecisionTableProvider(ServiceRegistryImpl.getInstance().get( DecisionTableProvider.class ) );
}
public static synchronized void loadProvider(ClassLoader cl) {
if (provider == null) {
try {
provider = (DecisionTableProvider)Class.forName(PROVIDER_CLASS, true, cl).newInstance();
} catch (Exception e) { }
}
}
}