use of org.springframework.beans.factory.parsing.BeanComponentDefinition in project spring-integration by spring-projects.
the class MBeanTreePollingChannelAdapterParser method parseSource.
@Override
protected BeanMetadataElement parseSource(Element element, ParserContext parserContext) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(MBeanTreePollingMessageSource.class);
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "server", "server");
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "query-name-ref", "queryNameReference");
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "query-expression-ref", "queryExpressionReference");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "query-name", "queryName");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "query-expression", "queryExpression");
if (StringUtils.hasText(element.getAttribute("query-name")) && StringUtils.hasText(element.getAttribute("query-name-ref"))) {
parserContext.getReaderContext().error("Cannot have both `query-name' and 'query-name-ref'", element);
}
if (StringUtils.hasText(element.getAttribute("query-expression")) && StringUtils.hasText(element.getAttribute("query-expression-ref"))) {
parserContext.getReaderContext().error("Cannot have both `query-expression' and 'query-expression-ref'", element);
}
BeanComponentDefinition innerBeanDef = IntegrationNamespaceUtils.parseInnerHandlerDefinition(element, parserContext);
String beanName = element.getAttribute("converter");
if (innerBeanDef != null) {
if (StringUtils.hasText(beanName)) {
parserContext.getReaderContext().error("Cannot have both a 'converter' and an inner bean", element);
}
beanName = BeanDefinitionReaderUtils.generateBeanName(innerBeanDef.getBeanDefinition(), parserContext.getRegistry(), true);
parserContext.getRegistry().registerBeanDefinition(beanName, innerBeanDef.getBeanDefinition());
} else if (!StringUtils.hasText(beanName)) {
BeanDefinitionBuilder childBuilder = BeanDefinitionBuilder.genericBeanDefinition(DefaultMBeanObjectConverter.class);
beanName = BeanDefinitionReaderUtils.generateBeanName(childBuilder.getBeanDefinition(), parserContext.getRegistry(), true);
parserContext.getRegistry().registerBeanDefinition(beanName, childBuilder.getBeanDefinition());
}
builder.addConstructorArgReference(beanName);
return builder.getBeanDefinition();
}
use of org.springframework.beans.factory.parsing.BeanComponentDefinition in project spring-data-commons by spring-projects.
the class BeanComponentDefinitionBuilder method getComponent.
/**
* Creates a new {@link BeanComponentDefinition} from the given {@link BeanDefinitionBuilder} using the given name and
* raw source object.
*
* @param builder must not be {@literal null}.
* @param name must not be {@literal null}.
* @param rawSource
* @return
*/
public BeanComponentDefinition getComponent(BeanDefinitionBuilder builder, String name, Object rawSource) {
Assert.notNull(builder, "Builder must not be null!");
Assert.hasText(name, "Name of bean must not be null or empty!");
AbstractBeanDefinition definition = builder.getRawBeanDefinition();
definition.setSource(context.extractSource(rawSource));
return new BeanComponentDefinition(definition, name);
}
use of org.springframework.beans.factory.parsing.BeanComponentDefinition in project spring-data-commons by spring-projects.
the class RepositoryBeanDefinitionParser method parse.
/*
* (non-Javadoc)
* @see org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)
*/
@Nullable
public BeanDefinition parse(Element element, ParserContext parser) {
XmlReaderContext readerContext = parser.getReaderContext();
try {
ResourceLoader resourceLoader = ConfigurationUtils.getRequiredResourceLoader(readerContext);
Environment environment = readerContext.getEnvironment();
BeanDefinitionRegistry registry = parser.getRegistry();
XmlRepositoryConfigurationSource configSource = new XmlRepositoryConfigurationSource(element, parser, environment);
RepositoryConfigurationDelegate delegate = new RepositoryConfigurationDelegate(configSource, resourceLoader, environment);
RepositoryConfigurationUtils.exposeRegistration(extension, registry, configSource);
for (BeanComponentDefinition definition : delegate.registerRepositoriesIn(registry, extension)) {
readerContext.fireComponentRegistered(definition);
}
} catch (RuntimeException e) {
handleError(e, element, readerContext);
}
return null;
}
use of org.springframework.beans.factory.parsing.BeanComponentDefinition in project spring-security by spring-projects.
the class AuthenticationConfigBuilder method createUserDetailsServiceFactory.
private void createUserDetailsServiceFactory() {
if (this.pc.getRegistry().containsBeanDefinition(BeanIds.USER_DETAILS_SERVICE_FACTORY)) {
// Multiple <http> case
return;
}
RootBeanDefinition bean = new RootBeanDefinition(UserDetailsServiceFactoryBean.class);
bean.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
this.pc.registerBeanComponent(new BeanComponentDefinition(bean, BeanIds.USER_DETAILS_SERVICE_FACTORY));
}
use of org.springframework.beans.factory.parsing.BeanComponentDefinition in project spring-security by spring-projects.
the class AuthenticationConfigBuilder method createRememberMeProvider.
private void createRememberMeProvider(String key) {
RootBeanDefinition provider = new RootBeanDefinition(RememberMeAuthenticationProvider.class);
provider.setSource(this.rememberMeFilter.getSource());
provider.getConstructorArgumentValues().addGenericArgumentValue(key);
String id = this.pc.getReaderContext().generateBeanName(provider);
this.pc.registerBeanComponent(new BeanComponentDefinition(provider, id));
this.rememberMeProviderRef = new RuntimeBeanReference(id);
}
Aggregations