Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Re: [NEWSDELIVER] Re: Scoping of weaved classes per aspect in aop.xml?


Barry,

Be very careful. There is no such thing as a private aop.xml file ("... put these aspects in their own module with their own aop.xml, ..."). AspectJ LTW will use every aop.xml file it can find and apply it to all the classed defined by the associated class loader. Please note the "Configuring Load-time Weaving with aop.xml files" section of the Development Environment Guide in particular: "The weaver is configured using one or more META-INF/aop.xml files located on the class loader search path." and "When several configuration files are visible from a given weaving class loader their contents are conceptually merged.". You cannot rely on packaging or the order in which you build your application to determine the scope of weaving. The only way to limit the scope of an aop.xml file is to use a modularity framework like OSGi. Alternatively revisit your pointcuts to ensure they only target the desired classes.

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx

http://w3.hursley.ibm.com/~websterm/

To:        Matthew Webster/UK/IBM@IBMGB
cc:        
Subject:        Re: [NEWSDELIVER] Re: Scoping of weaved classes per aspect in aop.xml?


Ok, this makes sense. The aspect in question is really to work around some limitations in the Seam EJB3 configuration which is preventing me from integrating cleanly with Spring (ie, concrete classes doing stuff with other concrete classes in their constructors). So really I should just put these aspects in their own module with their own aop.xml, and hence I will be sure that only these specific "hack-around" aspects get weaved into Seam.

thanks Matthew!

-barry

Matthew Webster wrote:


Barry,


You are correct; you cannot scope concrete aspects _individually_ using aop.xml. The LTW configuration was not designed to achieve this, merely to allow certain aspects or certain classes to be excluded from weaving. What you are trying to do is probably not a good idea as the definition of your cross-cutting, which should be modularized, would be in  two places: aspect, aop.xml. A better approach would be to either refine the pointcut in your concrete aspect or leave it abstract to allow different applications to tailor it (something we recommend in large projects).


Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB,
matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/

To:        undisclosed-recipients:;
cc:        
Subject:        
[NEWSDELIVER] Re: Scoping of weaved classes per aspect in aop.xml?


From: Matthew Webster

Barry,


Please take a look at the load-time weaving documentation:
http://www.eclipse.org/aspectj/doc/released/devguide/ltw.html. You can achieve what you want with the "concrete-aspect" aop.xml element. You just have to supply the abstract super-aspect.

---


Matthew, I poured over that doc already, but I don't see how I can achieve this with the concrete-aspect. I'm trying to specify that "no aspects should weave into package-X except aspect-Y". The "other" aspects are already concrete will happily weave into package-X if its included in the weaver section.

Maybe I'm just not seeing it? Do you know of an example that does this with concrete-aspects?

I suppose I could segregate the aspect into its own jar with its own aop.xml... but I'm looking for easier way.

thanks!

-barry



Back to the top