Uploaded image for project: 'DeltaSpike'
  1. DeltaSpike
  2. DELTASPIKE-599

CDI 1.1 friendly ViewConfig discovery

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.7
    • 1.0.1
    • JSF-Module
    • None

    Description

      CDI 1.1 introduced the "annotated" bean discovery mode. In this mode, ProcessAnnotatedType observers in CDI extensions are only called for classes that have CDI scope annotations. This is inconvenient for ViewConfigs, as it requires that every class (page) must be annotated with @Dependent:

      public interface Pages extends ViewConfig {
      
      	@Dependent
      	class Index implements Pages {}
      	
      	@Secured({AuthenticatedDecisionVoter.class, PermissionDecisionVoter.class})
      	interface SecuredByRoleAttribute extends Pages {
      		@Dependent
      		class TestPage implements SecuredByRoleAttribute {}
      	}
      	
      	@Secured(AuthenticatedDecisionVoter.class)
      	interface NoAuthorization extends Pages {
      		@Dependent
      		class TestPage implements NoAuthorization {}
      	}
      	
      }
      

      Another workaround would be to make a base class that is marked @Dependent and have all of the pages extend that class, but that's not really any better in terms of the amount of boilerplate.

      It would be nice if there were another way to discover ViewConfig classes. One idea: the application provides a producer method/field with some qualifier that provides the outer-most ViewConfig interface (Pages.class in the above example). Then DS injects Instance<Class<? extends ViewConfig>> and uses Class.getDeclaredClasses() to walk the tree.

      Attachments

        Activity

          People

            gpetracek Gerhard Petracek
            rcd Richard DiCroce
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: