/** * Gets the hostname of the current machine. * <p> * Gets the value from the cache if possible otherwise calls {@link #updateCache()}. * * @return the hostname of the current machine. */ public String getHostname() { if (expirationTimestamp < System.currentTimeMillis()) { updateCache(); } return hostname; }
/** * Sets default values for each field that hasn't been provided manually. * * @param event currently handled event. */ private static void autoSetMissingValues(Event event) { // Ensure that a timestamp is set (to now at least!) if (event.getTimestamp() == null) event.setTimestamp(new Date()); // Ensure that a platform is set if (event.getPlatform() == null) event.setPlatform(DEFAULT_PLATFORM); // Ensure that a hostname is set if (event.getServerName() == null) event.setServerName(HOSTNAME_CACHE.getHostname()); }