INT-4381: MessageSources refactoring (#2517)

* INT-4381: MessageSources refactoring

JIRA: https://jira.spring.io/browse/INT-4381

* Make all the out-of-the-box `MessageSource` implementations based
on the `AbstractMessageSource`
* Fix `JdbcPollingChannelAdapterIntegrationTests` for sporadic failure
because of `fixed-rate` for the poller

* Fix HeaderEnricherTests race condition

The `errorChannel()` expect an error in the `testErrorChannel` after
`1000` ms, but at the same time the `poller` in configured for the
`3000` ms.

* Increase all the timeouts for replies
* Decrease a `fixed-delay` on the `poller`
* Some other code style polishing for the `HeaderEnricherTests`
This commit is contained in:
Artem Bilan
2018-07-25 13:01:22 -04:00
committed by Gary Russell
parent d6c8baf50f
commit 0d0605be78
28 changed files with 207 additions and 319 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -68,8 +68,7 @@ public class MethodInvokingMessageSource extends AbstractMessageSource<Object>
}
@Override
public void afterPropertiesSet() throws Exception {
super.afterPropertiesSet();
protected void onInit() {
synchronized (this.initializationMonitor) {
if (this.initialized) {
return;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,6 +39,8 @@ import org.springframework.util.ObjectUtils;
* @author Oleg Zhurakousky
* @author Mark Fisher
* @author Gary Russell
* @author Artem Bilan
*
* @since 2.1
*/
public class ResourceRetrievingMessageSource extends AbstractMessageSource<Resource[]>
@@ -79,8 +81,7 @@ public class ResourceRetrievingMessageSource extends AbstractMessageSource<Resou
@Override
public void afterPropertiesSet() throws Exception {
super.afterPropertiesSet();
protected void onInit() {
if (this.patternResolver == null) {
this.patternResolver = this.applicationContext;
}
@@ -100,7 +101,7 @@ public class ResourceRetrievingMessageSource extends AbstractMessageSource<Resou
resources = null;
}
else {
resources = filteredResources.toArray(new Resource[filteredResources.size()]);
resources = filteredResources.toArray(new Resource[0]);
}
}
return resources;

View File

@@ -88,11 +88,13 @@ public abstract class AbstractExpressionEvaluator implements BeanFactoryAware, I
}
@Override
public void afterPropertiesSet() throws Exception {
public final void afterPropertiesSet() throws Exception {
getEvaluationContext();
if (this.beanFactory != null) {
this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(this.beanFactory);
}
onInit();
}
protected StandardEvaluationContext getEvaluationContext() {
@@ -169,4 +171,8 @@ public abstract class AbstractExpressionEvaluator implements BeanFactoryAware, I
return expression.getValue(this.getEvaluationContext(), input, expectedType);
}
protected void onInit() {
}
}