This book, teaches us Spring 2.5.x with Aspect Oriented Programming (Annotations and XML well cover) with a scalable learning approach, over 8 well-organized chapters, realistic and necessary Crosscutting Concerns are covered.
Chapter 1: Understanding AOP Concepts
As an introduction, this chapter teaches, in a concrete well explained way, the limits of OOP. Some graphics are used to get a better understanding of this situation, furthermore two important problems about coding with OOP are explained in a concrete way with a sample code for "Code Scattering" and "Code Tangling".
With this premise AOP is introduced as a solution. Here the author use 2 graphics to show us a representation of sequence of calling methods among objects with pure OOP and AOP. Therefore the author shows us a better understanding of the parts and its functions as components of AOP. There is a good the explanation again of the AOP components (theory way). After that, the types of Advice are introduced (even After(finally) ) and Spring is introduced in terms of AOP Code sample for "Programmatic Way" for each of the next advices
The old Spring XML way is introduced (with ProxyFactoryBean),
"Static AspectJ" and "Dynamic Spring" implementations are introduced, along with a comparison between them.
Furthermore there is a comparison of "Spring AOP" with "AspectJ".
The book is oriented for Spring 2.5, therefore AspectJ annotations (<aop:aspectj-autoproxy/> introduced) with code sample are introduced for the next advices:
And furthermore "Schema-based configuration" is introduced too for the following advices:
You can see all advices types are explained with these two approach forms.
Chapter 2: Spring AOP Components
This chapter offers an explanation of terms for "Aspect", "Pointcut" , detailed explanations and excellent code (Java and XML) for pointcuts already provided by Spring, that means for:
"Operations on Pointcut" are explained like "ComposablePointcut" therefore "union" and "intersection" methods are introduced and well explained in code sample, "ControlFlowPointcut" are covered too.
More terms like "Joinpoint", "Advice" are explained, with an interesting graphic for method "proceed()" about chain of interceptors are available for better understanding; Before, After Returning, After Throwing are explained with code. Another term is "Advisor" which is explained with extracts of code.
An important component is "Introductions"; almost six pages are dedicated for this topic. Something that I don’t like about this part is that it does not teach some "reason of the things" in some parts of the code.
Chapter 3: Spring AOP Proxies
This is an important chapter - "Proxy" is introduced and explained with an important theory. After that JDK and GLIB proxy are presented and well explained. A section called "Creating proxies programmatically" starts with
Both are well covered with good theory and code samples, the following topic covered is:
This covered really well, with many properties explained in an excellent concrete way. Something that I like very much, is that it offers scenarios about strategies to select proxies -
the code sample uses crosscutting concerns like
Logging , Time Execution.
Furthermore for "XML configuration" is well cover using:
A topic called "Advised objects" is introduced too, it has its own explanation and code sample. Now "Autoproxy" is introduced, covering "BeanNameAutoProxyCreator", "DefaultAdvisorAutoProxyCreator", both are well covered with a sample code again using "NameMatchMethodPointcut","DefaultPointCutAdvisor" how part of its XML configuration, "AutoProxyCreator with metadata" is cover too such as the previous already mentioned
After that, a brief but concrete explanation and configuration is offered for "AutoProxy with AspectJ, Annotation, XML Schema". Now "Target Sources" are covered with four interesting variations:
Each topic is covered with a simple but concrete sample code and of course each corresponding configuration.
Chapter 4: AspectJ Support
This chapter start teaching us about some concepts and configuration for "Aspect" and "Pointcuts" and the presentation for PCD (Pointcut Designators) like:
Most of these have sample code and do a comparison among themseleves (i.e.: "execution" and "within" ). Here you learn how to declare an Aspect class dedicated only to declare Pointcuts (i.e ApplicationPointCutAspect) and other Aspect classes using only advice methods to call or use the pointcuts from the aspect class already mentioned. This chapter offers a list of the PCD’s not supported by Spring AOP, and a good amount of PCD samples (more of ten that consist in a pointcut definition and its explanation) are offered.
Each group of the following selections are explained with a concrete sample
And for "Binding"
All are well covered in a concrete way with annotations. Now for more detail about Advice:
The introduction is covered again and teaches us how use the JVM "javaagent" argument with Eclipse. Now is the turn of the "XML Schema-based configuration", again with the same order already mentioned in the beginning for this chapter "Aspect" and "Pointcuts" are covered in a simple and concrete way, therefore now is the turn for the "Advice"
For almost each advice shown above the chapter offers the xml configuration to work with/without binding for each situation. "Introduction" and "Advisor" is covered with its theory and code sample. The follows topics appears under the section "recipes"
Something very important is LTW (Load Time Weaving)
"AOP strategy considerations" has a concrete list of conditions for:
Chapter 5: Design with AOP
Concurrency, is shown to us with two code samples. The first case, a class with some logic and thread safe control (read/write lock/unlock) together. After that, a custom Aspect class is created for thread safe control and the other class is modify, now of course thread control are not include inside
In Caching, for learning purposes, EHCache is used, an Aspect class and a target class is used together with a xml configuration.
In Security, Spring Security is used now, in this situation "AccessDecisionManager" and "AccessDecisionVoter" interfaces are mentioned and its implementations are cover in the sample code ("RoleVoter" and "AuthenticatedVoter"), now AOP is applied with three approaches:
Concrete and simple code samples are used for the above list.
Now to follow, the most parts interesting in the book (for the reality), a case study, is for the two next chapters:
Chapter 6 is really a long chapter because the Java code has has already been shown to us AOP not included here for the moment. There theory of DDD is introduced:
With all this theory explained, a sample application is used, starting with a simple "Package Explorer" of the project in Eclipse. The following sections are available
The code is not complex, but something that lacks this chapter is at least an UML class diagram, It could be better include it to get a better understanding of all structure of the project
Now is the turn for Chapter 7, here the chapter starts with Spring MVC working with annotations (Even a HandlerInterceptorAdapter is included ), Testing (JUnit 4.5 with annotations and DbUnit). Load Time Weaver is applied here, and the book teaches us again about the jvm parameter "javaagent" working inside Eclipse
Now AOP is used. Both XML and Annotation approaches are applied. The aspects managed here are the most principal, Caching, Concurrency, Time Executing, Transactions (<tx:advice is used here), Security.
The last chapter 8: Develop with AOP Tool
This simple chapter teaches us how download and configure in a fast way many for the tools used throughout book for Linux MacOSX and Windows.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)