Package com.embabel.agent.core
Interface AgentProcessCallback
-
- All Implemented Interfaces:
public interface AgentProcessCallbackCallback interface for interleaving logic with the lifecycle of an AgentProcess and its actions.
This is particularly useful for ConcurrentAgentProcess, where launched actions run in their own threads and may, for example, need a Spring Security context proliferated to the thread in which the action runs:
@Component @Scope("prototype") class SecurityContextAgentProcessCallback : AgentProcessCallback { var securityContext: SecurityContext? = null override fun beforeActionLaunched(process: AgentProcess) { securityContext = SecurityContextHolder.getContext() } override fun onActionLaunched( process: AgentProcess, action: Action, ) { securityContext?.let { SecurityContextHolder.setContext(it) } } override fun onActionCompleted( process: AgentProcess, action: Action, ) { SecurityContextHolder.clearContext() } }
-
-
Method Summary
Modifier and Type Method Description abstract UnitbeforeActionLaunched(AgentProcess process)abstract UnitonActionLaunched(AgentProcess process, Action action)abstract UnitonActionCompleted(AgentProcess process, Action action)-
-
Method Detail
-
beforeActionLaunched
abstract Unit beforeActionLaunched(AgentProcess process)
-
onActionLaunched
abstract Unit onActionLaunched(AgentProcess process, Action action)
-
onActionCompleted
abstract Unit onActionCompleted(AgentProcess process, Action action)
-
-
-
-