A Peruvian Analyst, Designer and Java Programmer that enjoys working with frameworks like Spring, Hibernate and others, Playing with Java and compositing Music, some interests are Playing bass and guitar, listening to music (Pink Floyd, Rick Wakeman), reading the Bible and normally buying and reading Java books, here my Blog http://manueljordan.wordpress.com/ Manuel has posted 31 posts at DZone. View Full User Profile

AspectJ in Action: Enterprise AOP with Spring Applications

02.24.2010
| 7036 views |
  • submit to reddit
Published by: Manning Publications
ISBN: 1933988053

Reviewer Ratings

Relevance:
5

Readability:
5

Overall:
5

Buy it now

One Minute Bottom Line

This powerful book teaches us how to learn AOP and how apply AspectJ and Spring AOP in our projects with very valuable theory including a lot of images to get an excellent understanding. All these features help make development life easier both with and without Spring framework. The book also covers important topics like Management, Security, Constraints, Concurrency and valuable patterns

Review

Part I Understanding AOP and AspectJ

Chapter 01: Discovering AOP

Here our author starts talking about Complexity and its respective solution, Modularization, and for first time the concern term is introduced, therefore we see definitions of both  core concerns and crosscutting concerns.

Then we have the AOP definition: AOP is a methodology that provides separation of crosscutting concerns by introducing a new unit of modularization—an aspect. And for an  aspect weaver that composes the final system by combining the core classes and crosscutting aspects through a process called weaving.

We follow with the section Life without AOP, where we have a clever image showing us a system as a composition of multiple concerns with a Java Business class with a method with many concerns included within it. Then the concept about code tangling with an image to offer a good complementation is available, including other image about Mapping the n-dimensional concern space using a one-dimensional language. Other important concept is code scattering with its respective explanation and again an image for a better understanding.

Now is the turn therefore for the section Modularizing with AOP, working with a good theory with an image about Implementing a security concern using AOP techniques and now you can see an important and clear difference between this image and the previous shown in code scattering

Now the author go deeper about AOP with Anatomy of an AOP language starting with a brief introduction for language specification and language implementation, then the author proceed to expand these languages

For language specification exists a good covering for implementation of concerns and weaving rules specification, and for language implementation its respective theory including an image about AOP language implementation that provides a weaver in the form of a compiler

We follow with the section Fundamental concepts in AOP, practically two pages covering importants topics like join points, pointcut, join point model, advice among other important things, a very interesting image is included about Generic model of an AOP system, where you can see all the topics already explained working together, even including Static crosscutting element, Dynamic crosscutting element, Weave time declarations and Inter-type declarations

Another section comes, about AOP by analogy for a better understanding, talking about:

  • Cascading Style Sheets (CSS)
  • Database systems (sql and pointcuts, triggers and advice)
  • Event-oriented programming

Good theory for these analogies.

Now the author talk about Implementations of AOP, then we start with:

  • AspectJ, good theory about this, even including a table discussion about Scala and AspectJ
  • Spring AOP
  • Other implementations of AOP, doing mention to JBoss, Guice, Seasar among others

An interesting section is available too for Alternatives to AOP, doing a good covering for:

  • Frameworks (EJB)
  • Code generation
  • Design patterns (observer pattern,chain of responsibility,decorator and proxy,interceptor)
  • Dynamic languages (Aquarium project to bring AOP to Ruby for example)

To end this chapter the author offer Costs and benefits of AOP , starting with :

  • cost we have need for greater skills and complex program flow
  • benefits we have simplified design, cleaner implementation and better code reuse

Chapter 02: Introducing AspectJ

We start quickly with the section Writing your first AspectJ program covering about installation and creating a simple Java class with two methods and executing this class with ajc AspectJ compiler you can see that all work normal, even using ajc and not java how execute command, then the author include two samples, the same Java class shown but based in code tangling and our first aspect file with the respective execution showing us how our aspect avoid code tangling, respective explanation for the aspect code is well covered

Now we follow with AspectJ crosscutting construct section where the follow sub sections are well covered with theory and snippet code:

  • Common crosscutting constructs (join point, pointcut, and aspect)
  • Dynamic crosscutting construct (advice around and working with thisJoinPointStaticPart)
  • Static crosscutting constructs (inter-type declaration (ITD) or introduction, weave-time declaration)

We follow with AspectJ alternative syntax where now we work with annotations, where our previous aspect is changed to do the same work with annotation support now, respective good explanation for these new changes and its respective execution is available too but where LTW load-time weaving is included

