final Map<DotName, List<AnnotationInstance>> annotationsOnBean = beanClass.annotations();
if (annotationsOnBean == null || annotationsOnBean.isEmpty()) {
return;
}
final EEApplicationDescription applicationDescription = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_DESCRIPTION);
final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
final SingletonComponentDescription singletonComponentDescription = componentDescriptionType.cast(componentDescription);
final List<AnnotationInstance> dependsOnAnnotations = annotationsOnBean.get(DotName.createSimple(DependsOn.class
.getName()));
if (dependsOnAnnotations == null || dependsOnAnnotations.isEmpty()) {
return;
}
validate(annotationsOnBean, dependsOnAnnotations, singletonComponentDescription.getEJBName());
final AnnotationInstance dependsOnAnnotation = dependsOnAnnotations.get(0);
// Add the dependencies
final String[] annotationValues = dependsOnAnnotation.value().asStringArray();
for (String annotationValue : annotationValues) {
final Set<ComponentDescription> components = applicationDescription.getComponents(annotationValue, deploymentRoot.getRoot());
if (components.isEmpty()) {
throw new DeploymentUnitProcessingException("Could not find EJB " + annotationValue + " referenced by @DependsOn annotation in " + componentDescription.getComponentClassName());
} else if (components.size() != 1) {
throw new DeploymentUnitProcessingException("More than one EJB called" + annotationValue + " referenced by @DependsOn annotation in " + componentDescription.getComponentClassName() + " Components: " + components);
}