Tải bản đầy đủ (.pdf) (567 trang)

Manning aspectj in action enterprise AOP with spring applications 2nd edition sep 2009 ISBN 1933988053 pdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (9.85 MB, 567 trang )

www.dbebooks.com - Free Books & magazines

Enterprise AOP with Spring Applications

IN ACTION

Ramnivas Laddad
FOREWORD BY ROD JOHNSON

MANNING


Praise for the First Edition
There are already several books about AspectJ—one of its major advantages.... My
favorite is AspectJ in Action.
—Rod Johnson, Creator of the Spring Framework
in J2EE Development without EJB
One of the clearest expositions of AOP and its benefits that I have seen.... It is
obvious that a lot of care and attention has gone into the preparation of the material.
—Adrian Colyer, AspectJ Project Lead, in The Computer Journal
I would highly recommend AspectJ in Action to anyone who is interested in AOP....
I liked the practical angle, and you could tell that Ramnivas has really used AOP/
AspectJ on his projects.
—Dion Almaer at TheServerSide.com
…real solutions to tough problems.
—Chris Bartling, Identix, Inc.
Laddad brings to the professional community a valuable book, to support AOP
tutoring and adoption...a well-constructed, well-balanced book that delivers what it
promises.
—Computing Reviews at www.reviews.com
I started reading at 11 PM and couldn’t stop…. It’s a must-read for anyone interested


in the future of programming.
—Arno Schmidmeier, AspectSoft
This book is to aspect-oriented programming what the Gang of Four book is to design
patterns.
—Computing Reviews at www.reviews.com
...a wonderful job of introducing the new AOP trend...no other book succeeded to
present the challenges of AOP so well.
—JavaRanch.com

Download at WoWeBook.Com

Licensed to Mylene Corbett <>


More Praise for the First Edition
The author succeeds brilliantly in gradually building your understanding of AOP,
then AspectJ’s own semantics, and then the coding possibilities these offer…. The
writing is clear and accessible, the content expertly graduated.
—a reader at Amazon.co.uk
...one of the few technical books that has blown my hair back.… [I] walked away
feeling as though I had actually grown as a developer.
—Alex Winston at AlexWinston.com
By far the best programming-related book I have read in a long time.
—a reader at Amazon.co.uk
...a very clear and complete treatment of aspects. Like the other books in the “In
Action” series from Manning, it is filled with very good diagrams.... This book will
definitely help.
—on The Daily Channel
...I would recommend going with AspectJ in Action...you will get the most bang for
your buck from Ramnivas’s work.... The subject-oriented approach in this book lends

itself well to future reuse.
—on jroller.com
...exactly what I needed...fantastic use of diagrams, figures, and annotated code.
They solidly add to understanding the content.... I found the book to really be
excellent from all viewpoints for getting into the subject matter from many angles and
diving down very deep into it.
—Max Spille at TheServerSide.com
This book provides a very good resource both for people starting to learn AOP and
AspectJ and for experienced AOP programmers who wish to deepen their knowledge
in this new area.
—Valentin Crettaz, JavaRanch
The only resource that presents AOP concepts and real-world examples in an
approachable, readable way.
—Jean Baltus, Metafron-Infosys

Download at WoWeBook.Com

Licensed to Mylene Corbett <>


AspectJ in Action
Second Edition
ENTERPRISE AOP WITH SPRING APPLICATIONS

RAMNIVAS LADDAD

MANNING
Greenwich
(74° w. long.)


Download at WoWeBook.Com

Licensed to Mylene Corbett <>