Then the author offer now Weaving mechanisms covering AspectJ's three weaving models:

  • Source weaving (ajc replaces javac)
  • Binary weaving, good explanation for its steps like compiling the java sources, compiling the aspect, weaving the aspect
  • Load-time weaving working with META-INF/aop.xml, LTW, -javaagent with aspectjweaver.jar

We follow with AspectJ weaving: under the hood with an interesting covering for The compiled aspect and The woven class, a table of discussion about Performance implications of AspectJ weaving is available too.

For Spring developers the section Spring AspectJ integration is available, where the author teaches us how configure a file called applicationContext.xml, here aop:aspectj-autoproxy tag is introduced, explanation for such code is available too, respective execution is covered too.

To end the chapter the section AspectJ logistics overview exists, where IDE integration (Eclipse + AspectJ Development Tools (AJDT) plug-in) is explained, even including an image about Developing applications using Eclipse-AspectJ integration (using STS distribution), a table discussion about What about other IDEs? is available too and AspectJ documentation tool is covered too, here the author shown us how use the command ajdoc for this purpose.

Chapter 03: Understanding the join point model

The chapter start with the section Understanding the join point model talking about of some tips like identify places, write a pointcut and write an aspect. Therefore the author follow with a good theory for two sub sections, the first Join points including a clever image about Join points in program execution about how work for this situation Method calls and execution, the second for Pointcuts based in a concrete theory and another image clever and important about Relationship between join points, signature patterns, and pointcuts.

After this we have the section Categorizing exposed join points based with an interesting theory and it offer a table called Overview of join point categories exposed by AspectJ based in three headers Category, Exposed join point, Code it represents. Therefore the author proceed to go deeper for many of these elements, starting with the subsection Method join points including a snippet code and a long table discussion called Execution vs. call: your place or mine?, for the follows sub sections almost same approach, concrete understable theory with a snippet code.

  • Constructor join points
  • Field access join points
  • Exception-handler join points
  • Class-initialization join points
  • Object initialization join points
  • Object pre-initialization join points
  • Advice execution join points

Something wise used by the author within the snippet code is that he do emphasis in which parts are the join points in the code using rows.

The follow section Join point demonstration example, based in two subsections called The aspect and The result, for the first almost one page for an aspect code including its respective explanation and for the second practically one page about its output with indentation effect and its respective explanation about how the code worked here.

Now the section Understanding pointcut basics is available doing explanation for two sub sections, the first Named and anonymous pointcuts with its respective explanation starting with reusability: named pointcuts including an image called Defining a named pointcut, the other part is use once: anonymous pointcuts including a snippet code. Now the second is Pointcut operators explain about Unary operator and Binary operators.

Other section is Signature syntax based in a wildcards like *,..,+ and following with the next sub sections, the first called Type signature patterns, interesting and important covering, we have the topic basic type signature pattern based mostly in a table with many samples about signatures of course, other topic is annotation-based type signature pattern working with @Retention policy annotations and again other table for here with some samples, even more other topic generic-based type signature patterns with its respective table, to end the last topic combining type signature patterns, again with this respective table. Good approach used by the author in all these tables using the headers Signature pattern, Description, Example types ,good amount of samples clearing and given a perfect idea about how work this.

The second subsection is Method and constructor signature patterns starting with a concrete theory and including an image based in Method signature patterns used in pointcuts, again we have topics, like basic method signature pattern based mostly in a long table almost for two pages for many samples of this signature pattern, here the table is well explained working with the headers Signature pattern, Matched methods, Example methods, really well explained, other topic is annotation-based method signature pattern, again other table in almost one page is used, well explained, the follow headers are included Signature pattern, Description, Example methods for a good understanding, the last topic is constructor signature pattern doing emphasis about how this type of signature differs from method signature

The third sub section is Field signature patterns starting with a concrete theory and including an image about Field signature patterns used in pointcuts and covering the follow topics based in tables

  • basic field signature pattern
  • annotation-based field signature pattern

A new section is Implementing pointcuts based in Kinded pointcuts and Non-kinded pointcuts. The first based in a table Mapping of exposed join points to pointcut designators and other long table discussion called A join point can have only one kind, the second based in a concrete theory and covering the follow topics control-flow based pointcuts with its respective theory and covering the pointcuts cflow and cflowbelow, an interesting image is available about Control-flow based pointcuts ... where you can see the difference in action about these pointcuts, and even including a table about samples for both pointcuts, other topic is lexical-structure based pointcuts covering two pointcuts within and withincode with a table with some samples, other topic is execution-object pointcuts covering the pointcuts this and target, again a table with some samples is included, same approach for the follow topics to end the chapter

  • argument pointcuts
  • annotation-based pointcuts
  • conditional check pointcuts

