Collection<EntryPointNode> entryPointNodes = sessionImpl.getKnowledgeBase().getRete().getEntryPointNodes().values();
public ClassLoader getClassLoader(CommandExecutor exec) { ClassLoader cl = null; if (exec instanceof StatefulKnowledgeSessionImpl) { cl = ((StatefulKnowledgeSessionImpl)exec).getKnowledgeBase().getRootClassLoader(); } else if (exec instanceof StatelessKnowledgeSessionImpl) { cl = ((StatelessKnowledgeSessionImpl)exec).getKnowledgeBase().getRootClassLoader(); } else if (exec instanceof CommandBasedStatefulKnowledgeSession) { cl = ((InternalKnowledgeBase)((CommandBasedStatefulKnowledgeSession)exec).getKieBase()).getRootClassLoader(); } return cl; }
@Test public void testInsertObjectWithDeclaredFactAndQuery() throws Exception { String str = ""; str += "package org.foo \n"; str += "declare Whee \n\ttype: String\n\tprice: Integer\n\toldPrice: Integer\nend\n"; str += "rule rule1 \n"; str += " when \n"; str += " $c : Whee(price < 30) \n"; str += " then \n"; str += " $c.setPrice( $c.getPrice() + 5 ); \n update($c);\n"; str += "end\n"; str += "query results\n"; str += " w: Whee(price > 0)"; str += "end\n"; KieSession ksession = getKieSession(ResourceFactory.newByteArrayResource(str.getBytes())); setExec(ksession); ClassLoader cl = ((StatefulKnowledgeSessionImpl)ksession).getKnowledgeBase().getRootClassLoader(); ClassLoader orig = null; try { orig = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(cl); String outXml = execContent("testInsertObjectWithDeclaredFactAndQuery.in.1"); ExecutionResults results = unmarshalOutXml(outXml, ExecutionResults.class); FactHandle fh = (FactHandle)results.getFactHandle("outStilton"); outXml = execContent("testInsertObjectWithDeclaredFactAndQuery.in.2"); assertXMLEqual(getContent("testInsertObjectWithDeclaredFactAndQuery.expected.1", fh.toExternalForm()), outXml); } finally { Thread.currentThread().setContextClassLoader(orig); } }
String outXml = null; ClassLoader orig = null; ClassLoader cl = ((StatefulKnowledgeSessionImpl)ksession).getKnowledgeBase().getRootClassLoader(); try { orig = Thread.currentThread().getContextClassLoader();
ClassLoader cl = ((StatefulKnowledgeSessionImpl)ksession).getKnowledgeBase().getRootClassLoader(); XStream xstream = BatchExecutionHelper.newXStreamMarshaller(); xstream.setClassLoader(cl);
Collection<EntryPointNode> entryPointNodes = sessionImpl.getKnowledgeBase().getRete().getEntryPointNodes().values();