Search in sources :

Example 71 with BeanDefinition

use of org.springframework.beans.factory.config.BeanDefinition in project joinfaces by joinfaces.

the class CustomScopeAnnotationConfigurer method postProcessBeanFactory.

@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory clbf) throws BeansException {
    for (String beanName : clbf.getBeanDefinitionNames()) {
        BeanDefinition definition = clbf.getBeanDefinition(beanName);
        registerJsfCdiToSpring(definition);
    }
}
Also used : AnnotatedBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition)

Example 72 with BeanDefinition

use of org.springframework.beans.factory.config.BeanDefinition in project commons by terran4j.

the class DsqlRepositoryConfigRegistrar method registBean.

final void registBean(DefaultListableBeanFactory registry, Class<?> daoClass) {
    if (log.isInfoEnabled()) {
        log.info("regist DsqlRepository: {}", daoClass);
    }
    BeanDefinition annotationProcessor = BeanDefinitionBuilder.genericBeanDefinition(daoClass).getBeanDefinition();
    String beanName = beanNameGenerator.generateBeanName(annotationProcessor, registry);
    registerBeanDefinitionIfNotExists(registry, beanName, daoClass);
}
Also used : BeanDefinition(org.springframework.beans.factory.config.BeanDefinition)

Example 73 with BeanDefinition

use of org.springframework.beans.factory.config.BeanDefinition in project commons by terran4j.

the class DsqlRepositoryConfigRegistrar method registerBeanDefinitionIfNotExists.

boolean registerBeanDefinitionIfNotExists(DefaultListableBeanFactory registry, String beanName, Class<?> beanClass) {
    if (registry.containsBeanDefinition(beanName)) {
        return false;
    }
    String[] candidates = registry.getBeanDefinitionNames();
    for (String candidate : candidates) {
        BeanDefinition beanDefinition = registry.getBeanDefinition(candidate);
        if (Objects.equals(beanDefinition.getBeanClassName(), beanClass.getName())) {
            return false;
        }
    }
    Object bean = DsqlRepositoryProxy.createProxyObject(beanClass);
    registry.registerSingleton(beanName, bean);
    return true;
}
Also used : BeanDefinition(org.springframework.beans.factory.config.BeanDefinition)

Example 74 with BeanDefinition

use of org.springframework.beans.factory.config.BeanDefinition in project tephra by heisedebaise.

the class ClassReloaderImpl method load.

private void load(ClassLoader loader, String name) {
    try {
        DefaultListableBeanFactory lbf = (DefaultListableBeanFactory) applicationContext.getAutowireCapableBeanFactory();
        BeanDefinition bd = BeanDefinitionReaderUtils.createBeanDefinition(null, name, loader);
        String dynamicBeanName = generator.uuid();
        lbf.registerBeanDefinition(dynamicBeanName, bd);
        Object bean = lbf.getBean(dynamicBeanName);
        String beanName = getBeanName(bean.getClass());
        Object oldBean = null;
        if (beanName != null) {
            oldBean = container.getBean(beanName);
            container.mapBeanName(beanName, dynamicBeanName);
        }
        inject(bean.getClass(), null, bean);
        inject(bean, oldBean);
    } catch (Exception e) {
        logger.warn(e, "重新载入[{}]时发生异常!", name);
    }
}
Also used : DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) BeansException(org.springframework.beans.BeansException)

Example 75 with BeanDefinition

use of org.springframework.beans.factory.config.BeanDefinition in project spring-integration by spring-projects.

the class ExpressionEvaluatingMessageProcessorTests method testProcessMessageWithMethodCallOnBean.

@Test
public void testProcessMessageWithMethodCallOnBean() throws Exception {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinition beanDefinition = new RootBeanDefinition(String.class);
    beanDefinition.getConstructorArgumentValues().addGenericArgumentValue("bar");
    context.registerBeanDefinition(IntegrationContextUtils.INTEGRATION_EVALUATION_CONTEXT_BEAN_NAME, new RootBeanDefinition(IntegrationEvaluationContextFactoryBean.class));
    context.registerBeanDefinition("testString", beanDefinition);
    context.refresh();
    Expression expression = expressionParser.parseExpression("@testString.concat(payload)");
    ExpressionEvaluatingMessageProcessor<String> processor = new ExpressionEvaluatingMessageProcessor<>(expression);
    processor.setBeanFactory(context);
    processor.afterPropertiesSet();
    GenericMessage<String> message = new GenericMessage<>("foo");
    assertEquals("barfoo", processor.processMessage(message));
}
Also used : GenericMessage(org.springframework.messaging.support.GenericMessage) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) Expression(org.springframework.expression.Expression) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) IntegrationEvaluationContextFactoryBean(org.springframework.integration.config.IntegrationEvaluationContextFactoryBean) Test(org.junit.Test)

Aggregations

BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)601 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)188 BeanDefinitionBuilder (org.springframework.beans.factory.support.BeanDefinitionBuilder)116 Test (org.junit.jupiter.api.Test)112 AbstractBeanDefinition (org.springframework.beans.factory.support.AbstractBeanDefinition)89 Element (org.w3c.dom.Element)72 Test (org.junit.Test)66 RuntimeBeanReference (org.springframework.beans.factory.config.RuntimeBeanReference)60 BeanComponentDefinition (org.springframework.beans.factory.parsing.BeanComponentDefinition)53 ClassPathScanningCandidateComponentProvider (org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider)41 ManagedList (org.springframework.beans.factory.support.ManagedList)39 AnnotatedBeanDefinition (org.springframework.beans.factory.annotation.AnnotatedBeanDefinition)36 BeanDefinitionRegistry (org.springframework.beans.factory.support.BeanDefinitionRegistry)35 BeanMetadataElement (org.springframework.beans.BeanMetadataElement)34 MutablePropertyValues (org.springframework.beans.MutablePropertyValues)34 AnnotationTypeFilter (org.springframework.core.type.filter.AnnotationTypeFilter)31 BeanDefinitionHolder (org.springframework.beans.factory.config.BeanDefinitionHolder)30 Method (java.lang.reflect.Method)28 ArrayList (java.util.ArrayList)28 Map (java.util.Map)27