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

  • Home
  • SEARCH
  • 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 8725883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:08:33+00:00 2026-06-13T08:08:33+00:00

The create() pointcut works just fine, but I can’t get the setStatus() pointcut to

  • 0

The create() pointcut works just fine, but I can’t get the setStatus() pointcut to work however I try… I’ve tried with @Before, @After, @AfterReturning, but nothing.

According to the debugger, both methods are called.

package com.baz;

@Aspect
public class ServiceAspect {
   @Pointcut("execution(* com.foo.ServiceImpl.create(..))")
    public void create() {}

    @Pointcut("execution(* com.bar.Subscription.setStatus(..))")
    public void setStatus() {}

    // works
    @AfterReturning(pointcut="create()", returning="retVal")
    public void afterCreate(Object retVal) {
        // omitted
    }

    // doesn't work
    @Before("setStatus()")
    public void status() {
        // omitted
    }

    // doesn't work
    @Before("setStatus() && args(status)")
    public void status(int status) {
        // omitted
    }

    // doesn't work
    @After("setStatus()")
    public void status() {
        // omitted
    }

    // doesn't work
    @AfterReturning(pointcut="setStatus()")
    public void status2() {
        // omitted
    }

    // doesn't work
    @AfterReturning(pointcut="setStatus()", returning="retVal")
    public void afterSetStatus(Object retVal) {
        // omitted
    }

    // doesn't work
    @Around("setStatus()")
    public Object aroundStatus(ProceedingJoinPoint pjp) throws Throwable {
        Object output = pjp.proceed();
        return output;
    }
}

The methods looks like this:

public class Subscription extends FooBar implements Baz {
    public void setStatus(int status) { /* ... */ }
}

public class ServiceImpl implements Service {
    public Subscription create(Session session, Subscription template) { /* ... */ }
}

Edit

I’ve tried using both <aop:aspectj-autoproxy />, <aop:aspectj-autoproxy proxy-target-class="true"/> and <aop:aspectj-autoproxy proxy-target-class="false"/>.

Edit 2

I’ve tried calling setStatus() directly on Subscription, but it didn’t catch that either.

Subscription subscription = new Subscription();
subscription.setStatus(1);
  • 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-13T08:08:34+00:00Added an answer on June 13, 2026 at 8:08 am

    Subscription subscription = new Subscription();

    subscription.setStatus(1);

    Subscription should be a spring-managed bean for the aspects to be applied, i.e. you should obtain objects of type Subscription from the ApplicationContext as follows:

    ClassPathXmlApplicationContext context = 
        new ClassPathXmlApplicationContext("classpath:META-INF/Spring.xml");
    Subscription subscription = context.getBean(Subscription.class);
    

    or get them injected using @Resource or @Autowired annotations.

    Then, the call to setStatus() on subscription object will go through the AOP proxy created by Spring framework and the code in the AOP advices that match the method definition get executed.

    Another way to get a spring-managed bean, while creating objects using new operator, is using the @Configurable annotation.

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

Sidebar

Related Questions

How can I create a Pointcut around my methods annotated with @RequestMapping? I have
Is it possible to create a pointcut for SpringBean Serializable ? I want to
Create a new appdomain, setup the assemblyResolve handler and you always get an exception
I need to create an aspect with a pointcut matching a method if: Is
I am trying to apply pointcut to an implemented method in childclass but the
I am using org.aspectj.lang.annotation.Pointcut . I have an interface com.home.learn.Try. I want a pointcut
Create facebook app Using a cURL to post a message from an App but
I created an Aspect with a pointcut to annotated method. What I get as
I want to create a pointcut that matches any method in my Web controller
create unique index In DB2 UDB I can create an index using the following

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.