0

I am working on a OSGi (apache felix) and maven based micro-service. I am in the process of learning jbpm. I have create a decision table that I need to invoke from my OSGi java project. Below is the code I am using from the javadoc of bpmn but seems like it is not working because although I imported bunch of dependencies from maven, still lot of other dependencies like

KnowledgeBaseConfiguration
ResourceFactoryService
ResourceFactoryService
KnowledgeBase

remain unresolved.

<drools.version>7.0.0.Final</drools.version>
  
  <dependency>
    <groupId>org.jbpm</groupId>
    <artifactId>jbpm-bpmn2</artifactId>
    <version>${drools.version}</version>
  </dependency><!-- https://mvnrepository.com/artifact/org.drools/drools-core -->
  <dependency>
    <groupId>org.drools</groupId>
    <artifactId>drools-core</artifactId>
    <version>${drools.version}</version>
  </dependency><!-- https://mvnrepository.com/artifact/org.drools/drools-osgi-integration --><!-- https://mvnrepository.com/artifact/org.drools/drools-decisiontables -->
  <dependency>
    <groupId>org.drools</groupId>
    <artifactId>drools-decisiontables</artifactId>
    <version>${drools.version}</version>
  </dependency><!-- https://mvnrepository.com/artifact/org.drools/drools-api -->
  <dependency>
    <groupId>org.drools</groupId>
    <artifactId>drools-compiler</artifactId>
    <version>${drools.version}</version>
  </dependency>
  <dependency>
    <groupId>org.kie</groupId>
    <artifactId>kie-api</artifactId>
    <version>${drools.version}</version>
  </dependency>

This is the logic that I found in the document of jbpm in the section of integration with OSGi

    ServiceReference serviceRef = bundleContext.getServiceReference( ServiceRegistry.class.getName() );
    ServiceRegistry registry = (ServiceRegistry) bundleContext.getService( serviceRef );

    KnowledgeBuilderFactoryService knowledgeBuilderFactoryService = registry.get( KnowledgeBuilderFactoryService.class );
    KnowledgeBaseFactoryService knowledgeBaseFactoryService = registry.get( KnowledgeBaseFactoryService.class );
    ResourceFactoryService resourceFactoryService = registry.get( ResourceFactoryService.class );

    KnowledgeBaseConfiguration kbaseConf = knowledgeBaseFactoryService.newKnowledgeBaseConfiguration( null, getClass().getClassLoader() );

    KnowledgeBuilderConfiguration kbConf = knowledgeBuilderFactoryService.newKnowledgeBuilderConfiguration( null, getClass().getClassLoader() );
    KnowledgeBuilder kbuilder = knowledgeBuilderFactoryService.newKnowledgeBuilder( kbConf );
    kbuilder.add( resourceFactoryService.newClassPathResource( "MyProcess.bpmn", Dummy.class ), ResourceType.BPMN2 );

    kbaseConf = knowledgeBaseFactoryService.newKnowledgeBaseConfiguration( null, getClass().getClassLoader() );
    KnowledgeBase kbase = knowledgeBaseFactoryService.newKnowledgeBase( kbaseConf );
    kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );

    StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
    return Optional.empty();

My questions are :

  1. How to integrate jbpm and Osgi java to invoke and execute a bpmn or decision table?
  2. Why are these dependencies unresolved? I tried the latest 7.46.0.FINAL version of drools as well?
4

1 回答 1

0

对于问题 1,您需要来自组 org.kie.server 的 kie-server-client。

您可能使用的其他依赖项是 apis(问题 2)中的定义:来自组 org.jbpm 的 jbpm-kie-services 和来自组 org.kie 的 kie-api、kie-internal。

于 2020-12-20T16:10:25.413 回答