Search in sources :

Example 56 with RuntimeBeanReference

use of org.springframework.beans.factory.config.RuntimeBeanReference in project spring-framework by spring-projects.

the class MessageBrokerBeanDefinitionParser method registerUserRegistryMessageHandler.

private RuntimeBeanReference registerUserRegistryMessageHandler(RuntimeBeanReference userRegistry, RuntimeBeanReference brokerTemplate, String destination, ParserContext context, Object source) {
    Object scheduler = WebSocketNamespaceUtils.registerScheduler(SCHEDULER_BEAN_NAME, context, source);
    RootBeanDefinition beanDef = new RootBeanDefinition(UserRegistryMessageHandler.class);
    beanDef.getConstructorArgumentValues().addIndexedArgumentValue(0, userRegistry);
    beanDef.getConstructorArgumentValues().addIndexedArgumentValue(1, brokerTemplate);
    beanDef.getConstructorArgumentValues().addIndexedArgumentValue(2, destination);
    beanDef.getConstructorArgumentValues().addIndexedArgumentValue(3, scheduler);
    String beanName = registerBeanDef(beanDef, context, source);
    return new RuntimeBeanReference(beanName);
}
Also used : RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) RuntimeBeanReference(org.springframework.beans.factory.config.RuntimeBeanReference)

Example 57 with RuntimeBeanReference

use of org.springframework.beans.factory.config.RuntimeBeanReference in project spring-framework by spring-projects.

the class MessageBrokerBeanDefinitionParser method registerMessagingTemplate.

private RuntimeBeanReference registerMessagingTemplate(Element element, RuntimeBeanReference brokerChannel, RuntimeBeanReference messageConverter, ParserContext context, Object source) {
    ConstructorArgumentValues cavs = new ConstructorArgumentValues();
    cavs.addIndexedArgumentValue(0, brokerChannel);
    RootBeanDefinition beanDef = new RootBeanDefinition(SimpMessagingTemplate.class, cavs, null);
    if (element.hasAttribute("user-destination-prefix")) {
        beanDef.getPropertyValues().add("userDestinationPrefix", element.getAttribute("user-destination-prefix"));
    }
    beanDef.getPropertyValues().add("messageConverter", messageConverter);
    String name = MESSAGING_TEMPLATE_BEAN_NAME;
    registerBeanDefByName(name, beanDef, context, source);
    return new RuntimeBeanReference(name);
}
Also used : RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) RuntimeBeanReference(org.springframework.beans.factory.config.RuntimeBeanReference) ConstructorArgumentValues(org.springframework.beans.factory.config.ConstructorArgumentValues)

Example 58 with RuntimeBeanReference

use of org.springframework.beans.factory.config.RuntimeBeanReference in project spring-framework by spring-projects.

the class WebSocketNamespaceUtils method registerHandshakeHandler.

public static RuntimeBeanReference registerHandshakeHandler(Element element, ParserContext context, Object source) {
    RuntimeBeanReference handlerRef;
    Element handlerElem = DomUtils.getChildElementByTagName(element, "handshake-handler");
    if (handlerElem != null) {
        handlerRef = new RuntimeBeanReference(handlerElem.getAttribute("ref"));
    } else {
        RootBeanDefinition defaultHandlerDef = new RootBeanDefinition(DefaultHandshakeHandler.class);
        defaultHandlerDef.setSource(source);
        defaultHandlerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
        String handlerName = context.getReaderContext().registerWithGeneratedName(defaultHandlerDef);
        handlerRef = new RuntimeBeanReference(handlerName);
    }
    return handlerRef;
}
Also used : Element(org.w3c.dom.Element) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) RuntimeBeanReference(org.springframework.beans.factory.config.RuntimeBeanReference)

Example 59 with RuntimeBeanReference

use of org.springframework.beans.factory.config.RuntimeBeanReference in project spring-framework by spring-projects.

the class WebSocketNamespaceUtils method registerScheduler.

public static RuntimeBeanReference registerScheduler(String schedulerName, ParserContext context, Object source) {
    if (!context.getRegistry().containsBeanDefinition(schedulerName)) {
        RootBeanDefinition taskSchedulerDef = new RootBeanDefinition(ThreadPoolTaskScheduler.class);
        taskSchedulerDef.setSource(source);
        taskSchedulerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
        taskSchedulerDef.getPropertyValues().add("poolSize", Runtime.getRuntime().availableProcessors());
        taskSchedulerDef.getPropertyValues().add("threadNamePrefix", schedulerName + "-");
        taskSchedulerDef.getPropertyValues().add("removeOnCancelPolicy", true);
        context.getRegistry().registerBeanDefinition(schedulerName, taskSchedulerDef);
        context.registerComponent(new BeanComponentDefinition(taskSchedulerDef, schedulerName));
    }
    return new RuntimeBeanReference(schedulerName);
}
Also used : RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) BeanComponentDefinition(org.springframework.beans.factory.parsing.BeanComponentDefinition) RuntimeBeanReference(org.springframework.beans.factory.config.RuntimeBeanReference)

Example 60 with RuntimeBeanReference

use of org.springframework.beans.factory.config.RuntimeBeanReference in project redisson by redisson.

the class DelayedQueueDecorator method decorate.

@Override
public void decorate(Element element, ParserContext parserContext, BeanDefinitionBuilder builder, RedissonNamespaceParserSupport helper) {
    Assert.state(element.hasAttribute(DESTINATION_QUEUE_REF), "Illegal state. property \"" + DESTINATION_QUEUE_REF + "\" is required in the \"" + helper.getName(element) + "\" element.");
    helper.addConstructorArgs(new RuntimeBeanReference(helper.getAttribute(element, DESTINATION_QUEUE_REF)), RQueue.class, builder);
}
Also used : RuntimeBeanReference(org.springframework.beans.factory.config.RuntimeBeanReference)

Aggregations

RuntimeBeanReference (org.springframework.beans.factory.config.RuntimeBeanReference)156 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)86 Element (org.w3c.dom.Element)47 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)39 BeanComponentDefinition (org.springframework.beans.factory.parsing.BeanComponentDefinition)33 BeanDefinitionBuilder (org.springframework.beans.factory.support.BeanDefinitionBuilder)32 ManagedList (org.springframework.beans.factory.support.ManagedList)27 BeanMetadataElement (org.springframework.beans.BeanMetadataElement)24 Test (org.junit.Test)21 ManagedMap (org.springframework.beans.factory.support.ManagedMap)20 MutablePropertyValues (org.springframework.beans.MutablePropertyValues)16 ConstructorArgumentValues (org.springframework.beans.factory.config.ConstructorArgumentValues)15 GroovyObject (groovy.lang.GroovyObject)12 TestBean (org.springframework.tests.sample.beans.TestBean)12 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)11 Map (java.util.Map)10 Node (org.w3c.dom.Node)10 HashMap (java.util.HashMap)9 CompositeComponentDefinition (org.springframework.beans.factory.parsing.CompositeComponentDefinition)9 ITestBean (org.springframework.tests.sample.beans.ITestBean)8