Announcement Announcement Module
Collapse
No announcement yet.
stage autowiring without XML (Flex 4.5, SAS 1.2-SNAPSHOT) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • stage autowiring without XML (Flex 4.5, SAS 1.2-SNAPSHOT)

    hello all,

    although it [1], [2] reads like using a FlexXMLApplicationContext and a ClassScannerObjectFactoryPostProcessor with Autowired/Inject annotations is enough to setup stage autowiring I can't get it to work without adding a XML to FlexXMLApplicationContext like below:

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <objects xsi:schemaLocation="http://www.springactionscript.org/schema/objects http://www.springactionscript.org/schema/objects/spring-actionscript-objects-1.0.xsd"
             xmlns="http://www.springactionscript.org/schema/objects"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    
      <object id="stageAutowirer" class="org.springextensions.actionscript.stage.DefaultAutowiringStageProcessor"/>
    
    </objects>
    Is there a way to use stage autowiring without XML?

    Thanks,
    O.

    [1] "The FlexXMLApplicationContext take care all by itself of creating the necessary objects to facilitate stage wiring." (2.1.2.21)

    [2] "IStageProcessor implementation that is created by default by the FlexXMLApplicationContext to perform autowiring and dependency injection on stage components." in DefaultAutowiringStageProcessor

  • #2
    ...

    Hey there,

    this information in the docs is slightly out of date, I'm afraid, my apologies for this.
    Since a while it is requried to add the stage processor explicitly, that way people can choose to completely ignore stage processing.

    You can add the DefaultAutowiringStageProcessor manually like this:

    Code:
    var processor:DefaultAutowiringStageProcessor = new DefaultAutowiringStageProcessor(applicationContext);
    FlexStageProcessorRegistry.getInstance().registerStageProcessor("autowirer", processor, processor.objectSelector);
    Hope that helps,

    cheers,

    Roland

    Comment


    • #3
      hi Roland,

      it doesn't work for me:
      Code:
      [TIMESTAMP] DEBUG - FlexStageProcessorRegistry - FlexStageProcessorRegistry didn't find appropriate stage processors for document 'application0', retrieving application processors instead
      cheers,
      O.

      Comment


      • #4
        hmmm

        hm, sorry to hear that,

        would it be possible for you to post a small sample application here that demonstrates the problem? I think I'll be able to easily figure out what is going wrong that way.

        Thanks a lot in advance!

        cheers,

        Roland

        Comment


        • #5
          hey Roland,

          here is the sample application: https://github.com/oliverlietz/sas-samples

          To break the application uncomment lines 58 and 59 in EdisApplication and remove stageAutowirer from context.xml.

          cheers,
          O.
          Last edited by oliverlietz; Aug 14th, 2011, 10:49 AM.

          Comment


          • #6
            upgraded to 2.0-SNAPSHOT but still not able to drop the XML. Roland, can you take a look?

            Thanks,
            O.

            Comment


            • #7


              Hey there,

              I was wondering when you'd make a comment about this Hehe, no, right now v2.0 will also not work with this scenario.
              I'm still thinking of an elegant solution, that's why it isn't supported yet. Here is my problem, if you're using the metadata based configuration
              you add the [Component] metadata to you project classes to have them turned into object definitions.
              But, if you want an object definition for an existing framework class, this is impossible right now.

              So, I was thinking about perhaps implementing some kind of [Configuration] metadata. Imagine you can add object definition like this:

              Code:
              [Configuration]
              public class configClass {
              
                public var autowireProcessor: DefaultAutowireProcessor;
              
                public var eventHandlerProcessor: EventHandlerMetadataProcessor;
              
              }
              This configClass itself will NEVER be instantiated, it is simply used as placeholder to define the metadata. Upon initializing the container will look for classes
              with the [Component] anootation, but also for [Configuration] annotations. If found, it iterates over the the properties of the Class, uses the name
              of the property as the object definition's id and the type of the property as the definition's class.

              One extra problem, something that you guys might be able to help with is how to inject properties and declare method invocations for these classes...

              Please help us out and think with us!

              cheers!

              Roland

              Comment


              • #8
                Hey again,

                alright, I think I came to a quite elegant solution, and quite straightforward too I think. To configure properties and method invocations on classes where you do not have access to the source code (so you can't add the metadata directly into the source).
                You could do something like this:

                Code:
                [Configuration]
                public class configClass {
                
                  [Property(name="autowireOnce",value="false")]
                  [Property(name="objectDefinitionResolver",ref="myObjectDefinitionResolver")]
                  [Component(scope="singleton")]
                  public var autowireStageProcessor: DefaultAutowiringStageProcessor;
                
                  [Component(scope="singleton",lazyInit="true")]
                  public var eventHandlerProcessor:EventHandlerMetadataProcessor;
                
                  [Invoke(name="myMethod",args="stringValue")]
                  [Component(scope="singleton",lazyInit="true",initMethod="initResolver")]
                  public var myObjectDefinitionResolver:CustomObjectDefinitionResolver;
                
                }
                What do you think? I think I'll go ahead and implement it this way, unless someone has some clear objections against this?

                cheers,

                Roland
                Last edited by 666shooter; Sep 18th, 2011, 03:25 PM.

                Comment


                • #9
                  beta sample

                  Hi again,

                  I've put up some sample apps on the beta site for Spring AS 2.0. There is also a sample app that demonstrates the new metadata driven configuration:

                  http://beta.springactionscript.org/s...data/Main.html

                  It has 'View Source' enabled, so you can check out the how and why in the sources.

                  I hope this is to your liking, let me know what you think!

                  cheers,

                  Roland

                  Comment


                  • #10
                    Roland,

                    thank you. I switched my sample app to annotated configuration class. It works
                    However I'm still interested in completely dropping external configuration and solve it with one or two lines of code as described in your first answer.

                    For now switching from Halo to Spark and from a custom framework to SAS, the use of a new state machine lib and of course the broken SAS Maven build prevent me from digging deeper into SAS (expect patches coming to JIRA).
                    In a best-case scenario, adding spring-actionscript-core (or spring-actionscript-flex) to a pom should be enough. But as you can see I have to do a lot of configuration in my poms to get a working build and swf.

                    cheers,
                    O.

                    Comment


                    • #11
                      Hey Olivier,

                      you mention the SAS maven build being broken, do you mean the version 2.0 pom? For me that one's working fine, what is failing for you exactly?
                      Indeed just adding the spring-actionscript-core ought to be enough. If not, the pom might need some tweaking, I'd appreciate any assistance with this
                      since many other people will run into the same issues I would guess.

                      cheers,

                      Roland

                      Comment


                      • #12
                        hi Roland,

                        after fixing SESPRINGACTIONSCRIPTAS-142 I have this output:

                        https://gist.github.com/1283865

                        I will start working on a minimal pom and add your doc build and tests later. Hope that helps in getting a proper and slim pom.

                        cheers,
                        O.

                        Comment


                        • #13
                          test problem

                          Hm,

                          weird that the test project refuses to compile for you. Someone else had the same problems apparently.
                          I see you're using -DskipTests=true, which doesn't seem to work actually. If you use -Dmaven.test.skip=true it will REALLY skip the tests
                          That way you'll at least be able to compile everything...

                          Let me know if you figure out why the testrunner refuses to build, should you be able to find out anything.

                          cheers,

                          Roland

                          Comment


                          • #14
                            work in progress: https://github.com/oliverlietz/sas

                            Comment


                            • #15
                              wow!

                              Hey dude,

                              wowsers! You're cleaning up all the poms! That is absolutely amazing! Thank you SO much!
                              Keep us posted on your progress, thanks!

                              cheers,

                              Roland

                              Comment

                              Working...
                              X