INT-2830 Resolve Class Tangle

* MessageGroupStore <-> MessageGroupCallback
  - Change callback to be an inner interface of the MGS.
* INT-2829 Fix Class Tangle in IP Module
  - 3 way tangle between TcpSender, TcpConnection, TcpMessageMapper
  - Clean up interfaces (remove setters); add top-level support classes for TcpConnection, TcpConnectionInterceptor.
* INT-2829 Remove TCP Package Tangle
  - tcp.connection <-> tcp.connection.support
  - Remove ...connection.support package - move classes to ...connection.
This commit is contained in:
Gary Russell
2013-01-03 12:53:29 -05:00
committed by Gunnar Hillert
parent f88a97332a
commit 91722b7a5f
43 changed files with 243 additions and 274 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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
@@ -31,8 +31,8 @@ import org.springframework.integration.core.MessageProducer;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.integration.handler.AbstractMessageHandler;
import org.springframework.integration.store.MessageGroup;
import org.springframework.integration.store.MessageGroupCallback;
import org.springframework.integration.store.MessageGroupStore;
import org.springframework.integration.store.MessageGroupStore.MessageGroupCallback;
import org.springframework.integration.store.MessageStore;
import org.springframework.integration.store.SimpleMessageGroup;
import org.springframework.integration.store.SimpleMessageStore;

View File

