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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:24:03+00:00 2026-06-10T00:24:03+00:00

I would like my first Aspect in a Roo project to run the advice

  • 0

I would like my first Aspect in a Roo project to run the advice when a web controller starts up. But I cant get the pointcut to match.

The controllers have a class name starting Cfx. I have tried with the following form:

pointcut setBrand() : initialization(Cfx*.new (..));

before()  : setBrand()
{
    log.info("xxxxxxxxxxxx  setting brand");
}

As well as “initialization” I have tried (from the book AspectJ Cookbook) call(Signature) with new keyword, preinitialization, staticinitialization. What is the formula?

Maybe this is related – the Roo aspects do not have this form – no pointcut for example. How are they working? Where is this documented?

Thanks

PS apologies, this is a re-post. I posted this to the Spring Roo forum but got no response. http://forum.springsource.org/showthread.php?129374-Aspect-to-trap-Controller-creation-how-to

  • 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-10T00:24:04+00:00Added an answer on June 10, 2026 at 12:24 am

    I know next to nothing about Roo or Spring, but some AspectJ, so I am going to answer your question from an AspectJ perspective only, assuming that you are an AOP newbie (sorry if my assumption is incorrect):

    • If you want to do something when a class is loaded, use a staticinitialization(TypePat) pointcut.
    • If you want to do something when an object (instance) is created, use something like execution(ConstructorPat). The initialization is for special purposes and preinitialization is needed even more rarely. I am assuming that the first one will do for you, not knowing your exact purpose.
    • Further assuming that something like execution(Cfx*.new (..)) is basically the thing you want, I suggest you look at possible errors or warnings like “advice defined in … has not been applied [Xlint:adviceDidNotMatch]”, because it might just be a pointcut matching issue. Please note that the type pattern you use assumes the matched constructors are in the same package as the aspect and that they have standard visibility (not public or anything else). So unless there is a class-loading issue, maybe you just want to specify more exactly (or more generally) what you want to match. Examples:
      • com.bigboxco.my_app.Cfx*.new(..)
      • com.bigboxco..Cfx*.new(..)
      • public com.bigboxco..Cfx*.new(..)
      • !private com.bigboxco..Cfx*.new(..)
      • * com.bigboxco..Cfx*.new(..)

    A good strategy could be trying to match one of your constructors by replicating its exact signature and using its fully qualified class name, then working on from that point to make it more general.

    Update: I know you can do a web search by yourself, but anyway here are some useful links:

    • AspectJ quick reference
    • AspectJ language semantics with topics about signatures, matching etc.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to get the first item from a list matching a condition.
For example, I have two elements in an enum. I would like the first
I would first like to admit that I am an extremely novice developer, so
I would like to keep first link as default selected with javascript, here is
I have the following String First Last <first.last@email.com> I would like to extract first.last
I would like to display the first and last name of the authenticated user.
I would like to replace the first character ' x ' with the number
I would like to make a First Access Database Setup Process in my spring
I would like to find the first occurrence of a string, after a certain
I would like to subset out the first 5 minutes of time series data

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.