Interface ActorProvider


public interface ActorProvider
Service provider interface for plugin-based actor registration. Plugins can implement this interface and register themselves using Java's ServiceLoader mechanism. This enables automatic actor discovery and registration at runtime.

Usage in Plugin


 // 1. Implement ActorProvider
 public class MathPluginProvider implements ActorProvider {
     @Override
     public void registerActors(ActorSystem system) {
         system.actorOf("mathActor", new MathPlugin());
         system.actorOf("calculatorActor", new Calculator());
     }
 }

 // 2. Create META-INF/services/com.scivicslab.pojoactor.ActorProvider
 // with content:
 // com.example.plugin.MathPluginProvider
 

Usage in Application


 ActorSystem system = new ActorSystem("mySystem");

 // Load all registered ActorProviders
 ServiceLoader<ActorProvider> loader = ServiceLoader.load(ActorProvider.class);
 for (ActorProvider provider : loader) {
     provider.registerActors(system);
 }

 // Now all plugin actors are registered and ready to use
 system.getActor("mathActor").tell(m -> m.calculate());
 
Since:
2.0.0, 2.0.0
Author:
devteam@scivics-lab.com
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default String
    Returns the name of this plugin.
    default String
    Returns the version of this plugin.
    void
    Registers actors provided by this plugin into the given ActorSystem.
  • Method Details

    • registerActors

      void registerActors(ActorSystem system)
      Registers actors provided by this plugin into the given ActorSystem. Implementations should create actor instances and register them using ActorSystem.actorOf(String, Object) or similar methods.
      Parameters:
      system - the ActorSystem to register actors into
    • getPluginName

      default String getPluginName()
      Returns the name of this plugin. This is optional but recommended for logging and debugging purposes.
      Returns:
      the plugin name, or a default name if not overridden
    • getPluginVersion

      default String getPluginVersion()
      Returns the version of this plugin. This is optional but recommended for version management.
      Returns:
      the plugin version, or "unknown" if not overridden