Skip to content

IoC Container

The IoC (Inversion of control) container of Swiz is the BeanLoader class. In the BeanLoader you usually define your non-view classes that you want registered with the framework and available as injection sources or targets. This generally means models, controllers, delegates and services. Beans are defined using regular MXML tags.

Flex 2/3

Flex 4

Most applications define at least one Beans.mxml in the root package and pass it to the SwizConfig tag in the application’s main MXML file.

Prototype

Similar to Spring’s prototype scope, Swiz provides a Prototype tag. Prototype enables a few different things:

  • Constructor injection – you can pass up to 8 arguments to your bean’s constructor
  • Unique copy for each injection target (like prototype scope behavior in Spring)
  • Deferred instantiation – Prototype beans will not be created until they are needed for injection

If you want deferred instantiation and/or constructor injection but not a unique copy for each injection you can set Prototype’s singleton property to true.

{ 1 } Trackback

  1. [...] I welcomes that eliminates the need to instantiate Swiz. As I understand it, you just need your Beans and SwizConfig. All other code can be written with the simple use of metadata tags, that Swiz 1.0 [...]