INT-1639 Externalize SpEL Evaluation Context

Allow modification of context property accessors and
functions.

Polishing

- Fix tests to ensure the EvaluationContextFactoryBean is
available when necessary.

Polishing - Use Utility for ALL EvaluationContexts

Add Test Showing Custom Function

See SpelTransformerIntegrationTests-context.xml

Polishing

Polishing -fix Remote Sync

Polishing - Emit WARN if No BeanFactory

Polishing - Do Not Override ConversionService

Kludge to Prevent Warning When No BeanFactory

Expressions for method invoking in the MessagingMethodInvokerHelper
don't need a BeanFactory - suppress the warning.

Polishing - PR Comments - Invert Boolean
This commit is contained in:
Gary Russell
2013-08-21 15:05:21 -04:00
committed by Mark Fisher
parent 351af6b16b
commit 7f008b58c2
53 changed files with 983 additions and 360 deletions

View File

@@ -39,6 +39,7 @@ import org.springframework.context.event.ContextClosedEvent;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.ContextStartedEvent;
import org.springframework.context.event.ContextStoppedEvent;
import org.springframework.context.event.SimpleApplicationEventMulticaster;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
@@ -138,9 +139,24 @@ public class ApplicationEventListeningMessageProducerTests {
ApplicationEventListeningMessageProducer adapter = new ApplicationEventListeningMessageProducer();
adapter.setPayloadExpression("'received: ' + source");
adapter.setOutputChannel(channel);
adapter.start();
GenericApplicationContext ctx = TestUtils.createTestApplicationContext();
ConfigurableListableBeanFactory beanFactory = ctx.getBeanFactory();
beanFactory.registerSingleton(AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME,
new SimpleApplicationEventMulticaster(beanFactory));
adapter.setBeanFactory(beanFactory);
beanFactory.registerSingleton("testListenerMessageProducer", adapter);
adapter.afterPropertiesSet();
ctx.refresh();
Message<?> message1 = channel.receive(0);
assertNull(message1);
// ContextRefreshedEvent
assertNotNull(message1);
assertTrue(message1.getPayload().toString()
.contains("org.springframework.integration.test.util.TestUtils$TestApplicationContext"));
adapter.onApplicationEvent(new TestApplicationEvent1());
adapter.onApplicationEvent(new TestApplicationEvent2());
Message<?> message2 = channel.receive(20);