本文整理匯總了Java中org.kie.api.KieServices.newKieClasspathContainer方法的典型用法代碼示例。如果您正苦於以下問題:Java KieServices.newKieClasspathContainer方法的具體用法?Java KieServices.newKieClasspathContainer怎麽用?Java KieServices.newKieClasspathContainer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.kie.api.KieServices
的用法示例。
在下文中一共展示了KieServices.newKieClasspathContainer方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: helloDroolsTest
import org.kie.api.KieServices; //導入方法依賴的package包/類
@Test
public void helloDroolsTest() {
System.out.println( "Bootstrapping the Rule Engine ..." );
// Bootstrapping a Rule Engine Session
KieServices ks = KieServices.Factory.get();
KieContainer kContainer = ks.newKieClasspathContainer();
KieBase kBase = kContainer.getKieBase( "confKBase" );
KieSession kSession = kBase.newKieSession();
ArrayList<String> errors = new ArrayList<String>();
kSession.setGlobal( "errors", errors );
House house = new House( "Maniac Mansion" );
kSession.insert( house );
int fired = kSession.fireAllRules();
assertEquals( 1, fired );
assertEquals( 1, errors.size() );
assertThat( errors, Matchers.contains( "Warn: Your House ( " + house.getName() + " ) has no Rooms" ) );
kSession.dispose();
}
示例2: start
import org.kie.api.KieServices; //導入方法依賴的package包/類
@Override
public void start(BundleContext context) throws Exception {
KieServices ks = KieServices.Factory.get();
KieContainer kcont = ks.newKieClasspathContainer(getClass()
.getClassLoader());
KieBase kbase = kcont.getKieBase("SimpleRuleKBase");
logger.info("KieSession newKieSession.");
ksession = kbase.newKieSession();
ksession.addEventListener(new DebugAgendaEventListener());
ksession.addEventListener(new DebugRuleRuntimeEventListener());
Customer customer = customerPoor();
logger.info("KieSession fireAllRules. {}", customer);
FactHandle fh = ksession.insert(customer);
ksession.fireAllRules();
ksession.delete(fh);
logger.info("After rule {}", customer);
customer = customerNormal();
logger.info("KieSession fireAllRules. {}", customer);
fh = ksession.insert(customer);
ksession.fireAllRules();
ksession.delete(fh);
logger.info("After rule {}", customer);
customer = customerVip();
logger.info("KieSession fireAllRules. {}", customer);
fh = ksession.insert(customer);
ksession.fireAllRules();
ksession.delete(fh);
logger.info("After rule {}", customer);
}
示例3: beforeClass
import org.kie.api.KieServices; //導入方法依賴的package包/類
/**
* beforeClass.
*/
@BeforeClass
public static void beforeClass() {
KieServices ks = KieServices.Factory.get();
KieContainer kcont = ks.newKieClasspathContainer();
KieBase kbase = kcont.getKieBase("SimpleRuleKBase");
ksession = kbase.newKieSession();
ksession.addEventListener(new DebugAgendaEventListener());
ksession.addEventListener(new DebugRuleRuntimeEventListener());
}
示例4: init
import org.kie.api.KieServices; //導入方法依賴的package包/類
@Override
public void init(ServletConfig config) throws ServletException {
tempDir = new File(System.getProperty("java.io.tmpdir"));
CamelHandler handler = CamelHandlerFactory.fileHandler();
KieServices kieServices = KieServices.Factory.get();
KieContainer kieContainer = kieServices.newKieClasspathContainer(this.getClass().getClassLoader());
kieSession = kieContainer.newKieSession("camel-workitem-ksession");
kieSession.getWorkItemManager().registerWorkItemHandler("CamelFile", handler);
}