Annotation Interface Behavior
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:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanWhether this behavior should be started automatically when the agent starts.Name of the initial FSM state forBehaviorType.FSMbehaviors.Delay before the first execution.Interval between executions forBehaviorType.CYCLICbehaviors.Per-state execution timeout forBehaviorType.FSMbehaviors.The execution pattern for this behavior.
-
Element Details
-
type
BehaviorType typeThe execution pattern for this behavior.Defaults to
BehaviorType.ONE_SHOT, which executes the method once when the agent starts. For repetitive work, useBehaviorType.CYCLIC.- Returns:
- the behavior type
- Default:
ONE_SHOT
-
interval
String intervalInterval between executions forBehaviorType.CYCLICbehaviors.Accepted formats:
"500ms","30s","2m","1h". Ignored for non-CYCLIC types.- Returns:
- the interval string, or empty string if not applicable
- Default:
""
-
initialDelay
String initialDelayDelay before the first execution.Accepted formats:
"5s","1m". When empty, the behavior starts immediately. Honoured byBehaviorType.ONE_SHOT— which fires once when the delay elapses — and byBehaviorType.CYCLIC, which waits before its first tick and then keeps itsinterval().- Returns:
- the initial delay string, or empty string for immediate start
- Default:
""
-
autoStart
boolean autoStartWhether this behavior should be started automatically when the agent starts.Set to
falseto create the behavior in a paused state; it can then be started programmatically viaAgent.addBehavior(dev.agenor.core.Behavior).- Returns:
trueto start automatically (default),falsefor manual start
- Default:
true
-
fsmInitialState
String fsmInitialStateName of the initial FSM state forBehaviorType.FSMbehaviors.- Returns:
- initial state name (default
"START") - Since:
- 0.2.0
- Default:
"START"
-
stateTimeout
String stateTimeoutPer-state execution timeout forBehaviorType.FSMbehaviors.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:
""
-