• Icon: Sub-task Sub-task
    • Resolution: Done
    • Icon: Major Major
    • None
    • None
    • None
    • 2022 Week 17-19 (from Apr 25), 2022 Week 20-22 (from May 16), 2022 Week 23-25 (from Jun 6), 2022 Week 26-28 (from Jun 27), MGDOBR - Sprint 220, 2022 Week 29-31 (from Jul 18), 2022 Week 32-34 (from Aug 8), 2022 Week 35-37 (from Aug 29)
    • 8
    • Medium
    • NEW
    • NEW
    • ---
    • ---

      Currently, both `KieRuntimeService` and `KieCompilerSevice` are discovered via SPI each time, through the invocation of `canManageInput(EfestoInput toEvaluate, K context);` and `canManageResource(EfestoResource toProcess); ` methods. This is not efficient and should be improved with a sort of "cache" populated during the startup.

      The issue is that some of the required information are statically defined (i.e. `canManageResource` is mapped to a statically defined `EfestoResource` type; `canManageInput` is mapped to a statically defined `EfestoInput` type) but other required informations depends on "dynamic" properties: e.g.

      `public boolean canManageResource(EfestoResource toProcess)

      { return toProcess instanceof EfestoFileResource && ((EfestoFileResource) toProcess).getModelType().equalsIgnoreCase(PMML_STRING); }

      `
      the `EfestoFileResource` is statically defined, but the `getModelType` is dynamically set at invocation;

      ` public static boolean canManage(EfestoInput toEvaluate)

      { return (toEvaluate instanceof AbstractEfestoInput) && (toEvaluate.getInputData() instanceof EfestoMapInputDTO) && getGeneratedExecutableResource(toEvaluate.getFRI(), "drl").isPresent(); }

      `
      the `AbstractEfestoInput` is statically defined, but the `getInputData` and `toEvaluate().getFRI()` are dynamically set at invocation;

      Some ideas coud be:
      1) load at startup all the services discovered by SPI, to avoid SPI invocation everytime and use it just once
      2) make services returns a boolean function that returns `true` based on statically defined parameters, and create a "map" to with that lambda as key and the service implementation as value
      3) instead of the lambda, use the "type" as key identifier - but this maybe tricky because some service may actually use the same type (i.e. almost all compilation services use "EfestoFileResource")

      Further consideration:
      this could be somehow related to the idea of implementing a "rest-like" api where, given a specifi kind of input, a specific service gets invoked. This, in turns, would be related to https://issues.redhat.com/browse/DROOLS-7066 (introduction of ResourceIdentifiers) - so we should consider which one to address first.

              mfusco@redhat.com Mario Fusco
              gcardosi Gabriele Cardosi (Inactive)
              Edoardo Vacchi (Inactive), Mario Fusco
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: