本文整理匯總了Java中org.springframework.beans.factory.support.AbstractBeanDefinition類的典型用法代碼示例。如果您正苦於以下問題:Java AbstractBeanDefinition類的具體用法?Java AbstractBeanDefinition怎麽用?Java AbstractBeanDefinition使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AbstractBeanDefinition類屬於org.springframework.beans.factory.support包,在下文中一共展示了AbstractBeanDefinition類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseConfigTypes
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入依賴的package包/類
private void parseConfigTypes(Element element, String configType, BeanDefinitionBuilder redissonDef, ParserContext parserContext) {
BeanDefinitionBuilder builder
= helper.createBeanDefinitionBuilder(element,
parserContext, null);
//Use factory method on the Config bean
AbstractBeanDefinition bd = builder.getRawBeanDefinition();
bd.setFactoryMethodName("use" + StringUtils.capitalize(configType));
bd.setFactoryBeanName(parserContext.getContainingComponent().getName());
String id = parserContext.getReaderContext().generateBeanName(bd);
helper.registerBeanDefinition(builder, id,
helper.parseAliase(element), parserContext);
helper.parseAttributes(element, parserContext, builder);
redissonDef.addDependsOn(id);
parseChildElements(element, id, null, redissonDef, parserContext);
parserContext.getDelegate().parseQualifierElements(element, bd);
}
示例2: parseNested
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入依賴的package包/類
@Override
protected void parseNested(Element element, ParserContext parserContext, BeanDefinitionBuilder builder, BeanDefinition bd) {
bd.setFactoryBeanName(element.getAttribute(
RedissonNamespaceParserSupport.REDISSON_REF_ATTRIBUTE));
String typeName
= Conventions.attributeNameToPropertyName(element.getLocalName());
bd.setFactoryMethodName("get" + StringUtils.capitalize(typeName));
helper.addConstructorArgs(element, KEY_ATTRIBUTE,
String.class, builder);
helper.addConstructorArgs(element, TOPIC_ATTRIBUTE,
String.class, builder);
helper.addConstructorArgs(element, PATTERN_ATTRIBUTE,
String.class, builder);
helper.addConstructorArgs(element, SERVICE_ATTRIBUTE,
String.class, builder);
helper.addConstructorArgs(element, CODEC_REF_ATTRIBUTE,
Codec.class, builder);
if (RDestroyable.class.isAssignableFrom(getBeanClass(element))) {
((AbstractBeanDefinition) bd).setDestroyMethodName("destroy");
}
}
示例3: doParse
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入依賴的package包/類
@Override
protected final void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
Assert.state(helper.isRedissonNS(element),
"Illegal state. "
+ this.getClass().getName()
+ " can only parse "
+ RedissonNamespaceParserSupport.REDISSON_NAMESPACE
+ " namespace elements");
Assert.state(element.hasAttribute(parentRefAttribute),
"Illegal state. property \"" + parentRefAttribute
+ "\" is required in the \""
+ helper.getName(element)
+ "\" element.");
helper.populateIdAttribute(element, builder, parserContext);
AbstractBeanDefinition bd = builder.getRawBeanDefinition();
parseNested(element, parserContext, builder, bd);
decorator.decorate(element, parserContext, builder, helper);
parserContext.getDelegate().parseQualifierElements(element, bd);
if (parserContext.isNested()) {
helper.registerBeanDefinition(builder, element, parserContext);
}
}
示例4: resolveId
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入依賴的package包/類
@Override
protected String resolveId(Element el, AbstractBeanDefinition def, ParserContext ctx) {
String id = super.resolveId(el, def, ctx);
deferredBaseBeans.forEach((baseBeanBuilder, baseBeanName) -> {
baseBeanBuilder.addPropertyValue("source", new RuntimeBeanReference(id));
AbstractBeanDefinition baseBean = baseBeanBuilder.getBeanDefinition();
if (baseBeanName == null) {
ctx.getRegistry().registerBeanDefinition(ctx.getReaderContext().generateBeanName(baseBean), baseBean);
} else {
ctx.getRegistry().registerBeanDefinition(baseBeanName, baseBean);
}
});
return id;
}
示例5: registerBeans
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入依賴的package包/類
@Override
protected void registerBeans(InjectRpcClient annotation, ResolvableType targetType, BeanDefinitionRegistry registry) {
String tag = annotation.tag().isEmpty() ? "" : '#' + annotation.tag();
String name = RpcClientBean.class.getName() + tag + "-" + targetType.toString();
if (!registry.containsBeanDefinition(name)) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(RpcClientBean.class)
.setLazyInit(true)
.addPropertyValue("rpcInterface", targetType.getType().getTypeName());
if (!annotation.tag().isEmpty()) {
builder.addPropertyValue("tag", annotation.tag());
}
AbstractBeanDefinition def = builder.getBeanDefinition();
AutowireCandidateQualifier qualifier = new AutowireCandidateQualifier(annotation.annotationType());
if (!annotation.tag().isEmpty()) {
qualifier.setAttribute("tag", annotation.tag());
}
def.addQualifier(qualifier);
registry.registerBeanDefinition(name, def);
}
}
示例6: doScan
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入依賴的package包/類
@Override
public Set<BeanDefinitionHolder> doScan(String... basePackages) {
Set<BeanDefinitionHolder> beanDefinitions = super.doScan(basePackages);
if (beanDefinitions.isEmpty()) {
logger.warn("No mapper was found in '" + Arrays.toString(basePackages) + "' package. Please check your configuration.");
} else {
for (BeanDefinitionHolder holder : beanDefinitions) {
GenericBeanDefinition definition = (GenericBeanDefinition) holder.getBeanDefinition();
if (logger.isDebugEnabled()) {
logger.debug("Creating MapperFactoryBean with name '" + holder.getBeanName() + "' and '" + definition.getBeanClassName()
+ "' mapperInterface");
}
definition.getPropertyValues().add("mapperProxy", getRegistry().getBeanDefinition("mapperProxy"));
definition.getPropertyValues().add("mapperInterface", definition.getBeanClassName());
definition.setBeanClass(MapperFactoryBean.class);
definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
}
}
return beanDefinitions;
}
示例7: getDefaultKeyValueTemplateBeanDefinition
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入依賴的package包/類
@Override
protected AbstractBeanDefinition getDefaultKeyValueTemplateBeanDefinition(
RepositoryConfigurationSource configurationSource) {
RootBeanDefinition keyValueTemplateDefinition = new RootBeanDefinition(TarantoolKeyValueTemplate.class);
ConstructorArgumentValues constructorArgumentValuesForKeyValueTemplate = new ConstructorArgumentValues();
constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(0,
new RuntimeBeanReference(TARANTOOL_OPS_IMPL_BEAN_NAME));
constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(1,
new RuntimeBeanReference(MAPPING_CONTEXT_BEAN_NAME));
constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(2,
new RuntimeBeanReference(TARANTOOL_CONVERTER_BEAN_NAME));
keyValueTemplateDefinition.setConstructorArgumentValues(constructorArgumentValuesForKeyValueTemplate);
return keyValueTemplateDefinition;
}
開發者ID:saladinkzn,項目名稱:spring-data-tarantool,代碼行數:18,代碼來源:TarantoolRepositoryConfigurationExtension.java
示例8: buildBeanDefinitionFor
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入依賴的package包/類
BeanDefinition buildBeanDefinitionFor(ComponentMetadata metadata) {
// shortcut (to avoid re-rewrapping)
if (metadata instanceof SimpleComponentMetadata) {
return ((SimpleComponentMetadata) metadata).getBeanDefinition();
}
AbstractBeanDefinition definition = buildBeanDefinition(metadata);
// add common properties
definition.setAttribute(MetadataConstants.COMPONENT_METADATA_ATTRIBUTE, metadata);
definition.setAttribute(MetadataConstants.COMPONENT_NAME, metadata.getId());
// Set<String> dependencies = metadata.;
// definition.setDependsOn(dependencies.toArray(new String[dependencies.size()]));
throw new UnsupportedOperationException("move depends on for BeanMetadata");
// return definition;
}
示例9: buildBeanDefinition
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入依賴的package包/類
private AbstractBeanDefinition buildBeanDefinition(ComponentMetadata metadata) {
if (metadata instanceof BeanMetadata) {
return buildLocalComponent((BeanMetadata) metadata);
}
if (metadata instanceof ServiceMetadata) {
return buildExporter((ServiceMetadata) metadata);
}
if (metadata instanceof ServiceReferenceMetadata) {
if (metadata instanceof ReferenceListMetadata) {
return buildReferenceCollection((ReferenceListMetadata) metadata);
}
if (metadata instanceof ReferenceMetadata) {
return buildReferenceProxy((ReferenceMetadata) metadata);
}
}
// unknown rich metadata type, unable to perform conversion
throw new IllegalArgumentException("Unknown metadata type" + metadata.getClass());
}
示例10: buildExporter
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入依賴的package包/類
private AbstractBeanDefinition buildExporter(ServiceMetadata metadata) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(EXPORTER_CLASS);
// add properties
builder.addPropertyValue(EXPORTER_RANKING_PROP, metadata.getRanking());
builder.addPropertyValue(EXPORTER_INTFS_PROP, metadata.getInterfaces());
builder.addPropertyValue(EXPORTER_PROPS_PROP, metadata.getServiceProperties());
builder.addPropertyValue(EXPORTER_AUTO_EXPORT_PROP,
DefaultInterfaceDetector.values()[metadata.getAutoExport() - 1]);
BeanMetadataElement beanMetadata = BeanMetadataElementFactory.buildBeanMetadata(metadata.getServiceComponent());
if (beanMetadata instanceof RuntimeBeanReference) {
builder.addPropertyValue(EXPORTER_TARGET_BEAN_NAME_PROP, beanMetadata);
} else {
builder.addPropertyValue(EXPORTER_TARGET_BEAN_PROP, beanMetadata);
}
// FIXME: add registration listeners
return builder.getBeanDefinition();
}
示例11: registerBeanDefinitions
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入依賴的package包/類
@Override
public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) {
AnnotationAttributes enableMenu = AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(EnableMenu.class
.getName(),
false));
if (enableMenu != null) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(DefaultMenuPlugin.class);
AbstractBeanDefinition beanDefinition = builder.getBeanDefinition();
MutablePropertyValues mutablePropertyValues = new MutablePropertyValues();
mutablePropertyValues.add("extensionPointId", enableMenu.getString("extensionPointId"));
mutablePropertyValues.add("pluginId", enableMenu.getString("pluginId"));
mutablePropertyValues.add("menu", toMenu(enableMenu.getAnnotationArray("menu")));
beanDefinition.setPropertyValues(mutablePropertyValues);
registry.registerBeanDefinition("menuPlugin:" + enableMenu.getString("pluginId"), beanDefinition);
}
}
示例12: parse
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入依賴的package包/類
public void parse(Set<BeanDefinitionHolder> configCandidates) {
for (BeanDefinitionHolder holder : configCandidates) {
BeanDefinition bd = holder.getBeanDefinition();
try {
if (bd instanceof AbstractBeanDefinition && ((AbstractBeanDefinition) bd).hasBeanClass()) {
parse(((AbstractBeanDefinition) bd).getBeanClass(), holder.getBeanName());
}
else {
parse(bd.getBeanClassName(), holder.getBeanName());
}
}
catch (IOException ex) {
throw new BeanDefinitionStoreException("Failed to load bean class: " + bd.getBeanClassName(), ex);
}
}
processDeferredImportSelectors();
}
示例13: processCommonDefinitionAnnotations
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入依賴的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"));
}
}
}
示例14: doScan
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入依賴的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;
}
示例15: createSqlSessionFactoryBean
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入依賴的package包/類
protected final AbstractBeanDefinition createSqlSessionFactoryBean(String dataSourceName, String mapperPackage,
String typeAliasesPackage, Dialect dialect, Configuration configuration) {
configuration.setDatabaseId(dataSourceName);
BeanDefinitionBuilder bdb = BeanDefinitionBuilder.rootBeanDefinition(SqlSessionFactoryBean.class);
bdb.addPropertyValue("configuration", configuration);
bdb.addPropertyValue("failFast", true);
bdb.addPropertyValue("typeAliases", this.saenTypeAliases(typeAliasesPackage));
bdb.addPropertyReference("dataSource", dataSourceName);
bdb.addPropertyValue("plugins", new Interceptor[] { new CustomPageInterceptor(dialect) });
if (!StringUtils.isEmpty(mapperPackage)) {
try {
mapperPackage = new StandardEnvironment().resolveRequiredPlaceholders(mapperPackage);
String mapperPackages = ClassUtils.convertClassNameToResourcePath(mapperPackage);
String mapperPackagePath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + mapperPackages + "/*.xml";
Resource[] resources = new PathMatchingResourcePatternResolver().getResources(mapperPackagePath);
bdb.addPropertyValue("mapperLocations", resources);
} catch (Exception e) {
log.error("初始化失敗", e);
throw new RuntimeException( String.format("SqlSessionFactory 初始化失敗 mapperPackage=%s", mapperPackage + ""));
}
}
return bdb.getBeanDefinition();
}