[webbeans-dev] Re: CreationalContext
Scott Ferguson
ferg at caucho.com
Fri Jan 9 10:34:36 EST 2009
On Jan 9, 2009, at 2:49 AM, Gavin King wrote:
> Hrm, after further thought I'm not sure this is necessary.
>
> * for objects with normal scope types, you can just inject proxies, no
> need to recurse
> * dependent objects are unshared, so they don't get added to
> CreationalContext
>
> So what cases, precisely, were you having problems with, Scott?
Even the most trivial case requires the capability:
@ApplicationScoped
class Foo {
@Current Bar _bar;
}
@ApplicationScoped
class Bar {
@Current Foo _bar;
}
Requiring proxies for all beans is a performance hit which is entirely
unnecessary with the proper SPI.
If the tradeoff is a performance hit on every method call (proxy) for
every bean, vs a slight added complexity in the _SPI_, i.e. an
interface that 98% of developers _never even see_, it should be
obvious that the SPI change is the right one.
> I guess I can that it might be useful for pseudo-scopes other than
> @Dependent, or possibly as a performance optimization...
It's not an "optimization", it's the basic overhead of the basic
method call.
-- Scott
>
>
> On Fri, Jan 9, 2009 at 5:03 AM, Gavin King <gavin at hibernate.org>
> wrote:
>> Folks, I would like to go ahead and write up this change, unless
>> anyone objects.
>>
>> It's a hole that needs fixing.
>>
>> On Fri, Jan 2, 2009 at 4:19 PM, Gavin King <gavin at hibernate.org>
>> wrote:
>>
>>> The alternate solution is something like:
>>>
>>> interface CreationalContext {
>>> <X> void add(Bean<X> bean, X instance); //registers an
>>> "incomplete" instance
>>> }
>>>
>>> interface Contextual<T> {
>>> public abstract T create(CreationalContext ctx);
>>> ...
>>> }
>>>
>>> interface Context {
>>> public <T> T get(Contextual<T> bean); //get any existing
>>> instance
>>> public <T> T get(Contextual<T> bean, CreationalContext ctx);
>>> //get
>>> or create an instance
>>>
>>> public Class<? extends Annotation> getScopeType();
>>> boolean isActive();
>>> }
>>>
>>> interface Manager {
>>> Object getInstanceToInject(CreationalContext ctx,
>>> InjectionPoint ij, Type type,
>>> Annotation... bindings);
>>> ...
>>> }
>>>
>>> And getInstanceToInject() would be smart enough to return any object
>>> that had already been registered with the CreationalContext.
>>>
>>> Note that this solution addresses the problem of circular
>>> references,
>>> and also fixes a hole in how the Manager knows about the
>>> InjectionPoint.
>>
>>
>> --
>> Gavin King
>> gavin.king at gmail.com
>> http://in.relation.to/Bloggers/Gavin
>> http://hibernate.org
>> http://seamframework.org
>>
>
>
>
> --
> Gavin King
> gavin.king at gmail.com
> http://in.relation.to/Bloggers/Gavin
> http://hibernate.org
> http://seamframework.org
>
>
More information about the weld-dev
mailing list