Search in sources :

Example 71 with BeanComponentDefinition

use of org.springframework.beans.factory.parsing.BeanComponentDefinition in project spring-framework by spring-projects.

the class JeeNamespaceHandlerEventTests method testRemoteSlsbComponentEventReceived.

@Test
public void testRemoteSlsbComponentEventReceived() {
    ComponentDefinition component = this.eventListener.getComponentDefinition("simpleRemoteEjb");
    assertTrue(component instanceof BeanComponentDefinition);
}
Also used : BeanComponentDefinition(org.springframework.beans.factory.parsing.BeanComponentDefinition) ComponentDefinition(org.springframework.beans.factory.parsing.ComponentDefinition) BeanComponentDefinition(org.springframework.beans.factory.parsing.BeanComponentDefinition) Test(org.junit.Test)

Example 72 with BeanComponentDefinition

use of org.springframework.beans.factory.parsing.BeanComponentDefinition in project spring-framework by spring-projects.

the class JeeNamespaceHandlerEventTests method testJndiLookupComponentEventReceived.

@Test
public void testJndiLookupComponentEventReceived() {
    ComponentDefinition component = this.eventListener.getComponentDefinition("simple");
    assertTrue(component instanceof BeanComponentDefinition);
}
Also used : BeanComponentDefinition(org.springframework.beans.factory.parsing.BeanComponentDefinition) ComponentDefinition(org.springframework.beans.factory.parsing.ComponentDefinition) BeanComponentDefinition(org.springframework.beans.factory.parsing.BeanComponentDefinition) Test(org.junit.Test)

Example 73 with BeanComponentDefinition

use of org.springframework.beans.factory.parsing.BeanComponentDefinition in project spring-framework by spring-projects.

the class SpringConfiguredBeanDefinitionParser method parse.

@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
    if (!parserContext.getRegistry().containsBeanDefinition(BEAN_CONFIGURER_ASPECT_BEAN_NAME)) {
        RootBeanDefinition def = new RootBeanDefinition();
        def.setBeanClassName(BEAN_CONFIGURER_ASPECT_CLASS_NAME);
        def.setFactoryMethodName("aspectOf");
        def.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
        def.setSource(parserContext.extractSource(element));
        parserContext.registerBeanComponent(new BeanComponentDefinition(def, BEAN_CONFIGURER_ASPECT_BEAN_NAME));
    }
    return null;
}
Also used : RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) BeanComponentDefinition(org.springframework.beans.factory.parsing.BeanComponentDefinition)

Example 74 with BeanComponentDefinition

use of org.springframework.beans.factory.parsing.BeanComponentDefinition in project jetcache by alibaba.

the class CacheAnnotationParser method doParse.

private synchronized void doParse(Element element, ParserContext parserContext) {
    String[] basePackages = StringUtils.tokenizeToStringArray(element.getAttribute("base-package"), ",; \t\n");
    AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element);
    if (!parserContext.getRegistry().containsBeanDefinition(CacheAdvisor.CACHE_ADVISOR_BEAN_NAME)) {
        Object eleSource = parserContext.extractSource(element);
        RootBeanDefinition configMapDef = new RootBeanDefinition(ConcurrentHashMap.class);
        configMapDef.setSource(eleSource);
        configMapDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
        String configMapName = parserContext.getReaderContext().registerWithGeneratedName(configMapDef);
        RootBeanDefinition interceptorDef = new RootBeanDefinition(JetCacheInterceptor.class);
        interceptorDef.setSource(eleSource);
        interceptorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
        interceptorDef.getPropertyValues().addPropertyValue(new PropertyValue("cacheConfigMap", new RuntimeBeanReference(configMapName)));
        String interceptorName = parserContext.getReaderContext().registerWithGeneratedName(interceptorDef);
        RootBeanDefinition advisorDef = new RootBeanDefinition(CacheAdvisor.class);
        advisorDef.setSource(eleSource);
        advisorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
        advisorDef.getPropertyValues().addPropertyValue(new PropertyValue("adviceBeanName", interceptorName));
        advisorDef.getPropertyValues().addPropertyValue(new PropertyValue("cacheConfigMap", new RuntimeBeanReference(configMapName)));
        advisorDef.getPropertyValues().addPropertyValue(new PropertyValue("basePackages", basePackages));
        parserContext.getRegistry().registerBeanDefinition(CacheAdvisor.CACHE_ADVISOR_BEAN_NAME, advisorDef);
        CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), eleSource);
        compositeDef.addNestedComponent(new BeanComponentDefinition(configMapDef, configMapName));
        compositeDef.addNestedComponent(new BeanComponentDefinition(interceptorDef, interceptorName));
        compositeDef.addNestedComponent(new BeanComponentDefinition(advisorDef, CacheAdvisor.CACHE_ADVISOR_BEAN_NAME));
        parserContext.registerComponent(compositeDef);
    }
}
Also used : CompositeComponentDefinition(org.springframework.beans.factory.parsing.CompositeComponentDefinition) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) PropertyValue(org.springframework.beans.PropertyValue) BeanComponentDefinition(org.springframework.beans.factory.parsing.BeanComponentDefinition) RuntimeBeanReference(org.springframework.beans.factory.config.RuntimeBeanReference)

Aggregations

BeanComponentDefinition (org.springframework.beans.factory.parsing.BeanComponentDefinition)74 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)50 RuntimeBeanReference (org.springframework.beans.factory.config.RuntimeBeanReference)32 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)23 BeanDefinitionBuilder (org.springframework.beans.factory.support.BeanDefinitionBuilder)18 CompositeComponentDefinition (org.springframework.beans.factory.parsing.CompositeComponentDefinition)15 Element (org.w3c.dom.Element)15 BeanMetadataElement (org.springframework.beans.BeanMetadataElement)10 BeanDefinitionHolder (org.springframework.beans.factory.config.BeanDefinitionHolder)10 ManagedList (org.springframework.beans.factory.support.ManagedList)9 Test (org.junit.Test)7 ComponentDefinition (org.springframework.beans.factory.parsing.ComponentDefinition)7 ManagedMap (org.springframework.beans.factory.support.ManagedMap)4 BeanDefinitionStoreException (org.springframework.beans.factory.BeanDefinitionStoreException)3 Method (java.lang.reflect.Method)2 MutablePropertyValues (org.springframework.beans.MutablePropertyValues)2 PropertyValue (org.springframework.beans.PropertyValue)2 BeanReference (org.springframework.beans.factory.config.BeanReference)2 AbstractBeanDefinition (org.springframework.beans.factory.support.AbstractBeanDefinition)2 AuthenticatedVoter (org.springframework.security.access.vote.AuthenticatedVoter)2