Interface ActionProvider


public interface ActionProvider
Action Provider SPI - Service Provider Interface for Action Discovery 动作提供者SPI - 动作发现的服务提供者接口

Implementations of this interface are discovered via ServiceLoader and can provide named actions for use in rule definitions.

此接口的实现通过ServiceLoader发现,可以提供命名动作用于规则定义。

Features | 主要功能:

  • ServiceLoader-based discovery - 基于ServiceLoader的发现
  • Named action registry - 命名动作注册表
  • Priority-based ordering - 基于优先级排序

Usage Examples | 使用示例:

// Implementation example
public class NotificationActionProvider implements ActionProvider {
    @Override
    public Map<String, Action> getActions() {
        return Map.of(
            "sendEmail", ctx -> sendEmail(ctx),
            "sendSms", ctx -> sendSms(ctx),
            "logEvent", ctx -> logEvent(ctx)
        );
    }

    @Override
    public String getName() {
        return "notification-actions";
    }
}

Security | 安全性:

  • Thread-safe: Implementation dependent - 线程安全: 取决于实现
  • Null-safe: No (action names must not be null) - 空值安全: 否(动作名称不能为null)
Since:
JDK 25, opencode-base-rules V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default Optional<Action>
    Gets an action by name 按名称获取动作
    Gets all actions provided by this provider 获取此提供者提供的所有动作
    Gets the provider name 获取提供者名称
    default int
    Gets the provider priority (lower = higher priority) 获取提供者优先级(数字越小 = 优先级越高)
    default boolean
    Checks if this provider is enabled 检查此提供者是否启用
  • Method Details

    • getActions

      Map<String,Action> getActions()
      Gets all actions provided by this provider 获取此提供者提供的所有动作
      Returns:
      map of action name to action | 动作名称到动作的映射
    • getAction

      default Optional<Action> getAction(String name)
      Gets an action by name 按名称获取动作
      Parameters:
      name - the action name | 动作名称
      Returns:
      the action if found | 如果找到则返回动作
    • getName

      String getName()
      Gets the provider name 获取提供者名称
      Returns:
      the provider name | 提供者名称
    • getPriority

      default int getPriority()
      Gets the provider priority (lower = higher priority) 获取提供者优先级(数字越小 = 优先级越高)
      Returns:
      the priority | 优先级
    • isEnabled

      default boolean isEnabled()
      Checks if this provider is enabled 检查此提供者是否启用
      Returns:
      true if enabled | 如果启用返回true