Search in sources :

Example 36 with BeanDefinitionRegistry

use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project cucumber-jvm by cucumber.

the class CucumberTestContextManager method registerStepClassBeanDefinition.

private void registerStepClassBeanDefinition(ConfigurableListableBeanFactory beanFactory, Class<?> stepClass) {
    BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
    BeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(stepClass).setScope(GlueCodeScope.NAME).getBeanDefinition();
    registry.registerBeanDefinition(stepClass.getName(), beanDefinition);
}
Also used : BeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition)

Example 37 with BeanDefinitionRegistry

use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project spring-framework by spring-projects.

the class PrototypeTargetSourceTests method setUp.

@Before
public void setUp() throws Exception {
    this.beanFactory = new DefaultListableBeanFactory();
    new XmlBeanDefinitionReader((BeanDefinitionRegistry) this.beanFactory).loadBeanDefinitions(CONTEXT);
}
Also used : XmlBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader) DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) BeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry) Before(org.junit.Before)

Example 38 with BeanDefinitionRegistry

use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project spring-boot by spring-projects.

the class ResourceServerTokenServicesConfigurationTests method userInfoWithClient.

@Test
public void userInfoWithClient() {
    EnvironmentTestUtils.addEnvironment(this.environment, "security.oauth2.client.client-id=acme", "security.oauth2.resource.userInfoUri:http://example.com", "server.port=-1", "debug=true");
    this.context = new SpringApplicationBuilder(ResourceNoClientConfiguration.class).environment(this.environment).web(WebApplicationType.SERVLET).run();
    BeanDefinition bean = ((BeanDefinitionRegistry) this.context).getBeanDefinition("scopedTarget.oauth2ClientContext");
    assertThat(bean.getScope()).isEqualTo("request");
}
Also used : SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) BeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) Test(org.junit.Test)

Example 39 with BeanDefinitionRegistry

use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project cuba by cuba-platform.

the class RemoteProxyBeanCreator method processSubstitutions.

protected void processSubstitutions(ConfigurableListableBeanFactory beanFactory) {
    if (substitutions != null) {
        BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
        for (Map.Entry<String, String> entry : substitutions.entrySet()) {
            // replace bean with substitution bean
            if (beanFactory.containsBean(entry.getKey())) {
                String beanName = entry.getKey();
                String beanClass = entry.getValue();
                BeanDefinition definition = new RootBeanDefinition(beanClass);
                MutablePropertyValues propertyValues = definition.getPropertyValues();
                propertyValues.add("substitutedBean", beanFactory.getBean(beanName));
                registry.registerBeanDefinition(beanName, definition);
            }
        }
    }
}
Also used : MutablePropertyValues(org.springframework.beans.MutablePropertyValues) BeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) Map(java.util.Map)

Example 40 with BeanDefinitionRegistry

use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project spring-data-mongodb by spring-projects.

the class MongoAuditingBeanDefinitionParser method doParse.

/*
	 * (non-Javadoc)
	 * @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser#doParse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext, org.springframework.beans.factory.support.BeanDefinitionBuilder)
	 */
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    String mappingContextRef = element.getAttribute("mapping-context-ref");
    if (!StringUtils.hasText(mappingContextRef)) {
        BeanDefinitionRegistry registry = parserContext.getRegistry();
        if (!registry.containsBeanDefinition(MAPPING_CONTEXT_BEAN_NAME)) {
            registry.registerBeanDefinition(MAPPING_CONTEXT_BEAN_NAME, new RootBeanDefinition(MongoMappingContext.class));
        }
        mappingContextRef = MAPPING_CONTEXT_BEAN_NAME;
    }
    IsNewAwareAuditingHandlerBeanDefinitionParser parser = new IsNewAwareAuditingHandlerBeanDefinitionParser(mappingContextRef);
    parser.parse(element, parserContext);
    builder.addConstructorArgValue(getObjectFactoryBeanDefinition(parser.getResolvedBeanName(), parserContext.extractSource(element)));
}
Also used : IsNewAwareAuditingHandlerBeanDefinitionParser(org.springframework.data.auditing.config.IsNewAwareAuditingHandlerBeanDefinitionParser) MongoMappingContext(org.springframework.data.mongodb.core.mapping.MongoMappingContext) BeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition)

Aggregations

BeanDefinitionRegistry (org.springframework.beans.factory.support.BeanDefinitionRegistry)72 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)29 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)17 AnnotatedBeanDefinition (org.springframework.beans.factory.annotation.AnnotatedBeanDefinition)13 Test (org.junit.jupiter.api.Test)12 BeanDefinitionBuilder (org.springframework.beans.factory.support.BeanDefinitionBuilder)12 SimpleBeanDefinitionRegistry (org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry)11 Map (java.util.Map)9 AnnotatedGenericBeanDefinition (org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition)9 AbstractBeanDefinition (org.springframework.beans.factory.support.AbstractBeanDefinition)6 CompositeComponentDefinition (org.springframework.beans.factory.parsing.CompositeComponentDefinition)5 Test (org.junit.Test)4 MutablePropertyValues (org.springframework.beans.MutablePropertyValues)4 RuntimeBeanReference (org.springframework.beans.factory.config.RuntimeBeanReference)4 BeanComponentDefinition (org.springframework.beans.factory.parsing.BeanComponentDefinition)4 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)4 XmlBeanDefinitionReader (org.springframework.beans.factory.xml.XmlBeanDefinitionReader)4 ApplicationContext (org.springframework.context.ApplicationContext)4 ClassPathResource (org.springframework.core.io.ClassPathResource)4 HashMap (java.util.HashMap)3