aspectj in action

513 175 0
aspectj in action

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

www.it-ebooks.info AspectJ in Action www.it-ebooks.info www.it-ebooks.info AspectJ in Action P RACTICAL A SPECT -O RIENTED P ROGRAMMING RAMNIVAS LADDAD MANNING Greenwich (74° w. long.) www.it-ebooks.info For online information and ordering of this and other Manning books, go to 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. 209 Bruce Park Avenue Fax: (203) 661-9018 Greenwich, CT 06830 email: orders@manning.com ©2003 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 they publish printed on acid-free paper, and we exert our best efforts to that end. Manning Publications Co. Copyeditor: Liz Welch 209 Bruce Park Avenue Typesetter: Denis Dalinnik Greenwich, CT 06830 Cover designer: Leslie Haimes ISBN 1-930110-93-6 Printed in the United States of America 12345678910–VHG–05 040302 www.it-ebooks.info To my late grandfather, Jodhrajji. You were always there for me. www.it-ebooks.info www.it-ebooks.info vii P ART 1U NDERSTANDING AOP AND A SPECT J 1 1 ■ Introduction to AOP 3 2 ■ Introducing AspectJ 32 3 ■ AspectJ: syntax basics 64 4 ■ Advanced AspectJ 100 P ART 2B ASIC APPLICATIONS OF A SPECT J 143 5 ■ Monitoring techniques: logging, tracing, and profiling 145 6 ■ Policy enforcement: system wide contracts 178 7 ■ Optimization: pooling and caching 202 P ART 3A DVANCED APPLICATIONS OF A SPECT J 243 8 ■ Design patterns and idioms 245 9 ■ Implementing thread safety 286 10 ■ Authentication and authorization 323 brief contents www.it-ebooks.info viii BRIEF CONTENTS 11 ■ Transaction management 356 12 ■ Implementing business rules 391 13 ■ The next step 425 A ■ The AspectJ compiler 438 B ■ Understanding Ant integration 447 ■ resources 455 ■ index 461 www.it-ebooks.info ix preface xvii how real is AspectJ? xix into the future! xxi acknowledgments xxiii about this book xxv P ART 1 U NDERSTANDING AOP AND A SPECT J 1 1 Introduction to AOP 3 1.1 The architect’s dilemma 5 1.2 Evolution of programming methodologies 6 1.3 Managing system concerns 7 Identifying system concerns 8 ■ A one-dimensional solution 10 ■ It’s all about modularizing 11 1.4 Implementing crosscutting concerns in nonmodularized systems 14 Symptoms of nonmodularization 15 ■ Implications of nonmodularization 18 ■ Introducing AOP 19 A bit of history 20 ■ The AOP methodology 21 contents www.it-ebooks.info [...]... Applying AspectJ to new problems 426 Talking the talk 426 ■ Walking the walk www.it-ebooks.info 427 xv xvi CONTENTS 13.2 Employing AspectJ in development phases 427 AspectJ in the design phase 428 AspectJ in the implementation phase 428 AspectJ in the testing phase 431 AspectJ in the maintenance phase 432 AspectJ in legacy projects 432 ■ ■ ■ ■ 13.3 13.4 Evangelizing AspectJ 434 13.5 A A word of warning... conventional logging 154 5.3 The beauty of AspectJ- based logging 156 5.4 Developing logging and tracing aspects 156 Method call tracing 5.5 157 ■ Exceptions logging 163 Common logging idioms 167 Logging the method parameters 168 Indenting the log statements 170 Aspect precedence 172 Changing the underlying logging mechanism 173 Using logging in a multithreaded environment 173 ■ ■ ■ ■ 5.6 Extending logging for... implementation 24 A weaving example 26 ■ ■ 1.6 1.7 Myths and realities of AOP 29 1.8 2 Benefits of AOP 27 Summary 30 Introducing AspectJ 32 2.1 AspectJ: a bird’s eye view 33 Crosscutting in AspectJ 33 ■ Crosscutting elements 2.2 AspectJ Hello World 37 2.3 AspectJ: under the hood 40 2.4 The join point model 43 Exposed join point categories demonstration example 50 44 2.5 ■ Join point Aspects 55 2.6 AspectJ logistics... concepts in AspectJ that you need to understand before you start writing nontrivial AspectJ programs Part 2 examines the real-world application of AspectJ using simple constructs Chapter 5 introduces logging and monitoring using AspectJ We show how AspectJ includes logging in a system without touching any of its core modules You’ll also see the ease with which you can switch between different logging APIs... 12 Using AspectJ with advanced transaction-management systems 387 Summary 390 Implementing business rules 391 12.1 Using business rules in enterprise applications 392 12.2 An overview of business rule implementation 393 12.3 Current mechanisms 393 12.4 Introducing a solution using AspectJ 394 12.5 Example: the banking system 396 The template 394 Implementing the core business logic 396 Implementing... constructs The join point model presented in this chapter is the most fundamental concept in AspectJ We finish the chapter by briefly showing the IDE support for AspectJ Chapter 3 gets into the details of the AspectJ language by examining the concepts of pointcuts, advice, the introduction mechanism, and so forth This chapter provides you with enough information to start writing simple AspectJ programs... first business rule 401 Implementing the second business rule 403 Writing a test program 406 ■ ■ ■ 12.6 Implementing business rules with a rule engine 411 An overview of the rule engine 412 Using a rule engine 412 Modularizing with AspectJ 415 ■ ■ 12.7 Example: a banking system with a rule engine 417 A brief overview of Jess (Java Expert System Shell) 417 Specifying rules 418 Understanding the rule invocation... People are using AspectJ in real projects for enhancing middleware platforms, monitoring and improving performance, adding security to existing applications, and implementing Enterprise Application Integration (EAI) All these projects have seen impressive results in reducing both the amount of code and the time required to create the products AOP is becoming an increasingly popular programming methodology;... Implementing the connection pool 216 Testing our solution 218 Tweaking the solution 222 ■ ■ 7.4 Example 2: thread pooling 223 The echo server 224 Understanding the thread pool interface 226 AspectJ- based thread pooling 226 Implementing the thread pool 230 Testing our solution 231 Tweaking the solution 234 ■ ■ ■ ■ www.it-ebooks.info 198 CONTENTS 7.5 xiii Extending pooling concepts to caching 235 AspectJ- based... warning 433 Parting thoughts 436 The AspectJ compiler 438 Downloading and setting up 439 A.2 An overview of the compiler 440 A.3 Compiling source files 441 A.4 Compiling source directories 441 A.5 Weaving into JAR files 442 A.6 Creating aspect libraries 443 A.7 Using aspect libraries 444 A.8 Utilizing incremental compilation mode 444 A.9 B A.1 Producing useful warnings 446 Understanding Ant integration . Employing AspectJ in development phases 427 AspectJ in the design phase 428 ■ AspectJ in the implementation phase 428 ■ AspectJ in the testing phase 431 ■ AspectJ in the maintenance phase 432 ■ AspectJ. www.it-ebooks.info AspectJ in Action www.it-ebooks.info www.it-ebooks.info AspectJ in Action P RACTICAL A SPECT -O RIENTED P ROGRAMMING RAMNIVAS LADDAD MANNING Greenwich (74° w. long.) www.it-ebooks.info For. Producing useful warnings 446 B Understanding Ant integration 447 B.1 Compiling source files using an Ant task 448 B.2 Weaving into JAR files using an Ant task 451 B.3 Creating aspect libraries using

Ngày đăng: 05/05/2014, 12:57

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan