Spring Framework AnnotationMetadata - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework AnnotationMetadata class.

This code example shows how to use the following methods:getAnnotationAttributes, getClassName
 
 
	@Override 
	public void setImportMetadata(AnnotationMetadata importMetadata) {
		this.enableAsync = AnnotationAttributes.fromMap(
				importMetadata.getAnnotationAttributes(EnableAsync.class.getName(), false));
		Assert.notNull(this.enableAsync,
				"@EnableAsync is not present on importing class " + importMetadata.getClassName());
	} 
 
	/** 
	 * Collect any {@link AsyncConfigurer} beans through autowiring. 
	 */ 
	@Autowired(required=false) 
	void setConfigurers(Collection<AsyncConfigurer> configurers) {
		if (CollectionUtils.isEmpty(configurers)) {
			return; 
		} 
		if (configurers.size() > 1) {
			throw new IllegalStateException("Only one AsyncConfigurer may exist");
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAnnotationAttributes, getClassName
	protected CacheErrorHandler errorHandler;
 
	@Override 
	public void setImportMetadata(AnnotationMetadata importMetadata) {
		this.enableCaching = AnnotationAttributes.fromMap(
				importMetadata.getAnnotationAttributes(EnableCaching.class.getName(), false));
		Assert.notNull(this.enableCaching,
				"@EnableCaching is not present on importing class " + 
						importMetadata.getClassName());
	} 
 
	@Autowired(required = false) 
	void setConfigurers(Collection<C> configurers) {
		if (CollectionUtils.isEmpty(configurers)) {
			return; 
		} 
		if (configurers.size() > 1) {
			throw new IllegalStateException(configurers.size() + " implementations of " +
					"CachingConfigurer were found when only 1 was expected. " + 
					"Refactor the configuration such that CachingConfigurer is " + 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getClassName
		Assert.notNull(metadata, "AnnotationMetadata must not be null");
		if (metadata instanceof StandardAnnotationMetadata) {
			setBeanClass(((StandardAnnotationMetadata) metadata).getIntrospectedClass());
		} 
		else { 
			setBeanClassName(metadata.getClassName());
		} 
		this.metadata = metadata;
	} 
 
	/** 
	 * Create a new AnnotatedGenericBeanDefinition for the given annotation metadata, 
	 * based on an annotated class and a factory method on that class. 
	 * @param metadata the annotation metadata for the bean class in question 
	 * @param factoryMethodMetadata metadata for the selected factory method 
	 * @since 4.1.1 
	 */ 
	public AnnotatedGenericBeanDefinition(AnnotationMetadata metadata, MethodMetadata factoryMethodMetadata) {
		this(metadata);
		Assert.notNull(factoryMethodMetadata, "MethodMetadata must not be null");
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:isAnnotated
	 * @param metadata the metadata of the annotated class 
	 * @return {@code true} if the given class is to be processed as a full 
	 * configuration class, including cross-method call interception 
	 */ 
	public static boolean isFullConfigurationCandidate(AnnotationMetadata metadata) {
		return metadata.isAnnotated(Configuration.class.getName());
	} 
 
	/** 
	 * Check the given metadata for a lite configuration class candidate 
	 * (e.g. a class annotated with {@code @Component} or just having 
	 * {@code @Import} declarations or {@code @Bean methods}). 
	 * @param metadata the metadata of the annotated class 
	 * @return {@code true} if the given class is to be processed as a lite 
	 * configuration class, just registering it and scanning it for {@code @Bean} methods 
	 */ 
	public static boolean isLiteConfigurationCandidate(AnnotationMetadata metadata) {
		// Do not consider an interface or an annotation... 
		if (metadata.isInterface()) {
			return false; 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:isAnnotated
 
	static void processCommonDefinitionAnnotations(AnnotatedBeanDefinition abd, AnnotatedTypeMetadata metadata) {
		if (metadata.isAnnotated(Lazy.class.getName())) {
			abd.setLazyInit(attributesFor(metadata, Lazy.class).getBoolean("value"));
		} 
		else if (abd.getMetadata().isAnnotated(Lazy.class.getName())) {
			abd.setLazyInit(attributesFor(abd.getMetadata(), Lazy.class).getBoolean("value"));
		} 
 
		if (metadata.isAnnotated(Primary.class.getName())) {
			abd.setPrimary(true);
		} 
		if (metadata.isAnnotated(DependsOn.class.getName())) {
			abd.setDependsOn(attributesFor(metadata, DependsOn.class).getStringArray("value"));
		} 
 
		if (abd instanceof AbstractBeanDefinition) {
			AbstractBeanDefinition absBd = (AbstractBeanDefinition) abd;
			if (metadata.isAnnotated(Role.class.getName())) {
				absBd.setRole(attributesFor(metadata, Role.class).getNumber("value").intValue());
5
CodeRank
Experience pair programming with AI  Get Codota for Java