当前位置: 首页>>代码示例>>Java>>正文


Java AnnotatedBeanDefinition类代码示例

本文整理汇总了Java中org.springframework.beans.factory.annotation.AnnotatedBeanDefinition的典型用法代码示例。如果您正苦于以下问题:Java AnnotatedBeanDefinition类的具体用法?Java AnnotatedBeanDefinition怎么用?Java AnnotatedBeanDefinition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AnnotatedBeanDefinition类属于org.springframework.beans.factory.annotation包,在下文中一共展示了AnnotatedBeanDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: afterPropertiesSet

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {

    // on recherche toutes les classes concrètes du package à la recherche de celles qui sont annotées 'TipiTopProcess'
    final ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false) {
        @Override
        protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
            return beanDefinition.getMetadata().isConcrete();
        }
    };
    scanner.addIncludeFilter(new AnnotationTypeFilter(TipiTopProcess.class));

    if (excludeFilters != null) {
        for (TypeFilter filter : excludeFilters) {
            scanner.addExcludeFilter(filter);
        }
    }

    Set<BeanDefinition> beans = scanner.findCandidateComponents(aPackage);
    LOGGER.info("Registering " + beans.size() + " Tipi activities");
    for (BeanDefinition bean : beans) {
        Class<?> clazz = Class.forName(bean.getBeanClassName());
        registerClass(clazz);
    }
}
 
开发者ID:shared-vd,项目名称:tipi-engine,代码行数:26,代码来源:AnnotationActivityRegistrar.java

示例2: registerBeanDefinitions

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
    Set<String> basePackages = getBasePackages(importingClassMetadata);
    ClassPathScanningCandidateComponentProvider scanner = getScanner();
    scanner.addIncludeFilter(new AnnotationTypeFilter(MuonRepository.class));
    for (String basePackage : basePackages) {
        Set<BeanDefinition> candidateComponents = scanner
                .findCandidateComponents(basePackage);
        for (BeanDefinition candidateComponent : candidateComponents) {
            if (candidateComponent instanceof AnnotatedBeanDefinition) {

                AnnotatedBeanDefinition beanDefinition = (AnnotatedBeanDefinition) candidateComponent;
                AnnotationMetadata annotationMetadata = beanDefinition.getMetadata();
                Assert.isTrue(annotationMetadata.isInterface(),
                        "@FeignClient can only be specified on an interface");

                BeanDefinitionHolder holder = createBeanDefinition(annotationMetadata);
                BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry);
            }
        }
    }

}
 
开发者ID:muoncore,项目名称:muon-java,代码行数:24,代码来源:MuonRepositoryRegistrar.java

示例3: registerBeanDefinitions

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
    LepServiceProvider scanner = getScanner();
    Set<String> basePackages = getBasePackages(importingClassMetadata);
    for (String basePackage : basePackages) {
        Set<BeanDefinition> candidateComponents = scanner.findCandidateComponents(basePackage);

        for (BeanDefinition candidateComponent : candidateComponents) {
            if (candidateComponent instanceof AnnotatedBeanDefinition) {
                AnnotatedBeanDefinition beanDefinition = (AnnotatedBeanDefinition) candidateComponent;
                AnnotationMetadata annotationMetadata = beanDefinition.getMetadata();

                Map<String, Object> attributes = annotationMetadata
                    .getAnnotationAttributes(LepService.class.getCanonicalName());

                registerLepService(registry, annotationMetadata, attributes);
            }
        }
    }
}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:24,代码来源:LepServicesRegistrar.java

