Rename SocketAddresses to NetworkConstants

This commit is contained in:
Trustin Lee 2012-06-09 08:44:56 +09:00
parent 86cf144b8a
commit 5661bff062
6 changed files with 16 additions and 16 deletions

View File

@ -24,13 +24,13 @@ import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Enumeration;
public final class SocketAddresses {
public final class NetworkConstants {
public static final InetAddress LOCALHOST;
public static final NetworkInterface LOOPBACK_IF;
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(SocketAddresses.class);
InternalLoggerFactory.getInstance(NetworkConstants.class);
static {
// We cache this because some machine takes almost forever to return
@ -80,7 +80,7 @@ public final class SocketAddresses {
LOOPBACK_IF = loopbackIf;
}
private SocketAddresses() {
private NetworkConstants() {
// Unused
}
}

View File

@ -20,7 +20,7 @@ import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import io.netty.testsuite.transport.socket.SocketTestPermutation.Factory;
import io.netty.testsuite.util.TestUtils;
import io.netty.util.SocketAddresses;
import io.netty.util.NetworkConstants;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@ -51,7 +51,7 @@ public abstract class AbstractDatagramTest {
sb = e.getKey().newInstance();
cb = e.getValue().newInstance();
addr = new InetSocketAddress(
SocketAddresses.LOCALHOST, TestUtils.getFreePort());
NetworkConstants.LOCALHOST, TestUtils.getFreePort());
sb.localAddress(addr);
cb.localAddress(0).remoteAddress(addr);

View File

@ -21,7 +21,7 @@ import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import io.netty.testsuite.transport.socket.SocketTestPermutation.Factory;
import io.netty.testsuite.util.TestUtils;
import io.netty.util.SocketAddresses;
import io.netty.util.NetworkConstants;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@ -52,7 +52,7 @@ public abstract class AbstractSocketTest {
sb = e.getKey().newInstance();
cb = e.getValue().newInstance();
addr = new InetSocketAddress(
SocketAddresses.LOCALHOST, TestUtils.getFreePort());
NetworkConstants.LOCALHOST, TestUtils.getFreePort());
sb.localAddress(addr);
cb.remoteAddress(addr);

View File

@ -24,7 +24,7 @@ import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.channel.ChannelOption;
import io.netty.channel.socket.DatagramChannel;
import io.netty.channel.socket.DatagramPacket;
import io.netty.util.SocketAddresses;
import io.netty.util.NetworkConstants;
import java.net.InetSocketAddress;
import java.util.concurrent.CountDownLatch;
@ -54,9 +54,9 @@ public class DatagramMulticastTest extends AbstractDatagramTest {
cb.handler(mhandler);
sb.option(ChannelOption.IP_MULTICAST_IF, SocketAddresses.LOOPBACK_IF);
sb.option(ChannelOption.IP_MULTICAST_IF, NetworkConstants.LOOPBACK_IF);
sb.option(ChannelOption.SO_REUSEADDR, true);
cb.option(ChannelOption.IP_MULTICAST_IF, SocketAddresses.LOOPBACK_IF);
cb.option(ChannelOption.IP_MULTICAST_IF, NetworkConstants.LOOPBACK_IF);
cb.option(ChannelOption.SO_REUSEADDR, true);
cb.localAddress(addr.getPort());
@ -66,13 +66,13 @@ public class DatagramMulticastTest extends AbstractDatagramTest {
String group = "230.0.0.1";
InetSocketAddress groupAddress = new InetSocketAddress(group, addr.getPort());
cc.joinGroup(groupAddress, SocketAddresses.LOOPBACK_IF).sync();
cc.joinGroup(groupAddress, NetworkConstants.LOOPBACK_IF).sync();
sc.write(new DatagramPacket(ChannelBuffers.copyInt(1), groupAddress)).sync();
assertTrue(mhandler.await());
// leave the group
cc.leaveGroup(groupAddress, SocketAddresses.LOOPBACK_IF).sync();
cc.leaveGroup(groupAddress, NetworkConstants.LOOPBACK_IF).sync();
// sleep a second to make sure we left the group
Thread.sleep(1000);

View File

@ -29,7 +29,7 @@ import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.spdy.SpdyConstants;
import io.netty.handler.codec.spdy.SpdyFrameDecoder;
import io.netty.handler.codec.spdy.SpdyFrameEncoder;
import io.netty.util.SocketAddresses;
import io.netty.util.NetworkConstants;
import java.io.IOException;
import java.net.InetSocketAddress;
@ -197,7 +197,7 @@ public class SocketSpdyEchoTest extends AbstractSocketTest {
Channel sc = sb.localAddress(0).bind().sync().channel();
int port = ((InetSocketAddress) sc.localAddress()).getPort();
Channel cc = cb.remoteAddress(SocketAddresses.LOCALHOST, port).connect().sync().channel();
Channel cc = cb.remoteAddress(NetworkConstants.LOCALHOST, port).connect().sync().channel();
cc.write(frames);
while (ch.counter < frames.writerIndex() - ignoredBytes) {

View File

@ -29,7 +29,7 @@ import io.netty.channel.EventLoop;
import io.netty.channel.ServerChannel;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import io.netty.util.SocketAddresses;
import io.netty.util.NetworkConstants;
import java.net.InetAddress;
import java.net.InetSocketAddress;
@ -43,7 +43,7 @@ import java.util.Queue;
public class ServerBootstrap {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(ServerBootstrap.class);
private static final InetSocketAddress DEFAULT_LOCAL_ADDR = new InetSocketAddress(SocketAddresses.LOCALHOST, 0);
private static final InetSocketAddress DEFAULT_LOCAL_ADDR = new InetSocketAddress(NetworkConstants.LOCALHOST, 0);
private final ChannelHandler acceptor = new ChannelInitializer<Channel>() {
@Override