use of org.glassfish.hk2.classmodel.reflect.Type in project Payara by payara.
the class CDISecondChanceResolver method justInTimeResolution.
/* (non-Javadoc)
* @see org.glassfish.hk2.api.JustInTimeInjectionResolver#justInTimeResolution(org.glassfish.hk2.api.Injectee)
*/
@SuppressWarnings({ "unchecked" })
@Override
public boolean justInTimeResolution(Injectee failedInjectionPoint) {
Type requiredType = failedInjectionPoint.getRequiredType();
Set<Annotation> setQualifiers = failedInjectionPoint.getRequiredQualifiers();
Annotation[] qualifiers = setQualifiers.toArray(new Annotation[setQualifiers.size()]);
BeanManager manager = getCurrentBeanManager();
if (manager == null)
return false;
Set<Bean<?>> beans = manager.getBeans(requiredType, qualifiers);
if (beans == null || beans.isEmpty()) {
return false;
}
DynamicConfiguration config = ServiceLocatorUtilities.createDynamicConfiguration(locator);
for (Bean<?> bean : beans) {
// Add a bean to the service locator
CDIHK2Descriptor<Object> descriptor = new CDIHK2Descriptor<Object>(manager, (Bean<Object>) bean, requiredType);
config.addActiveDescriptor(descriptor);
}
config.commit();
return true;
}
Aggregations