[cdi-dev] [JBoss JIRA] (CDI-628) Allow overriding of Scope at Injection Point

Stephan Knitelius (JIRA) issues at jboss.org
Thu Sep 8 04:38:00 EDT 2016

Stephan Knitelius created CDI-628:

             Summary: Allow overriding of Scope at Injection Point
                 Key: CDI-628
                 URL: https://issues.jboss.org/browse/CDI-628
             Project: CDI Specification Issues
          Issue Type: Feature Request
    Affects Versions: 2.0 (proposed)
            Reporter: Stephan Knitelius
            Priority: Optional

Allow overriding scopes at injection point.

public class FeatureState {...}

public class Bean B {
  @ConversationScoped //Overriding original scope
  public BeanA beanA;

Sample use-case for for a feature flag:

public class FeatureStateProducer {

  private FeatureState devState;

  private FeatureState viewState;

  private JNDIProvider jndiProvider;

  private boolean viewOnly = true;

  public void postConstruct() {
    this.viewMode = ...; //read config.

  public FeatureState produce() {
    return viewOnly ? viewState : devState;


Currently this can be solved by overriding scope with @Qualifiers:
public class ViewFeatureState extends FeatureState {...}

public class DevFeatureState extends FeatureState {...}

* developers might start to define the scopes at IP and on bean (hard to maintain).
* confusing when debugging, annotation on bean, e.g. @ApplicationScoped yet behaving differently.
* etc... 

This message was sent by Atlassian JIRA

More information about the cdi-dev mailing list