当前位置: 首页>>代码示例>>Java>>正文


Java ResourceFactory类代码示例

本文整理汇总了Java中org.kie.internal.io.ResourceFactory的典型用法代码示例。如果您正苦于以下问题:Java ResourceFactory类的具体用法?Java ResourceFactory怎么用?Java ResourceFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ResourceFactory类属于org.kie.internal.io包,在下文中一共展示了ResourceFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addRule

import org.kie.internal.io.ResourceFactory; //导入依赖的package包/类
/**
 * 单一规则上线
 *
 * @param packageName
 * @param ruleName
 */
public void addRule(String packageName, String ruleName) {
    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    kbuilder.add(ResourceFactory.newClassPathResource(packageName + "/" + ruleName + ".drl"), ResourceType.DRL);
    if (kbuilder.hasErrors()) {
        logger.error("Unable to compile drl. " + packageName + ruleName + ".drl");
        return;
    } else {
        if (kbase.getRule(packageName, ruleName) != null) {
            logger.info("update rule: " + packageName + "." + ruleName);
        } else {
            logger.info("add rule: " + packageName + "." + ruleName);
        }
    }

    kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
    kieSession = kbase.newStatelessKieSession();
    setGlobal();
    printRules();
}
 
开发者ID:ysrc,项目名称:Liudao,代码行数:26,代码来源:KieService.java

示例2: addResource

import org.kie.internal.io.ResourceFactory; //导入依赖的package包/类
public void addResource(Resource r){
    switch (r.getPathType()) {
        case CLASSPATH:
            this.kBuilder.add(ResourceFactory.newClassPathResource(r.getPath()),r.getType());
            break;
        case FILE:
            this.kBuilder.add(ResourceFactory.newFileResource(r.getPath()),r.getType());
            break;
        case URL:
            this.kBuilder.add(ResourceFactory.newUrlResource(r.getPath()),r.getType());
            break;
        default:
            throw new RuntimeException("not support pathtype");
    }
    if(this.kBuilder.hasErrors()){
        throw new RuntimeException(this.kBuilder.getErrors().toString());
    }
}
 
开发者ID:eternnoir,项目名称:RulEST,代码行数:19,代码来源:KnowledgeManager.java

示例3: getRuntimeManager

import org.kie.internal.io.ResourceFactory; //导入依赖的package包/类
/**
 * 
 * Create the runtime manager for the process in the classpath
 * 
 * @return
 */
public static RuntimeManager getRuntimeManager() {
	setupPoolingDataSource();
	EntityManagerFactory emf = Persistence
			.createEntityManagerFactory("org.jbpm.persistence.jpa");
	RuntimeEnvironment env = RuntimeEnvironmentBuilder.Factory
			.get()
			.newDefaultBuilder()
			.entityManagerFactory(emf)
			.addAsset(
					ResourceFactory
							.newClassPathResource("helloProcess.bpmn2"),
					ResourceType.BPMN2).get();
	RuntimeManager manager = RuntimeManagerFactory.Factory.get()
			.newSingletonRuntimeManager(env);
	return manager;
}
 
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:23,代码来源:Util.java

示例4: testCallService

