private Collection<AnnotationType> getAnnotationsAnnotatedWith(CompositeIndex index, DotName annotationName) { Set<AnnotationType> annotations = new HashSet<>(); for (ClassInfo classInfo : getAnnotatedClasses(index.getAnnotations(annotationName))) { if (ANNOTATION_PREDICATE.test(classInfo)) { annotations.add(FOR_CLASSINFO.apply(classInfo)); } } return annotations; }
private void getAllAsyncListenerClasses(CompositeIndex index, Set<String> classes) { if (index != null) { Set<ClassInfo> classInfos = index.getAllKnownImplementors(ASYNC_LISTENER_INTERFACE); for (ClassInfo classInfo : classInfos) { if(!Modifier.isAbstract(classInfo.flags()) && !Modifier.isInterface(classInfo.flags())) { classes.add(classInfo.name().toString()); } } } } }
private SessionType determineSessionType(final String ejbClass, final CompositeIndex compositeIndex) { if(ejbClass == null) { return null; } final ClassInfo info = compositeIndex.getClassByName(DotName.createSimple(ejbClass)); if (info == null) { return null; } if(info.annotations().get(STATEFUL_ANNOTATION) != null) { return SessionType.Stateful; } else if(info.annotations().get(STATELESS_ANNOTATION) != null) { return SessionType.Stateless; } else if(info.annotations().get(SINGLETON_ANNOTATION) != null) { return SessionType.Singleton; } return null; }
private Set<ClassInfo> processHandlesType(DotName typeName, Class<?> type, CompositeIndex index, CompositeIndex parent) throws DeploymentUnitProcessingException { Set<ClassInfo> classes = new HashSet<ClassInfo>(); if (type.isAnnotation()) { List<AnnotationInstance> instances = index.getAnnotations(typeName); for (AnnotationInstance instance : instances) { AnnotationTarget annotationTarget = instance.target(); classes.addAll(index.getAllKnownSubclasses(typeName)); classes.addAll(index.getAllKnownImplementors(typeName)); if(parent != null) { Set<ClassInfo> parentImplementors = new HashSet<>(); parentImplementors.addAll(parent.getAllKnownImplementors(typeName)); parentImplementors.addAll(parent.getAllKnownSubclasses(typeName)); for(ClassInfo pc: parentImplementors) { classes.addAll(index.getAllKnownSubclasses(pc.name())); classes.addAll(index.getAllKnownImplementors(pc.name()));
warMetaData.setAnnotationsMetaData(annotationsMetaData); Map<ResourceRoot, Index> indexes = AnnotationIndexUtils.getAnnotationIndexes(deploymentUnit); final List<WebMetaData> additional = new ArrayList<WebMetaData>(); for (Entry<ModuleIdentifier, CompositeIndex> entry : additionalModelAnnotations.entrySet()) { for(Index index : entry.getValue().getIndexes()) { additional.add(processAnnotations(index));
@Override protected void processAnnotations(DeploymentUnit deploymentUnit, CompositeIndex compositeIndex) throws DeploymentUnitProcessingException { if (MetadataCompleteMarker.isMetadataComplete(deploymentUnit)) { return; } processMessageBeans(deploymentUnit, compositeIndex.getAnnotations(MESSAGE_DRIVEN_ANNOTATION_NAME), compositeIndex); }
private boolean isVetoedTypeOrPackage() { if (isAnnotationDeclared(classInfo, DOT_NAME_VETOED)) { return true; } final DotName packageInfoName = DotName.createComponentized(getPackageName(classInfo.name()), PACKAGE_INFO_NAME); ClassInfo packageInfo = index.getClassByName(packageInfoName); if (packageInfo != null && isAnnotationDeclared(packageInfo, DOT_NAME_VETOED)) { return true; } return false; }
/** * Process annotations and merge any available metadata at the same time. */ @Override protected void processAnnotations(final DeploymentUnit deploymentUnit, final CompositeIndex compositeIndex) throws DeploymentUnitProcessingException { if (MetadataCompleteMarker.isMetadataComplete(deploymentUnit)) { return; } // Find and process any @Stateless bean annotations final List<AnnotationInstance> slsbAnnotations = compositeIndex.getAnnotations(STATELESS_ANNOTATION); if (!slsbAnnotations.isEmpty()) { processSessionBeans(deploymentUnit, slsbAnnotations, SessionBeanComponentDescription.SessionBeanType.STATELESS); } // Find and process any @Stateful bean annotations final List<AnnotationInstance> sfsbAnnotations = compositeIndex.getAnnotations(STATEFUL_ANNOTATION); if (!sfsbAnnotations.isEmpty()) { processSessionBeans(deploymentUnit, sfsbAnnotations, SessionBeanComponentDescription.SessionBeanType.STATEFUL); } // Find and process any @Singleton bean annotations final List<AnnotationInstance> sbAnnotations = compositeIndex.getAnnotations(SINGLETON_ANNOTATION); if (!sbAnnotations.isEmpty()) { processSessionBeans(deploymentUnit, sbAnnotations, SessionBeanComponentDescription.SessionBeanType.SINGLETON); } }
/** * * @param className * @param index * @param annotationClassAnnotationsCache */ public WeldClassFileInfo(String className, CompositeIndex index, ComputingCache<DotName, Set<String>> annotationClassAnnotationsCache, ClassLoader classLoader) { this.index = index; this.annotationClassAnnotationsCache = annotationClassAnnotationsCache; this.classInfo = index.getClassByName(DotName.createSimple(className)); if (this.classInfo == null) { throw WeldLogger.ROOT_LOGGER.nameNotFoundInIndex(className); } this.isVetoed = isVetoedTypeOrPackage(); this.hasCdiConstructor = this.classInfo.hasNoArgsConstructor() || hasInjectConstructor(); this.classLoader = classLoader; }
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final CompositeIndex index = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX); for (final CdiAnnotations annotation : CdiAnnotations.values()) { if (!index.getAnnotations(annotation.getDotName()).isEmpty()) { CdiAnnotationMarker.mark(deploymentUnit); return; } } }
@Override public Set<String> apply(DotName name) { ClassInfo annotationClassInfo = index.getClassByName(name); ImmutableSet.Builder<String> builder = ImmutableSet.builder(); if (annotationClassInfo != null) { for (DotName annotationName : annotationClassInfo.annotations().keySet()) { builder.add(annotationName.toString()); } } else { try { Class<?> annotationClass = moduleClassLoader.loadClass(name.toString()); for (Annotation annotation : annotationClass.getDeclaredAnnotations()) { builder.add(annotation.annotationType().getName()); } } catch (ClassNotFoundException e) { WeldLogger.DEPLOYMENT_LOGGER.unableToLoadAnnotation(name.toString()); } } return builder.build(); } }
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION); final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX); final List<AnnotationInstance> aroundInvokes = index.getAnnotations(AROUND_INVOKE_ANNOTATION_NAME); for (AnnotationInstance annotation : aroundInvokes) { processAroundInvoke(eeModuleDescription, annotation.target()); } }
ClassInfo fromClassInfo = index.getClassByName(name); if (fromClassInfo == null) {
private void handleAnnotations(final CompositeIndex index, final Set<String> managedBeanClasses) throws DeploymentUnitProcessingException { final List<AnnotationInstance> annotations = index.getAnnotations(MANAGED_BEAN_ANNOTATION); if (annotations != null) { for (final AnnotationInstance annotation : annotations) { final AnnotationTarget target = annotation.target(); if (target instanceof ClassInfo) { final String className = ((ClassInfo) target).name().toString(); managedBeanClasses.add(className); } else { throw new DeploymentUnitProcessingException(JSFLogger.ROOT_LOGGER.invalidManagedBeanAnnotation(target)); } } } }
private boolean containsAnnotation(ClassInfo classInfo, DotName requiredAnnotationName, Class<? extends Annotation> requiredAnnotation) { // Type and members if (classInfo.annotations().containsKey(requiredAnnotationName)) { return true; } // Meta-annotations for (DotName annotation : classInfo.annotations().keySet()) { if (annotationClassAnnotationsCache.getValue(annotation).contains(requiredAnnotationName.toString())) { return true; } } // Superclass final DotName superName = classInfo.superName(); if (superName != null && !OBJECT_NAME.equals(superName)) { final ClassInfo superClassInfo = index.getClassByName(superName); if (superClassInfo == null) { // we are accessing a class that is outside of the jandex index // fallback to using reflection return Reflections.containsAnnotation(loadClass(superName.toString()), requiredAnnotation); } if (containsAnnotation(superClassInfo, requiredAnnotationName, requiredAnnotation)) { return true; } } return false; }
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION); final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION); final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX); for (DotName annotationName : LIFE_CYCLE_ANNOTATIONS) { final List<AnnotationInstance> lifecycles = index.getAnnotations(annotationName); for (AnnotationInstance annotation : lifecycles) { processLifeCycle(eeModuleDescription, annotation.target(), annotationName, applicationClasses); } } }
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION); final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION); final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX); for (DotName annotationName : PASSIVATION_ANNOTATIONS) { final List<AnnotationInstance> lifecycles = index.getAnnotations(annotationName); for (AnnotationInstance annotation : lifecycles) { processPassivation(eeModuleDescription, annotation.target(), annotationName); } } }
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if(MetadataCompleteMarker.isMetadataComplete(deploymentUnit)) { return; } final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION); final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX); final List<AnnotationInstance> aroundInvokes = index.getAnnotations(AROUND_TIMEOUT_ANNOTATION_NAME); for (AnnotationInstance annotation : aroundInvokes) { processAroundInvoke(annotation.target(), eeModuleDescription); } }
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit unit = phaseContext.getDeploymentUnit(); final ModuleLoader moduleLoader = Module.getBootModuleLoader(); final ModuleSpecification moduleSpec = unit.getAttachment(Attachments.MODULE_SPECIFICATION); moduleSpec.addSystemDependency(new ModuleDependency(moduleLoader, TRANSACTION_API, false, false, true, false)); moduleSpec.addSystemDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.fromString("org.wildfly.transaction.client"), false, false, true, false)); final CompositeIndex compositeIndex = unit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX); if (compositeIndex == null) { return; } final List<AnnotationInstance> transactionalAnnotations = compositeIndex.getAnnotations(DotName.createSimple(Transactional.class.getName())); final List<AnnotationInstance> transactionScopedAnnotations = compositeIndex.getAnnotations(DotName.createSimple(TransactionScoped.class.getName())); if (transactionalAnnotations.size() > 0 || transactionScopedAnnotations.size() > 0) { addJTSModuleDependencyToDeployment(unit); } }
final List<AnnotationInstance> resourceAnnotations = index.getAnnotations(EJB_ANNOTATION_NAME); final List<AnnotationInstance> ejbsAnnotations = index.getAnnotations(EJBS_ANNOTATION_NAME); for (AnnotationInstance annotation : ejbsAnnotations) { final AnnotationTarget annotationTarget = annotation.target();