monitor.beginTask( "Loading RETE Tree",
100 );
monitor.subTask( "Loading Rule Base" );
ReteooRuleBase ruleBase = null;
try {
IResource resource = drlEditor.getResource();
ClassLoader newLoader = DroolsBuilder.class.getClassLoader();
if ( resource.getProject().getNature( "org.eclipse.jdt.core.javanature" ) != null ) {
IJavaProject project = JavaCore.create( resource.getProject() );
newLoader = ProjectClassLoader.getProjectClassLoader( project );
}
DRLInfo drlInfo = DroolsEclipsePlugin.getDefault().parseResource(drlEditor, true, true);
if (drlInfo == null) {
throw new Exception( "Could not find DRL info" );
}
if (drlInfo.getBuilderErrors().length > 0) {
throw new Exception( drlInfo.getBuilderErrors().length + " build errors" );
}
if (drlInfo.getParserErrors().size() > 0) {
throw new Exception( drlInfo.getParserErrors().size() + " parser errors" );
}
Package pkg = drlInfo.getPackage();
RuleBaseConfiguration config = new RuleBaseConfiguration();
config.setClassLoader(newLoader);
ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase(RuleBase.RETEOO, config);
if (pkg != null) {
ruleBase.addPackage(pkg);
}
} catch ( Throwable t ) {
DroolsEclipsePlugin.log( t );
throw new Exception( MSG_PARSE_ERROR + " " + t.getMessage());
}