You are previewing Spring 2.5 Aspect-Oriented Programming.
O'Reilly logo
Spring 2.5 Aspect-Oriented Programming

Book Description

Create dynamic, feature-rich, and robust enterprise applications using the Spring framework

  • Master Aspect-Oriented Programming and its solutions to implementation issues in Object-Oriented Programming

  • A practical, hands-on book for Java developers rich with code, clear explanations, and interesting examples

  • Includes Domain-Driven Design and Test-Driven Development of an example online shop using AOP in a three-tier Spring application

In Detail

Developing powerful web applications with clean, manageable code makes the maintenance process much easier. Aspect-Oriented Programming (AOP) is the easiest and quickest way to achieve such results. Spring is the only Java framework to offer AOP features. The combined power of Spring and AOP gives a powerful and flexible platform to develop and maintain feature-rich web applications quickly.

This book will help you to write clean, manageable code for your Java applications quickly, utilizing the combined power of Spring and AOP. You will master the concepts of AOP by developing several real-life AOP-based applications with the Spring Framework, implementing the basic components of Spring AOP: Advice, Joinpoint, Pointcut, and Advisor.

This book will teach you everything you need to know to use AOP with Spring. It starts by explaining the AOP features of Spring and then moves ahead with configuring Spring AOP and using its core classes, with lot of examples. It moves on to explain the AspectJ support in Spring. Then you will develop a three-layered example web application designed with Domain-Driven Design (DDD) and built with Test-Driven Development methodology using the full potential of AOP for security, concurrency, caching, and transactions.

Table of Contents

  1. Spring 2.5 Aspect-Oriented Programming
  2. Credits
  3. About the Author
  4. About the Reviewer
  5. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Conventions
    5. Reader feedback
    6. Customer support
      1. Downloading the example code for the book
      2. Errata
      3. Piracy
      4. Questions
  6. 1. Understanding AOP Concepts
    1. Limits of object-oriented programming
      1. Code scattering
      2. Code tangling
    2. The AOP solution
    3. What Spring provides in terms of AOP
      1. Programmatic way
        1. Before advice
        2. After returning advice
        3. Around advice
        4. After throwing advice
      2. The old Spring XML way
    4. AOP with IoC in Spring 2.5
      1. AspectJ annotations
        1. Before advice
        2. After returning advice
        3. Around advice
        4. After (finally) advice
        5. After throwing advice
      2. Schema-based configuration
        1. Before advice
        2. After advice
        3. After returning advice
        4. After throwing advice
        5. Around advice
    5. Summary
  7. 2. Spring AOP Components
    1. Aspect
    2. Pointcut
      1. Pointcut and its components
        1. NameMatchMethodPointcut
        2. RegexpMethodPointcut
        3. StaticMethodMatcherPointcut
        4. DynamicMethodMatcherPointcut
    3. Operations on Pointcut
        1. ComposablePointcut
        2. ControlFlowPointcut
        3. Pointcut constants
    4. Joinpoint
    5. Advice
      1. Before advice
      2. After returning advice
      3. After throwing advice
    6. Advisor
    7. Introductions
    8. Summary
  8. 3. Spring AOP Proxies
    1. Proxy
    2. JDK proxy
    3. CGLIB proxy
    4. Creating proxies programmatically
      1. ClassicProxy
      2. AspectJProxy
    5. ProxyFactoryBean
      1. ProxyFactoryBean and proxies
      2. ProxyFactoryBean in action
      3. Advised objects
    6. Autoproxy
      1. Autoproxy with classic Spring
        1. BeanNameAutoProxyCreator
        2. DefaultAdvisorAutoProxyCreator
        3. AbstractAdvisorAutoProxyCreator
      2. AutoProxyCreator with metadata
      3. Autoproxy with AspectJ
      4. Autoproxy with annotation
      5. Autoproxy with XML Schema
    7. Target sources
      1. Hot swappable target sources
      2. Pooling target sources
      3. Prototype target sources
      4. ThreadLocal target source
    8. Summary
  9. 4. AspectJ Support
    1. AspectJ annotations
      1. Aspect
      2. Pointcut
        1. execution
        2. within
        3. this
        4. target
        5. args
        6. @target
        7. @args
        8. @ within
        9. @ annotation
        10. bean
      3. Selection on methods' names
      4. Selection on types of argument
      5. Selection on type of return
      6. Selection on declared exceptions
      7. Selection on hierarchy
      8. Selection on annotations
      9. Binding advice arguments
        1. JoinPoint
        2. Binding arguments
        3. Binding of return values
        4. Exception binding
        5. Annotation binding
      10. Advice
        1. @Before
        2. @AfterReturning
        3. @AfterThrowing
        4. @After
        5. @Around
      11. Introduction
    2. XML Schema-based configuration
      1. Aspect
      2. Pointcut
      3. Advice
        1. Before advice
        2. After returning advice
        3. After throwing advice
        4. After (finally) advice
        5. Around advice
      4. Introduction
      5. Advisors
    3. Recipes
      1. Dependency injection in domain objects
      2. Advice ordering
      3. Configuration mixin
      4. Aspect instantiation model
    4. AspectJ weaving in Spring
      1. Load-time weaving with Spring
      2. Load-time weaving with AspectJ
      3. AOP strategy considerations
    5. Summary
  10. 5. Design with AOP
    1. Concurrency with AOP
    2. Transparent caching with AOP
    3. Security with AOP
      1. Securing methods with security interceptors
      2. Securing methods with pointcuts
      3. Securing methods with annotations
    4. Summary
  11. 6. Three-tier Spring Application, Domain-Driven Design
    1. Domain-Driven Design
      1. Roles and responsibilities
        1. Entities
        2. Aggregates
        3. Modules
        4. Value objects
        5. Factories
        6. Repositories
        7. Services
      2. Architecture
        1. User interface
        2. Application layer
        3. Domain layer
        4. Infrastructure layer
    2. Sample application
      1. Design
      2. Services
      3. Factories
      4. Repositories
    3. Summary
  12. 7. Three-tier Spring Application, Tests and AOP
    1. Application layer and user interface
    2. Test
    3. AOP
      1. Cache
      2. Concurrent
      3. TimeExecutionManagedAspect
      4. Transactions
      5. Security
    4. Summary
  13. 8. Develop with AOP Tools
    1. Java Development Kit
    2. Spring
    3. Eclipse
    4. Eclipse plug-ins (Linux, MacOSX, and Windows)
      1. SpringIDE
      2. AJDT
    5. Apache Tomcat
      1. Ubuntu Linux
      2. MacOSX
      3. Microsoft Windows
      4. Common steps for Linux, MacOSX, and Windows
    6. PostgreSQL
      1. Ubuntu Linux
      2. MacOSX
      3. Microsoft Windows
      4. Common steps for Linux, Apple MacOSX, and Microsoft Windows
      5. JDBC Driver
    7. Summary