ScriptedPicoContainer is primarily intended to be embedded inside other applications and frameworks. We recommend using a scripted container when your application consists of many loosely-coupled components that need composition driven by external scripts at runtime, ie when re-compilation is not possible.
Building a PicoContainer from a script is simple and straightforward using a ScriptedContainerBuilder. Let's look at an example:
Do note that both parent container and assembly scope are
optional and may be set to null
. The assembly scope is
simply a hint that may be used by container builders to build multiple
container content. The container may or may not be added to the parent
container - provided it is present.
The contract for interpreted languages is defined as follows:
pico
variable of
type MutablePicoContainernull
. It should be used
when constructing the pico
MutablePicoContainerassemblyScope
that may be used in order to decide how to compose the container. The
value of this variable can be any kind of object.Let's now in more detail at the supported interpreted languages for container composition, giving a sample script for each:
The above examples in XML would be rendered as: