Merge pull request #285 from garyrussell/INT-2347

* INT-2347:
  INT-2347 Update Channel Mappings Atomically
This commit is contained in:
Mark Fisher
2012-01-03 11:44:53 -05:00

View File

@@ -42,11 +42,12 @@ import org.springframework.util.StringUtils;
* @author Mark Fisher * @author Mark Fisher
* @author Oleg Zhurakousky * @author Oleg Zhurakousky
* @author Gunnar Hillert * @author Gunnar Hillert
* @author Gary Russell
* @since 2.1 * @since 2.1
*/ */
public abstract class AbstractMappingMessageRouter extends AbstractMessageRouter { public abstract class AbstractMappingMessageRouter extends AbstractMessageRouter {
private final Map<String, String> channelMappings = new ConcurrentHashMap<String, String>(); private volatile Map<String, String> channelMappings = new ConcurrentHashMap<String, String>();
private volatile ChannelResolver channelResolver; private volatile ChannelResolver channelResolver;
@@ -62,8 +63,14 @@ public abstract class AbstractMappingMessageRouter extends AbstractMessageRouter
* Channel names will be resolved by the {@link ChannelResolver}. * Channel names will be resolved by the {@link ChannelResolver}.
*/ */
public void setChannelMappings(Map<String, String> channelMappings) { public void setChannelMappings(Map<String, String> channelMappings) {
this.channelMappings.clear(); Map<String, String> oldChannelMappings = this.channelMappings;
this.channelMappings.putAll(channelMappings); Map<String, String> newChannelMappings = new ConcurrentHashMap<String, String>();
newChannelMappings.putAll(channelMappings);
this.channelMappings = newChannelMappings;
if (logger.isDebugEnabled()) {
logger.debug("Channel mappings:" + oldChannelMappings
+ " replaced with:" + newChannelMappings);
}
} }
/** /**