Chapter 04: Modifying behavior with dynamic crosscutting

We start with Advice overview covering the follow subtopics Advice classification doing a concrete explanation for Before, After and its variations and Around advices, following with the other subtopic Advice syntax here we have many snippet code with rows included to have a better explanation, an image about Various points in a program flow... is available.

Other section is Comparing advice to methods covered and explained with list but expanded within the subsections Similarities between advice and methods and Differences between advice and methods, well explained

Now is the turn for Advice in depth section, based mostly in subsections for many of the known types where they are explained with its respective theory and snippet code, really the author knows how teach clear and understable, seven pages for these covering, many sample code based in the classic style (no annotation)

We follow with Collecting join point context, starting with the subtopic Collecting objects at the join point offering us a good quality of theory and clever and important images, these including rows to see really how the parameters are passed (executing objects and argument context), furthermore a table AspectJ pointcuts for collecting join point context is available. The other subtopic is Implementing simple caching a good amount of sample code and well explained

Other section is offered called Accessing join point context via reflection doing a concrete explanation for Static information and Dynamic information, same appreciation for :

  • thisJoinPoint
  • thisJoinPointStaticPart
  • thisEnclosingJoinPointStaticPart

following with The reflection API subsection, based in an image The structural relationship among various interfaces supporting reflection with the respective explanation for such image, well covering for this. Other subsection is Improving caching using reflection APIs where the previous sample code now is changed

The final subsection ending the chapter is Comparing the reflection API to pointcuts where after to offer a brief list, a table in one page is included called Comparing styles for accessing join point context, well explained

Chapter 05: Modifying structure with static crosscutting

Here the chapter start quickly with the section Introducing members covering the follow subsections Scattering and tangling where the author offer us two classes one without property change–notification support and other with such support, the next subsection is Untangling with aspects where a Test class is available and an aspect that add change-notification functionality for the class that not has this property, the code for this aspect is well explained, a table discussion called A holistic approach toward member introduction is available too. The follow subsection is Mixing with mixins well theory explanation and same appreciation for the sample code, following now with the subsection Member introduction rules where the author explain these rules based in a list, now we go to the subsection Idiom: Providing a default interface implementation where we have a good amount of sample code in almost three pages.

Now we change the section, Modifying the type hierarchy based in declare parents for implementation and extension with some snippet codes, two tables discussion exists called Evaluation order: static and dynamic crosscutting and Experimental features: hasmethod() and hasfield(). The follow section is Introducing members to multiple types which include its respective theory and sample code.

Other interesting section is Supplying annotations where you can see AspectJ lets you associate annotations with methods, constructors, fields, and types, the author explain the parts of a snippet code, followed by a table AspectJ constructs for annotating program elements and continue with theory, and including a table discussion called Domain-object dependency injection and static crosscutting

The end the chapter we have the two last sections called Declaring weave-time errors and warnings and Softening checked exceptions the first based in snippet code with its respective explanation the second practically the same plus some sample code

Chapter 06: Aspects: putting it all together

We start quickly with Working with aspects section showing us an aspect declaration with its respective features and brief explanation. Then the subsection Working with aspects is introduced covering the follow sub topics based with concrete theory and some ones with some snippet code

  • aspects can include data members and methods
  • aspects can have access specifications
  • aspects can be abstract
  • aspects can extend classes and abstract aspects, as well as implement interfaces
  • aspects can be embedded in classes and interfaces as nested aspects

The other subsection is Differences between aspects and classes, this is explained with a brief list and introducing many sub topics like

  • aspects can’t be directly instantiated
  • aspects can’t inherit from concrete aspects
  • concrete aspects may not declare generic parameters
  • aspects can be marked as privileged

covered with a concrete explanation

The follow section is Aspect association, here we have an important covering for its types in many sub sections like:

  • Default singleton association
  • Per-object association
  • Per-control-flow association
  • Per-type association

Until here we have ten excellent pages in material with an important and well explained theory, sample code with its explanation and its respective output and for it again it respective explanation to see really the differences among them, and even more sequence diagram, really well explained

Even more we have more sub section yet with a good theory material

  • Implicit limiting of join points with aspect associations
  • Accessing aspect instances (including an important table Using the aspectOf() and hasAspect() methods)
  • Comparing per-object association and member introduction
  • Improving the caching aspect (working with Spring and using factory-method="aspectOf", good sample material and showing in one page the JMX Console and working yet with testing Mockito)

For this last sub section really well covered

