Information Technology Reference
In-Depth Information
The following sequence diagram shows how the interceptor pattern allows you to add
steps before and after the execution of commands:
Now that we have understood a bit more about what the interceptors do and how they in-
fluence the behavior of a command pattern's application, we can get into the details of
specific interceptors you can build for the task service, how to configure them, and what
classes constitute our model to create these interceptors.
Interceptors for the task service can extend an abstract class with some helper methods
called AbstractInterceptor . It provides basic implementations for all the methods,
except for the execute method, and provides an executeNext method to invoke the
next interceptor in line. With it, it becomes very simple to create a new interceptor.
In the project, human-task-extension-points , you will find that we created an
interceptor called UserLogInterceptor . It is just for demonstration purposes. The
main activity it provides around every method is the process of finding out whether it is a
user-related operation according to the type of the invoked command. If it is, it stores a
log of the operation that is called, inferred from the command name as well. The ex-
ecute method for UserLogInterceptor looks like the following code:
Search WWH ::




Custom Search