@Override public void cleanupAfterBoot() { if (annotationClassAnnotationsCache != null) { annotationClassAnnotationsCache.clear(); annotationClassAnnotationsCache = null; } index = null; }
/** * * @param index */ public WeldClassFileServices(CompositeIndex index, ClassLoader moduleClassLoader) { if (index == null) { throw WeldLogger.ROOT_LOGGER.cannotUseAtRuntime(ClassFileServices.class.getSimpleName()); } this.moduleClassLoader = moduleClassLoader; this.index = index; this.annotationClassAnnotationsCache = ComputingCacheBuilder.newBuilder().build(new AnnotationClassAnnotationLoader()); }
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; }
@Override public void cleanupAfterBoot() { this.enhancedAnnotatedTypes.clear(); this.annotations.clear(); backedAnnotatedTypes.forEachValue((BackedAnnotatedType::clear)); this.backedAnnotatedTypes.clear(); }
/** * removes all data for an annotation class. This should be called after an * annotation has been modified through the SPI */ public void clearAnnotationData(Class<? extends Annotation> annotationClass) { stereotypes.invalidate(annotationClass); scopes.invalidate(annotationClass); qualifiers.invalidate(annotationClass); interceptorBindings.invalidate(annotationClass); }
/** * Gets a stereotype model * <p/> * Adds the model if it is not present. * * @param <T> The type * @param stereotype The stereotype * @return The stereotype model */ public <T extends Annotation> StereotypeModel<T> getStereotype(final Class<T> stereotype) { return stereotypes.getCastValue(stereotype); }
/** * * @return a new builder instance */ public static ComputingCacheBuilder newBuilder() { return new ComputingCacheBuilder(); }
@SuppressWarnings("unchecked") @Override public <T> T getCastValue(Object key) { return (T) getValue((K) key); }
/** * Get the possible beans for the given name * * @param name The name to match * @return The set of matching beans */ public Set<Bean<?>> resolve(final String name) { return resolvedNames.getValue(name); }
/** * removes all data for an annotation class. This should be called after an * annotation has been modified through the SPI */ public void clearAnnotationData(Class<? extends Annotation> annotationClass) { stereotypes.invalidate(annotationClass); scopes.invalidate(annotationClass); qualifiers.invalidate(annotationClass); interceptorBindings.invalidate(annotationClass); }
/** * Gets a scope model * <p/> * Adds the model if it is not present. * * @param <T> The type * @param scope The scope type * @return The scope type model */ public <T extends Annotation> ScopeModel<T> getScopeModel(final Class<T> scope) { return scopes.getCastValue(scope); }
/** * * @return a new builder instance */ public static ComputingCacheBuilder newBuilder() { return new ComputingCacheBuilder(); }
@SuppressWarnings("unchecked") @Override public <T> T getCastValue(Object key) { return (T) getValue((K) key); }