Going now to the next section we have Aspect precedence, here the author start quickly including sample code about two aspects applied for a class and with its respective execution showing us the problem generated, therefore we follow with the subsection Ordering of advice which includes an important explanation and a clever image called Ordering the execution of advice and join points to give us a good complement, even then we follow with the next subsection Explicit aspect precedence where the author teaches us the respective syntax and showing too a new aspect that now coordinating the precedence of the two previous aspects introduced, now you can see in the new result output how all work fine now. Some precedence control patterns are included too, well covered, an important table discussion is available too Aspect inheritance and precedence, other sub section is available yet called Ordering advice in a single aspect where sample code and its respective execution output is shown

To end the chapter the section Privileged aspects including its respective explanation, code sample and output.

Chapter 07: Diving into the @AspectJ syntax

After for a concrete introduction we start with the section Syntax overview where you can see an important image about The mapping between the traditional and @AspectJ syntax, using rows to see really the mapping between them, we follow with the subsections, starting with Natural mapping covered with a well theory and a table called Crosscutting elements supported by the @AspectJ syntax and their mapped elements, following with the sub section Java compatibility and Early error detection both covered with concrete theory and a snippet code for the second.

We follow with the section Mapping aspects where the author shown us a general form of aspect declaration using @AspectJ syntax code followed with many snippet codes to see the equivalences between traditional syntax and @AspectJ syntax, this section has some subsections like:

  • Specifying aspect association
  • Accessing the aspect instance
  • Declaring aspect precedence

for all these covered by concrete theory

We follow with the section Mapping pointcuts covered with the subsections Mapping abstract pointcuts and Mapping concrete pointcuts and even with subtopics with a good amount about snippet code, almost six pages coverething these, furthermore including two table discussion interesting, called Weaving and error detection and Why the special treatment for if()?

Now we go to the section Mapping dynamic crosscutting constructs, really well covered, almost sixteen pages!! with solid theory and a good amount of code and code images with rows to give us an excellent understanding for these sub sections (even more they has its respectives sub topics)

  • The before advice
  • The after advice
  • The around advice

Same appreciation for the section Mapping static crosscutting covered in almost six pages for the subsections

  • Mapping weave-time declarations
  • Mapping declare parents

We have now the section Features not implemented in @AspectJ covering the follow subsections

  • Associating annotations
  • Introducing data and methods
  • Softening exceptions
  • Privileged aspects

covered with concrete theory and snippet code

The last section for the chapter is Comparing syntax styles, well covered in two pages, important theory for each comparison.

Chapter 08: AspectJ weaving models

The chapter start with the section Classifying weaving models where we have a list and brief introduction for:

  • Build-time weaving
  • Load-time weaving (LTW)
  • Source code weaving
  • Byte-code (binary) weaving

following with a table called Weaving models supported by AspectJ

Now we have the section Build-time weaving well theory for this topic, including two subsections starting with Build-time source code weaving based with its respective theory and an important image for a better understanding to show us how work this approach, a table discussion is there too called Javac vs. ajc: Similar but not the same, we follow with the subsection Build-time binary weaving, important theory and again an important image about how work this, for a better understanting, we have two images more and very important, very valuable for this sub section called Creating an aspect library ... and Augmenting the existing build system to weave in the aspects. For these subsections you going to find command executions for each one.

Now we follow with the section Load-time weaving with a solid theory and table discussion called Spring-native load-time weaving, therefore now we can start with the subsections, the first Load-time weaving overview well explained and showing us an important and clever image called Load-time weaving schematic working with aop.xml followed by a table discussion Alternative to aop.xml and a java command wotking with –javaagent and its respective explanation, other table discussion is available OSGi and LTW, we follow with the sub section Configuring the load-time weaver where you can see aop.xml in many snippet code covered with a long and well theory because we have many sub topics covered in almost six pages like:

  • defining concrete aspects
  • defining aspect precedence
  • specifying weaving options in aop.xml
  • using multiple aop.xml files

table discussion are included too like Why include and exclude? related with tags and Automatically generating aop.xml

Now we follow with the section Load-time weaver in action where the author give us instructions with its respective explanation to work with this approach, here we work with maven, an output is included too Choosing syntax and weaving

The last section available for this chapter is Choosing syntax and weaving where the author give us a list about guidelines where for each element include its respective explanation

Chapter 09: Integration with Spring

The chapter start with the section Spring AOP fundamentals well covered including a table discussion Dependency injection, we follow with the subsection Setting up the application where a java class implementing an interface, an application context file and Main class are introduced and showing us a simple output, therefore we follow with the sub section Utilizing the @AspectJ syntax where we have a java class with annotation support configuring the application context, and showing the output, were you can see how the aspect did its work, other sub section is Spring IDE where a concrete theory is available and an image is shown, called Eclipse integration for Spring showing the aspect-bean interaction

