throw new IOException(CoreMessages.cannotLoadFromClasspath(rulesFile).getMessage());
}
kbuilder.add(ResourceFactory.newInputStreamResource(is), ResourceType.DRL);
if (kbuilder.hasErrors())
{
throw new ConfigurationException(MessageFactory.createStaticMessage("Errors while parsing ruleset defined in file " + rulesFile + " : " + kbuilder.getErrors().toString()));
}
KnowledgeBaseConfiguration conf =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration(null, Thread.currentThread().getContextClassLoader());
if (rules.getConfiguration() != null)
{
conf.setOption((KnowledgeBaseOption) rules.getConfiguration());
}
else if (rules.isCepMode())
{
conf.setOption(EventProcessingOption.STREAM);
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(conf);
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
if (rules.isStateless())
{
// TODO Add support for stateless sessions, for now we assume all sessions are stateful.
throw new ConfigurationException(MessageFactory.createStaticMessage("Stateless sessions are not yet supported"));
}
StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();
KnowledgeRuntimeLogger droolsLogger = new WorkingMemorySLF4JLogger(session, logger);
if (messageService == null)
{
throw new ConfigurationException(MessageFactory.createStaticMessage("MessageService is not available"));
}
session.setGlobal("mule", messageService);
session.fireAllRules();