use of org.jboss.weld.resolution.ResolvableBuilder in project core by weld.
the class DefaultJsonDataProvider method receiveAvailableBeans.
@Override
public String receiveAvailableBeans(int pageIndex, int pageSize, String filters, String representation) {
Map<String, String> filterValues = Queries.Filters.parseFilters(filters);
// First validate input
if (!filterValues.containsKey(BDA_ID)) {
return getError("Bean deployment archive id (bdaId) must be specified: " + filters);
}
// Find the bean deployment archive
BeanManagerImpl beanManager = probe.getBeanManager(filterValues.get(BDA_ID));
if (beanManager == null) {
return getError("Unable to find the bean deployment archive for: " + filterValues.get(BDA_ID));
}
Set<Bean<?>> beans = null;
// Parse required type
Type requiredType;
if (filterValues.get(REQUIRED_TYPE) != null) {
requiredType = Parsers.parseType(filterValues.get(REQUIRED_TYPE), beanManager.getServices().get(ResourceLoader.class));
} else {
requiredType = Object.class;
}
if (requiredType == null) {
return getError("Invalid required type: parsing error or the type is not accessible from the specified bean archive!");
}
ResolvableBuilder resolvableBuilder = new ResolvableBuilder(requiredType, beanManager);
// Parse qualifiers
List<QualifierInstance> qualifierInstances;
if (filterValues.get(QUALIFIERS) != null) {
qualifierInstances = Parsers.parseQualifiers(filterValues.get(QUALIFIERS), beanManager.getServices().get(ResourceLoader.class), beanManager);
} else {
qualifierInstances = Collections.singletonList(QualifierInstance.DEFAULT);
}
for (QualifierInstance qualifierInstance : qualifierInstances) {
if (qualifierInstance == null) {
return getError("Invalid qualifiers: parsing error or one of the qualifier types is not accessible from the specified bean archive!");
}
resolvableBuilder.addQualifierUnchecked(qualifierInstance);
}
Resolvable resolvable = resolvableBuilder.create();
// Lookup beans
beans = beanManager.getBeanResolver().resolve(resolvable, false);
if (Boolean.valueOf(filterValues.get(RESOLVE))) {
// Apply resolution rules
beans = beanManager.getBeanResolver().resolve(beans);
}
return JsonObjects.createBeansJson(Queries.find(probe.getOrderedBeans(beans), pageIndex, pageSize, null), probe, beanManager, Representation.from(representation));
}
use of org.jboss.weld.resolution.ResolvableBuilder in project core by weld.
the class ResolutionTest method testResolveWithAnonymousAnnotationLiteral.
@Test
public // WELD-711
void testResolveWithAnonymousAnnotationLiteral() throws Exception {
Annotation defaultQualifier = new AnnotationLiteral<Default>() {
};
assertNotNull(getReference(beanManager, Foo.class, defaultQualifier));
TypeSafeBeanResolver resolver = beanManager.getBeanResolver();
assertFalse(resolver.isCached(new ResolvableBuilder(beanManager).addType(Foo.class).addQualifier(defaultQualifier).create()));
}
use of org.jboss.weld.resolution.ResolvableBuilder in project core by weld.
the class InstanceImpl method resolveBeans.
private Set<Bean<?>> resolveBeans() {
// Perform typesafe resolution, and possibly attempt to resolve the ambiguity
Resolvable resolvable = new ResolvableBuilder(getType(), getBeanManager()).addQualifiers(getQualifiers()).setDeclaringBean(getInjectionPoint().getBean()).create();
TypeSafeBeanResolver beanResolver = getBeanManager().getBeanResolver();
return beanResolver.resolve(beanResolver.resolve(resolvable, Reflections.isCacheable(getQualifiers())));
}
Aggregations