Annotation Interface AfterActionSpec


@Target(METHOD) @Retention(RUNTIME) public @interface AfterActionSpec
Marks a method as a post-action handler that runs after the action completes.

AfterAction methods are called after the action method body executes, allowing for post-processing tasks like:

  • Saving results to database
  • Writing audit logs
  • Updating cache
  • Sending notifications
  • Triggering follow-up actions

The annotation is placed on the AfterAction method itself, not on the action method. The value specifies which action this AfterAction belongs to.

AfterAction methods can have one of these signatures:

  • void afterActionMethod(ActionParams params, Object result)
  • void afterActionMethod(ActionParams params)
  • Object afterActionMethod(ActionParams params, Object result) - can modify result

Example usage:


 @ActionSpec(type = WEB_SERVICE, endpoint = "...")
 public Object getWeather(String location, ActionResult result) {
     return formatWeatherResult(result);
 }

 @AfterActionSpec("getWeather")
 public void afterGetWeather(ActionParams params, Object result) {
     // Save to database
     weatherRepository.save(params.getString("location"), result);

     // Write audit log
     auditLog.info("Weather queried for: " + params.getString("location"));
 }
 

AfterAction methods can be private, protected, or public.

See Also:
  • invalid reference
    BeforeAction
  • invalid reference
    Action
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The name of the action method this AfterAction belongs to.
  • Element Details

    • value

      String value
      The name of the action method this AfterAction belongs to.
      Returns:
      the action method name