Uploaded image for project: 'Sakai'
  1. Sakai
  2. SAK-42437

Remove usage of anti-pattern getBeansOfType

    Details

    • Type: Feature Request
    • Status: Awaiting Review
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: BasicLTI, Kernel, Search
    • Labels:
      None
    • Test Plan:
      Hide

      Please add a Test Plan here.

      Show
      Please add a Test Plan here.

      Description

      Earle mentioned on SAK-42394 that usage of getting the beans during init and injecting them was an anti-pattern and should be removed. 

       

      If it can't be done using dependencies (as Matt already stated) then by design I would potentially look at removing the use of:
      applicationContext.getBeansOfType(LearningResourceStoreProvider.class, true, false);
      by having the providers perform their own registration with service via org.sakaiproject.event.impl.BaseLearningResourceStoreService#registerProvider vs the service attempting to do it for them.
      

       

      I looked and there were 4 places doing this in core that should be investigated to see if we can remove these. Contrib tools that make use of this pattern would break but we should be able to fix these for core. Everything now except the one in basiclti are calling with the third parameter as "false".
      basiclti/basiclti-portlet/src/java/org/sakaiproject/blti/ProviderServlet.java
      221: Collection processors = ac.getParent().getBeansOfType(BLTIProcessor.class).values();

      search/elasticsearch/impl/src/java/org/sakaiproject/search/elasticsearch/ElasticSearchIndexBuilderAutoRegistrar.java
      54: applicationContext.getBeansOfType(ElasticSearchIndexBuilder.class, false, false);

      kernel/kernel-impl/src/main/java/org/sakaiproject/component/impl/BasicConfigurationService.java
      184: Map<String, ConfigurationProvider> providerBeans = this.applicationContext.getBeansOfType(ConfigurationProvider.class, false, false);

      kernel/kernel-impl/src/main/java/org/sakaiproject/event/impl/BaseLearningResourceStoreService.java
      94: Map<String, LearningResourceStoreProvider> beans = applicationContext.getBeansOfType(LearningResourceStoreProvider.class, true, false);

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  jonespm Matthew Jones
                  Reporter:
                  jonespm Matthew Jones
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:

                    Git Source Code