[MAGNOLIA-2787] InstallContext should not be available to ModuleVersionHandlers at instantiation time Created: 15/Jun/09  Updated: 04/Nov/15  Resolved: 04/Nov/15

Status: Closed
Project: Magnolia
Component/s: core
Affects Version/s: 4.1
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Magnolia International Assignee: Philipp Bärfuss
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
relation
supersession
supersedes MAGNOLIA-2788 InstallContext should provide the cor... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

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.



 Comments   
Comment by Jan Haderka [ 09/Oct/12 ]

I would say this is part of bigger bundle - rewrite module management to use guide ioc introduced in 4.5

Comment by Tobias Mattsson [ 02/Dec/13 ]

I'd be in favour of removing the ModuleManager.getInstallContext() completely. It appears to not be in use anywhere, expect for internally of course.

Comment by Michael Mühlebach [ 04/Nov/15 ]

Given the thousands of other issues we have open that are more highly requested, we won't be able to address this issue in the foreseeable future. Instead we will focus on issues with a higher impact, and more votes.
Thanks for taking the time to raise this issue. As you are no doubt aware this issue has been on our backlog for some time now with very little movement.
I'm going to close this to set expectations so the issue doesn't stay open for years with few updates. If the issue is still relevant please feel free to reopen it or create a new issue.

Generated at Mon Feb 12 03:40:06 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.