AspectJ Cookbook

Russ Miles

  • 出版商: O'Reilly
  • 出版日期: 2005-01-25
  • 售價: $1,660
  • 貴賓價: 9.5$1,577
  • 語言: 英文
  • 頁數: 356
  • 裝訂: Paperback
  • ISBN: 0596006543
  • ISBN-13: 9780596006549
  • 已過版
    無現貨庫存(No stock available)




When Object Oriented programming (OO) first appeared, it was a revelation. OO gave developers the ability to create software that was more flexible and robust, but as time went on and applications became more sophisticated, too, certain areas of "traditional" OO architectures were found wanting. Aspect-oriented programming (AOP) addresses those issues by extending the OO approach even further.

Many developers are interested in AOP--especially in AspectJ, the open source extension of the Java programming language that explicitly supports the AOP approach. Yet, although AspectJ is included with Eclipse, the increasingly popular open source IDE for Java, finding a practical and non-theoretical way to learn this language and other AOP tools and techniques has been a real problem.

Until now. The AspectJ Cookbook offers a hands-on solution--in fact, several--with a wide variety of code recipes for solving day-to-day design and coding problems using AOP's unique approach.

AOP allows the global properties of a program to determine how it's compiled into an executable program. Before AOP, important program design decisions were difficult to capture in actual code. Instead, the implementation of those design decisions--known as "aspects"--were scattered throughout, resulting in "tangled" code that was hard to develop and maintain. AOP has been compared to the manufacturing of cloth, in which threads are automatically interwoven. Without AOP, programmers must stitch the threads by hand.

The AspectJ Cookbook shows readers why, and how, common Java development problems can be solved by using AOP techniques. With our popular problem-solution-discussion format, the book presents real world examples to demonstrate that AOP is more than just a concept; it's a development process that will benefit users in an immediate and visible manner.

If you're interested in how AOP is changing the way software is developed, and how you can use AspectJ to make code more modular, easier to develop, maintain, evolve and deploy, this is the book that really delivers.



Table of Contents:


1. Aspect Orientation Overview

      1.1 AspectJ

      1.2 A Definition Of Aspect Orientation

      1.3 Where To Go For More Information

2. Getting Started With AspectJ

      2.1 Installing AspectJ

      2.2 Developing A Simple Aspect

      2.3 Compiling an Aspect and Multiple Java Files

      2.4 Weaving Aspects into Jars

      2.5 Weaving Aspects at Load-Time

      2.6 Generating Javadoc Documentation

      2.7 Compiling an AspectJ Project using Eclipse

      2.8 Selecting the Aspects that are Woven in a Build within Eclipse

      2.9 Building an AspectJ Project using Ant

3. Deploying AspectJ Applications

      3.1 Deploying a Command Line AspectJ Application

      3.2 Deploying an AspectJ Application as a fully contained Executable .Jar file

      3.3 Deploying a Java Servlet that uses AspectJ

      3.4 Deploying a JSP that uses AspectJ

      3.5 Deploying an Axis Web Service that uses AspectJ

4. Capturing Join Points on Methods

      4.1 Capturing a Method Call

      4.2 Capturing the Parameter Values passed on a Method Call

      4.3 Capturing the Target of a Method Call

      4.4 Capturing a Method when it is Executing

      4.5 Capturing the Value of the "this" Reference when a Method is Executing

5. Capturing Join Points on Exception Handling

      5.1 Capturing when an Exception is Caught

      5.2 Capturing the Thrown Exception

      5.3 Capturing the Object Handling the Exception

6. Capturing Join Points on Advice

      6.1 Capturing when Advice is Executing

      6.2 Excluding Join Points that are a Result of Advice Execution

      6.3 Exposing the original Join Point when Advice is being Advised

7. Capturing Join Points on Class and Object Construction

      7.1 Capturing a Call to a Constructor

      7.2 Capturing a Constructor when it is Executing

      7.3 Capturing when an Object is Initialized

      7.4 Capturing when an Object is about to be Initialized

      7.5 Capturing when a Class is Initialized

8. Capturing Join Points on Attributes

      8.1 Capturing when an Object's Attribute is Accessed

      8.2 Capturing the Value of the Field being Accessed

      8.3 Capturing when an Object's Field is Modified

      8.4 Capturing the Value of a Field when it is Modified

9. Capturing Join Points within Programmatic Scope

      9.1 Capturing all Join Points within a particular Class

      9.2 Capturing all Join Points within a particular Package

      9.3 Capturing all Join Points within a particular Method

