Class DynamicActorLoaderActor

java.lang.Object
com.scivicslab.pojoactor.workflow.DynamicActorLoaderActor
All Implemented Interfaces:
CallableByActionName

public class DynamicActorLoaderActor extends Object implements CallableByActionName
Generic actor that dynamically loads and creates other actors from plugins.

This actor enables workflows to load actors from external JAR files or ServiceLoader providers at runtime, without restarting the application.

Supported Actions:

  • loadFromJar: Load actor from external JAR file
  • createFromProvider: Create actor from ServiceLoader provider
  • listProviders: List all available ActorProvider instances
  • loadProvidersFromJar: Load ActorProvider plugins from JAR

Example Workflow (Loading from JAR):


 <workflow name="dynamic-loading">
   <matrix>
     <transition from="init" to="loaded">
       <action actor="loader" method="loadFromJar">
         /plugins/my-actor.jar,com.example.MyActor,myactor
       </action>
     </transition>

     <transition from="loaded" to="done">
       <action actor="myactor" method="someAction">args</action>
     </transition>
   </matrix>
 </workflow>
 

Example Workflow (Loading from ServiceLoader):


 <workflow name="service-loader">
   <matrix>
     <transition from="init" to="loaded">
       <action actor="loader" method="createFromProvider">
         math,mathactor
       </action>
     </transition>

     <transition from="loaded" to="done">
       <action actor="mathactor" method="add">5,3</action>
     </transition>
   </matrix>
 </workflow>
 
Since:
2.6.0
Author:
devteam@scivics-lab.com
  • Field Details

  • Constructor Details

    • DynamicActorLoaderActor

      public DynamicActorLoaderActor(IIActorSystem system)
      Constructs a new DynamicActorLoaderActor.
      Parameters:
      system - the actor system to register newly loaded actors
  • Method Details

    • callByActionName

      public ActionResult callByActionName(String actionName, String args)
      Description copied from interface: CallableByActionName
      Executes an action identified by its name with the given arguments.

      Implementations should parse the args string according to their own conventions. Common approaches include:

      • Comma-separated values: "5,3"
      • JSON: "{\"a\":5,\"b\":3}"
      • Key-value pairs: "a=5,b=3"

      The method should return an ActionResult indicating success or failure, along with any result data serialized as a string.

      Specified by:
      callByActionName in interface CallableByActionName
      Parameters:
      actionName - the name of the action to execute
      args - string arguments to pass to the action (format defined by implementation)
      Returns:
      an ActionResult indicating success or failure and any result data