For online information and ordering of this and other Manning books, please visit
www.manning.com. The publisher offers discounts on this book when ordered in quantity.
For more information, please contact
Special Sales Department
Manning Publications Co.
Sound View Court 3B fax: (609) 877-8256
Greenwich, CT 06830 email:
©2010 by Manning Publications Co. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in
any form or by means electronic, mechanical, photocopying, or otherwise, without prior written
permission of the publisher.

Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in the book, and Manning
Publications was aware of a trademark claim, the designations have been printed in initial caps
or all caps.
Recognizing the importance of preserving what has been written, it is Manning’s policy to have
the books we publish printed on acid-free paper, and we exert our best efforts to that end.
Recognizing also our responsibility to conserve the resources of our planet, Manning books are
printed on paper that is at least 15% recycled and processed without the use of elemental chlorine.

Manning Publications Co.
Sound View Court 3B
Greenwich, CT 06830


Development Editor:
Copyeditor:
Typesetter:
Cover designer:

Cynthia Kane
Tiffany Taylor
Gordan Salinovic
Marija Tudor

ISBN 978-1-933988-05-4
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 – MAL – 14 13 12 11 10 09

Download at WoWeBook.Com

Licensed to Mylene Corbett <>


To Ashish
In our hearts you will always remain

Download at WoWeBook.Com

Licensed to Mylene Corbett <>


Download at WoWeBook.Com

Licensed to Mylene Corbett <>



brief contents
PART 1

PART 2

UNDERSTANDING AOP AND ASPECTJ .............................1
1



Discovering AOP

3

2



Introducing AspectJ

3



Understanding the join point model 51

4




Modifying behavior with dynamic crosscutting

5



Modifying structure with static crosscutting 116

6



Aspects: putting it all together

7



Diving into the @AspectJ syntax 168

8



AspectJ weaving models

199


9



Integration with Spring

217

27
87

136

APPLICATIONS OF ASPECTJ WITH SPRING ................... 249
10



Monitoring techniques

251

11



Policy enforcement: keeping your design intact 288

12




Learning design patterns 319

13



Implementing concurrency control

14



Managing transactions

373

vii
Download at WoWeBook.Com

Licensed to Mylene Corbett <>

344


viii

BRIEF CONTENTS


15



Securing applications 404

16



Improving domain logic

17



Taking the next step

appendix A



Setting up the example

469

appendix B




Using Ant with AspectJ

486

appendix C



Using Maven with AspectJ

431

459

491

brief contents

Download at WoWeBook.Com

Licensed to Mylene Corbett <>


contents
foreword xix
preface xxiii
preface to the first edition xxv
acknowledgments xxvii
about this book xxix
about the title xxxiv

about the cover illustration xxxv
a real-world perspective of AOP xxxvii

PART 1 UNDERSTANDING AOP AND ASPECTJ .................1

1

Discovering AOP 3
1.1

Life without AOP
Code tangling

1.2
1.3

5

4


Code scattering

Modularizing with AOP 7
Anatomy of an AOP language
The AOP language specification
implementation 10

1.4


Fundamental concepts in AOP

7

9
9



The AOP language

11
contents

ix
Download at WoWeBook.Com

Licensed to Mylene Corbett <>


x

CONTENTS

1.5

AOP by analogy

13


Cascading Style Sheets (CSS)
Event-oriented programming

1.6

Implementations of AOP
AspectJ

1.7

13
15

15



16

Other implementations of AOP



17

Frameworks 17 Code generation
Dynamic languages 22

18




1.8

Costs and benefits of AOP
Costs of AOP

1.9

2

Summary

23



14

15

Spring AOP

Alternatives to AOP

Database systems



Design patterns




19

23

Benefits of AOP

24

25

Introducing AspectJ 27
2.1

Writing your first AspectJ program
Setting up the example

2.2

28



28

Adding an aspect

AspectJ crosscutting construct


29

31

Common crosscutting constructs 31 Dynamic crosscutting
construct: advice 32 Static crosscutting constructs 34




2.3
2.4

AspectJ alternative syntax 37
Weaving mechanisms 39
Source weaving
weaving 41

2.5

39

3

43



39




Load-time

42

The woven class

43

Spring AspectJ integration 44
AspectJ logistics overview 46
IDE integration

2.8

Binary weaving

AspectJ weaving: under the hood
The compiled aspect

