Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9268333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:47:04+00:00 2026-06-18T14:47:04+00:00

Is it possible to perform an action at the end of a method, in

  • 0

Is it possible to perform an action at the end of a method, in other words when the function control returns to the caller(either because of exception or normal return) using an annotation ?

Example:

@DoTaskAtMethodReturn
public void foo() {
.
.
. 
Method foo Tasks  
.
.
.

return;  -------->  Background task done by annotation hook here before returning to caller.
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T14:47:06+00:00Added an answer on June 18, 2026 at 2:47 pm

    Your question is tagged with Spring-Annotations, so you are obviously using Spring. There are several steps to do what you want with Spring:

    Enable AspectJ/AOP-Support in your configuration:

    <aop:aspectj-autoproxy/>
    

    Write an Aspect (c.f. Spring AOP vs AspectJ) that uses @After and the @annotation pointcut:

    @Aspect
    public class TaskDoer {
    
      @After("@annotation(doTaskAnnotation)")
      // or @AfterReturning or @AfterThrowing
      public void doSomething(DoTaskAtMethodReturn doTaskAnnotation) throws Throwable {
        // do what you want to do
        // if you want access to the source, then add a 
        // parameter ProceedingJoinPoint as the first parameter
      }
    }
    

    Please note the following restrictions:

    • Unless you enable AspectJ compile-time weaving or use a javaagent parameter, the object containing foo must be created via Spring, i.e. you must retrieve it from the application context.
    • Without additional dependencies, you can only apply aspects on methods that are declared through interfaces, i.e. foo() must be part of an interface. If you use cglib as an dependency, then you can also apply aspects on methods that are not exposed though an interface.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to update from an action/method other than the update action/method? For
Is it possible to update from an action/method other than the update action/method? For
Is it possible to perform an action when a UITableViewCell is highlighted? For example
Is it possible to perform a specific action after the resize event (of the
Is it possible to perform custom action when user touch autodetected phone link in
Is it possible to perform the reverse action of $(this) ? So instead of
I was wondering if would be possible to perform an action for each time
Is it possible to perform a Modal Segue like action, not using Storyboard? In
Is this possible to show MapView on a Dialog in android and perform action
Is it possible to perform a partial or patch commit in Team Foundation? I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.