Class KokosStatefulProgram

java.lang.Object
com.smeup.kokos.sdk.rpgle.caller.KokosProgram
com.smeup.kokos.sdk.rpgle.caller.KokosStatefulProgram
All Implemented Interfaces:
Closeable, AutoCloseable

public abstract class KokosStatefulProgram extends KokosProgram
This abstract class represents a program that can be executed with stateful caching functionality. It extends KokosProgram and provides methods for loading/storing cached values using Redis storage.

This class is designed to maintain state across multiple invocations of the same program within a user's session. The state is persisted in Redis, allowing the program to resume its execution from where it left off.

Provides protected `sessionValues`, which is loaded before the program execution, and is stored after that.

Author:
Davide Palladino (APU001) thanks to Mattia Bonardi.
  • Field Details

    • sessionValues

      protected Map<String,com.smeup.rpgparser.interpreter.Value> sessionValues
      Stores the session-specific values that represent the program's state. This map is used to load and store the program's state in Redis.
  • Constructor Details

    • KokosStatefulProgram

      public KokosStatefulProgram()
  • Method Details

    • executeWithCache

      public LinkedHashMap<String,com.smeup.rpgparser.interpreter.Value> executeWithCache(LinkedHashMap<String,com.smeup.rpgparser.interpreter.Value> params, ProgramCaller programCaller, String programName) throws Exception
      Executes the program with cache support. This method: 1. Creates a memory slice ID using the activation group and program name. 2. Connects to Redis storage using the user's session ID. 3. Loads cached values into the program's sessionValues. 4. Executes the program with the provided parameters. 5. Stores the updated program values back to Redis after execution.
      Parameters:
      params - The input values for the program execution.
      programCaller - The program caller object used to get execution context.
      programName - The name of the program being executed.
      Returns:
      The output parameters from the program execution.
      Throws:
      Exception - If any error occurs during execution or caching operations.