SeamFramework.orgCommunity Documentation

Chapter 4. Enhancements to the CDI Programming Model

4.1. Preventing a class from being processed
4.1.1. @Veto
4.1.2. @Requires
4.2. @Exact
4.3. @Client
4.4. Named packages
4.5. @FullyQualified bean names

Solder 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). Solder provides a built in qualifier, @Client for this purpose.

Solder 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 For example, to cause any beans defined in com.acme to be given their default name:


package com.acme

According to the CDI standard, the @Named annotation assigns a name to a bean equal to the value specified in the @Named annotation or, if a value is not provided, the simple name of the bean class. This behavior aligns with the needs of most application developers. However, framework writers should avoid trampling on the "root" bean namespace. Instead, frameworks should specify qualified names for built-in components. The motivation is the same as qualifying Java types. The @FullyQualified provides this facility without sacrificing type-safety.

Solder allows you to customize the bean name using the complementary @FullyQualified annotation. When the @FullyQualified annotation is added to a @Named bean type, producer method or producer field, the standard bean name is prefixed with the name of the Java package in which the bean resides, the segments separated by a period. The resulting fully-qualified bean name (FQBN) replaces the standard bean name.

package com.acme;

@FullyQualified @Named
public class NamedBean {
   public int getAge()
      return 5;

The bean in the previous code listing is assigned the name com.acme.namedBean. The value of its property age would be referenced in an EL expression (perhaps in a JSF view template) as follows:


The @FullyQualified annotation is permitted on a bean type, producer method or producer field. It can also be used on a Java package, in which case all @Named beans in that package get a bean name which is fully-qualified.


package com.acme;

If you want to use a different Java package as the namespace of the bean, rather than the Java package of the bean, you specify any class in that alternative package in the annotation value.

package com.acme;

@FullyQualified(ClassInOtherPackage.class) @Named
public class CustomNamespacedNamedBean {