Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-2787

InstallContext should not be available to ModuleVersionHandlers at instantiation time

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major Major
    • None
    • 4.1
    • core
    • None

      Considering the following code:

      public class MyModuleVersionHandler extends DefaultModuleVersionHandler {
          public MyModuleVersionHandler() {
              super();
              final ModuleDefinition currentModule = ModuleManager.Factory.getInstance().getInstallContext().getCurrentModuleDefinition();
              System.out.println(currentModule);
          }
      }
      

      As of 4.1, this print the ModuleDefinition of the module preceding the one corresponding to this version handler.
      As of 4.1.1, this will return the correct module; to avoid confusion however, I'd be in favor of preventing this sort of code to run at all. It is hard to prevent this sort of code from running at the moment because of the singleton nature of this API. By using IoC, I'm fairly convinced we could achieve something cleaner.

      In further versions, this should probably not be feasible at all, since one should only use the InstallContext in the execute method of Tasks. Also see info.magnolia.module.delta.RegisterModuleServletsTask, which uses the InstallContext at execution time to instanciate other tasks, which is something that might need to be simpler/cleaner too.

        Acceptance criteria

              pbaerfuss Philipp Bärfuss
              gjoseph Magnolia International
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD