Ulrich Mayring wrote:

Niclas Hedhman wrote:


?? Since when can you control the lifecycle ?? I must have missed that feature/bug ;o)


It's called IOC :-)

In Avalon you can control a component's lifecycle, in type3 you can't, because the component decides itself. No way of knowing what it does in its constructor. So I actually wonder whether type3 is IOC at all.


It is sometimes difficult to separate out what exactly IoC looks like when there are so many ways to implement it. That is why it is a *pattern* and not a predefined library.

At its root, IoC means inversion of control.  The component does not decide
what facilities it uses, that information is provided to the component by
the container.  Whether this is done through a constructor, getter/setter,
or an interface (like Avalon 4), is irrelevant.  As long as the life of the
component is directly controlled by the container, and not by itself then we
have IOC.

There are three basic "Phases" of life for a component: construction, active
use, and destruction.

What the "Type 3" IoC approach does is collapse all of the construction phase
into the constructor.  That is the contract between the component and the
container.

The "Type 2" IoC approach is not to use interfaces beyond the simple
Initializable and Desposable style interfaces.  Any method calls before
the initialize() method is called are construction phase calls.  Essentially
it looks like a JavaBean with setters/getters for all configuration points
and external service provision.  This is roughly what javax.sql.DataSource
components do.

The "Type 1" IoC approach is Avalon 4.

The titles of "Type 1,2,3,XXX" were applied by the folks who created nano and
pico container.

The choice of how to apply IoC is a matter of taste in many cases.  If
everything is passed in the constructor, then we have a more atomic construction
phase.  But in reality no component is used until after the construction phase.


--


"They that give up essential liberty to obtain a little temporary safety
 deserve neither liberty nor safety."
                - Benjamin Franklin


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to