From 8f669f059b6857c04f430f9072683c4f2af63bfd Mon Sep 17 00:00:00 2001 From: Major- Date: Fri, 8 Aug 2014 03:33:03 +0100 Subject: [PATCH] Change many log messages to the fine level. --- src/org/apollo/Server.java | 11 ++++++----- src/org/apollo/ServiceManager.java | 26 ++++++++++++++------------ src/org/apollo/game/model/World.java | 12 ++++++------ 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/org/apollo/Server.java b/src/org/apollo/Server.java index b691b492..af3ac9a0 100644 --- a/src/org/apollo/Server.java +++ b/src/org/apollo/Server.java @@ -44,6 +44,7 @@ public final class Server { */ public static void main(String[] args) { try { + long start = System.currentTimeMillis(); Server server = new Server(); server.init(args.length == 1 ? args[0] : Release317.class.getName()); @@ -53,6 +54,7 @@ public final class Server { server.start(); server.bind(service, http, jaggrab); + logger.fine("Starting apollo took " + (System.currentTimeMillis() - start) + " ms."); } catch (Throwable t) { logger.log(Level.SEVERE, "Error whilst starting server.", t); } @@ -86,7 +88,7 @@ public final class Server { /** * The service manager. */ - private final ServiceManager serviceManager; + private final ServiceManager serviceManager = new ServiceManager(); /** * Creates the Apollo server. @@ -95,7 +97,6 @@ public final class Server { */ public Server() throws Exception { logger.info("Starting Apollo..."); - serviceManager = new ServiceManager(); } /** @@ -106,10 +107,10 @@ public final class Server { * @param jagGrabAddress The JAGGRAB address to bind to. */ public void bind(SocketAddress serviceAddress, SocketAddress httpAddress, SocketAddress jagGrabAddress) { - logger.info("Binding service listener to address: " + serviceAddress + "..."); + logger.fine("Binding service listener to address: " + serviceAddress + "..."); serviceBootstrap.bind(serviceAddress); - logger.info("Binding HTTP listener to address: " + httpAddress + "..."); + logger.fine("Binding HTTP listener to address: " + httpAddress + "..."); try { httpBootstrap.bind(httpAddress); } catch (Throwable t) { @@ -117,7 +118,7 @@ public final class Server { "Binding to HTTP failed: client will use JAGGRAB as a fallback (not recommended)!", t); } - logger.info("Binding JAGGRAB listener to address: " + jagGrabAddress + "..."); + logger.fine("Binding JAGGRAB listener to address: " + jagGrabAddress + "..."); jagGrabBootstrap.bind(jagGrabAddress); logger.info("Ready for connections."); diff --git a/src/org/apollo/ServiceManager.java b/src/org/apollo/ServiceManager.java index 9828a1a6..1aaa724b 100644 --- a/src/org/apollo/ServiceManager.java +++ b/src/org/apollo/ServiceManager.java @@ -26,14 +26,16 @@ public final class ServiceManager { /** * The service map. */ - private Map, Service> services = new HashMap, Service>(); + private Map, Service> services = new HashMap<>(); /** * Creates and initializes the {@link ServiceManager}. * - * @throws Exception If an error occurs. + * @throws IOException If there is an error reading from the xml file. + * @throws SAXException If there is an error parsing the xml file. + * @throws ReflectiveOperationException If there is an error accessing or creating services using reflection. */ - public ServiceManager() throws Exception { + public ServiceManager() throws IOException, SAXException, ReflectiveOperationException { init(); } @@ -61,30 +63,30 @@ public final class ServiceManager { @SuppressWarnings("unchecked") private void init() throws SAXException, IOException, InstantiationException, IllegalAccessException, ClassNotFoundException { - logger.info("Registering services..."); + logger.fine("Registering services..."); XmlParser parser = new XmlParser(); - XmlNode rootNode; + XmlNode root; try (InputStream is = new FileInputStream("data/services.xml")) { - rootNode = parser.parse(is); + root = parser.parse(is); } - if (!rootNode.getName().equals("services")) { + if (!root.getName().equals("services")) { throw new IOException("Unexpected name of root node."); } - for (XmlNode childNode : rootNode) { - if (!childNode.getName().equals("service")) { + for (XmlNode child : root) { + if (!child.getName().equals("service")) { throw new IOException("Unexpected name of child node."); } - if (!childNode.hasValue()) { + if (!child.hasValue()) { throw new IOException("Child node must have a value."); } - Class clazz = (Class) Class.forName(childNode.getValue()); - register((Class) clazz, clazz.newInstance()); + Class service = (Class) Class.forName(child.getValue()); + register((Class) service, service.newInstance()); } } diff --git a/src/org/apollo/game/model/World.java b/src/org/apollo/game/model/World.java index 01f0edde..16507d03 100644 --- a/src/org/apollo/game/model/World.java +++ b/src/org/apollo/game/model/World.java @@ -10,10 +10,10 @@ import java.util.logging.Logger; import org.apollo.Service; import org.apollo.fs.IndexedFileSystem; +import org.apollo.fs.decoder.GameObjectDecoder; import org.apollo.fs.decoder.ItemDefinitionDecoder; import org.apollo.fs.decoder.NpcDefinitionDecoder; import org.apollo.fs.decoder.ObjectDefinitionDecoder; -import org.apollo.fs.decoder.GameObjectDecoder; import org.apollo.game.command.CommandDispatcher; import org.apollo.game.login.LoginDispatcher; import org.apollo.game.login.LogoutDispatcher; @@ -241,29 +241,29 @@ public final class World { ItemDefinitionDecoder itemDefDecoder = new ItemDefinitionDecoder(fs); ItemDefinition[] itemDefs = itemDefDecoder.decode(); ItemDefinition.init(itemDefs); - logger.info("Loaded " + itemDefs.length + " item definitions."); + logger.fine("Loaded " + itemDefs.length + " item definitions."); try (InputStream is = new BufferedInputStream(new FileInputStream("data/equipment-" + release + ".dat"))) { EquipmentDefinitionParser parser = new EquipmentDefinitionParser(is); EquipmentDefinition[] defs = parser.parse(); EquipmentDefinition.init(defs); - logger.info("Loaded " + defs.length + " equipment definitions."); + logger.fine("Loaded " + defs.length + " equipment definitions."); } NpcDefinitionDecoder npcDecoder = new NpcDefinitionDecoder(fs); NpcDefinition[] npcDefs = npcDecoder.decode(); NpcDefinition.init(npcDefs); - logger.info("Loaded " + npcDefs.length + " npc definitions."); + logger.fine("Loaded " + npcDefs.length + " npc definitions."); ObjectDefinitionDecoder objectDecoder = new ObjectDefinitionDecoder(fs); ObjectDefinition[] objDefs = objectDecoder.decode(); ObjectDefinition.init(objDefs); - logger.info("Loaded " + objDefs.length + " object definitions."); + logger.fine("Loaded " + objDefs.length + " object definitions."); GameObjectDecoder staticDecoder = new GameObjectDecoder(fs); GameObject[] objects = staticDecoder.decode(); placeEntities(objects); - logger.info("Loaded " + objects.length + " static objects."); + logger.fine("Loaded " + objects.length + " static objects."); manager.start(); pluginManager = manager; // TODO move!!