Chapter 11. Capturing Join Points Based on Object Type

Introduction

The pointcuts covered in this chapter enable you to examine the type of the this reference, the optional target reference or arguments at a particular join point.

The this([Type | Identifier]) examines the type of the object that is referenced by this at the captured join point. The target of a join point, specified by the target([Type | Identifier]) pointcut, differs depending on the join point type but is commonly the object upon which a method is being called, or an attribute that is being accessed in some way where the join point is encountered. The args of a join point, specified by the args([Types | Identifiers]) pointcut, are the arguments, if any, available at the captured join point.

The types of the this, target, and args references can be examined in one of two ways: using static Type specifications, or by using an Identifier that references an actual runtime object.

A Type specification provides a static compile-time evaluation of the object type at the join point and takes the form of a fully qualified class name (for example, com.oreilly.Foo is acceptable, but Foo or Foo.class is not).

An Identifier provides a means by which the actual types of runtime objects at the captured join point can be evaluated rather than just static types. An Identifier is dynamically assigned to the appropriate object at runtime.

11.1. Capturing When the this Reference Is a Specific Type

Problem

You want to capture all join points ...

Get AspectJ Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.