Annotation Interface Behavior


@Target(METHOD) @Retention(RUNTIME) public @interface Behavior
Marks a method as a Agenor behavior that the runtime will schedule and execute automatically according to the specified BehaviorType.

The annotated method must be public and, unless the behavior receives messages, take no parameters. The runtime wraps the method in the appropriate Behavior implementation at startup.

Common examples:


 // Cyclic behavior — executes every 30 seconds
 @Behavior(type = CYCLIC, interval = "30s")
 public void pollExternalService() { ... }

 // Cyclic behavior that waits before its first tick
 @Behavior(type = CYCLIC, interval = "30s", initialDelay = "5s")
 public void pollAfterWarmup() { ... }

 // One-shot behavior — runs once, ten seconds after the agent starts
 @Behavior(type = ONE_SHOT, initialDelay = "10s")
 public void announceReady() { ... }

 // FSM behavior — a state machine that decides its own transitions
 @Behavior(type = FSM, fsmInitialState = "START", stateTimeout = "30s")
 public void advanceOrder() { ... }
 

The parameters below that carry a deprecation belong to behavior types deprecated in 0.28.0. They keep working until 0.30.0, and each names what to use instead.

Since:
0.1.0
See Also:
  • Element Details

    • type

      The execution pattern for this behavior.

      Defaults to BehaviorType.ONE_SHOT, which executes the method once when the agent starts. For repetitive work, use BehaviorType.CYCLIC.

      Returns:
      the behavior type
      Default:
      ONE_SHOT
    • interval

      String interval
      Interval between executions for BehaviorType.CYCLIC behaviors.

      Accepted formats: "500ms", "30s", "2m", "1h". Ignored for non-CYCLIC types.

      Returns:
      the interval string, or empty string if not applicable
      Default:
      ""
    • initialDelay

      String initialDelay
      Delay before the first execution.

      Accepted formats: "5s", "1m". When empty, the behavior starts immediately. Honoured by BehaviorType.ONE_SHOT — which fires once when the delay elapses — and by BehaviorType.CYCLIC, which waits before its first tick and then keeps its interval().

      Returns:
      the initial delay string, or empty string for immediate start
      Default:
      ""
    • autoStart

      boolean autoStart
      Whether this behavior should be started automatically when the agent starts.

      Set to false to create the behavior in a paused state; it can then be started programmatically via Agent.addBehavior(dev.agenor.core.Behavior).

      Returns:
      true to start automatically (default), false for manual start
      Default:
      true
    • fsmInitialState

      String fsmInitialState
      Name of the initial FSM state for BehaviorType.FSM behaviors.
      Returns:
      initial state name (default "START")
      Since:
      0.2.0
      Default:
      "START"
    • stateTimeout

      String stateTimeout
      Per-state execution timeout for BehaviorType.FSM behaviors.

      Accepted formats: "30s", "2m". Empty string means no timeout.

      Returns:
      state timeout string, or empty string for no timeout (default)
      Since:
      0.2.0
      Default:
      ""