Class InMemoryPushNotificationConfigStore

java.lang.Object
org.a2aproject.sdk.server.tasks.InMemoryPushNotificationConfigStore
All Implemented Interfaces:
PushNotificationConfigStore

@ApplicationScoped public class InMemoryPushNotificationConfigStore extends Object implements PushNotificationConfigStore
In-memory implementation of the PushNotificationConfigStore interface. Stores push notification configurations in memory
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    deleteInfo(String taskId, String configId)
    Deletes a push notification configuration for a task.
    org.a2aproject.sdk.spec.ListTaskPushNotificationConfigsResult
    getInfo(org.a2aproject.sdk.spec.ListTaskPushNotificationConfigsParams params)
    Retrieves push notification configurations for a task with pagination support.
    getProtocolVersion(String taskId, String configId)
    Gets the protocol version associated with a push notification configuration.
    Gets all protocol versions for a task's push notification configurations in a single call.
    org.a2aproject.sdk.spec.TaskPushNotificationConfig
    setInfo(org.a2aproject.sdk.spec.TaskPushNotificationConfig notificationConfig)
    Sets or updates the push notification configuration for a task.
    org.a2aproject.sdk.spec.TaskPushNotificationConfig
    setInfo(org.a2aproject.sdk.spec.TaskPushNotificationConfig config, @Nullable String protocolVersion)
    Sets or updates the push notification configuration for a task, along with the protocol version that registered it.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • InMemoryPushNotificationConfigStore

      @Inject public InMemoryPushNotificationConfigStore()
  • Method Details

    • setInfo

      public org.a2aproject.sdk.spec.TaskPushNotificationConfig setInfo(org.a2aproject.sdk.spec.TaskPushNotificationConfig notificationConfig)
      Description copied from interface: PushNotificationConfigStore
      Sets or updates the push notification configuration for a task.

      If notificationConfig.id() is null or empty, it's set to the task ID. If a config with the same ID already exists for this task, it's replaced.

      Specified by:
      setInfo in interface PushNotificationConfigStore
      Parameters:
      notificationConfig - the task push notification configuration
      Returns:
      the potentially updated configuration (with ID set if it was null)
    • setInfo

      public org.a2aproject.sdk.spec.TaskPushNotificationConfig setInfo(org.a2aproject.sdk.spec.TaskPushNotificationConfig config, @Nullable String protocolVersion)
      Description copied from interface: PushNotificationConfigStore
      Sets or updates the push notification configuration for a task, along with the protocol version that registered it.

      This merged method ensures the protocol version is stored using the normalized config ID (after PushNotificationConfigStore.setInfo(TaskPushNotificationConfig) applies defaults).

      Specified by:
      setInfo in interface PushNotificationConfigStore
      Parameters:
      config - the task push notification configuration
      protocolVersion - the protocol version string, or null to use AgentInterface.CURRENT_PROTOCOL_VERSION
      Returns:
      the potentially updated configuration (with ID set if it was null)
    • getInfo

      public org.a2aproject.sdk.spec.ListTaskPushNotificationConfigsResult getInfo(org.a2aproject.sdk.spec.ListTaskPushNotificationConfigsParams params)
      Description copied from interface: PushNotificationConfigStore
      Retrieves push notification configurations for a task with pagination support.

      Returns all configs if params.pageSize() is 0. Otherwise, returns up to pageSize configs and a continuation token for the next page.

      Pagination Example:

      
       // First page
       ListTaskPushNotificationConfigsParams params =
           new ListTaskPushNotificationConfigsParams(taskId, 10, null, tenant);
       ListTaskPushNotificationConfigsResult result = store.getInfo(params);
      
       // Next page
       if (result.nextPageToken() != null) {
           params = new ListTaskPushNotificationConfigsParams(
               taskId, 10, result.nextPageToken(), tenant);
           result = store.getInfo(params);
       }
       
      Specified by:
      getInfo in interface PushNotificationConfigStore
      Parameters:
      params - the query parameters including task ID, page size, and page token
      Returns:
      the configurations for this task (empty list if none found)
    • deleteInfo

      public void deleteInfo(String taskId, String configId)
      Description copied from interface: PushNotificationConfigStore
      Deletes a push notification configuration for a task.

      If configId is null, it defaults to the task ID (deletes the default config). If no config exists with the given ID, this method returns normally (idempotent).

      Specified by:
      deleteInfo in interface PushNotificationConfigStore
      Parameters:
      taskId - the task ID
      configId - the push notification configuration ID (null = use task ID)
    • getProtocolVersion

      public String getProtocolVersion(String taskId, String configId)
      Description copied from interface: PushNotificationConfigStore
      Gets the protocol version associated with a push notification configuration.
      Specified by:
      getProtocolVersion in interface PushNotificationConfigStore
      Parameters:
      taskId - the task ID
      configId - the push notification configuration ID
      Returns:
      the protocol version string, defaults to the current protocol version if not set
    • getProtocolVersions

      public Map<String,String> getProtocolVersions(String taskId)
      Description copied from interface: PushNotificationConfigStore
      Gets all protocol versions for a task's push notification configurations in a single call.
      Specified by:
      getProtocolVersions in interface PushNotificationConfigStore
      Parameters:
      taskId - the task ID
      Returns:
      a map of config ID to protocol version (only includes configs with a version set)