Message-ID: <128116712.84498.1397665960912.JavaMail.email@example.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_84497_812644976.1397665960911" ------=_Part_84497_812644976.1397665960911 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
The advantages of dependency injection are numerous
Specifically to IzPack, PicoContainer allows
With pico, you create and manage your own container. Once created, you c= an
Here you create a new container, add CliAnalyzer as a dependency and get=
the instance of CliAnalizer.
The container is configured to "ca= che" dependencies. Meaning, it insures that there is only one instance= of this component created. It is the same as a Singleton in Guice.
Expect some particular cases, you don't need to lookup for your componen= t using the container. Exceptions are when component are constructed dynami= cally like panels. In this case, we add the panel and get the instance from= the compiler.
In most case, you should use injection to get dependencies.
Two injections methods have been used primary used.
PicoContainer supports many types of injections b= ut the preferred way is to pass dependencies in the constructor.
For example, given the following class :
The instance of AClass will be constructed using the instance of CliAnal= yzer.
Provider gives more flexibility to construct the component instance and i= t is useful to do some works prior to instantiation.
It is used to create component which need informations from xml (like Au= tomatedInstallData). All providers are available in packages *.container.pr= ovider
PicoConta= iner gives the possibilities to inject primitives (String, Integer, ...). T= hey are resolved by name and it is used to inject the install file name in = components.
If you create a component, you can add it to the container so that it wi= ll be avaible as a dependency.
On the compiler, the container is configured by the class co= m.izforge.izpack.compiler.container.CompilerContainer
On the installer, there are several containers :