/** * Determines a list of classes the given annotation instances are defined on. If an annotation instance is not defined on a * class (e.g. on a member) this annotation instance is not reflected anyhow in the resulting list. */ public static List<ClassInfo> getAnnotatedClasses(List<AnnotationInstance> instances) { List<ClassInfo> result = new ArrayList<ClassInfo>(); for (AnnotationInstance instance : instances) { AnnotationTarget target = instance.target(); if (target instanceof ClassInfo) { result.add((ClassInfo) target); } } return result; } }
private boolean isAnnotationDeclared(ClassInfo classInfo, DotName requiredAnnotationName) { List<AnnotationInstance> annotations = classInfo.annotations().get(requiredAnnotationName); if (annotations != null) { for (AnnotationInstance annotationInstance : annotations) { if (annotationInstance.target().equals(classInfo)) { return true; } } } return false; }
private boolean hasBeanDefiningAnnotation(ClassInfo classInfo, Set<AnnotationType> beanDefiningAnnotations) { Map<DotName, List<AnnotationInstance>> annotationsMap = classInfo.annotations(); for (AnnotationType beanDefiningAnnotation : beanDefiningAnnotations) { List<AnnotationInstance> annotations = annotationsMap.get(beanDefiningAnnotation.getName()); if (annotations != null) { for (AnnotationInstance annotationInstance : annotations) { if (annotationInstance.target().equals(classInfo)) { return true; } } } } return false; }
private boolean hasInjectConstructor() { List<AnnotationInstance> annotationInstances = classInfo.annotations().get(DOT_NAME_INJECT); if (annotationInstances != null) { for (AnnotationInstance instance : annotationInstances) { AnnotationTarget target = instance.target(); if (target instanceof MethodInfo) { MethodInfo methodInfo = (MethodInfo) target; if (methodInfo.name().equals(CONSTRUCTOR_METHOD_NAME)) { return true; } } } } return false; }
protected List<TargetAnnotation> fromMultiAnnotation(AnnotationInstance multiAnnotationInstance) { List<TargetAnnotation> instances = new ArrayList<TargetAnnotation>(); final AnnotationInstance[] values = multiAnnotationInstance.value().asNestedArray(); for(AnnotationInstance value : values) { instances.add(new TargetAnnotation(value, multiAnnotationInstance.target())); } return instances; }
private Set<String> findPersistenceTypeNames(PersistenceUnitMetadata pu) { synchronized (CACHED_TYPENAMES) { Set<String> typeNames = CACHED_TYPENAMES.get(pu); if (typeNames != null) { return typeNames; } } Set<String> persistenceTypeNames = new HashSet<String>(); for (Map.Entry<URL, Index> entry : pu.getAnnotationIndex().entrySet()) { List<AnnotationInstance> instances = entry.getValue().getAnnotations(DotName.createSimple(Entity.class.getName())); for (AnnotationInstance instance : instances) { AnnotationTarget target = instance.target(); if (target instanceof ClassInfo) { ClassInfo classInfo = (ClassInfo) target; persistenceTypeNames.add(classInfo.name().toString()); } } } synchronized (CACHED_TYPENAMES) { CACHED_TYPENAMES.put(pu, persistenceTypeNames); } return persistenceTypeNames; }
@Override protected String fromAnnotation(final AnnotationInstance annotationInstance, final PropertyReplacer propertyReplacer) { ROOT_LOGGER.legacySecurityDomainAnnotationIsUsed(annotationInstance.target().asClass().toString()); return 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)); } } } }
List<AnnotationInstance> instances = index.getAnnotations(typeName); for (AnnotationInstance instance : instances) { AnnotationTarget annotationTarget = instance.target(); if (annotationTarget instanceof ClassInfo) { classes.add((ClassInfo) annotationTarget);
private String getMessageListenerInterface(final CompositeIndex compositeIndex, final AnnotationInstance messageBeanAnnotation) throws DeploymentUnitProcessingException { final AnnotationValue value = messageBeanAnnotation.value("messageListenerInterface"); if (value != null) return value.asClass().name().toString(); final ClassInfo beanClass = (ClassInfo) messageBeanAnnotation.target(); final Set<DotName> interfaces = new HashSet<DotName>(getPotentialViewInterfaces(beanClass)); // check super class(es) of the bean DotName superClassDotName = beanClass.superName(); while (interfaces.isEmpty() && superClassDotName != null && !superClassDotName.toString().equals(Object.class.getName())) { final ClassInfo superClass = compositeIndex.getClassByName(superClassDotName); if (superClass == null) { break; } interfaces.addAll(getPotentialViewInterfaces(superClass)); // move to next super class superClassDotName = superClass.superName(); } if (interfaces.size() != 1) throw EjbLogger.ROOT_LOGGER.mdbDoesNotImplementNorSpecifyMessageListener(beanClass); return interfaces.iterator().next().toString(); }
@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()); } }
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); } } }
private List<BindingConfiguration> getAnnotatedClassBindingConfigurations(EEModuleDescription moduleDescription, AnnotationInstance annotationInstance) throws DeploymentUnitProcessingException { final AnnotationTarget target = annotationInstance.target(); if (!(target instanceof ClassInfo)) { throw ROOT_LOGGER.classOnlyAnnotation(annotationInstance.toString(), target); } final ClassInfo classInfo = (ClassInfo) target; return moduleDescription.addOrGetLocalClassDescription(classInfo.name().toString()).getBindingConfigurations(); }
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); } }
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); } } }
ArrayList<Annotation> annotations = new ArrayList<Annotation>(instances.size()); for (AnnotationInstance instance : instances) { AnnotationTarget target = instance.target(); Annotation annotation = null; if (target instanceof MethodInfo) {
final AnnotationTarget annotationTarget = annotation.target(); final EJBResourceWrapper annotationWrapper = new EJBResourceWrapper(annotation, propertyReplacer); if (annotationTarget instanceof FieldInfo) { final AnnotationTarget annotationTarget = annotation.target(); if (annotationTarget instanceof ClassInfo) { final AnnotationValue annotationValue = annotation.value(); throw EjbLogger.ROOT_LOGGER.annotationOnlyAllowedOnClass(EJBs.class.getName(), annotation.target());
instances.put(annotation.annotationClass, discoveredClasses); for (AnnotationInstance annotationInstance : annotationInstances) { final AnnotationTarget target = annotationInstance.target(); if (target instanceof ClassInfo) { final DotName className = ClassInfo.class.cast(target).name();
deploymentUnit.putAttachment(EjbDeploymentAttachmentKeys.APPLICATION_EXCEPTION_DESCRIPTIONS, descriptions); for (AnnotationInstance annotationInstance : applicationExceptionAnnotations) { AnnotationTarget target = annotationInstance.target(); if (!(target instanceof ClassInfo)) { throw EjbLogger.ROOT_LOGGER.annotationOnlyAllowedOnClass(ApplicationException.class.getName(), target);
final AnnotationTarget annotationTarget = annotation.target(); final AnnotationValue nameValue = annotation.value("name"); final String name = (nameValue != null) ? replacer.replaceProperties(nameValue.asString()) : null; final AnnotationTarget annotationTarget = outerAnnotation.target(); if (annotationTarget instanceof ClassInfo) { final ClassInfo classInfo = (ClassInfo) annotationTarget;