@@ -1,30 +0,0 @@
/*
* Copyright 2002-2012 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.store;
/**
* Invoked when a MessageGroupStore expires a group.
* <p/>
* <strong>Note: This interface will become an inner interface of
* MessageGroupStore in release 3.0.</strong>
* @author Dave Syer
*
* @since 2.0
*
*/
public interface MessageGroupCallback {
void execute(MessageGroupStore messageGroupStore, MessageGroup group);
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2002-2011 the original author or authors.
*
* Copyright 2002-2013 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.
@@ -19,19 +19,20 @@ import org.springframework.jmx.export.annotation.ManagedAttribute;
/**
* Interface for storage operations on groups of messages linked by a group id.
*
*
* @author Dave Syer
* @author Oleg Zhurakousky
*
* @author Gary Russell
*
* @since 2.0
*
*
*/
public interface MessageGroupStore {
/**
* Optional attribute giving the number of messages in the store over all groups. Implementations may decline to
* respond by throwing an exception.
*
*
* @return the number of messages
* @throws UnsupportedOperationException if not implemented
*/
@@ -40,13 +41,13 @@ public interface MessageGroupStore {
/**
* Optional attribute giving the number of message groups. Implementations may decline
* to respond by throwing an exception.
*
*
* @return the number message groups
* @throws UnsupportedOperationException if not implemented
*/
@ManagedAttribute
int getMessageGroupCount();
/**
* Returns the size of this MessageGroup
* @param groupId
@@ -57,19 +58,19 @@ public interface MessageGroupStore {
/**
* Return all Messages currently in the MessageStore that were stored using
* {@link #addMessageToGroup(Object, Message)} with this group id.
*
*
* @return a group of messages, empty if none exists for this key
*/
MessageGroup getMessageGroup(Object groupId);
/**
* Store a message with an association to a group id. This can be used to group messages together.
*
*
* @param groupId the group id to store the message under
* @param message a message
*/
MessageGroup addMessageToGroup(Object groupId, Message<?> message);
/**
* Persist a deletion on a single message from the group. The group is modified to reflect that 'messageToRemove' is
* no longer present in the group.
@@ -80,14 +81,14 @@ public interface MessageGroupStore {
/**
* Remove the message group with this id.
*
*
* @param groupId the id of the group to remove
*/
void removeMessageGroup(Object groupId);
/**
* Register a callback for when a message group is expired through {@link #expireMessageGroups(long)}.
*
*
* @param callback a callback to execute when a message group is cleaned up
*/
void registerMessageGroupExpiryCallback(MessageGroupCallback callback);
@@ -97,36 +98,46 @@ public interface MessageGroupStore {
* each of the registered callbacks on them in turn. For example: call with a timeout of 100 to expire all groups
* that were created more than 100 milliseconds ago, and are not yet complete. Use a timeout of 0 (or negative to be
* on the safe side) to expire all message groups.
*
*
* @param timeout the timeout threshold to use
* @return the number of message groups expired
*
*
* @see #registerMessageGroupExpiryCallback(MessageGroupCallback)
*/
int expireMessageGroups(long timeout);
/**
* Allows you to set the sequence number of the last released Message. Used for Resequencing use cases
* @param sequenceNumber
*/
void setLastReleasedSequenceNumberForGroup(Object groupId, int sequenceNumber);
/**
* Returns the iterator of currently accumulated {@link MessageGroup}s
*/
Iterator<MessageGroup> iterator();
/**
* Polls Message from this {@link MessageGroup} (in FIFO style if supported by the implementation)
* while also removing the polled {@link Message}
*/
Message<?> pollMessageFromGroup(Object groupId);
/**
* Completes this MessageGroup. Completion of the MessageGroup generally means
* that this group should not be allowing any more mutating operation to be performed on it.
* Completes this MessageGroup. Completion of the MessageGroup generally means
* that this group should not be allowing any more mutating operation to be performed on it.
* For example any attempt to add/remove new Message form the group should not be allowed.
*/
void completeGroup(Object groupId);
/**
* Invoked when a MessageGroupStore expires a group.
*/
public interface MessageGroupCallback {
void execute(MessageGroupStore messageGroupStore, MessageGroup group);
}
}

View File

@@ -24,6 +24,7 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.store.MessageGroupStore.MessageGroupCallback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -31,6 +32,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
* @author Dave Syer
* @author Dave Turanski
* @author Artem Bilan
* @author Gary Russell
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2013 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.
@@ -16,6 +16,8 @@
package org.springframework.integration.store;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -23,22 +25,21 @@ import java.util.Iterator;
import java.util.List;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.store.MessageGroupStore.MessageGroupCallback;
import org.springframework.test.util.ReflectionTestUtils;
import static org.junit.Assert.assertEquals;
/**
* @author Dave Syer
* @author Gary Russell
*/
public class MessageStoreTests {
@Test
public void shouldRegisterCallbacks() throws Exception {
TestMessageStore store = new TestMessageStore();
store.setExpiryCallbacks(Arrays.<MessageGroupCallback> asList(new MessageGroupCallback() {
store.setExpiryCallbacks(Arrays.<MessageGroupCallback> asList(new MessageGroupStore.MessageGroupCallback() {
public void execute(MessageGroupStore messageGroupStore, MessageGroup group) {
}
}));
@@ -81,8 +82,8 @@ public class MessageStoreTests {
MessageGroup testMessages = new SimpleMessageGroup(Arrays.asList(new GenericMessage<String>("foo")), "bar");
private boolean removed = false;
public Iterator<MessageGroup> iterator() {
return Arrays.asList(testMessages).iterator();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2013 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.
@@ -29,12 +29,14 @@ import java.util.List;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.MessagingException;
import org.springframework.integration.store.MessageGroupStore.MessageGroupCallback;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.test.util.ReflectionTestUtils;
/**
* @author Iwein Fuld
* @author Dave Syer
* @author Gary Russell
*/
public class SimpleMessageStoreTests {
@@ -116,7 +118,7 @@ public class SimpleMessageStoreTests {
@Test
public void shouldRegisterCallbacks() throws Exception {
SimpleMessageStore store = new SimpleMessageStore();
store.setExpiryCallbacks(Arrays.<MessageGroupCallback> asList(new MessageGroupCallback() {
store.setExpiryCallbacks(Arrays.<MessageGroupCallback> asList(new MessageGroupStore.MessageGroupCallback() {
public void execute(MessageGroupStore messageGroupStore, MessageGroup group) {
}
}));