[BooK] Aspectj Cookbook.pdf


Aperçu du fichier PDF book-aspectj-cookbook.pdf

Page 1 2 345364




Aperçu texte


Contents
Contents .............................................................................................................................................. 3
Preface................................................................................................................................................. 7
Audience......................................................................................................................................... 8
About This Book ............................................................................................................................ 9
Assumptions This Book Makes .................................................................................................... 11
Conventions Used in This Book ................................................................................................... 12
Using the Code Examples............................................................................................................. 13
We'd Like to Hear from You ........................................................................................................ 14
Safari Enabled............................................................................................................................... 15
Acknowledgments ........................................................................................................................ 16
Chapter 1. Aspect Orientation Overview .......................................................................................... 17
1.1. A Brief History of Aspect Orientation................................................................................... 18
1.2. AspectJ................................................................................................................................... 19
1.3. A Definition of Aspect Orientation ....................................................................................... 20
1.4. Where to Go for More Information ....................................................................................... 22
Chapter 2. Getting Started with AspectJ ........................................................................................... 23
Introduction .................................................................................................................................. 24
Recipe 2.1. Installing AspectJ ...................................................................................................... 25
Recipe 2.2. Developing a Simple Aspect ..................................................................................... 28
Recipe 2.3. Compiling an Aspect and Multiple Java Files........................................................... 31
Recipe 2.4. Weaving Aspects into Jars......................................................................................... 33
Recipe 2.5. Weaving Aspects at Load Time................................................................................. 35
Recipe 2.6. Generating Javadoc Documentation .......................................................................... 38
Recipe 2.7. Compiling an AspectJ Project Using Eclipse ............................................................ 41
Recipe 2.8. Selecting the Aspects That Are Woven in a Build Within Eclipse ........................... 45
Recipe 2.9. Building an AspectJ Project Using Ant ..................................................................... 49
Chapter 3. Deploying AspectJ Applications ..................................................................................... 50
Introduction .................................................................................................................................. 51
Recipe 3.1. Deploying a Command-Line AspectJ Application.................................................... 52
Recipe 3.2. Deploying an AspectJ Application as a Fully Contained Executable JAR File ........ 55
Recipe 3.3. Deploying a Java Servlet That Uses AspectJ ............................................................ 58
Recipe 3.4. Deploying a JSP That Uses AspectJ.......................................................................... 63
Recipe 3.5. Deploying an Axis Web Service That Uses AspectJ................................................. 68
Chapter 4. Capturing Joing Points on Methods ................................................................................ 71
Introduction .................................................................................................................................. 72
Recipe 4.1. Capturing a Method Call ........................................................................................... 73
Recipe 4.2. Capturing the Parameter Values Passed on a Method Call ....................................... 77
Recipe 4.3. Capturing the Target of a Method Call...................................................................... 79
Recipe 4.4. Capturing a Method When It Is Executing ................................................................ 81
Recipe 4.5. Capturing the Value of the this Reference When a Method Is Executing ................. 83
Chapter 5. Capturing Join Points on Exception Handling ................................................................ 85
Introduction .................................................................................................................................. 86
Recipe 5.1. Capturing When an Exception Is Caught .................................................................. 87
Recipe 5.2. Capturing the Thrown Exception............................................................................... 89
Recipe 5.3. Capturing the Object Handling the Exception........................................................... 90
Chapter 6. Capturing Join Points on Advice..................................................................................... 92
Introduction .................................................................................................................................. 93
Recipe 6.1. Capturing When Advice Is Executing ....................................................................... 94
Recipe 6.2. Excluding Join Points That Are a Result of Advice Execution................................. 96
Recipe 6.3. Exposing the Original Join Point When Advice Is Being Advised ........................... 99