org.springframework.beans.factory.config.EmbeddedValueResolver Java Examples

The following examples show how to use org.springframework.beans.factory.config.EmbeddedValueResolver. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MessageMappingMessageHandlerTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
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;
	}
 
Example #2
Source File: CommonAnnotationBeanPostProcessor.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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);
	}
}
 
Example #3
Source File: KafkaChannelDefinitionProcessor.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
    this.beanFactory = beanFactory;
    if (beanFactory instanceof ConfigurableListableBeanFactory) {
        this.embeddedValueResolver = new EmbeddedValueResolver((ConfigurableBeanFactory) beanFactory);
        this.resolver = ((ConfigurableListableBeanFactory) beanFactory).getBeanExpressionResolver();
        this.expressionContext = new BeanExpressionContext((ConfigurableListableBeanFactory) beanFactory, null);
    }
}
 
Example #4
Source File: JmsListenerAnnotationBeanPostProcessor.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * 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);
}
 
Example #5
Source File: MethodJmsListenerEndpoint.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Set the {@link BeanFactory} to use to resolve expressions (may be {@code null}).
 */
@Override
public void setBeanFactory(@Nullable BeanFactory beanFactory) {
	if (this.embeddedValueResolver == null && beanFactory instanceof ConfigurableBeanFactory) {
		this.embeddedValueResolver = new EmbeddedValueResolver((ConfigurableBeanFactory) beanFactory);
	}
}
 
Example #6
Source File: RabbitChannelDefinitionProcessor.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
    this.beanFactory = beanFactory;
    if (beanFactory instanceof ConfigurableListableBeanFactory) {
        this.embeddedValueResolver = new EmbeddedValueResolver((ConfigurableBeanFactory) beanFactory);
        this.resolver = ((ConfigurableListableBeanFactory) beanFactory).getBeanExpressionResolver();
        this.expressionContext = new BeanExpressionContext((ConfigurableListableBeanFactory) beanFactory, null);
    }
}
 
Example #7
Source File: CommonAnnotationBeanPostProcessor.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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);
	}
}
 
Example #8
Source File: JmsChannelModelProcessor.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
    this.beanFactory = beanFactory;
    if (beanFactory instanceof ConfigurableBeanFactory) {
        this.embeddedValueResolver = new EmbeddedValueResolver((ConfigurableBeanFactory) beanFactory);
    }
}
 
Example #9
Source File: JmsListenerAnnotationBeanPostProcessor.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * 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);
}
 
Example #10
Source File: MethodJmsListenerEndpoint.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Set the {@link BeanFactory} to use to resolve expressions (may be {@code null}).
 */
@Override
public void setBeanFactory(@Nullable BeanFactory beanFactory) {
	if (this.embeddedValueResolver == null && beanFactory instanceof ConfigurableBeanFactory) {
		this.embeddedValueResolver = new EmbeddedValueResolver((ConfigurableBeanFactory) beanFactory);
	}
}
 
Example #11
Source File: CommonAnnotationBeanPostProcessor.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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);
	}
}
 
Example #12
Source File: SpelResolverTest.java    From resilience4j with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    sut = new SpelResolver(new SpelExpressionParser(), new StandardReflectionParameterNameDiscoverer());
    sut.setEmbeddedValueResolver(new EmbeddedValueResolver(configurableBeanFactory));
}
 
Example #13
Source File: ExpressionResolver.java    From spring-data-cosmosdb with MIT License 4 votes vote down vote up
private static void setEmbeddedValueResolver(EmbeddedValueResolver embeddedValueResolver) {
    ExpressionResolver.embeddedValueResolver = embeddedValueResolver;
}
 
Example #14
Source File: ExpressionResolver.java    From spring-data-cosmosdb with MIT License 4 votes vote down vote up
public ExpressionResolver(BeanFactory beanFactory) {
    if (beanFactory instanceof ConfigurableBeanFactory) {
        setEmbeddedValueResolver(new EmbeddedValueResolver((ConfigurableBeanFactory) beanFactory));
    }
}
 
Example #15
Source File: ApplicationContextAwareProcessor.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a new ApplicationContextAwareProcessor for the given context.
 */
public ApplicationContextAwareProcessor(ConfigurableApplicationContext applicationContext) {
	this.applicationContext = applicationContext;
	this.embeddedValueResolver = new EmbeddedValueResolver(applicationContext.getBeanFactory());
}
 
Example #16
Source File: AnnotationJmxAttributeSource.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void setBeanFactory(BeanFactory beanFactory) {
	if (beanFactory instanceof ConfigurableBeanFactory) {
		this.embeddedValueResolver = new EmbeddedValueResolver((ConfigurableBeanFactory) beanFactory);
	}
}
 
Example #17
Source File: ApplicationContextAwareProcessor.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Create a new ApplicationContextAwareProcessor for the given context.
 */
public ApplicationContextAwareProcessor(ConfigurableApplicationContext applicationContext) {
	this.applicationContext = applicationContext;
	this.embeddedValueResolver = new EmbeddedValueResolver(applicationContext.getBeanFactory());
}
 
Example #18
Source File: AnnotationJmxAttributeSource.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public void setBeanFactory(BeanFactory beanFactory) {
	if (beanFactory instanceof ConfigurableBeanFactory) {
		this.embeddedValueResolver = new EmbeddedValueResolver((ConfigurableBeanFactory) beanFactory);
	}
}
 
Example #19
Source File: ApplicationContextAwareProcessor.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Create a new ApplicationContextAwareProcessor for the given context.
 */
public ApplicationContextAwareProcessor(ConfigurableApplicationContext applicationContext) {
	this.applicationContext = applicationContext;
	this.embeddedValueResolver = new EmbeddedValueResolver(applicationContext.getBeanFactory());
}
 
Example #20
Source File: AnnotationJmxAttributeSource.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public void setBeanFactory(BeanFactory beanFactory) {
	if (beanFactory instanceof ConfigurableBeanFactory) {
		this.embeddedValueResolver = new EmbeddedValueResolver((ConfigurableBeanFactory) beanFactory);
	}
}