[ 
http://jira.magnolia-cms.com/browse/MAGNOLIA-2787?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Grégory Joseph updated MAGNOLIA-2787:
-------------------------------------

    Description: 
Considering the following code:
{code}
public class MyModuleVersionHandler extends DefaultModuleVersionHandler {
    public MyModuleVersionHandler() {
        super();
        final ModuleDefinition currentModule = 
ModuleManager.Factory.getInstance().getInstallContext().getCurrentModuleDefinition();
        System.out.println(currentModule);
    }
}
{code}
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.


  was:
Considering the following code:
{code}
public class MyModuleVersionHandler extends DefaultModuleVersionHandler {
    public MyModuleVersionHandler() {
        super();
        final ModuleDefinition currentModule = 
ModuleManager.Factory.getInstance().getInstallContext().getCurrentModuleDefinition();
        System.out.println(currentModule);
    }
}
{code}
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.




> InstallContext should not be available to ModuleVersionHandlers at 
> instantiation time
> -------------------------------------------------------------------------------------
>
>                 Key: MAGNOLIA-2787
>                 URL: http://jira.magnolia-cms.com/browse/MAGNOLIA-2787
>             Project: Magnolia
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 4.1
>            Reporter: Grégory Joseph
>            Assignee: Philipp Bärfuss
>             Fix For: 4.2
>
>
> Considering the following code:
> {code}
> public class MyModuleVersionHandler extends DefaultModuleVersionHandler {
>     public MyModuleVersionHandler() {
>         super();
>         final ModuleDefinition currentModule = 
> ModuleManager.Factory.getInstance().getInstallContext().getCurrentModuleDefinition();
>         System.out.println(currentModule);
>     }
> }
> {code}
> 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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.magnolia-cms.com/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira



----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to