Bean<?> bean;
if (annotations != null) {
bean = bm.getBeans(clazz, annotations).iterator().next();
} else {
bean = bm.getBeans(clazz, new DefaultLiteral()).iterator().next();
}
CreationalContext<?> ctx = bm.createCreationalContext(bean);
return (T) bm.getReference(bean, clazz, ctx);
}