[webbeans-dev] Replacement pattern for Manager.getInstanceByType
David Allen
drallendc at gmail.com
Wed May 27 04:15:17 EDT 2009
On Tue, 2009-05-26 at 20:42 -0500, Clint Popetz wrote:
> >From what I can tell, code that used to do:
>
> manager.getInstanceByType(clazz)
>
> now need to do:
>
>
> manager.getReference(manager.getBeans(clazz).iterator().next(),clazz);
>
> (plus checking that the set contains only one element and throwing an
> exception if not.)
Yes, this is the first case I mentioned earlier that I postponed
yesterday. This is a drastic API difference that does affect many of
the other projects too.
For the TCK, I was thinking of just adding the corresponding behavior
into the abstract test class we use so that the changes are localized to
a single line of code (each call to getInstanceByType).
Outside of the TCK, I am not sure how much it is used. And since there
will be less of a framework involved in some cases, many instances of
the call will need to be replaced with a number of lines of code (a lot
of duplicate code as you mentioned above).
>
> Is that really true? Is there no more direct way to obtain this in
> the SPI? It seems like a pretty common case. If not, I can have a
> utility method to do the above in the core, as many things don't cast
> to ManagerImpl, so I'd rather not put it there.
>
> -Clint
>
>
> --
> Clint Popetz
> http://42lines.net
> Scalable Web Application Development
> _______________________________________________
> webbeans-dev mailing list
> webbeans-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/webbeans-dev
More information about the weld-dev
mailing list