Announcement Announcement Module
Collapse
No announcement yet.
ApplicationContext within the application Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      Hi,

      Thanks so much for the response!

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

      Dan

      Comment


      • #4
        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!

        Comment


        • #5
          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

          Comment

          Working...
          X