We forward now to Spring AOP under the hood covering the subsection A quick introduction to dynamic proxies where the author offer us two classes one related with Tracing invocation handler to be used in a proxy and Main class to execute and its respective output of course, now we follow with Proxy-based AOP with Spring covering with a list and explaining each element about Spring’s programming model where overcomes issues with the raw use of proxies. Other sub section is Spring AOP internals where includes an image about A simplified schematic of Spring AOP with pointcuts and advice and a well explanation for each component we have, the next subsection is Proxy-based AOP in DI framework where we have other interesting image about Proxy-based AOP working with DI , the author cover too aop:aspectj-autoproxy tag doing furthermore a well explantion of its use, the last subsection is Limitations of Spring AOP listing each one with its respective explanation and including other image about Spring AOP advises method execution resulting from an external call

Changing of section now we have @AspectJ support in depth where we have aop:aspectj-autoproxy working with and without cglib (proxy-target-class="true") including an image The @AspectJ integration where you can see how the aop:aspectj-autoproxy work related with our java @Aspect class. We have more, starting with the subsection Dynamic crosscutting where we have almost six pages for important cover based in theory, tables (snippet code and explanation) really important and well cover this, for:

  • pointcuts
  • selecting spring beans ( important image about Selecting horizontal and vertical slices of beans based on their names using the bean() pointcut designator )
  • advice
  • aspect ordering
  • aspect instantiation models

We have other subsection yet, called Static crosscutting including an @Aspect java class with its respective explanation

Now we change of section Schema-style AOP support including an important image about Schema-style AOP where you can see really the relation of aop:config and its nested elements with a java class, rows are used here to see the specific relation among these components, even we have a table discussion Light treatment of schema-style AOP, again we go deeper with sub sections for

  • Mapping aspects
  • Mapping pointcuts
  • Mapping advice
  • Mapping static crosscutting

almost five fives for these sub sections with a long and solid theory

We follow with the section Tapping into the full power of AspectJ covering two subsections, starting with Configuring aspects using Spring DI pure concrete theory, the second is Spring-driven LTW, really well covered for the sub topic spring-driven ltw in action where the auhtor gives us steps to have the application work with Spring-driven LTW each one explained and snippet code are included about configurations, the second sub topic is spring-driven ltw: under the hood, more theory and an important image about Schematic of Spring-driven LTW really well explained by itself this image, a brief list about servers support Spring-driven LTW are available too, a table discussion about Spring-driven LTW without Spring

The last section of the chapter is Choosing an appropriate AOP system covering in three pages with a good amount of theory based in a list and explanation for each element for the follow sub sections

  • Comparing AspectJ to Spring AOP
  • Comparing Spring AOP syntax
  • It’s decision time

Part II Applications of AspectJ with Spring

Chapter 10: Monitoring techniques

After of an introduction we go to the section Tracing in action, covering the follow subsections Tracing the aspect-oriented way where an aspect code is available with its respective explanation, showing us too its output, a table dicussion is available too Standard logging toolkit vs. log4j vs. commons logging. The follow subsection is Tracing the conventional way where you can see a java class and explanation for some features for such class, including a table discussion Logging toolkit and automatic extraction of caller information

We forward to the section Conventional vs. AOP tracing including an image based in Conventional tracing and even with a table discussion about Logging vs. tracing including good theory, following with other image about An overall schematic of AspectJ-based tracing , where you can see now clearly the differences.

Now we have the section Selecting join points of interest covering two subsections, the first Selection based on static structure covering the follow sub topics with well theory, and a good amount of snippet code:

  • leveraging package structure
  • leveraging type structure
  • leveraging annotations
  • leveraging method signature

The follow subsection is Selection based on dynamic context covered with a concrete theory and snippet code

Now we go to the section Tracing, almost eight pages in cover the follow sub sections:

  • Indenting trace calls (important table discussion Nested Diagnostic Context and Mapped Diagnostic Context)
  • Sharing tracing aspect functionality
  • Tracing intra-method activities
  • Logging the method parameters
  • Choosing a type-specific logger

good amount of code, with its respective explanation, output results available

Other section is A detour: deployment options for monitoring aspects covering the two sub sections

  • Utilizing load-time weaving (working with aop.xml including a well explanation for such configuration)
  • Utilizing Spring AOP for tracing (working with a java class with @AspectJ support )

Again well explanation and output results

The follow section is Exception monitoring starting with a concrete theory and including a table discussion First-failure data capture, we have an aspect code ExceptionTraceAspect: tracing exceptions using log4j detailed explanation for such code available with its respective output

The follow section is Improving conventional logging covering two sub sections Modularizing NDC with conventional logging and Modularizing MDC with conventional logging based in well theory and java code and its respective output, well covered this section

Other section is Performance monitoring where you going to see some aspect code and adding performance monitoring through Spring AOP, well explanation and even output results available

To end the chapter we have the section Runtime control of monitoring aspects where we have more aspect code and some configuration for exposing the monitoring aspect using Spring’s JMX support where such configuration is well explained and an image JConsole to monitor and control aspect exposed through JMX is included to show us how Spring/AOP/JMX work all together

Chapter 11: Policy enforcement: keeping your design intact

After of an interesting introduction we start with the section AOP-based policy enforcement overview where we have an image about A typical layered architecture for enterprise applications where now the author offer us an aspect to enforcement of layered architecture, where it controls that each layer only must call its above layer or itself, for this control we work with declare error, a table discussion is available too Crosscut Programming Interface, the author in code used reusable aspects (i.e for jdbc, jpa), the author shown us how the aspect work detecting when we break the rules, an image about The overall scheme of policy enforcement using AspectJ is available too

Now we have long theory for the sections Policy origins and destinations and Enforcement using AOP where for this last covers the subsections Compile-time enforcement including its limitations on the kinds of checks it can perform, other subsection is Runtime enforcement including a table discussion about Contract enforcements (Contract4J)

We follow with the section Comparison with code-analysis tools doing mention to FindBugs,Checkstyle,PMD, well explanation among other things

Other section is Implementing flexible access control, covering in almost five pages the subsections:

  • Restricting exposure
  • Limiting collaboration
  • Enforcing the factory pattern

which includes a good amount of java classes and aspect with many output results

We follow with Enforcement idiom: return-value restriction where the author offer us an aspect called RepositoryNullReturnDetector where is applied to shown us how it do its job well in detect such violation in case of return some null value. The follow section is Enforcing JPA-JDBC integration policies which contains some java classes and @AspectJ support, well explained those code, even including two table discussion, the first called JPA and bulk update and delete and the second Using traditional-style aspect from Spring AOP

The other section that becomes is Implementing EJB policies covered almost in five pages the subsections:

  • Developing a core EJB enforcement aspect
  • Defining EJB pointcuts
  • Dealing with XML-based EJBs
  • Implementing a “no EJBs” policy

based through in two aspect code with a very descriptive explanation, a class with @Stateless support and output results

The last section is Detecting Swing concurrency control policy violations, five pages for covering the two follow subsections Understanding the problem and Detecting the violation well explained theory with its respective code with explanation and practically one page for output results

Chapter 12: Learning design patterns

Interesting chapter, starting with the section The worker object pattern where in seven pages the follow subtopics are covered:

  • The current solution
  • An overview of the worker object pattern
  • The worker object pattern template
  • Getting the return value
  • A summary of the worker object pattern

well solid theory with a good amount of code and output results

The follow pattern and section is The wormhole pattern where in four pages you going to find the covering for the follow subsections:

  • The current solution
  • An overview of the wormhole pattern (including an image The wormhole pattern for better understanding)
  • The wormhole pattern template
  • A summary of the wormhole pattern

Like the previous pattern, here the author give us well theory and java classes and aspect code with its respective explanation

The follow pattern is The participant pattern same appreciation for the both previous pattern well theory and many java classes and aspect code with its respective explanation for the follow sub sections

  • Current solutions
  • An overview of the participant pattern
  • The participant pattern template (Including and image about A typical structure using the participant pattern)
  • Consequences of the participant pattern
  • A summary of the participant pattern

The last section of the chapter and interesting is Annotation-driven participant pattern, again same appreciation like the all previous sections, covering the sub sections, including an image to give a better understanding

  • Current solution
  • The annotation-driven participant pattern template
  • Annotation type abstraction
  • Variation: bridged participation pattern (including an image Bridged participation pattern for better understanding)
  • Role of ADPP in library aspects

Seven pages in covering these topics

Chapter 13: Implementing concurrency control

The chapter start quickly with the section Modularizing Swing’s single-thread rule based with a long theory and covering the follow subsections A test problem where we have a Main class working with Swing (JFrame and DefaultTableModel) where the author explain such code and the reason of the problem, followed by an aspect code LogUIActivitiesAspect that control each call and its respective output and the error shown within it, a table discussion is included Automated testing, the follow subsection is Solution: the conventional way where you can see the previous Main class edited (working with EventQueue and its methods) and its respective explanation, again other table discussion is included SwingWorker doing reference to JDK 6, output for new changes is shown without error now, the follow section is Solution: the AspectJ way covering in ten pages three versions working with aspects, really a good amount the code you going to see with a valuable explanation for these codes of course, for each version its respective output is shown, therefore the last subsection is Improving the solution covering the sub topics dealing with exceptions and avoiding the overhead where snippet code and its explanation is used

The follow section is Improving the responsiveness of UI applications covered with many aspect code and concrete explanation

Now the section Modularizing the read-write lock pattern is introduced, covering the subsections Implementation: the conventional way and Implementation: the AspectJ way where in seven pages a good amount of code with its respective explanation is available, interesting and well covered for these subsections.

Chapter 14: Managing transactions

Of course a critical topic, well after to an introduction we start with the section Transaction management implementations covering two subsections Conventional implementation and AOP implementation for each one its respective snippet code and well explanation.

We follow with the section Transaction-management players covering the follow subsections Transaction management in architecture based with concrete theory and including an important image about Layered architecture of the enterprise system, the other sub section is Transaction management: one concept,too many implementations covered only with theory, and the last section is Transaction-management abstraction covering the Spring interface PlatformTransactionManager and doing a concrete explanation for its methods.

The follow section is Aspect implementation choices covering quickly the follow sub sections, Proxy-based AOP based in an important explanation for the objects included in an important image Structure of transaction management implemented in a proxybased AOP framework, well explained, the other subsection is Byte-code weaving covered with pure concrete theory.

Now we turn to Transaction-management aspect (almost) from scratch section, covering the follow subsections Implementing the aspect where an abstract @Aspect code is included with its respective explanation for its important parts, followed by the sub @Aspect code, again doing an explanation for its important parts, therefore the follow subsection is Testing the aspect where we have two pages for a java test class TransactionManagementAspectTest working with @Mock, interesting code really, the follow subsection is Road test for the aspect working with a Main class and two @Aspect code and other java class annoted with @Transactional, for this last one code explanation is available, the last part is about aspectj byte-code weaving where a Configuring transaction-management aspect for AspectJ weaving is available, then for all these code its respective output is included, practically one page for this, even highlighting the most importants parts, other approach used is too spring’s proxy-based aop including Configuring transaction-management aspect for Spring’ proxy weaving and again its respective output is included, again practically one page for this, highlighting the most importants parts.

The follow section is Spring’s transaction management covering the subsections XML-driven transaction management including a Configuration for XML-driven transaction management with its respective explanation and output highlighting the most importants parts and Annotation-driven transaction management including XML configuration for annotation-driven transaction management and concrete theory, the follow subsection is AspectJ weaver-based transaction management where do emphasis in tx:annotation-driven mode="aspectj" after following with its output highlighting the most importants parts, one page about this output

The follow section and to finish the chapter is Implementing fault tolerance for transactional operations which includes the covering for the follow subsections:

  • Base aspect (working with an abstract @Aspect code with its respective explanation)
  • Using the annotation-driven participant pattern (well theory and image included Relationship between transactional operations ... and subclass @Aspect)
  • Configuring the aspect (working with beans configuration fault-tolerance-context.xml )
  • Testing the fault-tolerance aspect (working with a FaultToleranceInventoryServiceTest class, with its respective explanation)
  • Improving the solution (working with an aspect NonTransactionalWorkCoordinatorAspect and using percflow )

Seven pages in covering these topics.

Chapter 15: Securing applications

Another important topic, we start quickly with the section Securing applications with conventional techniques covering the follow subsections with concrete theory The do-it-yourself approach which includes a snippet code and The framework-based approach. The follow section is Modularizing security using AOP based in concrete theory again and with snippet code.

Now Spring comes, with the section A quick overview of Spring Security, covering the follow sub sections, the first Authentication based with concrete theory and including an image called Overview of the authentication in Spring Security, the second is Authorization with its respective theory and other image called Spring Security authorization sequence.

We follow now to the section Implementing a security solution from scratch, covering the follow sub sections, the first is Implementing authentication aspects which it cover the sub topic base authentication aspect based in an abstract, @Aspect with its respective explanation working together with a java util class offered by the author,where explanation for such code is available, followed by a sub @Aspect class and Configuration for authentication security tags are available, with its respective explanation and output too. Then the second sub section is Implementing authorization aspects where an image called Securing the service layer using proxy-based AOP and Spring Security is included followed by an abstract @Aspect code with its respective configuration, working together with other java util class offered, explanation for such class is available too, two table discussion are available Just in time authentication and Noninvasive crosscutting, even more an @Aspect code and java code is available followed with its respective configuration where for this is well explained, after of these code and configuration the output is included, where you can confirm how all work well, a variation is taken here, where annotation-driven subaspect now is included, workin with @Aspect,@Security and @Secured with its respective output which is identical with the noneannotation approach.

