INT-1257, INT-1263 Refactoring Message History (work in progress): removed MessageHistory and MessageHistoryEvent, moved MessageHistoryWriter and NamedComponent to the 'context' package.

This commit is contained in:
Mark Fisher
2010-08-25 14:20:30 +00:00
parent d98ff8eaa1
commit 220538ec08
14 changed files with 14 additions and 253 deletions

View File

@@ -37,6 +37,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.config.ConsumerEndpointFactoryBean;
import org.springframework.integration.context.MessageHistoryWriter;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.MessageHandler;

View File

@@ -1,81 +0,0 @@
/*
* Copyright 2002-2010 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.history;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
/**
* @author Oleg Zhurakousky
* @since 2.0
*/
public class MessageHistoryTests {
private long times = 1000;
private ExecutorService executor = Executors.newCachedThreadPool();
@Test
public void testConcurrentModificationsOnObjectMethods() throws Exception{
final MessageHistory history = new MessageHistory();
final MessageHistory otherHistory = new MessageHistory();
final NamedComponent component = new NamedComponent() {
public String getComponentType() {
return "testType";
}
public String getComponentName() {
return "testName";
}
};
executor.execute(new Runnable() {
public void run() {
for (int i = 0; i < times; i++) {
history.addEvent(component);
otherHistory.addEvent(component);
}
}
});
executor.execute(new Runnable() {
public void run() {
for (int i = 0; i < times; i++) {
history.toString();
}
}
});
executor.execute(new Runnable() {
public void run() {
for (int i = 0; i < times; i++) {
history.hashCode();
}
}
});
executor.execute(new Runnable() {
public void run() {
for (int i = 0; i < times; i++) {
history.equals(new Object());
}
}
});
executor.shutdown();
executor.awaitTermination(3, TimeUnit.SECONDS);
}
}

View File

@@ -5,6 +5,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd">
<bean class="org.springframework.integration.history.MessageHistoryWriter"/>
<bean class="org.springframework.integration.history.MessageHistoryWriter"/>
<bean class="org.springframework.integration.context.MessageHistoryWriter"/>
<bean class="org.springframework.integration.context.MessageHistoryWriter"/>
</beans>

View File

@@ -30,5 +30,5 @@
<int:channel id="endOfThePipeChannel"/>
<bean class="org.springframework.integration.history.MessageHistoryWriter"/>
<bean class="org.springframework.integration.context.MessageHistoryWriter"/>
</beans>

View File

@@ -38,11 +38,11 @@ import org.springframework.integration.MessageRejectedException;
import org.springframework.integration.channel.MessagePublishingErrorHandler;
import org.springframework.integration.context.BeanFactoryChannelResolver;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.endpoint.AbstractEndpoint;
import org.springframework.integration.endpoint.AbstractPollingEndpoint;
import org.springframework.integration.history.NamedComponent;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.support.PeriodicTrigger;
import org.springframework.util.Assert;