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 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; }
@Override public AnnotationType apply(ClassInfo clazz) { return new AnnotationType(clazz.name(), clazz.annotations().containsKey(Indices.INHERITED_NAME)); } };
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; }
@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(); } }
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; }
private void processAroundInvoke(final EEModuleDescription eeModuleDescription, final AnnotationTarget target) throws DeploymentUnitProcessingException { if (!(target instanceof MethodInfo)) { throw EeLogger.ROOT_LOGGER.methodOnlyAnnotation(AROUND_INVOKE_ANNOTATION_NAME); } final MethodInfo methodInfo = MethodInfo.class.cast(target); final ClassInfo classInfo = methodInfo.declaringClass(); final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString()); final List<AnnotationInstance> classAroundInvokes = classInfo.annotations().get(AROUND_INVOKE_ANNOTATION_NAME); if(classAroundInvokes.size() > 1) { throw EeLogger.ROOT_LOGGER.aroundInvokeAnnotationUsedTooManyTimes(classInfo.name(), classAroundInvokes.size()); } validateArgumentType(classInfo, methodInfo); InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription()); builder.setAroundInvoke(MethodIdentifier.getIdentifier(Object.class, methodInfo.name(), InvocationContext.class)); classDescription.setInterceptorClassDescription(builder.build()); }
private boolean isAnnotationDeclared(ClassInfo classInfo, DotName requiredAnnotationName) { Map<DotName, List<AnnotationInstance>> annotationsMap = classInfo.annotations(); List<AnnotationInstance> annotations = annotationsMap.get(requiredAnnotationName); if (annotations != null) { for (AnnotationInstance annotationInstance : annotations) { if (annotationInstance.target().equals(classInfo)) { return true; } } } return false; }
private boolean isAnnotationDeclared(ClassInfo classInfo, DotName requiredAnnotationName) { Map<DotName, List<AnnotationInstance>> annotationsMap = classInfo.annotations(); List<AnnotationInstance> annotations = annotationsMap.get(requiredAnnotationName); if (annotations != null) { for (AnnotationInstance annotationInstance : annotations) { if (annotationInstance.target().equals(classInfo)) { return true; } } } return false; }
private boolean isAnnotationDeclared(ClassInfo classInfo, DotName requiredAnnotationName) { Map<DotName, List<AnnotationInstance>> annotationsMap = classInfo.annotations(); List<AnnotationInstance> annotations = annotationsMap.get(requiredAnnotationName); if (annotations != null) { for (AnnotationInstance annotationInstance : annotations) { if (annotationInstance.target().equals(classInfo)) { return true; } } } return false; }
private boolean isAnnotationDeclared(ClassInfo classInfo, DotName requiredAnnotationName) { Map<DotName, List<AnnotationInstance>> annotationsMap = classInfo.annotations(); List<AnnotationInstance> annotations = annotationsMap.get(requiredAnnotationName); if (annotations != null) { for (AnnotationInstance annotationInstance : annotations) { if (annotationInstance.target().equals(classInfo)) { return true; } } } return false; }
/** * @param classInfo the class info from which to retrieve the annotation instance * @param annotationName the annotation to retrieve from the class info * * @return the single annotation defined on the class or {@code null} in case the annotation is not specified at all * * @throws org.hibernate.AssertionFailure in case there is there is more than one annotation of this type. */ public static AnnotationInstance getSingleAnnotation(ClassInfo classInfo, DotName annotationName) throws AssertionFailure { return getSingleAnnotation( classInfo.annotations(), annotationName ); }
private static WebContextAnnotationWrapper getWebContextWrapper(final ClassInfo webServiceClassInfo) { if (!webServiceClassInfo.annotations().containsKey(WEB_CONTEXT_ANNOTATION)) return new WebContextAnnotationWrapper(null); final AnnotationInstance webContextAnnotation = webServiceClassInfo.annotations().get(WEB_CONTEXT_ANNOTATION).get(0); return new WebContextAnnotationWrapper(webContextAnnotation); }
public static boolean isJaxwsEndpointInterface(final ClassInfo clazz) { final short flags = clazz.flags(); if (!Modifier.isInterface(flags)) return false; if (!Modifier.isPublic(flags)) return false; return clazz.annotations().containsKey(WEB_SERVICE_ANNOTATION); }
public static boolean isJaxwsEndpointInterface(final ClassInfo clazz) { final short flags = clazz.flags(); if (!Modifier.isInterface(flags)) return false; if (!Modifier.isPublic(flags)) return false; return clazz.annotations().containsKey(WEB_SERVICE_ANNOTATION); }
private static WebContextAnnotationWrapper getWebContextWrapper(final ClassInfo webServiceClassInfo) { if (!webServiceClassInfo.annotations().containsKey(WEB_CONTEXT_ANNOTATION)) return new WebContextAnnotationWrapper(null); final AnnotationInstance webContextAnnotation = webServiceClassInfo.annotations().get(WEB_CONTEXT_ANNOTATION).get(0); return new WebContextAnnotationWrapper(webContextAnnotation); }
private boolean isAnnotationDeclared(ClassInfo classInfo, DotName requiredAnnotationName) { Map<DotName, List<AnnotationInstance>> annotationsMap = classInfo.annotations(); List<AnnotationInstance> annotations = annotationsMap.get(requiredAnnotationName); if (annotations != null) { for (AnnotationInstance annotationInstance : annotations) { if (annotationInstance.target().equals(classInfo)) { return true; } } } return false; }
/** * @param classInfo the class info from which to retrieve the annotation instance * @param annotationName the annotation to retrieve from the class info * * @return the single annotation defined on the class or {@code null} in case the annotation is not specified at all * * @throws org.hibernate.AssertionFailure in case there is there is more than one annotation of this type. */ public static AnnotationInstance getSingleAnnotation(ClassInfo classInfo, DotName annotationName) throws AssertionFailure { return getSingleAnnotation( classInfo.annotations(), annotationName ); }
private boolean isAnnotationDeclared(ClassInfo classInfo, DotName requiredAnnotationName) { Map<DotName, List<AnnotationInstance>> annotationsMap = classInfo.annotations(); List<AnnotationInstance> annotations = annotationsMap.get(requiredAnnotationName); if (annotations != null) { for (AnnotationInstance annotationInstance : annotations) { if (annotationInstance.target().equals(classInfo)) { return true; } } } return false; }