2.6
2.7



Summary

46




AspectJ documentation tool

48

49

Understanding the join point model 51
3.1

Understanding the join point model
Join points

3.2

53



Pointcuts

52

54

Categorizing exposed join points

55


Method join points 56 Constructor join points 57 Field
access join points 58 Exception-handler join
points 59 Class-initialization join points 59 Object
initialization join points 60 Object pre-initialization join
points 60 Advice execution join points 61














Download at WoWeBook.Com

Licensed to Mylene Corbett <>

17


xi

CONTENTS


3.3

Join point demonstration example
The aspect

3.4

61



The result

62

Understanding pointcut basics
Named and anonymous pointcuts

3.5

Signature syntax

61

64
64




Pointcut operators

65

65

Type signature patterns 66 Method and constructor signature
patterns 69 Field signature patterns 73




3.6

Implementing pointcuts
Kinded pointcuts

3.7

4

Summary

75



75

Non-kinded pointcuts


77

85

Modifying behavior with dynamic crosscutting
4.1

Advice overview

88

Advice classification

4.2

88



Advice syntax

Comparing advice to methods

Advice in depth
Before advice

4.4

92


90

Differences between



92


After advice

Collecting join point context
Collecting objects at the join point
caching 102

4.5

88

90

Similarities between advice and methods
advice and methods 91

4.3

87

92




Around advice

94

99
99



Implementing simple

Accessing join point context via reflection

105

The reflection API 106 Improving caching using reflection
APIs 109 Comparing the reflection API to pointcuts 113




4.6

5

Summary


115

Modifying structure with static crosscutting
5.1

Introducing members

116

117

Scattering and tangling 117 Untangling with
aspects 118 Mixing with mixins 121 Member
introduction rules 123 Idiom: Providing a default interface
implementation 124








5.2
5.3
5.4
5.5

Modifying the type hierarchy 128
Introducing members to multiple types 129

Supplying annotations 130
Declaring weave-time errors and warnings 132
Download at WoWeBook.Com

Licensed to Mylene Corbett <>


xii

CONTENTS

5.6
5.7

6

Softening checked exceptions
Summary 134

133

Aspects: putting it all together 136
6.1

Working with aspects

137

Similarities between aspects and classes
aspects and classes 139


6.2

Aspect association

137



Differences between

140

Default singleton association 141 Per-object association 143
Per-control-flow association
145 Per-type association 148
Implicit limiting of join points with aspect associations 150
Accessing aspect instances 151 Comparing per-object
association and member introduction 152 Improving the
caching aspect 153








6.3


Aspect precedence

159

Ordering of advice 161 Explicit aspect precedence
Ordering advice in a single aspect 164

162



6.4
6.5

7

Privileged aspects
Summary 167

166

Diving into the @AspectJ syntax 168
7.1

7.2

Syntax overview

169


Natural mapping
detection 171

170

Mapping aspects

172

Java compatibility



171



Early error

Specifying aspect association 173 Accessing the aspect
instance 173 Declaring aspect precedence 173




7.3

Mapping pointcuts

174


Mapping abstract pointcuts

7.4



180



The after advice

Mapping static crosscutting

175

179

184



The around

189

Mapping weave-time declarations
parents 190


7.6

Mapping concrete pointcuts

Mapping dynamic crosscutting constructs
The before advice
advice 187

7.5

174

189



Mapping declare

Features not implemented in @AspectJ

194

Associating annotations 194 Introducing data and methods
Softening exceptions 195 Privileged aspects 196




Download at WoWeBook.Com


Licensed to Mylene Corbett <>

194


xiii

CONTENTS

7.7
7.8

8

Comparing syntax styles
Summary 197

196

AspectJ weaving models 199
8.1
8.2

Classifying weaving models
Build-time weaving 201

200

Build-time source code weaving
weaving 202


8.3

Load-time weaving

9



Build-time binary

206

Load-time weaving overview
weaver 208

8.4
8.5
8.6

201

206



Configuring the load-time

Load-time weaver in action 213
Choosing syntax and weaving 215

Summary 216

Integration with Spring 217
9.1

Spring AOP fundamentals

218

Setting up the application 219 Utilizing the @AspectJ
syntax 221 Spring IDE 222




9.2

Spring AOP under the hood

222

A quick introduction to dynamic proxies 223 Proxy-based
AOP with Spring 224 Spring AOP internals 225 Proxybased AOP in DI framework 226 Limitations of Spring
AOP 227









9.3

@AspectJ support in depth
Dynamic crosscutting

9.4

230

Schema-style AOP support

229


Static crosscutting

235

236

Mapping aspects 236 Mapping pointcuts 237
advice 238 Mapping static crosscutting 239




Mapping




9.5

Tapping into the full power of AspectJ
Configuring aspects using Spring DI
LTW 241

9.6

Choosing an appropriate AOP system
Comparing AspectJ to Spring AOP
syntax 246 It’s decision time


9.7

240

Summary

245
246



240


Spring-driven


245
Comparing Spring AOP

247

Download at WoWeBook.Com

Licensed to Mylene Corbett <>


xiv

CONTENTS

PART 2 APPLICATIONS OF ASPECTJ WITH SPRING .......249

10

Monitoring techniques 251
10.1

Tracing in action

252

Tracing the aspect-oriented way
way 255

10.2

10.3

253

Tracing the conventional

Conventional vs. AOP tracing 257
Selecting join points of interest 258
Selection based on static structure
dynamic context 263

10.4



Tracing

259



Selection based on

264

Indenting trace calls 264 Sharing tracing aspect functionality
Tracing intra-method activities 267 Logging the method
parameters 268 Choosing a type-specific logger 270



266





10.5

A detour: deployment options for monitoring aspects
Utilizing load-time weaving
tracing 273

10.6
10.7

271



Exception monitoring 275
Improving conventional logging

Utilizing Spring AOP for

277

Modularizing NDC with conventional logging
Modularizing MDC with conventional logging

10.8

10.9
10.10

11

Performance monitoring 281
Runtime control of monitoring aspects
Summary 286

277
279

284

Policy enforcement: keeping your design intact 288
11.1
11.2
11.3

AOP-based policy enforcement overview
Policy origins and destinations 294
Enforcement using AOP 294
Compile-time enforcement

11.4
11.5



Runtime enforcement


Comparison with code-analysis tools 297
Implementing flexible access control 298
Restricting exposure
collaboration 299

11.6
11.7

295

289

298 Limiting
Enforcing the factory pattern




301

Enforcement idiom: return-value restriction 303
Enforcing JPA-JDBC integration policies 304
Download at WoWeBook.Com

Licensed to Mylene Corbett <>

296

271



xv

CONTENTS

11.8

Implementing EJB policies

308

Developing a core EJB enforcement aspect 309 Defining EJB
pointcuts 310 Dealing with XML-based EJBs 312
Implementing a “no EJBs” policy 312




11.9

Detecting Swing concurrency control policy violations
Understanding the problem

11.10

12

Summary


314



Detecting the violation

313

315

318

Learning design patterns 319
12.1

The worker object pattern

320

The current solution 320 An overview of the worker object
pattern 321 The worker object pattern template 321
Getting the return value 324 A summary of the worker object
pattern 326






12.2


The wormhole pattern

327

The current solution 327 An overview of the wormhole pattern 327
The wormhole pattern template 328 A summary of the wormhole
pattern 330




12.3

The participant pattern

330

Current solutions 331 An overview of the participant
pattern 333 The participant pattern template 333
Consequences of the participant pattern 336 A summary of the
participant pattern 336






12.4


Annotation-driven participant pattern

336

Current solution 337 The annotation-driven participant
pattern template 337 Annotation type abstraction 338
Variation: bridged participation pattern 341 Role of ADPP in
library aspects 342






