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;
}
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);
}
}
}
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));
}
}
}
}
}
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;
}
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);
}
}
Aggregations