Announcement Announcement Module
No announcement yet.
Autowired when components are removed and subsequent addChild is called Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Autowired when components are removed and subsequent addChild is called

    We use Spring Actionscript to wire ours Views to their Presentation Models. This worked quite fine until we started to remove Components and add them later. This is a problem, because the Presentation Model is prototype scoped and all data in the original presentation model is lost when it is replaced by a new presentation model.

    Is there a possibility to prevent Autowireing at all addChild call when the component is already wired?

    public var browserDialogPM:BrowserDialogPM;

    Where the SomeUIComponent is used:
    --> Autowired ist done the first time in someUIComponent

    --> Autowired ist done the second time time in someUIComponent

  • #2
    that's a bug/issue indeed

    Hey Andy,

    I had this issue in the back of my mind when autowiring of stage components was implemented, I think I have some ideas on how to tackle this.
    If you can, please add a ticket in JIRA with a feature request for this, I'll try and come up with a solution a.s.a.p.

    You can add bug reports and feature requests if you follow this link:




    • #3
      Fixed in the trunk

      Alright, nevermind the feature request. I have made a small change to the DefaultAutowiringStageProcessor where it now checks if a given component has been autowired yet or not.

      This behavior can optionally be turned off by setting the autowireOnce property to false on the DefaultAutowiringStageProcessor.

      To do this using the configuration, add this XML to your config:

      <object class="org.springextensions.actionscript.stage.DefaultAutowiringStageProcessor" id="defaultAutowiringStageProcessor">
        <property name="autowireOnce" value="false"/>
      All these changes can be found in the trunk, do a full checkout here:

      hope that helps,




      • #4
        Hi Roland,

        thanks for your quick response and for fixing the issue.
        I'm new to Actionscript and also to spring actionscript, so i prefer a post to the forum before writing a jira issue.
        As you've already made a fix for this i wont't create a jira isse.

        In fix (revision 677) you use a Dictionary where the object is the reference. If the object is in the Dictionary you skipp subsequent autorwireing.

        For me, this smells bit like a memory leack:
        When the UIComponent object is removed from the stage and all references to it are nulled in client code, I expect the garbage collector to destroy the object. But as there is still a reference to the object from your componentCache. So the garbage collector won't ever delete this component. All stage components that have been autowired will stay in memory forever.

        Maybe i missed something, as i don't speak actionscript fluently right now - i'll be happy if you can tell me why the sollution isn't a memory leak

        The Code snippets i'm referring to:
        protected var componentCacheictionary;
        override public function process(object:Object):Object {
        if (((componentCache[object] == null) && (_autowireOnce)) || (!_autowireOnce))
        if (_objectFactory && _objectDefinitionResolver) {
        componentCache[object] = true;
        _objectFactory.wire(object, _objectDefinitionResolver.resolveObjectDefinition( object));

        Last edited by AndyBaumann; Aug 28th, 2009, 03:39 AM.


        • #5

          Hey Andy,

          the Dictionary I use is created like this: new Dictionary(true).

          Where the true value is for the 'weakKeys' parameter (default its false), which means that the keys in the dictionary (in this case the stage components) are weak references, so the memory leak shouldn't occur.


          Last edited by 666shooter; Aug 29th, 2009, 05:19 AM.