12.5

13

Summary

343

Implementing concurrency control 344
13.1

Modularizing Swing’s single-thread rule

345

A test problem 346 Solution: the conventional way 348

Solution: the AspectJ way 351 Improving the solution 361




13.2
13.3

Improving the responsiveness of UI applications
Modularizing the read-write lock pattern 365
Implementation: the conventional way
AspectJ way 367

13.4

Summary

365



362

Implementation: the

371

Download at WoWeBook.Com

Licensed to Mylene Corbett <>



xvi

CONTENTS

14

Managing transactions 373
14.1

Transaction management implementations
Conventional implementation
implementation 375

14.2

374



Transaction-management players

374

AOP

376

Transaction management in architecture 376 Transaction

management: one concept, too many implementations 377
Transaction-management abstraction 377


14.3

Aspect implementation choices
Proxy-based AOP

14.4

378



Byte-code weaving

379

Transaction-management aspect (almost) from scratch
Implementing the aspect
test for the aspect 384

14.5

378

380

Testing the aspect




Spring’s transaction management

382



379

Road

390

XML-driven transaction management 391 Annotation-driven
transaction management 393 AspectJ weaver-based transaction
management 394




14.6

Implementing fault tolerance for transactional operations
Base aspect 395 Using the annotation-driven participant
pattern 397 Configuring the aspect 398 Testing the faulttolerance aspect 399 Improving the solution 401









14.7

15

Summary

402

Securing applications 404
15.1

Securing applications with conventional techniques
The do-it-yourself approach
approach 406

15.2
15.3



407



Authorization


408

Implementing a security solution from scratch
Implementing authentication aspects
authorization aspects 413

15.5
15.6

405

The framework-based

Modularizing security using AOP 406
A quick overview of Spring Security 407
Authentication

15.4

405

410



409

Implementing


Implementing field-level authorization 421
Spring Security prebuilt solutions 425
Web security 425
security 428



Service level security

425



Download at WoWeBook.Com

Licensed to Mylene Corbett <>

Domain-object

395


xvii

CONTENTS

15.7

Additional ideas in implementing security
Auditing access


15.8

16

Summary

429

428

Filtering field content



429

429

Improving domain logic 431
16.1

Empowering objects

432

Enabling rich behavior 433 Injecting dependencies with Spring
and AspectJ 434 Possibilities enabled by domain-object DI 442





16.2

Implementing business logic

447

Improving inventory management 447 Checking for the orderlevel constraint 449 Refactoring using aspects 450




16.3

Managing access to objects
Applying specific policies

16.4

17

Summary

452

452




Applying general policies

453

458

Taking the next step 459
17.1

The adoption path: technologies
Spring AOP

17.2

460

460

460



462



460

Production aspects


Applying AOP to new problems
Talking the talk

17.4

AspectJ

The adoption path: applications
Development aspects

17.3



459

462

462

Walking the walk

Employing AOP in development phases

463

464

AOP in the design phase 464 AOP in the implementation
phase 464 AOP in the maintenance phase 466 AOP in

legacy projects 467




17.5
appendix A
appendix B
appendix C

Parting thoughts



468

Setting up the example 469
Using Ant with AspectJ 486
Using Maven with AspectJ 491
index 497

Download at WoWeBook.Com

Licensed to Mylene Corbett <>


Download at WoWeBook.Com

Licensed to Mylene Corbett <>



foreword
This is a timely book, about a powerful and widely used technology that continues to
grow in importance.
Since the first edition of AspectJ in Action, much has changed in AspectJ and the
broader environment. This comprehensive update squarely addresses these changes.
Among the changes, three issues stand out: important new capabilities of AspectJ,
increasing interest in dynamic languages in general and on the JVM, and the emergence of AspectJ as a key practical technology in mainstream enterprise Java.
AspectJ has matured greatly since the first edition. It now has comprehensive support for Java annotations, along with support for other language improvements such as
generics, variable-length argument lists, and covariant return types. Annotations fit
hand in glove with AOP, providing an ideal way of adding information about program
structure and semantics for use by aspects. For example, one concise aspect might add
consistent additional behavior to all executions of a method with a given annotation;
another might cause a set of classes to be annotated with a particular annotation to
direct an enterprise framework to add behavior at runtime. These language enhancements not only simplify the authoring of many aspects—they also make AspectJ an ideal
match for modern enterprise Java programming models, and truly a new language.
The last few years has seen a significant rise in interest in dynamic languages—many
of which (such as Groovy) provide capabilities for metaprogramming. Although this is
a welcome change, it has caused some confusion regarding the role of AOP. Metaprogramming can solve some of the problems solved by AOP, but it doesn’t directly offer
the ability to exploit program structure in a complementary way to OOP that is core to

xix
Download at WoWeBook.Com

Licensed to Mylene Corbett <>


xx

FOREWORD


