Information Technology Reference
In-Depth Information
ternal systems to the internal information of the task, but not a great place to make once-
per-method-invocation operation inside the task service.
Interceptors, on the other hand, will be invoked for each method's invocation and will be
able to wrap a lot more of execution than each method of the listener; for one invocation
in a task service method, many different task life cycle event listeners might be fired, all
detached from one another. However, the interceptor will be able to handle what happens
before and after that whole invocation and even take care of exception handling if some of
the actions taken in the proprietary code need to roll back the task service operation if
there is an error.
For some cases, using both on a single class could be an alternative. For example, let's
consider a cache for tasks. Whenever a task is changed, we want to mark it to update the
cache. However, we don't want the cache to be updated until we finish the method's invoc-
ation. A good way to manage such a case would be to implement an interceptor to handle
the cache update and a life cycle event listener to control which tasks are being changed
by a particular method's invocation in the task service.
Many more possible cases might trigger the necessity of one over the other. The important
thing to understand is that they are not mutually exclusive, and each deal with a different
aspect of the task management, something we can take advantage of.
Task model provider
One final extension point that we will discuss in this chapter is the possibility of changing
the JPA entity model used by the application. This will be an advanced feature that users
can use that will allow people to add extra attributes (and therefore, extra columns) to the
domain model to make it easier for you to create your own queries on the persistence.
You could have the possibility of adding, for example, an external entity ID passed to the
task as a data input to your task objects. Later on, you could use this ID to create queries
with your particular model, provided that they are both working in the same persistence
unit.
This is possible because no components of the core of the Human task component con-
struct any of the model objects directly. Instead, they use a factory called
TaskModelFactory . This factory provides a concrete implementation of the interfaces
that compose the core model of the task service, as follows:
Search WWH ::




Custom Search