The follow section is Implementing field-level authorization based in an important theory and table discussion called Annotation isn’t the only choice, then the java code comes, where a Custom annotation to mark secured fields is shown, this is an interface using (@Target(ElementType.FIELD) with @Retention(RetentionPolicy.RUNTIME)) followed by a Spring class Test which uses (@RunWith(SpringJUnit4ClassRunner.class) with @ContextConfiguration), a domain class and @Aspect AccessFieldSecurityAspect is introduced too, explanation for this @Aspect is included, the last here is the Configuration of the aspect for the test

The follow section is Spring Security prebuilt solutions covering the follow subsections Web security based in a concrete theory and snippet code about security:http, the follow subsection is Service level security based in a snippet code for security:global-method-security or with other approach about a class working with @Secured, where explanation for such code is available, table discussion is included What about prescreening?, the follow sub section is Domain-object security covered with a concrete theory

To end the chapter the section Additional ideas in implementing security is available covering with pure and concrete theory the follow sub sections Auditing access and Filtering field content.

Chapter 16: Improving domain logic

After to a theory introduction we start with the section Empowering objects based in a long theory and table discussion called Spring Roo and domain-driven design and covering the follow subsections Enabling rich behavior based in a snippet code and long and well theory, again other table discussion is included Static field dependency injection?, followed by the sub section Injecting dependencies with Spring and AspectJ which includes an image Domain object DI through an aspect, followed by java code for a domain class annoted with @Entity, @Table, @Configurable, respective explanation for such class available followed by a Spring Configuration to inject dependencies with its respective explanation, a Spring Test class is included, followed with a brief table discussion Unit-testing with @Configurable objects, Spring's autowiring is included and used too for the domain class, other table discussion is included too All Spring container services now showing in objects near you, even more in this sub section the sub topic domain interfaces-based DI is included, based in a java and aspect code and for this last one its respective explanation (well covered) and Spring beans configuration included too, another table discussion is available A right-sized approach to design, now the last subsection is Possibilities enabled by domain-object DI covering the subtopics:

  • enriching domain object behavior (includes tables discussion Package arrangement with domain object DI and Inject repositories?)
  • discussion: rethinking the service layer (includes table discussion Implication on service-oriented architecture)
  • simplifying the domain object api (includes table discussion Humane interfaces)

based in many versions of the domain and service class, all these sub topics covered in almost six pages

The follow section is Implementing business logic covering the follow sub sections, the first Improving inventory management based in a java and aspect code, the second is Checking for the order-level constraint based in an aspect code and including a table discussion ORM and validation, the third and last sub section is Refactoring using aspects based in our domain class working with a nested static aspect.

The follow section and to end the chapter is Managing access to objects which cover the follow sub sections:

  • Applying specific policies (based in a aspect code)
  • Applying general policies (based with concrete theory, including an image Managing access to an aggregate and java code about creating our @Aggregate annotation and applied to many domain classes, an aspect AggregateBoundaryEnforcementAspect is included, almost one page in code and well explained the most important parts, followeb by a test class AggregateBoundaryEnforcementTest)

Chapter 17: Taking the next step

This is the last chapter of this powerful book, pure theory, starting with the section The adoption path: technologies covering the follow sub sections Spring AOP and AspectJ

The follow section is The adoption path: applications covering many subsections, the first Development aspects covering the sub topics

  • helping with debugging
  • monitoring performance
  • enforcing policies
  • helping with testing

The second section is Production aspects covering the sub topics

  • infrastructure aspects
  • crosscutting domain logic
  • refactoring aspects

The follow section is Applying AOP to new problems covering the follow sub sections in a list approach, explaining each element, for Talking the talk and Walking the walk, concrete and interesting material

The next section is Employing AOP in development phases like the previous section, covering four sub sections and explaining by list theory each one, the first is for the sub section AOP in the design phase and the second for AOP in the implementation phase but doing covering for the sub topics:

  • implementing core concerns
  • implementing crosscutting concerns

The third sub section is AOP in the maintenance phase and the fourth and last is AOP in legacy projects

The last section of the chapter is Parting thoughts again applying list approach covering the follow elements

  • Start simple
  • Join the community
  • View AOP as augmenting technology
  • Experiment
  • Develop a repertoire of reusable aspects
Published at DZone with permission of its author, Manuel Jordan.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)