import org.kie.internal.io.ResourceFactory; //导入依赖的package包/类
@Test
public void testCallService() throws Exception {
    final Holder holder = new Holder();
    serviceDomain.registerService(new QName("CallService"), new InOnlyService(), new BaseHandler(){
        public void handleMessage(Exchange exchange) throws HandlerException {
            holder.setValue("message handled");
        }
    });
    serviceDomain.registerServiceReference(new QName("CallService"), new InOnlyService());
    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    kbuilder.add(ResourceFactory.newClassPathResource(CALL_SERVICE_BPMN), ResourceType.BPMN2);
    KieBase kbase = kbuilder.newKnowledgeBase();
    KieSession ksession = kbase.newKieSession();
    SwitchYardServiceTaskHandler ssth = new SwitchYardServiceTaskHandler();
    ssth.setProcessRuntime(ksession);
    ssth.setInvoker(new SwitchYardServiceInvoker(serviceDomain));
    ksession.getWorkItemManager().registerWorkItemHandler(SWITCHYARD_SERVICE_TASK, ssth);
    ksession.startProcess("CallService");
    ksession.halt();
    ksession.dispose();
    Assert.assertEquals("message handled", holder.getValue());
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:23,代码来源:BPMServiceTests.java

示例5: runFaultBoundaryProcess

import org.kie.internal.io.ResourceFactory; //导入依赖的package包/类
private void runFaultBoundaryProcess(final boolean bomb) throws Exception {
    serviceDomain.registerService(new QName("TestService"), new InOnlyService(), new BaseHandler(){
        public void handleMessage(Exchange exchange) throws HandlerException {
            if (bomb) {
                throw new HandlerException("BOOM!");
            }
        }
    });
    serviceDomain.registerServiceReference(new QName("TestService"), new InOutService());
    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    kbuilder.add(ResourceFactory.newClassPathResource(FAULT_BOUNDARY_PROCESS_BPMN), ResourceType.BPMN2);
    KieBase kbase = kbuilder.newKnowledgeBase();
    KieSession ksession = kbase.newKieSession();
    SwitchYardServiceTaskHandler ssth = new SwitchYardServiceTaskHandler();
    ssth.setProcessRuntime(ksession);
    ssth.setInvoker(new SwitchYardServiceInvoker(serviceDomain));
    ksession.getWorkItemManager().registerWorkItemHandler(SWITCHYARD_SERVICE_TASK, ssth);
    WorkflowProcessInstance wpi = (WorkflowProcessInstance)ksession.startProcess("FaultBoundaryProcess");
    String output = (String)wpi.getVariable("TestOutput");
    Assert.assertEquals(bomb ? "Failure" : "Success", output);
    ksession.halt();
    ksession.dispose();
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:24,代码来源:BPMServiceTests.java

示例6: testCallService

import org.kie.internal.io.ResourceFactory; //导入依赖的package包/类
@Test
public void testCallService() throws Exception {
    final Holder holder = new Holder();
    serviceDomain.registerService(new QName("CallService"), new InOnlyService(), new BaseHandler() {
        public void handleMessage(Exchange exchange) throws HandlerException {
            holder.setValue("message handled");
        }
    });
    serviceDomain.registerServiceReference(new QName("CallService"), new InOnlyService());
    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    kbuilder.add(ResourceFactory.newClassPathResource(CALL_SERVICE_BPMN), ResourceType.BPMN2);
    KieBase kbase = kbuilder.newKnowledgeBase();
    KieSession ksession = kbase.newKieSession();
    SwitchYardServiceTaskHandler ssth = new SwitchYardServiceTaskHandler();
    ssth.setProcessRuntime(ksession);
    ssth.setInvoker(new SwitchYardServiceInvoker(serviceDomain));
    ksession.getWorkItemManager().registerWorkItemHandler(SWITCHYARD_SERVICE_TASK, ssth);
    ksession.startProcess("CallService");
    ksession.halt();
    ksession.dispose();
    Assert.assertEquals("message handled", holder.getValue());
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:23,代码来源:BPMServiceTests.java

示例7: runFaultBoundaryProcess

import org.kie.internal.io.ResourceFactory; //导入依赖的package包/类
private void runFaultBoundaryProcess(final boolean bomb) throws Exception {
    serviceDomain.registerService(new QName("TestService"), new InOnlyService(), new BaseHandler() {
        public void handleMessage(Exchange exchange) throws HandlerException {
            if (bomb) {
                throw new HandlerException("BOOM!");
            }
        }
    });
    serviceDomain.registerServiceReference(new QName("TestService"), new InOutService());
    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    kbuilder.add(ResourceFactory.newClassPathResource(FAULT_BOUNDARY_PROCESS_BPMN), ResourceType.BPMN2);
    KieBase kbase = kbuilder.newKnowledgeBase();
    KieSession ksession = kbase.newKieSession();
    SwitchYardServiceTaskHandler ssth = new SwitchYardServiceTaskHandler();
    ssth.setProcessRuntime(ksession);
    ssth.setInvoker(new SwitchYardServiceInvoker(serviceDomain));
    ksession.getWorkItemManager().registerWorkItemHandler(SWITCHYARD_SERVICE_TASK, ssth);
    WorkflowProcessInstance wpi = (WorkflowProcessInstance)ksession.startProcess("FaultBoundaryProcess");
    String output = (String)wpi.getVariable("TestOutput");
    Assert.assertEquals(bomb ? "Failure" : "Success", output);
    ksession.halt();
    ksession.dispose();
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:24,代码来源:BPMServiceTests.java

示例8: testInsertWithReturnObjectFalse

import org.kie.internal.io.ResourceFactory; //导入依赖的package包/类
@Test
public void testInsertWithReturnObjectFalse() throws Exception {
    String str = "";
    str += "package org.kie \n";
    str += "import org.kie.camel.testdomain.Cheese \n";
    str += "rule rule1 \n";
    str += "  when \n";
    str += "    $c : Cheese() \n";
    str += " \n";
    str += "  then \n";
    str += "    $c.setPrice( $c.getPrice() + 5 ); \n";
    str += "end\n";

    KieSession ksession = getKieSession(ResourceFactory.newByteArrayResource(str.getBytes()));
    setExec(ksession);

    String outXml = execContent("testInsertWithReturnObjectFalse.in.1");
    ExecutionResults result = unmarshalOutXml(outXml, ExecutionResults.class);

    String expectedXml = getContent("testInsertWithReturnObjectFalse.expected.1", ((FactHandle)result.getFactHandle("outStilton")).toExternalForm());

    assertXMLEqual(expectedXml, outXml);
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:24,代码来源:BatchTest.java

示例9: testExecuteUsingKieAPI

import org.kie.internal.io.ResourceFactory; //导入依赖的package包/类
/**
 * Test execute using kie api.
 *
 * @throws Exception the exception
 */
@Test
public void testExecuteUsingKieAPI() throws Exception {
    // get the resource
    Resource dt = ResourceFactory.newClassPathResource("/data/IntegrationExampleTest.xls", getClass());

    // create the builder
    KieSession ksession = getKieSession(dt);

    ksession.insert(new Cheese("stilton", 42));
    ksession.insert(new Person("michael", "stilton", 42));
    final List<String> list = new ArrayList<String>();
    ksession.setGlobal("list", list);
    ksession.fireAllRules();
    assertEquals(1, list.size());
    assertEquals("Old man stilton", list.get(0));
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:22,代码来源:SpreadsheetIntegrationExampleTest.java

示例10: testNamedWorksheet

import org.kie.internal.io.ResourceFactory; //导入依赖的package包/类
/**
 * Test named worksheet.
 *
 * @throws Exception the exception
 */
@Test
public void testNamedWorksheet() throws Exception {
    DecisionTableConfiguration dtconf = KnowledgeBuilderFactory.newDecisionTableConfiguration();
    dtconf.setInputType(DecisionTableInputType.XLS);
    dtconf.setWorksheetName("Tables");

    Resource dt = ResourceFactory.newClassPathResource("/data/IntegrationExampleTest.xls", getClass()).setConfiguration(
            dtconf);
    KieSession ksession = getKieSession(dt);

    // ASSERT AND FIRE
    ksession.insert(new Cheese("cheddar", 42));
    ksession.insert(new Person("michael", "stilton", 21));
    final List<String> list = new ArrayList<String>();
    ksession.setGlobal("list", list);
    ksession.fireAllRules();
    assertEquals(1, list.size());
    assertEquals("Young man cheddar", list.get(0));
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:25,代码来源:SpreadsheetIntegrationExampleTest.java

示例11: uploadDroolFiles

import org.kie.internal.io.ResourceFactory; //导入依赖的package包/类
private void uploadDroolFiles() {
  logger.info("Starting Drools with drl files from:  " + resourceFilePath);
  File directory = new File(resourceFilePath);
  File[] fList = directory.listFiles();
  logger.info("Uploading Drool rules...");
  if (fList != null && fList.length > 0) {
    for (File file : fList) {
      kfs.write(ResourceFactory.newFileResource(resourceFilePath + "/" + file.getName()));
      logger.info("... " + file.getName());
    }
  } else {
    logger.info("...no rules found to upload");
  }
}
 
开发者ID:edgexfoundry,项目名称:support-rulesengine,代码行数:15,代码来源:RuleEngine.java

示例12: initKieJar

import org.kie.internal.io.ResourceFactory; //导入依赖的package包/类
/** 
 * 初始化一个kjar:把原有的drl包含进新建的kjar中 
 * 
 * @param ks 
 * @param releaseId 
 * @return 
 * @throws IOException 
 */  
public static InternalKieModule initKieJar(KieServices ks, ReleaseId releaseId) throws IOException {  
    KieFileSystem kfs = createKieFileSystemWithKProject(ks, true);  
    kfs.writePomXML(getPom(releaseId));  
    for (File file : getRuleFiles()) {  
        kfs.write("src/main/resources/" + file.getName(),  
                ResourceFactory.newClassPathResource(RULES_PATH + File.separator + file.getName(), "UTF-8"));  
    }  
    KieBuilder kieBuilder = ks.newKieBuilder(kfs);  
    if (!kieBuilder.buildAll().getResults().getMessages().isEmpty()) {  
        throw new IllegalStateException("Error creating KieBuilder.");  
    }  
    return (InternalKieModule) kieBuilder.getKieModule();  
}
 
开发者ID:lansheng228,项目名称:kie-dynamic-rule,代码行数:22,代码来源:DroolsUtils.java

示例13: addPackage

import org.kie.internal.io.ResourceFactory; //导入依赖的package包/类
/**
 * 规则集上线
 *
 * @param packageName
 */
public void addPackage(String packageName) {
    try {
        File path = new File(this.getClass().getClassLoader().getResource(packageName).toURI().getPath());
        if (path.isDirectory()) {
            KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
            File[] files = path.listFiles();
            for (File file : files) {
                if (file.getName().endsWith(".drl")) {
                    kbuilder.add(ResourceFactory.newClassPathResource(packageName + "/" + file.getName()), ResourceType.DRL);
                    if (kbuilder.hasErrors()) {
                        logger.error("Unable to compile drl. " + packageName + file.getName());
                        return;
                    } else {
                        String ruleName = file.getName().replace(".drl", "");
                        if (kbase.getRule(packageName, ruleName) != null) {
                            logger.info("update rule: " + packageName + "." + ruleName);
                        } else {
                            logger.info("add rule: " + packageName + "." + ruleName);
                        }
                    }
                }
            }

            kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
            kieSession = kbase.newStatelessKieSession();
            setGlobal();
            printRules();
        }
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
}
 
开发者ID:ysrc,项目名称:Liudao,代码行数:38,代码来源:KieService.java

示例14: visitFile

import org.kie.internal.io.ResourceFactory; //导入依赖的package包/类
@Override
public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException {
	File file = path.toFile();
	if (file.isFile() && file.getName().endsWith(RULE_FILENAME_EXTENSION)) {
		kieFileSystem.write(ResourceFactory.newFileResource(file));
		rulesLoaded++;
	}

	return FileVisitResult.CONTINUE;
}
 
开发者ID:IHTSDO,项目名称:snomed-drools,代码行数:11,代码来源:RuleExecutor.java

示例15: addClassPathResource

import org.kie.internal.io.ResourceFactory; //导入依赖的package包/类
@Override
public KnowledgeService addClassPathResource(String resourceName, Handler<AsyncResult<Void>> handler) {

  Resource resource = ResourceFactory.newClassPathResource(resourceName);
  environmentBuilder.addAsset(resource, resource.getResourceType());

  handler.handle(Future.succeededFuture());
  return this;
}
 
开发者ID:diabolicallabs,项目名称:vertx-process-manager,代码行数:10,代码来源:KnowledgeServiceImpl.java


注:本文中的org.kie.internal.io.ResourceFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。