O'Reilly logo

AspectJ Cookbook by Russ Miles

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

2.8. Selecting the Aspects That Are Woven in a Build Within Eclipse

Problem

You want to vary the aspects that are woven into your application when developing in Eclipse.

Solution

Create a separate AspectJ build configuration for each different selection of aspects that you want to weave into your application. Eclipse then allows you to select the current build configuration it will use to build your AspectJ project so you can easily select the set of aspects you want to apply for a particular build.

Discussion

Recipe 2.3 showed that the AspectJ compiler can use a build confiuguration .lst file to select the classes and aspects it will include in its aspect weaving. By default, an AspectJ project in Eclipse has a single .lst file, naturally called default.lst, that lists all the of the files in your project. Using this default, the AspectJ compile will apply all the aspects to all of classes where indicated by the pointcut logic in those aspects.

For many applications, this default behavior is fine but there are times when you may want to vary the aspects that are applied to a particular application depending on such things as deployment target or feature selection. AspectJ provides a neat way of varying the selection of aspects to be applied using a custom build configuration .lst file that excludes or includes the aspects you wish to apply.

Eclipse provides the means by which a custom AspectJ build configuration can be created and used for a particular project.

When the project created ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required