Skip to content

Qualifiers with Members #8

Description

@hendryluk

Currently when resolving components, Cormo matches qualifiers using only their types.
According to CDI spec however, attribute properties can be used to further discriminate a qualifier, which helps reducing the number of qualifiers needed. Ref: http://docs.jboss.org/weld/reference/latest/en-US/html/injection.html#_qualifiers_with_members

E.g.

public class PayByAttribute: QualifierAttribute
{
   public PaymentType PaymentType {get; set;}
}

Then we select one of the possible property values when applying the qualifier:

[Inject, PayBy(PaymentType.Check)] PaymentProcessor _checkPayment;

We can force the container to ignore a member of a qualifier type by annotating the property with [Nonbinding] attribute.

public class PayByAttribute: QualifierAttribute
{
   public PaymentType PaymentType {get; set;}
   [NonBinding] string Comment {get; set;}
}

The same should also be applied on interceptor bindings and mixin-bindings.
https://docs.jboss.org/weld/reference/1.0.0/en-US/html/interceptors.html#d0e3527

E.g.

[Transactional(RequiresNew=false)]
public class RequiresNewTransactionInterceptor: IAroundInvokeInterceptor
{
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions