Skip to content

Commit 0e1be35

Browse files
authored
Document custom argument resolvers (#999)
This commit provides documentation for writing and registering a ActionMethodArgumentResolver. See gh-890 Signed-off-by: Arjen Poutsma <[email protected]>
1 parent dc6052c commit 0e1be35

File tree

1 file changed

+18
-1
lines changed
  • embabel-agent-docs/src/main/asciidoc/reference/annotations

1 file changed

+18
-1
lines changed

embabel-agent-docs/src/main/asciidoc/reference/annotations/page.adoc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ A nullable domain object parameter will be populated if it is non-null on the bl
6262
This enables nice-to-have parameters that are not required for the action to run.
6363
In Kotlin, use a nullable parameter with `?`: in Java, mark the parameter with the `org.springframework.lang.Nullable` or another `Nullable` annotation.
6464

65-
* _Infrastructure objects_. `OperationContext` parameters may be passed to action or condition methods.
65+
* _Infrastructure parameters_, such as the `OperationContext`, `ProcessContext`, and `Ai` may be used in action or condition methods.
6666

6767
NOTE: Domain objects drive planning, specifying the preconditions to an action.
6868

@@ -73,6 +73,23 @@ This is an important element of composition.
7373
> Use the least specific type possible for parameters.
7474
Use `OperationContext` unless you are creating a subprocess.
7575

76+
===== Custom Parameters
77+
78+
Besides two default parameter categories described above, you can provide your own parameters by implementing the `ActionMethodArgumentResolver` interface.
79+
The two main methods of this interface are:
80+
81+
* `supportsParameter`, which indicates what kind of parameters are supported, and
82+
* `resolveArgument`, which resolves the argument into an object used to invoke the action method.
83+
84+
NOTE: Note the similarity with Spring MVC, where you can provide custom parameters by implementing a `HandlerMethodArgumentResolver`.
85+
86+
> All default parameters are provided by `ActionMethodArgumentResolver` implementations.
87+
88+
To register your custom argument resolver, provide it to the `DefaultActionMethodManager` component in your Spring configuration.
89+
Typically, you will register (some of) the defaults as well your custom resolver, in order to support the default parameters.
90+
91+
TIP: Make sure to register the `BlackboardArgumentResolver` as last resolver, to ensure that others take precedence.
92+
7693
==== Binding by name
7794

7895
The `@RequireNameMatch` annotation can be used to <<reference.flow__binding, bind parameters by name>>.

0 commit comments

Comments
 (0)