SeamFramework.orgCommunity Documentation
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 a class @Veto
will cause the type to be ignored, such that any definitions on the
type will not be processed, including:
For example:
@Veto
class Utilities {
...
}
The ProcessAnnotatedType
container lifecycle event will be called for vetoed types.
Annotating a class @Requires
will cause the type to be ignored if the class dependencies
can be satisfied. Any definitions on the type will not be processed:
Weld will use the Thread Context ClassLoader, as well as the classloader of the type annotated
@Requires
to attempt to satisfy the class dependency.
For example:
@Requires(EntityManager.class)
class EntityManagerProducer {
@Produces
EntityManager getEntityManager() {
...
}
}
The ProcessAnnotatedType
container lifecycle event will be called for vetoed types.
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