示例4: resolveScopeMetadata

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入依赖的package包/类
@Override
public ScopeMetadata resolveScopeMetadata(final BeanDefinition definition) {

    if (definition instanceof AnnotatedBeanDefinition) {
        final AnnotatedBeanDefinition beanDefinition = (AnnotatedBeanDefinition) definition;
        final ScopeMetadata metadata = new ScopeMetadata();
        final Set<String> annotationTypes = beanDefinition.getMetadata().getAnnotationTypes();

        if (annotationTypes.contains(RequestScoped.class
            .getName())) {
            metadata.setScopeName("request");
            metadata.setScopedProxyMode(ScopedProxyMode.TARGET_CLASS);
        } else if (annotationTypes
            .contains(ApplicationScoped.class.getName())) {
            metadata.setScopeName("singleton");
        } else {
            return super.resolveScopeMetadata(definition);
        }
        return metadata;
    } else {
        return super.resolveScopeMetadata(definition);
    }
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:24,代码来源:CdiScopeMetadataResolver.java

示例5: processCommonDefinitionAnnotations

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入依赖的package包/类
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());
		}
		if (metadata.isAnnotated(Description.class.getName())) {
			absBd.setDescription(attributesFor(metadata, Description.class).getString("value"));
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:AnnotationConfigUtils.java

示例6: resolveScopeMetadata

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入依赖的package包/类
@Override
public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
	ScopeMetadata metadata = new ScopeMetadata();
	if (definition instanceof AnnotatedBeanDefinition) {
		AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
		AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(annDef.getMetadata(), this.scopeAnnotationType);
		if (attributes != null) {
			metadata.setScopeName(attributes.getString("value"));
			ScopedProxyMode proxyMode = attributes.getEnum("proxyMode");
			if (proxyMode == null || proxyMode == ScopedProxyMode.DEFAULT) {
				proxyMode = this.defaultProxyMode;
			}
			metadata.setScopedProxyMode(proxyMode);
		}
	}
	return metadata;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:AnnotationScopeMetadataResolver.java

示例7: determineBeanNameFromAnnotation

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入依赖的package包/类
/**
 * Derive a bean name from one of the annotations on the class.
 * @param annotatedDef the annotation-aware bean definition
 * @return the bean name, or {@code null} if none is found
 */
protected String determineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef) {
	AnnotationMetadata amd = annotatedDef.getMetadata();
	Set<String> types = amd.getAnnotationTypes();
	String beanName = null;
	for (String type : types) {
		AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(amd, type);
		if (isStereotypeWithNameValue(type, amd.getMetaAnnotationTypes(type), attributes)) {
			Object value = attributes.get("value");
			if (value instanceof String) {
				String strVal = (String) value;
				if (StringUtils.hasLength(strVal)) {
					if (beanName != null && !strVal.equals(beanName)) {
						throw new IllegalStateException("Stereotype annotations suggest inconsistent " +
								"component names: '" + beanName + "' versus '" + strVal + "'");
					}
					beanName = strVal;
				}
			}
		}
	}
	return beanName;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:AnnotationBeanNameGenerator.java

示例8: doScan

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入依赖的package包/类
/**
 * Perform a scan within the specified base packages,
 * returning the registered bean definitions.
 * <p>This method does <i>not</i> register an annotation config processor
 * but rather leaves this up to the caller.
 * @param basePackages the packages to check for annotated classes
 * @return set of beans registered if any for tooling registration purposes (never {@code null})
 */
protected Set<BeanDefinitionHolder> doScan(String... basePackages) {
	Assert.notEmpty(basePackages, "At least one base package must be specified");
	Set<BeanDefinitionHolder> beanDefinitions = new LinkedHashSet<BeanDefinitionHolder>();
	for (String basePackage : basePackages) {
		Set<BeanDefinition> candidates = findCandidateComponents(basePackage);
		for (BeanDefinition candidate : candidates) {
			ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(candidate);
			candidate.setScope(scopeMetadata.getScopeName());
			String beanName = this.beanNameGenerator.generateBeanName(candidate, this.registry);
			if (candidate instanceof AbstractBeanDefinition) {
				postProcessBeanDefinition((AbstractBeanDefinition) candidate, beanName);
			}
			if (candidate instanceof AnnotatedBeanDefinition) {
				AnnotationConfigUtils.processCommonDefinitionAnnotations((AnnotatedBeanDefinition) candidate);
			}
			if (checkCandidate(beanName, candidate)) {
				BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(candidate, beanName);
				definitionHolder = AnnotationConfigUtils.applyScopedProxyMode(scopeMetadata, definitionHolder, this.registry);
				beanDefinitions.add(definitionHolder);
				registerBeanDefinition(definitionHolder, this.registry);
			}
		}
	}
	return beanDefinitions;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:ClassPathBeanDefinitionScanner.java

示例9: getBeanFactoryClassName

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入依赖的package包/类
/**
 * Get the Factory class name which corresponds to given bean definition.
 * @param definition Bean definition
 * @param beanFactory Bean factory
 * @return Factory class name, or <code>null</code> if not found
 */
private static String getBeanFactoryClassName(BeanDefinition definition,
		ConfigurableListableBeanFactory beanFactory) {
	if (definition instanceof AnnotatedBeanDefinition) {
		return ((AnnotatedBeanDefinition) definition).getMetadata().getClassName();
	} else {
		if (definition.getFactoryBeanName() != null) {
			BeanDefinition fd = beanFactory.getBeanDefinition(definition.getFactoryBeanName());
			if (fd != null) {
				return fd.getBeanClassName();
			}
		} else {
			return definition.getBeanClassName();
		}
	}
	return null;
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:23,代码来源:BeanRegistryUtils.java

示例10: getFactoryMethod

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入依赖的package包/类
private Method getFactoryMethod(ConfigurableListableBeanFactory beanFactory,
		BeanDefinition definition) throws Exception {
	if (definition instanceof AnnotatedBeanDefinition) {
		MethodMetadata factoryMethodMetadata = ((AnnotatedBeanDefinition) definition)
				.getFactoryMethodMetadata();
		if (factoryMethodMetadata instanceof StandardMethodMetadata) {
			return ((StandardMethodMetadata) factoryMethodMetadata)
					.getIntrospectedMethod();
		}
	}
	BeanDefinition factoryDefinition = beanFactory
			.getBeanDefinition(definition.getFactoryBeanName());
	Class<?> factoryClass = ClassUtils.forName(factoryDefinition.getBeanClassName(),
			beanFactory.getBeanClassLoader());
	return getFactoryMethod(definition, factoryClass);
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:17,代码来源:BeanTypeRegistry.java

示例11: processCommonDefinitionAnnotations

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入依赖的package包/类
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() != metadata && 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());
		}
		if (metadata.isAnnotated(Description.class.getName())) {
			absBd.setDescription(attributesFor(metadata, Description.class).getString("value"));
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:AnnotationConfigUtils.java

示例12: resolveScopeMetadata

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入依赖的package包/类
@Override
public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
	ScopeMetadata metadata = new ScopeMetadata();
	if (definition instanceof AnnotatedBeanDefinition) {
		AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
		AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(annDef.getMetadata(), this.scopeAnnotationType);
		if (attributes != null) {
			metadata.setScopeName(attributes.getAliasedString("value", this.scopeAnnotationType, definition.getSource()));
			ScopedProxyMode proxyMode = attributes.getEnum("proxyMode");
			if (proxyMode == null || proxyMode == ScopedProxyMode.DEFAULT) {
				proxyMode = this.defaultProxyMode;
			}
			metadata.setScopedProxyMode(proxyMode);
		}
	}
	return metadata;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:AnnotationScopeMetadataResolver.java

示例13: buildDefaultBeanName

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入依赖的package包/类
@Override
protected String buildDefaultBeanName(BeanDefinition definition) {
	String beanName = null;
	if (definition instanceof AnnotatedBeanDefinition) {
		boolean hasProtectedAnnotation = ((AnnotatedBeanDefinition) definition).getMetadata().hasAnnotation("io.leopard.beans.Protected");
		if (hasProtectedAnnotation) {
			beanName = definition.getBeanClassName();
			// System.err.println("beanName:" + beanName);
		}
	}

	if (beanName == null) {
		if (qualifiedBeanName) {
			beanName = definition.getBeanClassName();
		}
		else {
			beanName = super.buildDefaultBeanName(definition);
		}
	}

	beanName = this.replaceBeanName(beanName);
	this.initPrimaryBean(definition);
	return beanName;
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:25,代码来源:LeopardAnnotationBeanNameGenerator.java

示例14: registerJsfCdiToSpring

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入依赖的package包/类
/**
 * Checks how is bean defined and deduces scope name from JSF CDI annotations.
 *
 * @param definition beanDefinition
 */
private void registerJsfCdiToSpring(BeanDefinition definition) {

	if (definition instanceof AnnotatedBeanDefinition) {
		AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;

		String scopeName = null;
		// firstly check whether bean is defined via configuration
		if (annDef.getFactoryMethodMetadata() != null) {
			scopeName = deduceScopeName(annDef.getFactoryMethodMetadata());
		}
		else {
			// fallback to type
			scopeName = deduceScopeName(annDef.getMetadata());
		}

		if (scopeName != null) {
			definition.setScope(scopeName);

			log.debug("{} - Scope({})", definition.getBeanClassName(), scopeName.toUpperCase());
		}
	}
}
 
开发者ID:joinfaces,项目名称:joinfaces,代码行数:28,代码来源:CustomScopeAnnotationConfigurer.java

示例15: hasCustomBeanDefinition

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; //导入依赖的package包/类
private static <T> boolean hasCustomBeanDefinition(
		ConfigurableListableBeanFactory beanFactory, Class<T> type,
		Class<?> configClass) {
	String[] names = beanFactory.getBeanNamesForType(type, true, false);
	if (names == null || names.length != 1) {
		return false;
	}
	BeanDefinition definition = beanFactory.getBeanDefinition(names[0]);
	if (definition instanceof AnnotatedBeanDefinition) {
		MethodMetadata factoryMethodMetadata = ((AnnotatedBeanDefinition) definition)
				.getFactoryMethodMetadata();
		if (factoryMethodMetadata != null) {
			String className = factoryMethodMetadata.getDeclaringClassName();
			return !configClass.getName().equals(className);
		}
	}
	return true;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:EndpointWebMvcAutoConfiguration.java


注:本文中的org.springframework.beans.factory.annotation.AnnotatedBeanDefinition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。