Search in sources :

Example 16 with ConfigurableBeanFactory

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

the class AbstractBeanFactoryTests method aliasing.

// TODO: refactor in AbstractBeanFactory (tests for AbstractBeanFactory)
// and rename this class
@Test
public void aliasing() {
    BeanFactory bf = getBeanFactory();
    if (!(bf instanceof ConfigurableBeanFactory)) {
        return;
    }
    ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) bf;
    String alias = "rods alias";
    try {
        cbf.getBean(alias);
        fail("Shouldn't permit factory get on normal bean");
    } catch (NoSuchBeanDefinitionException ex) {
        // Ok
        assertTrue(alias.equals(ex.getBeanName()));
    }
    // Create alias
    cbf.registerAlias("rod", alias);
    Object rod = getBeanFactory().getBean("rod");
    Object aliasRod = getBeanFactory().getBean(alias);
    assertTrue(rod == aliasRod);
}
Also used : ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) BeanFactory(org.springframework.beans.factory.BeanFactory) ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) NoSuchBeanDefinitionException(org.springframework.beans.factory.NoSuchBeanDefinitionException) Test(org.junit.Test)

Example 17 with ConfigurableBeanFactory

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

the class SimpAnnotationMethodMessageHandler method initArgumentResolvers.

protected List<HandlerMethodArgumentResolver> initArgumentResolvers() {
    ConfigurableBeanFactory beanFactory = (getApplicationContext() instanceof ConfigurableApplicationContext ? ((ConfigurableApplicationContext) getApplicationContext()).getBeanFactory() : null);
    List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>();
    // Annotation-based argument resolution
    resolvers.add(new HeaderMethodArgumentResolver(this.conversionService, beanFactory));
    resolvers.add(new HeadersMethodArgumentResolver());
    resolvers.add(new DestinationVariableMethodArgumentResolver(this.conversionService));
    // Type-based argument resolution
    resolvers.add(new PrincipalMethodArgumentResolver());
    resolvers.add(new MessageMethodArgumentResolver(this.messageConverter));
    resolvers.addAll(getCustomArgumentResolvers());
    resolvers.add(new PayloadArgumentResolver(this.messageConverter, this.validator));
    return resolvers;
}
Also used : ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) HeadersMethodArgumentResolver(org.springframework.messaging.handler.annotation.support.HeadersMethodArgumentResolver) ArrayList(java.util.ArrayList) HeaderMethodArgumentResolver(org.springframework.messaging.handler.annotation.support.HeaderMethodArgumentResolver) MessageMethodArgumentResolver(org.springframework.messaging.handler.annotation.support.MessageMethodArgumentResolver) HandlerMethodArgumentResolver(org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver) PayloadArgumentResolver(org.springframework.messaging.handler.annotation.support.PayloadArgumentResolver) DestinationVariableMethodArgumentResolver(org.springframework.messaging.handler.annotation.support.DestinationVariableMethodArgumentResolver)

Example 18 with ConfigurableBeanFactory

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

the class DefaultMessageHandlerMethodFactory method initArgumentResolvers.

protected List<HandlerMethodArgumentResolver> initArgumentResolvers() {
    List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>();
    ConfigurableBeanFactory cbf = (this.beanFactory instanceof ConfigurableBeanFactory ? (ConfigurableBeanFactory) this.beanFactory : null);
    // Annotation-based argument resolution
    resolvers.add(new HeaderMethodArgumentResolver(this.conversionService, cbf));
    resolvers.add(new HeadersMethodArgumentResolver());
    // Type-based argument resolution
    resolvers.add(new MessageMethodArgumentResolver(this.messageConverter));
    if (this.customArgumentResolvers != null) {
        resolvers.addAll(this.customArgumentResolvers);
    }
    resolvers.add(new PayloadArgumentResolver(this.messageConverter, this.validator));
    return resolvers;
}
Also used : ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) ArrayList(java.util.ArrayList) HandlerMethodArgumentResolver(org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver)

Aggregations

ConfigurableBeanFactory (org.springframework.beans.factory.config.ConfigurableBeanFactory)18 ArrayList (java.util.ArrayList)3 NoSuchBeanDefinitionException (org.springframework.beans.factory.NoSuchBeanDefinitionException)3 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)3 PostConstruct (javax.annotation.PostConstruct)2 ProxyFactory (org.springframework.aop.framework.ProxyFactory)2 BeanFactory (org.springframework.beans.factory.BeanFactory)2 EmbeddedValueResolver (org.springframework.beans.factory.config.EmbeddedValueResolver)2 AbstractBeanDefinition (org.springframework.beans.factory.support.AbstractBeanDefinition)2 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)2 HandlerMethodArgumentResolver (org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver)2 AnnotatedElement (java.lang.reflect.AnnotatedElement)1 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 WebService (javax.jws.WebService)1 Endpoint (javax.xml.ws.Endpoint)1 WebServiceProvider (javax.xml.ws.WebServiceProvider)1 HystrixConfigurationCommon (org.apache.camel.model.HystrixConfigurationCommon)1