You want to define a set of roles to be implemented by unknown sets of application classes so they can be interacted with generically by an abstract aspect.
Apply the Director aspect-oriented design pattern. Figure 23-2 shows the key components of the Director pattern.
Figure 23-2. The structure of the Director pattern
The key roles in the Director pattern shown in Figure 23-2 are:
The abstract aspect at the center of the design pattern that specifies the roles to be directed using Java interfaces and optionally specifies interactions that can occur between those roles.
A pair of example roles defined as nested interfaces within the
A pair of business classes within the target application that are
candidates for the roles defined by the
Applies the roles to specific classes within the target application.
In this example,
Role1 is applied to
BusinessClassB does not implement the
bar( ) method necessary for the
Role2 interface, this can be supplied using
static cross-cutting techniques by
The Director pattern decouples the generic and reusable aspect behavior from the implementation classes of a specific application, ...