Search in sources :

Example 1 with EmbeddedValueResolver

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

the class CommonAnnotationBeanPostProcessor method setBeanFactory.

@Override
public void setBeanFactory(BeanFactory beanFactory) {
    Assert.notNull(beanFactory, "BeanFactory must not be null");
    this.beanFactory = beanFactory;
    if (this.resourceFactory == null) {
        this.resourceFactory = beanFactory;
    }
    if (beanFactory instanceof ConfigurableBeanFactory) {
        this.embeddedValueResolver = new EmbeddedValueResolver((ConfigurableBeanFactory) beanFactory);
    }
}
Also used : ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) EmbeddedValueResolver(org.springframework.beans.factory.config.EmbeddedValueResolver)

Example 2 with EmbeddedValueResolver

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

the class JmsListenerAnnotationBeanPostProcessor method setBeanFactory.

/**
 * Making a {@link BeanFactory} available is optional; if not set,
 * {@link JmsListenerConfigurer} beans won't get autodetected and an
 * {@link #setEndpointRegistry endpoint registry} has to be explicitly configured.
 */
@Override
public void setBeanFactory(BeanFactory beanFactory) {
    this.beanFactory = beanFactory;
    if (beanFactory instanceof ConfigurableBeanFactory) {
        this.embeddedValueResolver = new EmbeddedValueResolver((ConfigurableBeanFactory) beanFactory);
    }
    this.registrar.setBeanFactory(beanFactory);
}
Also used : ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) EmbeddedValueResolver(org.springframework.beans.factory.config.EmbeddedValueResolver)

Example 3 with EmbeddedValueResolver

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

the class MessageMappingMessageHandlerTests method initMesssageHandler.

private MessageMappingMessageHandler initMesssageHandler() {
    List<Decoder<?>> decoders = Collections.singletonList(StringDecoder.allMimeTypes());
    List<Encoder<?>> encoders = Collections.singletonList(CharSequenceEncoder.allMimeTypes());
    ReactiveAdapterRegistry registry = ReactiveAdapterRegistry.getSharedInstance();
    this.returnValueHandler = new TestEncoderMethodReturnValueHandler(encoders, registry);
    PropertySource<?> source = new MapPropertySource("test", Collections.singletonMap("path", "path123"));
    StaticApplicationContext context = new StaticApplicationContext();
    context.getEnvironment().getPropertySources().addFirst(source);
    context.registerSingleton("testController", TestController.class);
    context.refresh();
    MessageMappingMessageHandler messageHandler = new MessageMappingMessageHandler();
    messageHandler.getReturnValueHandlerConfigurer().addCustomHandler(this.returnValueHandler);
    messageHandler.setApplicationContext(context);
    messageHandler.setEmbeddedValueResolver(new EmbeddedValueResolver(context.getBeanFactory()));
    messageHandler.setDecoders(decoders);
    messageHandler.afterPropertiesSet();
    return messageHandler;
}
Also used : TestEncoderMethodReturnValueHandler(org.springframework.messaging.handler.invocation.reactive.TestEncoderMethodReturnValueHandler) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) CharSequenceEncoder(org.springframework.core.codec.CharSequenceEncoder) Encoder(org.springframework.core.codec.Encoder) MapPropertySource(org.springframework.core.env.MapPropertySource) ReactiveAdapterRegistry(org.springframework.core.ReactiveAdapterRegistry) EmbeddedValueResolver(org.springframework.beans.factory.config.EmbeddedValueResolver) Decoder(org.springframework.core.codec.Decoder) StringDecoder(org.springframework.core.codec.StringDecoder)

Aggregations

EmbeddedValueResolver (org.springframework.beans.factory.config.EmbeddedValueResolver)3 ConfigurableBeanFactory (org.springframework.beans.factory.config.ConfigurableBeanFactory)2 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)1 ReactiveAdapterRegistry (org.springframework.core.ReactiveAdapterRegistry)1 CharSequenceEncoder (org.springframework.core.codec.CharSequenceEncoder)1 Decoder (org.springframework.core.codec.Decoder)1 Encoder (org.springframework.core.codec.Encoder)1 StringDecoder (org.springframework.core.codec.StringDecoder)1 MapPropertySource (org.springframework.core.env.MapPropertySource)1 TestEncoderMethodReturnValueHandler (org.springframework.messaging.handler.invocation.reactive.TestEncoderMethodReturnValueHandler)1