From 02a3170382cd26514b81f38157f313c13abdcaab Mon Sep 17 00:00:00 2001 From: Major- Date: Sat, 1 Aug 2015 14:17:39 +0100 Subject: [PATCH] Implement toString for Release. --- game/src/main/org/apollo/Server.java | 56 +++++++++---------- .../main/org/apollo/net/release/Release.java | 5 ++ 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/game/src/main/org/apollo/Server.java b/game/src/main/org/apollo/Server.java index 6f0246b9..41673ecd 100644 --- a/game/src/main/org/apollo/Server.java +++ b/game/src/main/org/apollo/Server.java @@ -72,7 +72,7 @@ public final class Server { /** * The {@link ServerBootstrap} for the JAGGRAB listener. */ - private final ServerBootstrap jagGrabBootstrap = new ServerBootstrap(); + private final ServerBootstrap jaggrabBootstrap = new ServerBootstrap(); /** * The {@link ServerBootstrap} for the service listener. @@ -94,22 +94,22 @@ public final class Server { /** * Binds the server to the specified address. * - * @param serviceAddress The service address to bind to. - * @param httpAddress The HTTP address to bind to. - * @param jagGrabAddress The JAGGRAB address to bind to. + * @param service The service address to bind to. + * @param http The HTTP address to bind to. + * @param jaggrab The JAGGRAB address to bind to. */ - public void bind(SocketAddress serviceAddress, SocketAddress httpAddress, SocketAddress jagGrabAddress) { + public void bind(SocketAddress service, SocketAddress http, SocketAddress jaggrab) { try { - logger.fine("Binding service listener to address: " + serviceAddress + "..."); - serviceBootstrap.bind(serviceAddress).sync(); + logger.fine("Binding service listener to address: " + service + "..."); + serviceBootstrap.bind(service).sync(); - logger.fine("Binding HTTP listener to address: " + httpAddress + "..."); - httpBootstrap.bind(httpAddress).sync(); + logger.fine("Binding HTTP listener to address: " + http + "..."); + httpBootstrap.bind(http).sync(); - logger.fine("Binding JAGGRAB listener to address: " + jagGrabAddress + "..."); - jagGrabBootstrap.bind(jagGrabAddress).sync(); - } catch (InterruptedException e) { - logger.log(Level.SEVERE, "Binding to a port failed: ensure apollo isn't already running.", e); + logger.fine("Binding JAGGRAB listener to address: " + jaggrab + "..."); + jaggrabBootstrap.bind(jaggrab).sync(); + } catch (InterruptedException exception) { + logger.log(Level.SEVERE, "Binding to a port failed: ensure apollo isn't already running.", exception); System.exit(1); } @@ -119,42 +119,42 @@ public final class Server { /** * Initialises the server. * - * @param releaseClassName The class name of the current active {@link Release}. + * @param releaseName The class name of the current active {@link Release}. * @throws Exception If an error occurs. */ - public void init(String releaseClassName) throws Exception { - Class clazz = Class.forName(releaseClassName); + public void init(String releaseName) throws Exception { + Class clazz = Class.forName(releaseName); Release release = (Release) clazz.newInstance(); - int releaseNo = release.getReleaseNumber(); + int version = release.getReleaseNumber(); - logger.info("Initialized release #" + releaseNo + "."); + logger.info("Initialized " + release + "."); serviceBootstrap.group(loopGroup); httpBootstrap.group(loopGroup); - jagGrabBootstrap.group(loopGroup); + jaggrabBootstrap.group(loopGroup); World world = new World(); ServiceManager services = new ServiceManager(world); - IndexedFileSystem fs = new IndexedFileSystem(Paths.get("data/fs", Integer.toString(releaseNo)), true); + IndexedFileSystem fs = new IndexedFileSystem(Paths.get("data/fs", Integer.toString(version)), true); ServerContext context = new ServerContext(release, services, fs); ApolloHandler handler = new ApolloHandler(context); - ChannelInitializer serviceInitializer = new ServiceChannelInitializer(handler); + ChannelInitializer service = new ServiceChannelInitializer(handler); serviceBootstrap.channel(NioServerSocketChannel.class); - serviceBootstrap.childHandler(serviceInitializer); + serviceBootstrap.childHandler(service); - ChannelInitializer httpInitializer = new HttpChannelInitializer(handler); + ChannelInitializer http = new HttpChannelInitializer(handler); httpBootstrap.channel(NioServerSocketChannel.class); - httpBootstrap.childHandler(httpInitializer); + httpBootstrap.childHandler(http); - ChannelInitializer jagGrabInitializer = new JagGrabChannelInitializer(handler); - jagGrabBootstrap.channel(NioServerSocketChannel.class); - jagGrabBootstrap.childHandler(jagGrabInitializer); + ChannelInitializer jaggrab = new JagGrabChannelInitializer(handler); + jaggrabBootstrap.channel(NioServerSocketChannel.class); + jaggrabBootstrap.childHandler(jaggrab); PluginManager manager = new PluginManager(world, new PluginContext(context)); services.startAll(); - world.init(releaseNo, fs, manager); + world.init(version, fs, manager); } } \ No newline at end of file diff --git a/net/src/main/org/apollo/net/release/Release.java b/net/src/main/org/apollo/net/release/Release.java index 09f7ccb3..e1fee4f7 100644 --- a/net/src/main/org/apollo/net/release/Release.java +++ b/net/src/main/org/apollo/net/release/Release.java @@ -111,4 +111,9 @@ public abstract class Release { decoders[opcode] = decoder; } + @Override + public final String toString() { + return Release.class.getSimpleName() + " " + releaseNumber; + } + } \ No newline at end of file