SeamFramework.orgCommunity Documentation

Chapter 2. Enhancements to the CDI Programming Model

2.1. Preventing a class from being processed
2.1.1. @Veto
2.1.2. @Requires
2.2. @Exact
2.3. @Client
2.4. Named packages

Weld Extensions provides a number enhancements to the CDI programming model which are under trial and may be included in later releases of Contexts and Dependency Injection.

Annotating an injection point with @Exact allows you to select an exact implementation of the injection point type to inject. For example:

interface PaymentService { 

   ...
}
class ChequePaymentService implements PaymentService { 

   ...
}
class CardPaymentService implements PaymentService { 

   ...
}
class PaymentProcessor { 

   
   @Inject @Exact(CardPaymentService.class)
   PaymentService paymentService;
   
   ...
   
}

It is common to want to qualify a bean as belonging to the current client (for example we want to differentiate the default system locale from the current client's locale). Weld Extensions provides a built in qualifier, @Client for this purpose.

Weld Extensions allows you to annotate the package @Named, which causes every bean defined in the package to be given its default name. Package annotations are defined in the file package-info.java. For example, to cause any beans defined in com.acme to be given their default name:

@Named

package com.acme