Search in sources :

Example 21 with AbstractBeanDefinition

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

the class MyPostProcessor method postProcessBeanFactory.

@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    AbstractBeanDefinition bd = (AbstractBeanDefinition) beanFactory.getBeanDefinition("someDependency");
    bd.setDescription("post processed by MyPostProcessor");
}
Also used : AbstractBeanDefinition(org.springframework.beans.factory.support.AbstractBeanDefinition)

Example 22 with AbstractBeanDefinition

use of org.springframework.beans.factory.support.AbstractBeanDefinition in project spring-security-oauth by spring-projects.

the class ProviderBeanDefinitionParser method parseInternal.

@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
    String tokenServicesRef = element.getAttribute("token-services-ref");
    String serializerRef = element.getAttribute("serialization-service-ref");
    if (!StringUtils.hasText(tokenServicesRef)) {
        tokenServicesRef = "oauth2TokenServices";
        BeanDefinitionBuilder tokenServices = BeanDefinitionBuilder.rootBeanDefinition(DefaultTokenServices.class);
        AbstractBeanDefinition tokenStore = BeanDefinitionBuilder.rootBeanDefinition(InMemoryTokenStore.class).getBeanDefinition();
        tokenServices.addPropertyValue("tokenStore", tokenStore);
        parserContext.getRegistry().registerBeanDefinition(tokenServicesRef, tokenServices.getBeanDefinition());
    }
    return parseEndpointAndReturnFilter(element, parserContext, tokenServicesRef, serializerRef);
}
Also used : InMemoryTokenStore(org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore) BeanDefinitionBuilder(org.springframework.beans.factory.support.BeanDefinitionBuilder) AbstractBeanDefinition(org.springframework.beans.factory.support.AbstractBeanDefinition)

Example 23 with AbstractBeanDefinition

use of org.springframework.beans.factory.support.AbstractBeanDefinition in project grails-core by grails.

the class GenericBeanFactoryAccessor method findAnnotationOnBean.

/**
     * Find a {@link Annotation} of <code>annotationType</code> on the specified
     * bean, traversing its interfaces and super classes if no annotation can be
     * found on the given class itself, as well as checking its raw bean class
     * if not found on the exposed bean reference (e.g. in case of a proxy).
     * @param beanName the name of the bean to look for annotations on
     * @param annotationType the annotation class to look for
     * @return the annotation of the given type found, or <code>null</code>
     * @see org.springframework.core.annotation.AnnotationUtils#findAnnotation(Class, Class)
     */
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType) {
    Class<?> handlerType = beanFactory.getType(beanName);
    A ann = AnnotationUtils.findAnnotation(handlerType, annotationType);
    if (ann == null && beanFactory instanceof ConfigurableBeanFactory && beanFactory.containsBeanDefinition(beanName)) {
        ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory;
        BeanDefinition bd = cbf.getMergedBeanDefinition(beanName);
        if (bd instanceof AbstractBeanDefinition) {
            AbstractBeanDefinition abd = (AbstractBeanDefinition) bd;
            if (abd.hasBeanClass()) {
                Class<?> beanClass = abd.getBeanClass();
                ann = AnnotationUtils.findAnnotation(beanClass, annotationType);
            }
        }
    }
    return ann;
}
Also used : ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) AbstractBeanDefinition(org.springframework.beans.factory.support.AbstractBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) AbstractBeanDefinition(org.springframework.beans.factory.support.AbstractBeanDefinition)

Example 24 with AbstractBeanDefinition

use of org.springframework.beans.factory.support.AbstractBeanDefinition in project ignite by apache.

the class GridFactorySelfTest method getTestApplicationContext.

/**
     * Gets test Spring application context with single {@link StringBuilder} bean
     * with name "myBean" and value "Test string".
     *
     * @return Spring application context.
     */
private ApplicationContext getTestApplicationContext() {
    AbstractBeanDefinition def = new GenericBeanDefinition();
    def.setBeanClass(StringBuilder.class);
    ConstructorArgumentValues args = new ConstructorArgumentValues();
    args.addGenericArgumentValue("Test string");
    def.setConstructorArgumentValues(args);
    GenericApplicationContext ctx = new GenericApplicationContext();
    ctx.registerBeanDefinition("myBean", def);
    return ctx;
}
Also used : GenericBeanDefinition(org.springframework.beans.factory.support.GenericBeanDefinition) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) AbstractBeanDefinition(org.springframework.beans.factory.support.AbstractBeanDefinition) ConstructorArgumentValues(org.springframework.beans.factory.config.ConstructorArgumentValues)

Example 25 with AbstractBeanDefinition

use of org.springframework.beans.factory.support.AbstractBeanDefinition in project elastic-job by dangdangdotcom.

the class AbstractJobBeanDefinitionParser method parseInternal.

@Override
protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
    BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(SpringJobScheduler.class);
    factory.setInitMethodName("init");
    factory.setDestroyMethodName("shutdown");
    if ("".equals(element.getAttribute(CLASS_ATTRIBUTE))) {
        factory.addConstructorArgValue(null);
    } else {
        factory.addConstructorArgValue(BeanDefinitionBuilder.rootBeanDefinition(element.getAttribute(CLASS_ATTRIBUTE)).getBeanDefinition());
    }
    factory.addConstructorArgReference(element.getAttribute(REGISTRY_CENTER_REF_ATTRIBUTE));
    factory.addConstructorArgValue(createLiteJobConfiguration(element));
    BeanDefinition jobEventConfig = createJobEventConfig(element);
    if (null != jobEventConfig) {
        factory.addConstructorArgValue(jobEventConfig);
    }
    factory.addConstructorArgValue(createJobListeners(element));
    return factory.getBeanDefinition();
}
Also used : BeanDefinitionBuilder(org.springframework.beans.factory.support.BeanDefinitionBuilder) AbstractBeanDefinition(org.springframework.beans.factory.support.AbstractBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition)

Aggregations

AbstractBeanDefinition (org.springframework.beans.factory.support.AbstractBeanDefinition)44 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)13 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)13 Test (org.junit.Test)10 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)9 BeanDefinitionBuilder (org.springframework.beans.factory.support.BeanDefinitionBuilder)7 BeanDefinitionHolder (org.springframework.beans.factory.config.BeanDefinitionHolder)6 ConstructorArgumentValues (org.springframework.beans.factory.config.ConstructorArgumentValues)5 BeanDefinitionStoreException (org.springframework.beans.factory.BeanDefinitionStoreException)4 RuntimeBeanReference (org.springframework.beans.factory.config.RuntimeBeanReference)4 BeanWrapperImpl (org.springframework.beans.BeanWrapperImpl)3 AnnotatedBeanDefinition (org.springframework.beans.factory.annotation.AnnotatedBeanDefinition)3 GenericBeanDefinition (org.springframework.beans.factory.support.GenericBeanDefinition)3 ArrayList (java.util.ArrayList)2 BeanCreationException (org.springframework.beans.factory.BeanCreationException)2 ConfigurableBeanFactory (org.springframework.beans.factory.config.ConfigurableBeanFactory)2 BeanDefinitionRegistry (org.springframework.beans.factory.support.BeanDefinitionRegistry)2 ChildBeanDefinition (org.springframework.beans.factory.support.ChildBeanDefinition)2 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1