This is an automated email from the ASF dual-hosted git repository. gk pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/turbine-core.git
commit f369263bcc3bbde443b75fa17f2b6ffecd744c20 Author: Georg Kallidis <[email protected]> AuthorDate: Thu Jul 6 15:34:18 2023 +0200 Add info about TurbineTool annotation --- src/changes/changes.xml | 5 ++++- src/java/org/apache/turbine/annotation/TurbineTool.java | 2 +- xdocs/howto/annotations.xml | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 160e7201..9c009851 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -32,7 +32,10 @@ Fix java.lang.NoSuchFieldError: DEFAULT_TIME_BETWEEN_EVICTION_RUNS. This field changed from being an long to a Duration in commons-pool2 v 2.10.0 and commons-dbcp2 v2.9.0. </action> </release> - <release version="5.1" date="2021-11-23"> + <action type="add" dev="gk"> + Add Annotation @TurbineTool to annotate tools for advanced usage in action methods. + </action> + <release version="5.1" date="2021-11-23"> <action type="update" dev="painter"> Updated dependencies: yauaa to 5.23, commons-lang3 to 3.12, jython-standalone to 2.7.2 Update turbine-parent 8 (released) diff --git a/src/java/org/apache/turbine/annotation/TurbineTool.java b/src/java/org/apache/turbine/annotation/TurbineTool.java index ad783f2e..292e2341 100644 --- a/src/java/org/apache/turbine/annotation/TurbineTool.java +++ b/src/java/org/apache/turbine/annotation/TurbineTool.java @@ -28,7 +28,7 @@ import org.apache.turbine.services.pull.ApplicationTool; /** - * Annotation to mark fields in modules that require a loader to be injected + * Annotation to mark fields in modules and actions that require a tool to be injected */ @Retention( RetentionPolicy.RUNTIME ) @Target( ElementType.FIELD ) diff --git a/xdocs/howto/annotations.xml b/xdocs/howto/annotations.xml index debd4e05..015212aa 100644 --- a/xdocs/howto/annotations.xml +++ b/xdocs/howto/annotations.xml @@ -146,6 +146,22 @@ is required and defines the name of the event. See the for usage and examples. </subsection> +<subsection name="@TurbineTool"> +The annotation can only be used with a field. +A declared field in a class annotated with <code>@TurbineTool</code> +gets injected an instance of the specified <code>ApplicationTool</code> at +the time the instance of the class is created. The field should have +the type of the tool. +<source><![CDATA[ +// Injected loader instance +@TurbineTool( TemplateLink.class ) +private TemplateLink templateLink; +]]></source> +Normally a tool needs an context (request, global, user). You have to set the context by calling the +tool.init(Object object) method. E.g. in action methods you have access to request and session context objects. +The annotation parameter is required and defines the type of the tool. +</subsection> + <subsection name="Performance Considerations"> It is important to note that the processing of the annotations at the time the module class is instantiated takes some time. It is
