Core AOP: Aspect-Oriented Programming with Spring AOP and AspectJ

Course Summary

This 2-day course provides an introduction to aspect-oriented programming and its role in enterprise application development. Using the very latest AOP support in Spring 2.0 and AspectJ 5, attendees will gain practical experience in developing and using aspects to produce more flexible, maintainable, and higher quality applications. Delegates will leave with knowledge that can be applied to immediate benefit on their own projects.

Course Objectives

Upon completion of this course, you will:

  • Understand what AOP is and the kind of problems it can solve
  • Know the fundamentals of Spring AOP and AspectJ, the two leading AOP solutions
  • Be able to choose the most appropriate AOP approach for a given situation
  • Have the practical knowledge needed to start introducing AOP in their own projects
  • Know how to use aspect libraries
  • Understand the use of aspects for protecting design modularity, transactions, security, management, profiling, tracing, failure handling, optimistic concurrency, caching, domain models, and more!
  • Have at your disposal a proven roadmap for exploiting AOP in your own organisation

General information

Audience

This course benefits Java developers who want to learn what AOP really is and how they can use AOP and AspectJ in their everyday work. The course is also suitable for hands-on architects and team-leads who want to assess how and when to start introducing AOP to their own projects and organisations. 

Prerequisites

This course assumes that participants have a good understanding of Object Oriented programming and the Java language, as well as a basic knowledge of Spring dependency injection and bean configuration. After you register, an Interface21 staff member will be happy to recommend any necessary reading to ensure that you get maximum value from the training.

Lab Work

The AOP course places a heavy emphasis on gaining practical skills for using AOP in your own projects. There are a number of labs and exercises and approximately a 50-50 split between presentation-based instruction and hands-on application.

Since lab work is a major part of the course, you use a computer when taking this course. Computers will be provided.

Programme

Day 1

  • What is AOP?
    • Motivations, join points, pointcuts, advice, aspects
    • Aspects: HelloWorld in AspectJ
  • Approaches to AOP
    • Proxy based vs language based
    • Different weaving time
    • Introduction to Spring AOP and AspectJ
    • Where AOP fits in an enterprise application, choosing the right tool for the job
  • Writing pointcut expressions, part 1
    • execution, call, get, set, handler, within, withincode
    • aspects: making the service layer transactional
  • Design-level assertions
    • declare warning and error
    • demo of use in refactoring flow
    • aspects: DontWriteToConsole, SpringHibernateUsageGuidelines, SpringJDBCUsageGuidelines, EJBCorporatePolicy "SystemArchitecture"
    • architectural layering
    • making it practical
      • link source folders
      • ant build integration
      • producing an HTML report
  • Advice
    • the 5 advice types, and how to declare them in AspectJ,@AspectJ, and Spring AOP
    • aspects: HibernateExceptionTranslator, OptimisticOperationExecutor, SQLExceptionTranslator (w. declare soft)
    • thisJoinPoint etc.

Day 2

  • Writing pointcut expressions, part 2
    • this, target, args
    • aspects: simple caching, clustered caching with Tangosol coherence
  • Using an aspect library
    • configuration :- AJDT, ant, LTW
    • aop.xml
      • getting information on the weaving process
      • controlling weaving extent
      • integrating log messages
      • concrete aspects
    • aspects: Dependency injection for domain objects
  • Writing infrastructure aspects
    • transactions
    • security
    • remoting
    • tracing
    • profiling
    • failure handling
    • management
    • + aspect design guidelines developed along the way
  • Aspects and annotations
    • @annotation etc
    • using annotations wisely
    • aspects: AnnotationUsageGuidelines, @Configurable, @Transactional, auditing, asynchronous execution (with task priority by customer status)
  • Adoption roadmap
    • roadmap, extended to include Spring AOP
    • aspects: LostUpdateDetector (in read-only transactions), PotentialOptimisationDetector (read-only tx marked as read-write), default interface implementation, inner aspects for interface implementation, lazy initialization support, SafeExecution, WarnOnSwallowedException (AspectJ compiler), ITD support and compilation loop adaptation (from AJ compiler)