本文整理汇总了Java中org.kie.internal.runtime.StatefulKnowledgeSession类的典型用法代码示例。如果您正苦于以下问题:Java StatefulKnowledgeSession类的具体用法?Java StatefulKnowledgeSession怎么用?Java StatefulKnowledgeSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StatefulKnowledgeSession类属于org.kie.internal.runtime包,在下文中一共展示了StatefulKnowledgeSession类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: findFacts
import org.kie.internal.runtime.StatefulKnowledgeSession; //导入依赖的package包/类
public static Collection<Object> findFacts(StatefulKnowledgeSession session, final String className) {
ObjectFilter filter = new ObjectFilter() {
@Override
public boolean accept(Object object) {
return true;
}
};
Collection<FactHandle> factHandles = session.getFactHandles();
Collection<Object> facts = new ArrayList<Object>();
for (FactHandle handle : factHandles) {
Object fact = session.getObject(handle);
facts.add(fact);
}
return facts;
}
开发者ID:eternnoir,项目名称:RulEST,代码行数:18,代码来源:FactHelper.java
示例2: doTest
import org.kie.internal.runtime.StatefulKnowledgeSession; //导入依赖的package包/类
@Test
public void doTest() {
logger.info("Running test using persistence");
// start our mock DB
JBPMHelper.startH2Server();
JBPMHelper.setupDataSource();
// setting persistence
EntityManagerFactory emf = Persistence
.createEntityManagerFactory("org.jbpm.persistence.jpa");
Environment env = KnowledgeBaseFactory.newEnvironment();
// to load our kbase
KieContainer kc = KieServices.Factory.get().getKieClasspathContainer();
KieBase kb = kc.getKieBase("TestProcessKB");
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
StatefulKnowledgeSession kSession = JPAKnowledgeService
.newStatefulKnowledgeSession(kb, null, env);
kSession.startProcess("HelloWorldProcess");
}
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:19,代码来源:ProcessPersistenceTest.java
示例3: testFactHandleMarshall
import org.kie.internal.runtime.StatefulKnowledgeSession; //导入依赖的package包/类
@Test
public void testFactHandleMarshall() throws JAXBException {
JAXBContext jaxbContext = getJaxbContext();
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
FactHandle fh1 = ksession.insert(new Person("darth", 105));
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
marshaller.marshal(fh1, baos);
assertXMLEqual("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<fact-handle external-form=\"" + fh1.toExternalForm() + "\"/>",
new String(baos.toByteArray()));
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
FactHandle fh2 = (FactHandle)unmarshaller.unmarshal(new StringReader(baos.toString()));
assertEquals(fh1, fh2);
}
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:22,代码来源:JaxbTest.java
示例4: testExecutionResults
import org.kie.internal.runtime.StatefulKnowledgeSession; //导入依赖的package包/类
@Test
public void testExecutionResults() throws JAXBException {
JAXBContext jaxbContext = getJaxbContext();
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
List<Command> commands = new ArrayList<Command>();
commands.add(CommandFactory.newInsert(new Person("darth", 105), "p"));
commands.add(CommandFactory.newFireAllRules());
ExecutionResults res1 = ksession.execute(CommandFactory.newBatchExecution(commands));
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
marshaller.marshal(res1, baos);
// note it's using xsi:type
logger.debug(new String(baos.toByteArray()));
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
ExecutionResults res2 = (ExecutionResults)unmarshaller.unmarshal(new StringReader(baos.toString()));
}
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:25,代码来源:JaxbTest.java
示例5: configure
import org.kie.internal.runtime.StatefulKnowledgeSession; //导入依赖的package包/类
/** configures camel-drools integration and defines 3 routes:
* 1) testing route (connection to drools with JAXB command format)
* 2) unmarshalling route (for unmarshalling command results)
* 3) marshalling route (enables creating commands through API and converting to XML) */
private CamelContext configure(StatefulKnowledgeSession session) throws Exception {
Context context = new JndiContext();
context.bind("ksession", session);
CamelContext camelContext = new DefaultCamelContext(context);
camelContext.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
JaxbDataFormat jdf = new JaxbDataFormat();
jdf.setContextPath("org.kie.camel.testdomain");
jdf.setPrettyPrint(true);
from("direct:test-session").policy(new KiePolicy()).unmarshal(jdf).to("kie://ksession").marshal(jdf);
from("direct:unmarshall").policy(new KiePolicy()).unmarshal(jdf);
from("direct:marshall").policy(new KiePolicy()).marshal(jdf);
}
});
return camelContext;
}
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:25,代码来源:JaxbInsertTest.java
示例6: performInserts
import org.kie.internal.runtime.StatefulKnowledgeSession; //导入依赖的package包/类
@Override
public void performInserts( StatefulKnowledgeSession session )
{
elemA.performInserts( session );
elemB.performInserts( session );
super.performInserts( session );
}
开发者ID:viridian1138,项目名称:SimpleAlgebra_V2,代码行数:8,代码来源:SymbolicMultRevCoeff.java
示例7: performInserts
import org.kie.internal.runtime.StatefulKnowledgeSession; //导入依赖的package包/类
@Override
public void performInserts( StatefulKnowledgeSession session )
{
re.performInserts( session );
im.performInserts( session );
super.performInserts( session );
}
开发者ID:viridian1138,项目名称:SimpleAlgebra_V2,代码行数:8,代码来源:ComplexElem.java
示例8: performInserts
import org.kie.internal.runtime.StatefulKnowledgeSession; //导入依赖的package包/类
@Override
public void performInserts( StatefulKnowledgeSession session )
{
value.performInserts( session );
uncertainty.performInserts( session );
super.performInserts( session );
}
开发者ID:viridian1138,项目名称:SimpleAlgebra_V2,代码行数:8,代码来源:ValueWithUncertaintyElem.java
示例9: insertSessionConfigItems
import org.kie.internal.runtime.StatefulKnowledgeSession; //导入依赖的package包/类
/**
* Inserts standard configuration items into a Drools session.
*
* @param session The session into which to insert the configuration items.
*/
protected void insertSessionConfigItems( final StatefulKnowledgeSession session )
{
session.insert( new DroolsSession( session ) );
if( LoggingConfiguration.LOGGING_ON )
{
session.insert( new LoggingConfiguration() );
}
if( LoggingConfiguration.EVENT_LOGGING_ON )
{
session.addEventListener( generateEventLoggingListener() );
}
}
开发者ID:viridian1138,项目名称:SimpleAlgebra_V2,代码行数:20,代码来源:Elem.java
示例10: testCompareInstances
import org.kie.internal.runtime.StatefulKnowledgeSession; //导入依赖的package包/类
@Test
public void testCompareInstances() throws Exception {
KieBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
config.setOption(EventProcessingOption.STREAM);
KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(config);
KieSessionConfiguration ksconf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
ksconf.setOption(ClockTypeOption.get("pseudo"));
ksconf.setOption(TimerJobFactoryOption.get("trackable"));
StatefulKnowledgeSession ksessionA = knowledgeBase.newStatefulKnowledgeSession(ksconf, null);
StatefulKnowledgeSession ksessionB = knowledgeBase.newStatefulKnowledgeSession(ksconf, null);
Assert.assertTrue(KieGimcrack.class.getSimpleName() + " is broken!", kieGimcrack.compareInstances(ksessionA, ksessionB));
}
开发者ID:mrietveld,项目名称:gimcrack,代码行数:16,代码来源:TestMarshallingUtilsTest.java
示例11: main
import org.kie.internal.runtime.StatefulKnowledgeSession; //导入依赖的package包/类
public static void main(String[] args) {
//rule,rule2可以放在数据库中,有个唯一code和他们对于,代码要执行规则的时候,根据code从数据库获取出来就OK了,这样自己开发的规则管理系统那边对数据库里的规则进行维护就行了
String rule = "package com.neo.drools\r\n";
rule += "import com.neo.drools.model.Message;\r\n";
rule += "rule \"rule1\"\r\n";
rule += "\twhen\r\n";
rule += "Message( status == 1, myMessage : msg )";
rule += "\tthen\r\n";
rule += "\t\tSystem.out.println( 1+\":\"+myMessage );\r\n";
rule += "end\r\n";
String rule2 = "package com.neo.drools\r\n";
rule += "import com.neo.drools.model.Message;\r\n";
rule += "rule \"rule2\"\r\n";
rule += "\twhen\r\n";
rule += "Message( status == 2, myMessage : msg )";
rule += "\tthen\r\n";
rule += "\t\tSystem.out.println( 2+\":\"+myMessage );\r\n";
rule += "end\r\n";
StatefulKnowledgeSession kSession = null;
try {
KnowledgeBuilder kb = KnowledgeBuilderFactory.newKnowledgeBuilder();
//装入规则,可以装入多个
kb.add(ResourceFactory.newByteArrayResource(rule.getBytes("utf-8")), ResourceType.DRL);
kb.add(ResourceFactory.newByteArrayResource(rule2.getBytes("utf-8")), ResourceType.DRL);
KnowledgeBuilderErrors errors = kb.getErrors();
for (KnowledgeBuilderError error : errors) {
System.out.println(error);
}
KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase();
kBase.addKnowledgePackages(kb.getKnowledgePackages());
kSession = kBase.newStatefulKnowledgeSession();
Message message1 = new Message();
message1.setStatus(1);
message1.setMsg("hello world!");
Message message2 = new Message();
message2.setStatus(2);
message2.setMsg("hi world!");
kSession.insert(message1);
kSession.insert(message2);
kSession.fireAllRules();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} finally {
if (kSession != null)
kSession.dispose();
}
}
开发者ID:ityouknow,项目名称:drools-examples,代码行数:63,代码来源:DdLoadTest.java
示例12: getSession
import org.kie.internal.runtime.StatefulKnowledgeSession; //导入依赖的package包/类
public StatefulKnowledgeSession getSession(){
return this.ksession;
}
开发者ID:eternnoir,项目名称:RulEST,代码行数:4,代码来源:KnowledgeManager.java
示例13: performInserts
import org.kie.internal.runtime.StatefulKnowledgeSession; //导入依赖的package包/类
@Override
public void performInserts( StatefulKnowledgeSession session )
{
elemA.performInserts( session );
super.performInserts( session );
}
开发者ID:viridian1138,项目名称:SimpleAlgebra_V2,代码行数:7,代码来源:SymbolicReverseLeft.java
示例14: performInserts
import org.kie.internal.runtime.StatefulKnowledgeSession; //导入依赖的package包/类
@Override
public void performInserts( StatefulKnowledgeSession session )
{
elem.performInserts( session );
super.performInserts( session );
}
开发者ID:viridian1138,项目名称:SimpleAlgebra_V2,代码行数:7,代码来源:SymbolicConjugateRight.java
示例15: performInserts
import org.kie.internal.runtime.StatefulKnowledgeSession; //导入依赖的package包/类
@Override
public void performInserts( StatefulKnowledgeSession session )
{
tensorWithRespectTo.performInserts( session );
super.performInserts( session );
}
开发者ID:viridian1138,项目名称:SimpleAlgebra_V2,代码行数:7,代码来源:MaterialDerivativeFactory.java
示例16: performInserts
import org.kie.internal.runtime.StatefulKnowledgeSession; //导入依赖的package包/类
@Override
public void performInserts( StatefulKnowledgeSession session )
{
elem.performInserts(session);
super.performInserts( session );
}
开发者ID:viridian1138,项目名称:SimpleAlgebra_V2,代码行数:7,代码来源:SymbolicReduction.java
注:本文中的org.kie.internal.runtime.StatefulKnowledgeSession类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论