diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2013-09-25 22:47:15 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2013-09-25 22:47:15 +1200 |
commit | c1b6fb0e25020b845b059aef0adebeac7d90ed7c (patch) | |
tree | bf52439140ecd372ff2e6a7c0aab634059c6aa46 | |
parent | e9f466d5169fbbdea0e780a3a7b8221481035ec3 (diff) | |
download | traccar-server-c1b6fb0e25020b845b059aef0adebeac7d90ed7c.tar.gz traccar-server-c1b6fb0e25020b845b059aef0adebeac7d90ed7c.tar.bz2 traccar-server-c1b6fb0e25020b845b059aef0adebeac7d90ed7c.zip |
Small refactoring
-rw-r--r-- | src/org/traccar/Main.java | 29 | ||||
-rw-r--r-- | src/org/traccar/geocode/GoogleReverseGeocoder.java | 9 | ||||
-rw-r--r-- | src/org/traccar/geocode/ReverseGeocoder.java | 8 | ||||
-rw-r--r-- | src/org/traccar/helper/Log.java | 27 |
4 files changed, 31 insertions, 42 deletions
diff --git a/src/org/traccar/Main.java b/src/org/traccar/Main.java index 144ad1ec7..b7ae3e924 100644 --- a/src/org/traccar/Main.java +++ b/src/org/traccar/Main.java @@ -15,38 +15,11 @@ */ package org.traccar; -import java.lang.management.ManagementFactory; -import java.lang.management.MemoryMXBean; -import java.lang.management.OperatingSystemMXBean; -import java.lang.management.RuntimeMXBean; import java.util.Locale; import org.traccar.helper.Log; public class Main { - private static void printSystemInfo() { - try { - OperatingSystemMXBean operatingSystemBean = ManagementFactory.getOperatingSystemMXBean(); - Log.info("Operating System" + - " name: " + operatingSystemBean.getName() + - " version: " + operatingSystemBean.getVersion() + - " architecture: " + operatingSystemBean.getArch()); - - RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean(); - Log.info("Java Runtime" + - " name: " + runtimeBean.getVmName() + - " vendor: " + runtimeBean.getVmVendor() + - " version: " + runtimeBean.getVmVersion()); - - MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean(); - Log.info("Memory Limit" + - " heap: " + memoryBean.getHeapMemoryUsage().getMax() / (1024 * 1024) + "mb" + - " non-heap: " + memoryBean.getNonHeapMemoryUsage().getMax() / (1024 * 1024) + "mb"); - } catch (Exception e) { - Log.warning("Failed to get system info"); - } - } - public static void main(String[] args) throws Exception { Locale.setDefault(Locale.ENGLISH); @@ -54,7 +27,7 @@ public class Main { service.init(args); Log.info("Starting server..."); - printSystemInfo(); + Log.logSystemInfo(); service.start(); diff --git a/src/org/traccar/geocode/GoogleReverseGeocoder.java b/src/org/traccar/geocode/GoogleReverseGeocoder.java index 1e61eb6ee..9aebbf8a0 100644 --- a/src/org/traccar/geocode/GoogleReverseGeocoder.java +++ b/src/org/traccar/geocode/GoogleReverseGeocoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,16 +23,11 @@ import java.nio.charset.Charset; import org.traccar.helper.Log; -/** - * Reverse geocoder implementation using Google - */ public class GoogleReverseGeocoder implements ReverseGeocoder { private final static String MARKER = "\"formatted_address\" : \""; - /** - * Get address string by coordinates - */ + @Override public String getAddress(double latitude, double longitude) { try { diff --git a/src/org/traccar/geocode/ReverseGeocoder.java b/src/org/traccar/geocode/ReverseGeocoder.java index d8ea5d7ab..67ce68ac2 100644 --- a/src/org/traccar/geocode/ReverseGeocoder.java +++ b/src/org/traccar/geocode/ReverseGeocoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,14 +15,8 @@ */ package org.traccar.geocode; -/** - * Reverse geocoder interface - */ public interface ReverseGeocoder { - /** - * Get address string by coordinates - */ public String getAddress(double latitude, double longitude); } diff --git a/src/org/traccar/helper/Log.java b/src/org/traccar/helper/Log.java index d14a7b0bb..a5e9f7594 100644 --- a/src/org/traccar/helper/Log.java +++ b/src/org/traccar/helper/Log.java @@ -16,6 +16,10 @@ package org.traccar.helper; import java.io.IOException; +import java.lang.management.ManagementFactory; +import java.lang.management.MemoryMXBean; +import java.lang.management.OperatingSystemMXBean; +import java.lang.management.RuntimeMXBean; import java.util.Properties; import org.apache.log4j.Appender; import org.apache.log4j.DailyRollingFileAppender; @@ -63,6 +67,29 @@ public class Log { return logger; } + public static void logSystemInfo() { + try { + OperatingSystemMXBean operatingSystemBean = ManagementFactory.getOperatingSystemMXBean(); + Log.info("Operating System" + + " name: " + operatingSystemBean.getName() + + " version: " + operatingSystemBean.getVersion() + + " architecture: " + operatingSystemBean.getArch()); + + RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean(); + Log.info("Java Runtime" + + " name: " + runtimeBean.getVmName() + + " vendor: " + runtimeBean.getVmVendor() + + " version: " + runtimeBean.getVmVersion()); + + MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean(); + Log.info("Memory Limit" + + " heap: " + memoryBean.getHeapMemoryUsage().getMax() / (1024 * 1024) + "mb" + + " non-heap: " + memoryBean.getNonHeapMemoryUsage().getMax() / (1024 * 1024) + "mb"); + } catch (Exception e) { + Log.warning("Failed to get system info"); + } + } + public static void error(String msg) { getLogger().error(msg); } |