Announcement Announcement Module
Collapse
No announcement yet.
Unloading modules Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unloading modules

    Hi List,

    I have some difficulties in unloading modules.

    Accordingly to the multimodule example project in the SVN I created an application (load-application) which is able to load modules.

    The testmodule has it's own application context in which the presentation model for testmodule is defined. The inside used service references to a service configured in the load-application. The injection works well, my module is able to use the service.

    My load-application is designed to have only one module loaded. Therefore it is necessary to unload the currently loaded module before the next module is loaded.

    I think I did something wrong because it seems the unloading is not working properly. I added an event listener ModuleEvent.UNLOAD for the currently loaded module before I call the unload method.
    The event listener method is called. If I now reload the testmodule I get an error
    Code:
    Error: Can't find an autowired candidate: Unsatisfied dependency in object
    for the presentation model used in the testmodule.
    The first load is successful so I suppose the unload is not done completely and the application context of the testmodule is reinstantiated even though the old context still exists.

    Is there any example what to do to unload a loaded SAS module savely? Any suggestions?

    Christoph

  • #2
    IDisposable

    Hi there,

    I've only recently started looking into the issues concerning module unloading and its connection with application contexts.

    I have added a small interface to Spring Actionscript called IDisposable, its very simple and looks like this:

    Code:
    public interface IDisposable {
    	function get isDisposed():Boolean;
    	function dispose():void;
    }
    This interface needs to be implemented by objects that hold references to resources (eventlisteners and such). The ApplicationContext itself now also implements this interface and what it does is to loop through its internal cache of singleton objects, checks if each objects implements IDisposable, and if so, calls its dispose() method. After that it clears its cache and nulls it.

    So, before unloading a module you can invoke the dispose() method on the context, after which, hopefully, it'll properly release memory and resources.

    I have also implemented the interface in several of the exisiting framework classes that are used by the context (such as the eventhandler processor, etc).

    This is still a work in progress and not tested very thoroughly yet, but if you feel up to it you can check out the latest trunk of SpringAS and play around with it. I would greatly appreciate your help and findings.

    cheers,

    Roland

    Comment


    • #3
      part 2

      Ok,

      I've worked some more on the dispose() methods of the application context. I have augmented the multi-module sample application as well to demonstrate the unloading. If I need to believe the Flashbuilder profiler both modules are no longer in memory after tehy've been unloaded.
      Changes are available in the SVN trunk.

      cheers,

      Roland

      Comment


      • #4
        Hi Roland,

        thank you very much for your work!

        Unfortunately your reply was a little late so I developed a custom solution without using the dispose() method.
        My solution consists of a SASModuleLoader.mxml component and a UnloadableSASModule.as.
        If I believe the Flashbuilder Profiler UnloadableSASModules are garbage collected.

        My bosses allowed me to contribute the code. Currently I'm working on a version which might fit into your package structure and fits your code conventions. Hopefully this work is done in the next two days and I can send you my code.

        Is the "dispose" solution intended to be in the 1.0 release version?

        Regards,
        Christoph

        Comment


        • #5
          thanx!

          Hey Christoph,

          good to hear you already had a solution, sorry I was too late with the fix though.
          The dispose() functionality will indeed be part of the final 1.0 release, I'll try to implement the 'destroy-method' attribute as well. That way an arbitrary destroy method can called by the container and removes the depedency on any framework interfaces.
          I'm definitely interested in your code, I'll have a look if it fits into the framework or not. Thanks!

          cheers,

          Roland

          Comment


          • #6
            Hi Roland,

            I sent my approach to your eMail address given in the SAS main POM file.

            Regards,
            Christoph

            Comment

            Working...
            X