From 7e8f49edbb5cab0651c1183ded61cd6425282999 Mon Sep 17 00:00:00 2001 From: Mark Nellemann Date: Tue, 15 Dec 2020 10:29:54 +0100 Subject: [PATCH] Cleanup. --- build.gradle | 5 ++--- gradle.properties | 2 +- .../syslogd/{SyslogServer.java => Application.java} | 6 +++--- src/main/java/biz/nellemann/syslogd/TcpServer.java | 5 ++--- src/main/java/biz/nellemann/syslogd/UdpServer.java | 6 ++---- 5 files changed, 10 insertions(+), 14 deletions(-) rename src/main/java/biz/nellemann/syslogd/{SyslogServer.java => Application.java} (92%) diff --git a/build.gradle b/build.gradle index 1d6d727..0e3aa21 100644 --- a/build.gradle +++ b/build.gradle @@ -12,9 +12,8 @@ repositories { } dependencies { - compile 'info.picocli:picocli:4.5.2' annotationProcessor 'info.picocli:picocli-codegen:4.5.2' - + implementation 'info.picocli:picocli:4.5.2' implementation 'org.slf4j:slf4j-api:1.7.+' runtimeOnly 'ch.qos.logback:logback-classic:1.+' @@ -23,7 +22,7 @@ dependencies { } application { - mainClassName = 'biz.nellemann.syslogd.SyslogServer' + mainClassName = 'biz.nellemann.syslogd.Application' } test { diff --git a/gradle.properties b/gradle.properties index 7edf4dd..ba840a7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ id = syslogd group = biz.nellemann.syslogd -version = 1.0.5 +version = 1.0.6 diff --git a/src/main/java/biz/nellemann/syslogd/SyslogServer.java b/src/main/java/biz/nellemann/syslogd/Application.java similarity index 92% rename from src/main/java/biz/nellemann/syslogd/SyslogServer.java rename to src/main/java/biz/nellemann/syslogd/Application.java index 30e18c7..bad3e9a 100644 --- a/src/main/java/biz/nellemann/syslogd/SyslogServer.java +++ b/src/main/java/biz/nellemann/syslogd/Application.java @@ -27,9 +27,9 @@ import java.util.concurrent.Callable; mixinStandardHelpOptions = true, description = "Basic syslog server.", versionProvider = biz.nellemann.syslogd.VersionProvider.class) -public class SyslogServer implements Callable, LogListener { +public class Application implements Callable, LogListener { - private final static Logger log = LoggerFactory.getLogger(SyslogServer.class); + private final static Logger log = LoggerFactory.getLogger(Application.class); @CommandLine.Option(names = {"-p", "--port"}, description = "Listening port [default: 514].") private int port = 514; @@ -48,7 +48,7 @@ public class SyslogServer implements Callable, LogListener { public static void main(String... args) { - int exitCode = new CommandLine(new SyslogServer()).execute(args); + int exitCode = new CommandLine(new Application()).execute(args); System.exit(exitCode); } diff --git a/src/main/java/biz/nellemann/syslogd/TcpServer.java b/src/main/java/biz/nellemann/syslogd/TcpServer.java index b31ec6c..bf60454 100644 --- a/src/main/java/biz/nellemann/syslogd/TcpServer.java +++ b/src/main/java/biz/nellemann/syslogd/TcpServer.java @@ -100,9 +100,8 @@ public class TcpServer { private synchronized void sendEvent(String message) { LogEvent event = new LogEvent( this, message ); - Iterator listeners = eventListeners.iterator(); - while( listeners.hasNext() ) { - listeners.next().onLogEvent( event ); + for (LogListener eventListener : eventListeners) { + eventListener.onLogEvent(event); } } diff --git a/src/main/java/biz/nellemann/syslogd/UdpServer.java b/src/main/java/biz/nellemann/syslogd/UdpServer.java index b2b1d67..8e34d71 100644 --- a/src/main/java/biz/nellemann/syslogd/UdpServer.java +++ b/src/main/java/biz/nellemann/syslogd/UdpServer.java @@ -20,7 +20,6 @@ import java.net.DatagramPacket; import java.net.DatagramSocket; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; public class UdpServer extends Thread { @@ -57,9 +56,8 @@ public class UdpServer extends Thread { private synchronized void sendEvent(String message) { LogEvent event = new LogEvent( this, message); - Iterator listeners = eventListeners.iterator(); - while( listeners.hasNext() ) { - listeners.next().onLogEvent( event ); + for (LogListener eventListener : eventListeners) { + eventListener.onLogEvent(event); } }