Results 1 to 5 of 5

Thread: ApplicationContext within the application

  1. #1
    Join Date
    Oct 2009
    Posts
    2

    Default ApplicationContext within the application

    Hi,

    In spring actionscript, how's it is supposed for the whole application to lookup the ApplicationContext? Is it supposed to passing around through singleton? Any suggestions?

    Dan

  2. #2
    Join Date
    Oct 2008
    Location
    Belgium
    Posts
    160

    Default

    Hi,

    if you are talking about classes that have an object definition in the application context, you can let them implement the IApplicationContextAware interface.

    For all other components not defined in the application context, you could indeed create a singleton that contains the application context, although I would not encourage you to do so.

    regards,
    Christophe
    Christophe Herreman
    Spring ActionScript Founder
    http://www.herrodius.com

  3. #3
    Join Date
    Oct 2009
    Posts
    2

    Default

    Hi,

    Thanks so much for the response!

    so, is there better suggestion other then the singleton.?

    Dan

  4. #4
    Join Date
    Oct 2008
    Location
    Belgium
    Posts
    160

    Default

    You can autowire/inject dependencies into view components and other objects defined in the application context. That way is preferred instead of working with dependency lookup where you just reference the container globally.

    In general, try to use dependency injection as much as possible.

    You can also post specific implementation questions if you have any.

    Good luck!
    Christophe Herreman
    Spring ActionScript Founder
    http://www.herrodius.com

  5. #5
    Join Date
    Dec 2008
    Location
    Brussels
    Posts
    406

    Thumbs up subclass application

    If you want a 'surrogate' singleton for the application context you can always subclass Application and add a property to it to which you assign the FlexXMLApplicationContext.
    Something like:

    Code:
    public class MyApplication extends Application {
    
      public var applicationContext:FlexXMLApplicationContext;
    
    }
    Whenever you need a reference to it in your app just look it up like this:
    Code:
    MyApplication(Application.application).applicationContext;
    That way you're not stuck with a 'real' singleton but you still have access to the main context should you need to.

    cheers,

    Roland

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •