use of org.apache.aries.cdi.container.internal.model.ServiceModel in project aries by apache.
the class Phase_Publish method processRequirementDefinedServices.
private void processRequirementDefinedServices(BeanManagerImpl beanManagerImpl) {
Collection<ServiceModel> serviceModels = _bc.getServiceModels();
for (ServiceModel serviceModel : serviceModels) {
try {
Class<?> beanClass = _bc.loadClass(serviceModel.getBeanClass());
Set<Bean<?>> beans = beanManagerImpl.getBeans(beanClass, AnyLiteral.INSTANCE);
if (beans.isEmpty()) {
_log.error("CDIe - MANIFEST service processing cannot find bean for class {}", serviceModel.getBeanClass());
continue;
}
Bean<?> bean = beanManagerImpl.resolve(beans);
CreationalContext<?> creationalContext = beanManagerImpl.createCreationalContext(bean);
List<String> provides = serviceModel.getProvides();
List<Class<?>> interfaces = new ArrayList<>();
for (String provide : provides) {
try {
interfaces.add(_bc.loadClass(provide));
} catch (Exception e) {
_log.error("CDIe - Failure loading provided interface for service {}", provide);
}
}
ServiceDeclaration serviceDeclaration = new ServiceDeclaration(ServiceLiteral.from(interfaces.toArray(new Class<?>[interfaces.size()]), serviceModel.getProperties()), bean, creationalContext);
processServiceDeclaration(serviceDeclaration);
} catch (ClassNotFoundException cnfe) {
_log.error("CDIe - MANIFEST service processing cannot load class {}", serviceModel.getBeanClass(), cnfe);
}
}
}
Aggregations