Tabnine Logo
ResourceFactory
Code IndexAdd Tabnine to your IDE (free)

How to use
ResourceFactory
in
org.kie.io

Best Java code snippets using org.kie.io.ResourceFactory (Showing top 5 results out of 315)

origin: org.jbpm/jbpm-simulation

public static SimulationRepository runSimulation(String processId, String bpmn2Container, int numberOfAllInstances, long interval, boolean runRules, String... rules) {
  
  Resource[] resources = new Resource[rules.length];
  for (int i = 0; i < rules.length; i++) {
    resources[i] = ResourceFactory.newClassPathResource(rules[i]);
  }
  
  return runSimulation(processId, bpmn2Container, numberOfAllInstances, interval, runRules, resources);
}

origin: org.jbpm/jbpm-simulation

public WorkingMemorySimulationRepository(boolean fireRulesOnStore, String... rules) {
  this.fireRulesOnStore = fireRulesOnStore;
  KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
  
  for (String path : rules) {
  
    kbuilder.add(ResourceFactory.newClassPathResource(path), ResourceType.DRL);
  }
  if (kbuilder.hasErrors()) {
    throw new RuntimeException("Error while building knowledge base: " + kbuilder.getErrors());
  }
  
  this.ksession = kbuilder.newKnowledgeBase().newStatefulKnowledgeSession();
  try {
    // register global for aggregated events
    ksession.setGlobal("simulation", new ArrayList<AggregatedActivitySimulationEvent>());
  } catch (Exception e) {
    // catch it as there could be no simulation global declared
  }
}

origin: org.jbpm/jbpm-simulation

  @Test
  public void testSimulationCommand() {
    
    PathFinder finder = PathFinderFactory.getInstance(this.getClass().getResourceAsStream("/BPMN2-ExclusiveSplit.bpmn2"));
    
    List<SimulationPath> paths = finder.findPaths(new SimulationFilterPathFormatConverter());
    SimulationContext context = SimulationContextFactory.newContext(new HardCodedSimulationDataProvider());
    
    KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    
    builder.add(ResourceFactory.newClassPathResource("BPMN2-ExclusiveSplit.bpmn2"), ResourceType.BPMN2);
    
    KnowledgeBase kbase = builder.newKnowledgeBase();
    KieSessionConfiguration config = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
    config.setOption(ClockTypeOption.get("pseudo") );
    
    for (SimulationPath sp : paths) {
    
      StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession(config, EnvironmentFactory.newEnvironment());
      ((SessionPseudoClock) session.getSessionClock()).advanceTime(System.currentTimeMillis(), TimeUnit.MILLISECONDS);
      
      session.execute(new SimulateProcessPathCommand("com.sample.test", context, sp));
    }
  }
}
origin: org.jbpm/jbpm-simulation

public static ReleaseId createKJarWithMultipleResources(String id, String[] resourceFiles, ResourceType[] types) throws IOException {
  KieServices ks = KieServices.Factory.get();
  KieModuleModel kproj = ks.newKieModuleModel();
  KieFileSystem kfs = ks.newKieFileSystem();
  for (int i = 0; i < resourceFiles.length; i++) {            
    Resource resource = ResourceFactory.newClassPathResource(resourceFiles[i]);
    String res = readResourceContent(resource);
    String type = types[i].getDefaultExtension();
    kfs.write("src/main/resources/" + id.replaceAll("\\.", "/")
        + "/org/test/res" + i + "." + type, res);
  }
  KieBaseModel kBase1 = kproj.newKieBaseModel(id)
      .setEqualsBehavior(EqualityBehaviorOption.EQUALITY)
      .setEventProcessingMode(EventProcessingOption.STREAM);
  KieSessionModel ksession1 = kBase1
      .newKieSessionModel(id + ".KSession1")
      .setType(KieSessionModel.KieSessionType.STATEFUL)
      .setClockType(ClockTypeOption.get("pseudo"));
  kfs.writeKModuleXML(kproj.toXML());
  KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
  assertTrue(kieBuilder.getResults().getMessages().isEmpty());
  KieModule kieModule = kieBuilder.getKieModule();
  return kieModule.getReleaseId();
}

origin: org.jbpm/jbpm-simulation

public static StatefulKnowledgeSession createSession(String process) {
  KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
  builder.add(ResourceFactory.newClassPathResource(process), ResourceType.BPMN2);
org.kie.ioResourceFactory

Most used methods

  • newClassPathResource

Popular in Java

  • Reading from database using SQL prepared statement
  • notifyDataSetChanged (ArrayAdapter)
  • getExternalFilesDir (Context)
  • setRequestProperty (URLConnection)
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • JFileChooser (javax.swing)
  • Option (scala)
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now