On 9/23/11 10:21 , Paul Merlin wrote:
On Fri, 23 Sep 2011 14:04:34 +0800, Niclas Hedhman wrote:
Gang,
In 1.x, it seems that there were many (all?) cases where if no use()
was given in the builders, the construction of the object (transient?)
would fail. In 2.0, the current code will create a new object on the
fly if it can. For instance;
public class A
{
@Uses B b;
}
public class B
{
// default constructor
}
Then if one do;
A anObject = module.newObject( A.class );
this will not fail. In 1.x it would, since no use() is given.
That's weird, because I use that a lot in Streamflow, which uses Qi4j
1.x. Specifically, I would instantiate a View, and then constructor has
a @Uses SomeModel that gets instantiated and injected automatically.
In any case:
So the question is; Which one is the correct behavior? Explicit use()
declarations or on-the-fly-creation-if-possible?
I like the idea of on-the-fly-creation-if-possible. IMO it will ease the
pain when working with graphs of objects. Anyway runtime still respect
assembly
and visibility.
I also like the on-the-fly-creation, since I can instantiate a big graph
just by creating the "root" object, and then every dependency is created
and injected properly.
/Rickard
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev