File IO Opration.

pingale.indrajit's Avatar

pingale.indrajit

01 Jun, 2012 03:11 PM

Hi,

In my application, there is Singleton class (AppUitls.as) which reads config.xml and store value in local variables to access within App from anywhere.
On application context startup() I mapped AppUtils class as singleton. But as File read operation is Event based (FileStream), the other injected classes get initialized before FileStream's Event.COMPLETE event fires and my other class constructor uses variables from AppUitls.as class for initialization. And application fails as null values are there in AppUtils class variables.

Am I doing anything wrong? Or there is a way to first let the files IO operation to complete and then start injecting other classes?
Thanks,
Indrajit

  1. 1 Posted by neil on 01 Jun, 2012 03:29 PM

    neil's Avatar

    What I tend to do is to remove mappings from the context and into commands.
    you can then split you bootstrap into phases.

    in the context inject your AppUitls ( which shall we say dispatched a COMPLETE event )
    then map your Mapping commands to fire on AppUitlsCompleteEvent.COMPLETE.

    being me, I also tend to hook all this into an FSM that manages progression through the Bootstrap sequence, so you can sequence your dependencies nicely.

  2. 2 Posted by pingale.indraji... on 02 Jun, 2012 05:32 PM

    pingale.indrajit's Avatar

    Thanks Neil. You are right. This is the only solution for my problem.
    Thanks again.

  3. pingale.indrajit closed this discussion on 02 Jun, 2012 05:32 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac