Java Reference
In-Depth Information
* This decorator class is applied to the employee hiring process to implement
* additional functionality to any of the methods implemented within are called.
* @author Juneau
public class EmployeeProcessorDecorator implements Hire{
Hire hire;
public String badgeEmployee() {
String result = null;
// Perform a test implementation for badging an employee
return result;
public String trainEmployee() {
String result = null;
// Perform a test implementation for training an employee
return result;
As of CDI 1.1, it is possible to define the ordering of decorator classes by applying the @Priority annotation.
The following example demonstrates how to specify priority for a decorator class known as EmployeeProcessorDecorator :
public class EmployeeProcessorDecorator implements Hire{
Please refer to Table 7-4 for more information regarding Interceptor.Priority values. Also, if you are unfamiliar
with the concept of decorators, please refer to the documentation that can be found within the online Java EE 7
tutorial for more information.
Alternatives provide a good solution for implementing multiple versions of a bean that can be used for different
purposes. Qualifiers can be utlilized during the development phase for injecting different bean implementations,
whereas alternatives allow one to choose between different implementations at deployment time. Alternatives are
useful for scenarios where an application may be deployed with some default functionality, but made configurable to
utlize a different functionality if deployed in another environment. They can also be useful for testing different versions
of beans, whereby a default implementation is written, but an alternate bean can be specified at deployment time.
Search WWH ::

Custom Search