AOP. This book will help you understand which approach is appropriate to your everyday problems and how you can use them together. Ramnivas Laddad neatly expresses
the relationship between AOP and dynamic languages in Chapter 1: “…statically typed
languages use AOP to gain metaprogramming support. In contrast, dynamic languages
benefit from AOP as a disciplined application of metaprogramming.”
Another important change since the first edition of this book is the rise of modern
frameworks, which constitutes a huge validation of AOP. Today, the Spring Framework
has become the most popular component model for enterprise Java. Its core benefit—sophisticated provision of declarative services to simple POJOs containing business
logic and unpolluted by infrastructure concerns—is built on AOP, and its popularity
and proven usefulness demonstrate the benefits of the modularization AOP is designed
to achieve. (Indeed, all modern enterprise Java technologies follow Spring’s approach
of providing enterprise services with minimal infrastructure API calls in user code.)
Furthermore, Spring 2.0 made the important architectural decision to adopt the
AspectJ pointcut expression language—the heart of AspectJ—and a subset of the
AspectJ annotation programming model as its preferred AOP programming
model—another validation, which exposes more developers to the benefits of AspectJ.
As a result, AspectJ works hand in hand with Spring and is particularly relevant to
solving enterprise Java problems. Ramnivas has embraced this synergy in this book: he
explains clearly how you can benefit from AspectJ concepts if you’re already using
Spring, and how AspectJ the language is a natural extension of the AOP concepts supported by Spring. Readers who aren’t using Spring will still benefit from the valuable
case studies and examples the Spring AOP experience provides.
This practical bent is important and to be commended. Programming languages
are only as valuable as their practical usage potential, as history repeatedly shows.
Another key to practical usage potential is tool support. In the case of AspectJ, there
has recently been a huge step forward in this regard. Improvements to the Eclipse
AspectJ plugin (AJDT) have resulted in dramatic performance and stability improvements, making AspectJ easier for less experienced developers to use. Meanwhile, the
new Spring Roo project ( makes innovative use of
AspectJ in greatly simplifying the authoring of enterprise Java applications. Not only is
this a further validation of AspectJ, but it also promises to make the full power of
AspectJ available in a large number of applications without developers needing to

make an explicit choice to adopt AspectJ.
Together, these advances remove a key practical barrier to adopting AspectJ. The
remaining barrier to adoption is the effort in learning AOP and AspectJ concepts—an
effort well worth making. Learning AspectJ is like learning to type: it requires the
investment of some time up front to be able to reap ongoing rewards in productivity.
This book will make that effort as easy and as pleasurable as possible. As you learn
about AOP and AspectJ, I highly recommend Ramnivas Laddad as your guide.
A long-term advocate of AOP, Ramnivas is outstandingly knowledgeable about his
subject. Even more important, he deeply understands how it fits into a broader context.
foreword

Download at WoWeBook.Com

Licensed to Mylene Corbett <>


FOREWORD

xxi

Through many years of experience as an enterprise architect and consultant, he has
gained a deep practical knowledge about real-world problems, seeing aspects as just one
(albeit an important) weapon in the armory of the modern architect. This experience
stands out in the relevance and value of the examples and in the fact that the book is
well balanced. Ramnivas isn’t a mere cheerleader, and he provides excellent discussion
of alternatives to AOP that will help you make the right architectural choices.
Finally, this book, like the previous edition, is a pleasure to read. Clear, concisely
worded, and well organized, it will make your navigation of AspectJ and AOP concepts
easy.
I wish you great success with AspectJ and the Java platform, and I hope you enjoy

reading this book as much as I have.
ROD JOHNSON
CREATOR OF THE SPRING FRAMEWORK

Download at WoWeBook.Com

Licensed to Mylene Corbett <>


Download at WoWeBook.Com

Licensed to Mylene Corbett <>


preface
My association with AOP and AspectJ has now lasted more than a decade. I still remember my initial experience with AspectJ around 1998 and more serious exploration
in 2002. It felt like a breath of fresh air that finally addressed some of the shortcomings
of object-oriented programming. My initial experimentation led me to write an article
series in JavaWorld in 2002 and the first edition of this book in 2003. After writing the
book, I gave talks at many conferences about facets of AOP and AspectJ, and how to use
them with the Spring Framework commonly referred to as Spring. Over the last few
years, as a Spring committer, I have been trying to improve Spring-AspectJ integration.
While doing this, I have been actively using these technologies on many projects. This
book is a reflection of my experience with the technologies, understanding the best
ways to explain them, and finding pragmatic ways to adopt them.
A lot has changed since the publication of the first edition of this book. Back then,
AspectJ was a new language, Spring had just come out, and alternative languages on
the Java platform were far fewer. Now, AspectJ is a 10-year-old language, Spring is the
de facto lightweight framework for developing enterprise software, and new languages
on the Java platforms are numerous.

Yet some things haven’t changed. Software complexity is still increasing at breakneck speed. Our ability to cope with complexity remains essentially unaltered. As a
result, our search for better ways to reduce implementation complexity also remains
unchanged. These factors make AOP implemented using AspectJ an important tool in
an enterprise Java developer’s toolbox.
preface

xxiii
Download at WoWeBook.Com

Licensed to Mylene Corbett <>


xxiv

PREFACE

The changes to AspectJ have been dramatic. It now includes two syntax possibilities: the traditional syntax and the annotation-based @AspectJ syntax, which lowers
the barrier to begin using AspectJ. It supports many weaving possibilities, including
load-time weaving, making the use of AspectJ for applications such as monitoring and
tracing a simple experience. To top it off, Spring has adopted AspectJ’s programming
model as its AOP solution. This caused the Spring community to be drawn to the
power of AOP with AspectJ as the preferred programming model.
Below the surface, significant changes have also taken place. SpringSource (now
part of VMWare) is sponsoring AspectJ development. Due to the complexity involved
on the compiler and tools front, projects such as AspectJ require serious attention. Fulltime development afforded by SpringSource support has been crucial in recent years.
And so, it was time to write a new edition of AspectJ in Action. My initial thought was
that I would update most chapters with new AspectJ features and update a few examples. I estimated the overall effort would take six months. Boy, was my estimate off the
mark! It took more than three years to update and re-update the book. There were
many reasons (besides being busy at my day job). AspectJ kept improving over the last
three years. The ecosystem surrounding Spring changed dramatically. Through my

consulting experience, my understanding of the problems that AOP is trying to solve
and its adoption in the real world changed, as well. Therefore, many examples from the
first edition wouldn’t work any more, even if I gave them a facelift. Like the first edition,
I wanted this book to be of immediate practical value. Therefore, I decided to rewrite
many of the chapters and most of the examples. I’m glad that I took that path.
I humbly hope that you’ll appreciate my effort, like this book, and use it in your
applications.

Download at WoWeBook.Com

Licensed to Mylene Corbett <>


×