/** * Checks whether this object has the given stereotype directly declared on the object. * * @param stereotype The annotation * @return True if the annotation is present */ default boolean hasDeclaredStereotype(@Nullable Class<? extends Annotation> stereotype) { if (stereotype != null) { Repeatable repeatable = stereotype.getAnnotation(Repeatable.class); if (repeatable != null) { return hasDeclaredStereotype(repeatable.value()); } else { return hasDeclaredStereotype(stereotype.getName()); } } return false; }
@Override default boolean hasDeclaredStereotype(@Nullable Class<? extends Annotation> stereotype) { return getAnnotationMetadata().hasDeclaredStereotype(stereotype); }
@Override default boolean hasDeclaredStereotype(Class<? extends Annotation>... annotations) { return getAnnotationMetadata().hasDeclaredStereotype(annotations); }
@Override default boolean hasDeclaredStereotype(String annotation) { return getAnnotationMetadata().hasDeclaredStereotype(annotation); }
/** * Checks whether this object has any of the given stereotype directly declared on the object. * * @param annotations The annotations * @return True if any of the given stereotypes are present */ @SuppressWarnings("unchecked") default boolean hasDeclaredStereotype(@Nullable Class<? extends Annotation>... annotations) { if (ArrayUtils.isEmpty(annotations)) { return false; } for (Class<? extends Annotation> annotation : annotations) { if (hasDeclaredStereotype(annotation)) { return true; } } return false; }
private boolean isValueType(AnnotationMetadata annotationMetadata) { if (annotationMetadata != null) { return annotationMetadata.hasDeclaredStereotype(Value.class) || annotationMetadata.hasDeclaredStereotype(Property.class); } return false; }
private boolean isValueType(AnnotationMetadata annotationMetadata) { if (annotationMetadata != null) { return annotationMetadata.hasDeclaredStereotype(Value.class) || annotationMetadata.hasDeclaredStereotype(Property.class); } return false; }
@Override public boolean isSingleton() { return annotationMetadata.hasDeclaredStereotype(Singleton.class); }
@Override public boolean isSingleton() { return annotationMetadata.hasDeclaredStereotype(Singleton.class); }
@Override public boolean isContextScope() { return getAnnotationMetadata().hasDeclaredStereotype(Context.class); }
@Override public boolean isContextScope() { return getAnnotationMetadata().hasDeclaredStereotype(Context.class); }
@Override public boolean isPrototype(@Nonnull String name) throws NoSuchBeanDefinitionException { if (super.containsSingleton(name)) { return false; } final BeanDefinitionReference<?> definition = beanDefinitionMap.get(name); if (definition != null) { final AnnotationMetadata annotationMetadata = definition.getAnnotationMetadata(); if (annotationMetadata.hasDeclaredStereotype(Prototype.class)) { return true; } else { final boolean hasScope = annotationMetadata.getAnnotationNamesByStereotype(Scope.class).isEmpty(); return !hasScope; } } return false; }
/** * Processes parallel bean definitions. */ protected void processParallelBeans() { new Thread(() -> beanDefinitionsClasses.stream() .filter(bd -> bd.getAnnotationMetadata().hasDeclaredStereotype(Parallel.class)) .forEach(beanDefinitionReference -> ForkJoinPool.commonPool().execute(() -> { try { if (isRunning()) { synchronized (singletonObjects) { loadContextScopeBean(beanDefinitionReference); } } } catch (Throwable e) { LOG.error("Parallel Bean definition [" + beanDefinitionReference.getName() + "] could not be loaded: " + e.getMessage(), e); Boolean shutdownOnError = beanDefinitionReference.getAnnotationMetadata().getValue(Parallel.class, "shutdownOnError", Boolean.class).orElse(true); if (shutdownOnError) { stop(); } } }))).start(); }
/** * Processes parallel bean definitions. */ protected void processParallelBeans() { new Thread(() -> { final List<BeanDefinitionReference> parallelBeans = beanDefinitionsClasses.stream() .filter(bd -> bd.getAnnotationMetadata().hasDeclaredStereotype(Parallel.class) && bd.isEnabled(this)) .collect(Collectors.toList()); filterReplacedBeans((Collection) parallelBeans); parallelBeans.forEach(beanDefinitionReference -> ForkJoinPool.commonPool().execute(() -> { try { if (isRunning()) { synchronized (singletonObjects) { loadContextScopeBean(beanDefinitionReference); } } } catch (Throwable e) { LOG.error("Parallel Bean definition [" + beanDefinitionReference.getName() + "] could not be loaded: " + e.getMessage(), e); Boolean shutdownOnError = beanDefinitionReference.getAnnotationMetadata().getValue(Parallel.class, "shutdownOnError", Boolean.class).orElse(true); if (shutdownOnError) { stop(); } } })); }).start(); }
this.interfaceTypes = new HashSet<>(); this.interfaceTypes.add(BeanFactory.class); this.isConfigurationProperties = annotationMetadata.hasDeclaredStereotype(ConfigurationProperties.class);
this.interfaceTypes = new HashSet<>(); this.interfaceTypes.add(BeanFactory.class); this.isConfigurationProperties = annotationMetadata.hasDeclaredStereotype(ConfigurationProperties.class);
this.type = type; this.isAbstract = Modifier.isAbstract(this.type.getModifiers()); this.isProvided = beanAnnotationMetadata.hasDeclaredStereotype(Provided.class); this.singleton = beanAnnotationMetadata.hasDeclaredStereotype(Singleton.class); this.declaringType = type; if (requiresReflection) {
this.type = type; this.isAbstract = Modifier.isAbstract(this.type.getModifiers()); this.isProvided = beanAnnotationMetadata.hasDeclaredStereotype(Provided.class); this.singleton = beanAnnotationMetadata.hasDeclaredStereotype(Singleton.class); this.declaringType = type; if (requiresReflection) {
this.singleton = beanAnnotationMetadata.hasDeclaredStereotype(Singleton.class); this.isProvided = beanAnnotationMetadata.hasDeclaredStereotype(Provided.class); this.type = producedType; this.isAbstract = false; // factory beans are never abstract
this.singleton = beanAnnotationMetadata.hasDeclaredStereotype(Singleton.class); this.isProvided = beanAnnotationMetadata.hasDeclaredStereotype(Provided.class); this.type = producedType; this.isAbstract = false; // factory beans are never abstract