On Tue, Jul 21, 2009 at 10:50 AM, Peter Royle
<howardmoon@screamingcoder.com> wrote:
Sorry to drag this up again, but this has changed now that
manager.getReference(...) requires a CreationalContext, about which I
know very little. I'll try reading the latest spec soon, but in the
meantime if anyone has any silver bullets please let me know.
I'm currently using this utility method:
public static <T> T getInstanceByType(BeanManager manager,
Class<T> type, Annotation... bindings) {
return (T)manager.getReference(
manager.getBeans(type).iterator().next(), type, null);
}
Obviously it's that null at the end (where CreationalContext should
be) that's causing the problem.
You just use the manager to create a CreationalContext for the bean.
beanManager.createCreationalContext(bean)
If an instance already exists, the CreationalContext is not used. Someone correct me if I am wrong.
-Dan