INT-1619 removed cycle by moving SocketIoUtils into the util package

This commit is contained in:
Mark Fisher
2010-11-13 23:43:04 -05:00
parent a2dfe9d069
commit bc10b621e3
6 changed files with 16 additions and 19 deletions

View File

@@ -21,8 +21,8 @@ import java.net.SocketTimeoutException;
import org.springframework.core.serializer.Deserializer;
import org.springframework.integration.Message;
import org.springframework.integration.ip.tcp.SocketIoUtils;
import org.springframework.integration.ip.tcp.serializer.SoftEndOfStreamException;
import org.springframework.integration.ip.util.SocketIoUtils;
/**
* A TcpConnection that uses and underlying {@link Socket}.

View File

@@ -30,8 +30,8 @@ import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import org.springframework.integration.Message;
import org.springframework.integration.ip.tcp.SocketIoUtils;
import org.springframework.integration.ip.tcp.serializer.SoftEndOfStreamException;
import org.springframework.integration.ip.util.SocketIoUtils;
/**
* A TcpConnection that uses and underlying {@link SocketChannel}.

View File

@@ -56,8 +56,7 @@ import org.springframework.util.Assert;
* @author Dave Syer
* @since 2.0
*/
public class DatagramPacketMessageMapper implements InboundMessageMapper<DatagramPacket>,
OutboundMessageMapper<DatagramPacket> {
public class DatagramPacketMessageMapper implements InboundMessageMapper<DatagramPacket>, OutboundMessageMapper<DatagramPacket> {
private volatile String charset = "UTF-8";
@@ -68,9 +67,9 @@ public class DatagramPacketMessageMapper implements InboundMessageMapper<Datagra
private boolean lengthCheck = false;
private static Pattern udpHeadersPattern =
Pattern.compile(RegexUtils.escapeRegExSpecials(IpHeaders.ACK_ADDRESS) +
Pattern.compile(RegexUtils.escapeRegexSpecials(IpHeaders.ACK_ADDRESS) +
"=" + "([^;]*);" +
RegexUtils.escapeRegExSpecials(MessageHeaders.ID) +
RegexUtils.escapeRegexSpecials(MessageHeaders.ID) +
"=" + "([^;]*);");

View File

@@ -20,7 +20,7 @@ package org.springframework.integration.ip.util;
* Regular Expression Utilities.
*
* @author Gary Russell
*
* @since 2.0
*/
public abstract class RegexUtils {
@@ -32,7 +32,7 @@ public abstract class RegexUtils {
* @param stringToEscape The string to escape.
* @return The escaped string.
*/
public static String escapeRegExSpecials(String stringToEscape) {
public static String escapeRegexSpecials(String stringToEscape) {
// In the following, we look for all the specials and any we find
// are escaped in the output string, allowing that string to
// be used as a pattern containing the literal specials.

View File

@@ -13,16 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.ip.tcp;
package org.springframework.integration.ip.util;
import java.net.InetAddress;
import java.net.Socket;
/**
* @author Gary Russell
*
* @since 2.0
*/
public class SocketIoUtils {
public abstract class SocketIoUtils {
public static String getSocketId(Socket socket) {
InetAddress inetAddress = socket.getInetAddress();
@@ -30,8 +31,7 @@ public class SocketIoUtils {
if (inetAddress != null) {
hostName = inetAddress.getHostName();
}
return hostName + ":" + socket.getPort() + ":" +
socket.hashCode();
return hostName + ":" + socket.getPort() + ":" + socket.hashCode();
}
}

View File

@@ -17,10 +17,10 @@
package org.springframework.integration.ip.util;
import static org.junit.Assert.assertEquals;
import static org.springframework.integration.ip.util.RegexUtils.escapeRegExSpecials;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.integration.MessageHeaders;
/**
@@ -34,8 +34,7 @@ public class RegexUtilsTests {
@Test
public void testRegex () {
String s = "xxx$^[]{()}+*\\?|.xxx";
assertEquals("xxx\\$\\^\\[\\]\\{\\(\\)\\}\\+\\*\\\\\\?\\|\\.xxx",
escapeRegExSpecials(s));
assertEquals("xxx\\$\\^\\[\\]\\{\\(\\)\\}\\+\\*\\\\\\?\\|\\.xxx", RegexUtils.escapeRegexSpecials(s));
}
/**
@@ -46,8 +45,7 @@ public class RegexUtilsTests {
public void testSiPrefix () {
// protect the test in case we ever change the prefix
if ("$^[]{()}+*\\?|.".contains(MessageHeaders.PREFIX)) {
assertEquals(escapeRegExSpecials(MessageHeaders.PREFIX), "\\"
+ MessageHeaders.PREFIX);
assertEquals(RegexUtils.escapeRegexSpecials(MessageHeaders.PREFIX), "\\" + MessageHeaders.PREFIX);
}
}