10. Capturing Join Points based on Control Flow

      10.1 Capturing all Join Points within a Program's Control Flow initiated by an Initial Join Point

      10.2 Capturing all Join Points within a Program's Control Flow, Excluding the Initial Join Point

11. Capturing Join Points based on Object Type

      11.1 Capturing when the "this" reference is a specific Type

      11.2 Capturing when a Join Point's Target Object is a specific Type

      11.3 Capturing when the Arguments to a Join Point are a certain Number, Type and Ordering

12. Capturing Join Points based on a Boolean or Combined Expression

      12.1 Capturing when a Runtime Condition evaluates to True on a Join Point

      12.2 Combining Pointcuts Using a Logical AND (&&)

      12.3 Combining Pointcuts Using a Logical OR (||)

      12.4 Capturing all Join Points NOT specified by a Pointcut Definition

      12.5 Declaring Anonymous Pointcuts

      12.6 Reusing Pointcuts

13. Defining Advice

      13.1 Accessing Class Members

      13.2 Accessing the Join Point Context

      13.3 Executing Advice Before a Join Point

      13.4 Executing Advice Around a Join Point

      13.5 Executing Advice Unconditionally After a Join Point

      13.6 Executing Advice Only After a Normal Return from a Join Point

      13.7 Executing Advice Only After an Exception has been raised in a Join Point

      13.8 Controlling Advice Precedence

      13.9 Advising Aspects

14. Defining Aspect Instantiation

      14.1 Defining Singleton Aspects

      14.2 Defining an Aspect Per-Instance

      14.3 Defining an Aspect Per-Control Flow

15. Defining Aspect Relationships

      15.1 Inheriting Pointcut Definitions

      15.2 Implementing Abstract Pointcuts

      15.3 Inheriting Classes into Aspects

      15.4 Declaring Aspects Inside Classes

16. Enhancing Classes and the Compiler

      16.1 Extending An Existing Class

      16.2 Declaring Inheritance between Classes

      16.3 Implementing Interfaces using Aspects

      16.4 Declaring a Default Interface Implementation

      16.5 Softening Exceptions

      16.6 Extending Compilation

17. Implementing Creational Object-Oriented Design Patterns

      17.1 Implementing the Singleton Pattern

      17.2 Implementing the Prototype Pattern

      17.3 Implementing the Abstract Factory Pattern

      17.4 Implementing the Factory Method Pattern

      17.5 Implementing the Builder Pattern

18. Implementing Structural Object-Oriented Design Patterns

      18.1 Implementing the Composite Pattern

      18.2 Implementing the Flyweight Pattern

      18.3 Implementing the Adapter Pattern

      18.4 Implementing the Bridge Pattern

      18.5 Implementing the Decorator Pattern

      18.6 Implementing the Proxy Pattern

19. Implementing Behavioral Object-Oriented Design Patterns

      19.1 Implementing the Observer Pattern

      19.2 Implementing the Command Pattern

      19.3 Implementing the Iterator Pattern

      19.4 Implementing the Mediator Pattern

      19.5 Implementing the Chain of Responsibility Pattern

      19.6 Implementing the Memento Pattern

      19.7 Implementing the Strategy Pattern

      19.8 Implementing the Visitor Pattern

      19.9 Implementing the Template Method Pattern

      19.10 Implementing the State Pattern

      19.11 Implementing the Interpreter Pattern

20. Applying Class and Component Scale Aspects

      20.1 Validating Parameters Passed to a Method

      20.2 Overriding the Class Instantiated on a Call to a Constructor

      20.3 Adding Persistence to a Class

      20.4 Applying Mock Components to Support Unit Testing

21. Applying Application Scale Aspects

      21.1 Applying Aspect-Oriented Tracing

      21.2 Applying Aspect-Oriented Logging

      21.3 Applying Lazy Loading

      21.4 Managing Application Properties

22. Applying Enterprise Scale Aspects

      22.1 Applying Development Guidelines and Rules

      22.2 Applying Transactions

      22.3 Applying Resource Pooling

      22.4 Remoting a Class Transparently using RMI

      22.5 Applying a Security Policy

23. Applying Aspect-Oriented Design Patterns

      23.1 Applying the Cuckoo's Egg Design Pattern

      23.2 Applying the Director Design Pattern

      23.3 Applying the Border Control Design Pattern

      23.4 Applying the Policy Design Pattern

A. The AspectJ Runtime API