Class SmsProviderFactory

java.lang.Object
cloud.opencode.base.sms.provider.SmsProviderFactory

public final class SmsProviderFactory extends Object
SMS Provider Factory 短信提供商工厂

Factory for creating SMS providers.

创建短信提供商的工厂。

Features | 主要功能:

  • Config-based provider creation - 基于配置的提供商创建
  • Custom provider registration - 自定义提供商注册
  • SPI (ServiceLoader) discovery fallback - SPI服务发现回退

Usage Examples | 使用示例:

SmsProvider provider = SmsProviderFactory.create(config);
SmsProvider console = SmsProviderFactory.console();
SmsProviderFactory.registerProvider(SmsProviderType.CUSTOM, MyProvider::new);

Security | 安全性:

  • Thread-safe: Yes (ConcurrentHashMap for provider registry) - 线程安全: 是(ConcurrentHashMap注册表)
Since:
JDK 25, opencode-base-sms V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • create

      public static SmsProvider create(SmsConfig config)
      Create provider from config 从配置创建提供商
      Parameters:
      config - the config | 配置
      Returns:
      the provider | 提供商
    • registerProvider

      public static void registerProvider(SmsProviderType type, Function<SmsConfig, SmsProvider> factory)
      Register custom provider factory 注册自定义提供商工厂
      Parameters:
      type - the provider type | 提供商类型
      factory - the factory function | 工厂函数
    • unregisterProvider

      public static void unregisterProvider(SmsProviderType type)
      Unregister provider factory 取消注册提供商工厂
      Parameters:
      type - the provider type | 提供商类型
    • console

      public static SmsProvider console()
      Get console provider 获取控制台提供商
      Returns:
      the console provider | 控制台提供商