Search in sources :

Example 6 with DotName

use of org.jboss.jandex.DotName in project wildfly by wildfly.

the class WeldClassFileInfo method isVetoedTypeOrPackage.

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;
}
Also used : DotName(org.jboss.jandex.DotName) ClassInfo(org.jboss.jandex.ClassInfo)

Example 7 with DotName

use of org.jboss.jandex.DotName in project wildfly by wildfly.

the class LifecycleAnnotationParsingProcessor method deploy.

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);
        }
    }
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DotName(org.jboss.jandex.DotName) AnnotationInstance(org.jboss.jandex.AnnotationInstance)

Example 8 with DotName

use of org.jboss.jandex.DotName in project wildfly by wildfly.

the class ResourceDefinitionAnnotationProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    if (moduleDescription == null) {
        return;
    }
    final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
    if (index == null) {
        return;
    }
    final PropertyReplacer propertyReplacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit);
    final DotName annotationName = getAnnotationDotName();
    for (AnnotationInstance annotationInstance : index.getAnnotations(annotationName)) {
        final List<BindingConfiguration> bindingConfigurations = getAnnotatedClassBindingConfigurations(moduleDescription, annotationInstance);
        final ResourceDefinitionInjectionSource injectionSource = processAnnotation(annotationInstance, propertyReplacer);
        bindingConfigurations.add(new BindingConfiguration(injectionSource.getJndiName(), injectionSource));
    }
    final DotName collectionAnnotationName = getAnnotationCollectionDotName();
    if (collectionAnnotationName != null) {
        for (AnnotationInstance annotationInstance : index.getAnnotations(collectionAnnotationName)) {
            final AnnotationInstance[] nestedAnnotationInstances = annotationInstance.value().asNestedArray();
            if (nestedAnnotationInstances != null && nestedAnnotationInstances.length > 0) {
                final List<BindingConfiguration> bindingConfigurations = getAnnotatedClassBindingConfigurations(moduleDescription, annotationInstance);
                for (AnnotationInstance nestedAnnotationInstance : nestedAnnotationInstances) {
                    final ResourceDefinitionInjectionSource injectionSource = processAnnotation(nestedAnnotationInstance, propertyReplacer);
                    bindingConfigurations.add(new BindingConfiguration(injectionSource.getJndiName(), injectionSource));
                }
            }
        }
    }
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) PropertyReplacer(org.jboss.metadata.property.PropertyReplacer) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DotName(org.jboss.jandex.DotName) AnnotationInstance(org.jboss.jandex.AnnotationInstance) BindingConfiguration(org.jboss.as.ee.component.BindingConfiguration)

Example 9 with DotName

use of org.jboss.jandex.DotName in project wildfly by wildfly.

the class ViewInterfaces method getPotentialViewInterfaces.

/**
     * Returns all interfaces implemented by a bean that are eligible to be view interfaces
     *
     * @param beanClass The bean class
     * @return A collection of all potential view interfaces
     */
static Set<DotName> getPotentialViewInterfaces(ClassInfo beanClass) {
    DotName[] interfaces = beanClass.interfaces();
    if (interfaces == null) {
        return Collections.emptySet();
    }
    final Set<DotName> names = new HashSet<DotName>();
    for (DotName dotName : interfaces) {
        String name = dotName.toString();
        // & FR 5.4.2
        if (name.equals(Serializable.class.getName()) || name.equals(Externalizable.class.getName()) || name.startsWith("javax.ejb.") || name.startsWith("groovy.lang.")) {
            continue;
        }
        names.add(dotName);
    }
    return names;
}
Also used : DotName(org.jboss.jandex.DotName) HashSet(java.util.HashSet)

Example 10 with DotName

use of org.jboss.jandex.DotName in project wildfly by wildfly.

the class HibernateAnnotationScanner method getClassesInJar.

@Override
public Set<Class<?>> getClassesInJar(URL jarToScan, Set<Class<? extends Annotation>> annotationsToLookFor) {
    if (jarToScan == null) {
        throw JPA_LOGGER.nullVar("jarToScan");
    }
    JPA_LOGGER.tracef("getClassesInJar url=%s annotations=%s", jarToScan.getPath(), annotationsToLookFor);
    PersistenceUnitMetadata pu = PERSISTENCE_UNIT_METADATA_TLS.get();
    if (pu == null) {
        throw JPA_LOGGER.missingPersistenceUnitMetadata();
    }
    if (pu.getAnnotationIndex() != null) {
        Index index = getJarFileIndex(jarToScan, pu);
        if (index == null) {
            JPA_LOGGER.tracef("No classes to scan for annotations in jar '%s' (jars with classes '%s')", jarToScan, pu.getAnnotationIndex().keySet());
            return new HashSet<Class<?>>();
        }
        if (annotationsToLookFor == null) {
            throw JPA_LOGGER.nullVar("annotationsToLookFor");
        }
        if (annotationsToLookFor.size() == 0) {
            throw JPA_LOGGER.emptyParameter("annotationsToLookFor");
        }
        Set<Class<?>> result = new HashSet<Class<?>>();
        for (Class<? extends Annotation> annClass : annotationsToLookFor) {
            DotName annotation = DotName.createSimple(annClass.getName());
            List<AnnotationInstance> classesWithAnnotation = index.getAnnotations(annotation);
            Set<Class<?>> classesForAnnotation = new HashSet<Class<?>>();
            for (AnnotationInstance annotationInstance : classesWithAnnotation) {
                // may generate bytecode with annotations placed on methods (see AS7-2559)
                if (annotationInstance.target() instanceof ClassInfo) {
                    String className = annotationInstance.target().toString();
                    try {
                        JPA_LOGGER.tracef("getClassesInJar found class %s with annotation %s", className, annClass.getName());
                        Class<?> clazz = pu.cacheTempClassLoader().loadClass(className);
                        result.add(clazz);
                        classesForAnnotation.add(clazz);
                    } catch (ClassNotFoundException e) {
                        JPA_LOGGER.cannotLoadEntityClass(e, className);
                    } catch (NoClassDefFoundError e) {
                        JPA_LOGGER.cannotLoadEntityClass(e, className);
                    }
                }
            }
            cacheClasses(pu, jarToScan, annClass, classesForAnnotation);
        }
        return result;
    } else {
        return getCachedClasses(pu, jarToScan, annotationsToLookFor);
    }
}
Also used : Index(org.jboss.jandex.Index) DotName(org.jboss.jandex.DotName) PersistenceUnitMetadata(org.jipijapa.plugin.spi.PersistenceUnitMetadata) AnnotationInstance(org.jboss.jandex.AnnotationInstance) HashSet(java.util.HashSet) ClassInfo(org.jboss.jandex.ClassInfo)

Aggregations

DotName (org.jboss.jandex.DotName)15 ClassInfo (org.jboss.jandex.ClassInfo)10 AnnotationInstance (org.jboss.jandex.AnnotationInstance)7 HashSet (java.util.HashSet)6 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)6 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)5 HashMap (java.util.HashMap)3 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)3 Set (java.util.Set)2 BindingConfiguration (org.jboss.as.ee.component.BindingConfiguration)2 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)2 AnnotationTarget (org.jboss.jandex.AnnotationTarget)2 AnnotationValue (org.jboss.jandex.AnnotationValue)2 Module (org.jboss.modules.Module)2 Annotation (java.lang.annotation.Annotation)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ServletContainerInitializer (javax.servlet.ServletContainerInitializer)1 HandlesTypes (javax.servlet.annotation.HandlesTypes)1 FieldInjectionTarget (org.jboss.as.ee.component.FieldInjectionTarget)1