Announcement Announcement Module
Collapse
No announcement yet.
Stage Autowiring in a Non-Flex Application not Working Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stage Autowiring in a Non-Flex Application not Working

    I can't seem to get stage autowiring working in my non-Flex application. How does Spring ActionScript get access to the stage in a non-Flex application? It appears that stage processing is simply not happening. I defined my own custom object selector and no objects are being passed to it, I am getting no output from my logging system:

    My XML application context:
    Code:
    <?xml version="1.0"?>
    <objects xmlns="http://www.springactionscript.org/schema/objects"
        	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        	xsi:schemaLocation="http://www.springactionscript.org/schema/objects
    				http://www.springactionscript.org/schema/objects/spring-actionscript-objects-1.0.xsd">
                            
    	<property file="application.properties"/>
    	
    	<!-- SPRING OBJECTS -->
    	<object class="org.springextensions.actionscript.stage.DefaultAutowiringStageProcessor" 
    			id="autowiringStageProcessor">
    		<property name="objectSelector">
    			<object class="com.tkassembled.spring.CustomObjectSelector"/>
    		</property>
    	</object>
    </objects>

    My object selector:
    Code:
    package com.tkassembled.spring.CustomObjectSelector {
    	import com.carlcalderon.arthropod.Debug;
    	import org.as3commons.reflect.Type;
    	import org.springextensions.actionscript.stage.IObjectSelector;
    
    	/**
    	 * @author TK Kocheran <a href="mailto:[email protected]">&lt;[email protected]&gt;</a>
    	 */
    	public class CustomObjectSelector implements IObjectSelector {
    		
    		public function approve(object:Object):Boolean {
    			Debug.log(Type.forInstance(object).fullName);
    			return true;
    		}
    	}
    }
    I never get the output from this code. I am sure that my application is loading the XML application context properly (i am getting Event.COMPLETE), I'm sure that my compiler is including the "Autowired" metadata tag, and I can't think of any other reason this might not be working. I'm trying to figure out how Spring ActionScript is getting access to the stage, but I can't see a way that it does it and that might be the problem. Can anyone help me out?

  • #2
    Flex only functionality

    Hey there,

    currently the stage processing system only works for Flex applications indeed. The FlexStagePrcoessorRegistry uses the Flex SystemManager to get access to the stage, therefore this is Flex only for the moment.

    My main experience with actionscript is indeed with Flex, so I don't know of any clean way of getting access to the stage in a pure actionscript project. If you have any suggestions for this I would be very interested to hear them because I would love to have the stage processing functions available to non-Flex applications as well.

    cheers,

    Roland
    Last edited by 666shooter; Sep 18th, 2010, 11:36 AM.

    Comment


    • #3
      Oh, well, I was able to make things happen by wiring things up myself. Unfortunately, there really isn't a clean way in strict AS3 to get a reference to the stage. What we could do is essentially create a property on XMLApplicationContext called "stage" which can be set to the stage by the developer. This way, we can send this to the autowire processor when needed. What do you think?

      Comment


      • #4
        alrighty

        Ok, thanks for making that clear. I will try and get something committed into SVN this weekend. I will probably create another IStageProcessorRegistry implementation that has a stage property, the FlexXMLStageProcessorRegistry will then inherit from this one.

        I'll let you know when I've got something working, maybe after I've committed you can give it a spin, I'd appreciate the help a lot.


        cheers,

        Roland

        Comment


        • #5
          frist draft

          Right,

          I added a class called FlashStageProcessorRegistry and made the FlexStageProcessorRegistry inherit from it.

          In order to use this new FlashStageProcessorRegistry with an XMLApplicationContext you'll need to assign the stage to it BEFORE you create the XMLApplicationContext.

          Like this:
          Code:
          FlashStageProcessorRegistry.getInstance().stage = stage;
          context = new XMLApplicationContext('application-context.xml');
          context.load();
          //etc...
          If you could take this out for a spin, I'd appreciate it. (Changes are available in the SVN trunk)

          cheers,

          Roland
          Last edited by 666shooter; Sep 18th, 2010, 10:45 AM.

          Comment


          • #6
            Excellent! I was going to recommend just inserting a post processor which would check the application context for an object definition called "__stage" and wire it automatically to all requesting objects. But this is good too! I will check it out! Thanks a bunch!

            Comment


            • #7
              I've created a few simple unit tests and in them it all seemed to work as required, if you run into any issues please let me know.

              cheers,

              Roland

              Comment

              Working...
              X