Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Params to Aspects?

AspectJ doesn't provide any dependency injection features, but you can use AspectJ in conjunction with an IoC container that does.

See section 6.8.3 of the Spring Reference Guide for details on configuring aspects using Spring (

Regards, Adrian.

On 15 Mar 2008, at 14:09, Buck, Robert wrote:


I have a family of aspects that are all identical except for an
"internal" name I want to uniquely assign to each aspect instance.
Rather than write one aspect class for each, I'd like to reuse one class
for all. So what I would like to do is something like this:

    <concrete-aspect name="$$Aspect"
      <pointcut name="scope" _expression_="execution(public *
<param name="id" value="hello"/>  <<<<<<  THIS
extends="">  <<<< OR THIS
      <pointcut name="scope" _expression_="execution(public *
    <include within="*"/>

In the above "hello world" example, the aspect would
"System.out.println(id);", or some such.

Is this sort of thing possible?

Alternatively, can one pass in a constructor argument to the named
concrete aspect from the XML definition?

Or, can one pass in arguments to the "scope" method that is generated?

Thanks in advance,

aspectj-users mailing list

Back to the top