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 6767633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:58:29+00:00 2026-05-26T14:58:29+00:00

I have a Class, call it X, in this class I have successfully advised

  • 0

I have a Class, call it X, in this class I have successfully advised a method call it method(){} from an Annotated Spring.

So, here it is:

public class X {
    public void method(){...}
    public void method2(){...}
}

Here is my aspect, shortened of course:

@Aspect
public class MyAspect{
    @Pointcut("execution(* X.method(..))")
    public void methodJP(){}

    @Pointcut("execution(* X.method2(..))")
    public void method2JP(){}

    @Around("methodJP()")
    public void doMethodJP(ProceedingJoinPoint pjp) throws Exception {
        pjp.proceed(); //Amongst other things!!!
    }

    @After("method2JP()")
    public void doMethod2JP(JoinPoint jp) throws Exception {
        //Do some stuff here
    }
}

Now… both join points work well, however, I within my X.method, I also call the method that is advised by method2JP()… and of course, my method2JP does not get triggered.

Is there any way I can get this to work?

Thanks.

  • 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-05-26T14:58:29+00:00Added an answer on May 26, 2026 at 2:58 pm

    Since Spring AOP works by proxying classes, for the advice to be invoked, you must call the method through the proxy or wrapper supplied by the bean factory.

    If you don’t want to break out into multiple classes, you can have the method retrieve a the proxied version of “itself” from the beanfactory. Something like this

    @Service
    public class MyService {
        @Autowired
        ApplicationContext context;
    
        public void method1() {
            context.getBean(MyService.class).method2();
        }
    
        public void method2() {
        }
    
    }
    

    This will guarantee that the invocation of method2 from method1 will apply any aspects on the method2 pointcut.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Visual Studio 2008 (C++) I have a class destructor (Let's call this class
I have derived from a 3rd party class, and when I attempt to call
I have a custom-authentication-provider defined in my Spring Security configuration. This class implements AuthenticationProvider,
Say I have a class like this: public class MyClass { public string Name;
I have this class ('Scheduler.as'): package { import flash.events.TimerEvent; import flash.utils.Timer; public class Scheduler
Currently I have this problem. Client downloads from server successfully only the 1st time.
I have small class called 'Call' and I need to store these calls into
Say you have a custom class call it Foo. When you then have an
In python, If I have a class foo , I can call foo.__module__ to
I have a template class that I serialize (call it C), for which 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.