This appendix provides a quick guide to notation for modeling aspects as used in this book. Let’s recount the principles we use to model aspects. We treat aspect as part of an overlay (i.e., use-case slice) that is placed on top of an existing class or a set of classes. The names of the classes and operations must match those in the element structure before proper overlaying can take place. The use-case slice is a larger concept of an overlay than aspects. Whereas aspects can only add to existing classes, use-case slices can add entire new classes as well. Moreover, whereas parameterization of pointcuts is for binding existing locations (i.e., join points), use-case-slice template parameters allow you to define completely new elements. The key to understanding the notation is to know how overlaying is achieved.
A class extension is a modular extension to an existing class. It defines the features (attributes, operations, and relationships) to be overlaid onto an existing class. The name of the class and the class extension must correspond. See Figure A-1.
An operation is the behavioral response when an element is invoked. An operation extension is a modular extension to an operation. Since operations are defined within classes, operation extensions are also defined within class extensions. See Figure A-2.
The logging aspect adds:
an operation extension logData
to the ReserveRoomHandler
class makeReservation()
operation, that is, to the structural context,
before the execution point when a call is made to Room.retrieve()
, that is, behavioral context.
This corresponds to an advice as follows:
1. public aspect Logging { 2. before () : 3. withincode (void ReserveRoomHandler.makeReservation()) 4. && call (void Room.retrieve()) { 5. // code 6. } 7. }
Before
and after
operation extensions execute before or after existing execution points. Figure A-3 shows the use of before
and after
operation extensions.
The figure contains two frames:
Frame shows the execution of operation extension logData1
before call to Room.retrieve()
.
Frame shows the execution of operation extension logData2
after call to Room.retrieve()
.
Around
operation extensions wrap up existing codes and determine if existing code can proceed. Figure A-4 shows how operation extensions execute around existing execution points.
The figure contains two frames:
Frame shows the execution of operation extension checkAuthorization
around call 〈Control〉.performRequest()
.
Frame shows the continuation of call to 〈Control〉.performRequest()
when checkAuthorization
initiates proceed
.
A pointcut gives the context in which an operation extension executes a name. This context can comprise structural context, behavioral context, or both. See Figure A-5.
an operation extension logData
to an existing operation within the ReserveRoomHandler
class (This is parameterized as 〈roomAccessOp〉
, and it establishes the structural context of the operation extension.)
before a call to a Room operation (This is parameterized as 〈roomCall〉
and it establishes the behavioral context of the operation extension.)
A use-case slice contains one collaboration, zero or more classes, and one or more aspects. The diagram in Figure A-6 depicts the various parts of a use-case slice.
3.144.244.250