aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/ServerManager.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2022-01-15 23:20:48 -0800
committerGitHub <noreply@github.com>2022-01-15 23:20:48 -0800
commit4f30409c3bf1c2ea70823eb45bdf43bc5a4b6ad1 (patch)
treeecdad61979167b4fc605ba2ec4420709b5c1b0fd /src/main/java/org/traccar/ServerManager.java
parent839751e76e329adb573150644bd6198beba0d3b6 (diff)
parent0ce163ba62cc991fee56d9c05fca41c9f7a28143 (diff)
downloadtrackermap-server-4f30409c3bf1c2ea70823eb45bdf43bc5a4b6ad1.tar.gz
trackermap-server-4f30409c3bf1c2ea70823eb45bdf43bc5a4b6ad1.tar.bz2
trackermap-server-4f30409c3bf1c2ea70823eb45bdf43bc5a4b6ad1.zip
Merge pull request #4797 from traccar/polling
Implement polling protocol support
Diffstat (limited to 'src/main/java/org/traccar/ServerManager.java')
-rw-r--r--src/main/java/org/traccar/ServerManager.java19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/ServerManager.java b/src/main/java/org/traccar/ServerManager.java
index 935a821aa..0db786bdb 100644
--- a/src/main/java/org/traccar/ServerManager.java
+++ b/src/main/java/org/traccar/ServerManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2020 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2022 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@ import org.traccar.config.Keys;
import java.io.File;
import java.io.IOException;
import java.net.BindException;
+import java.net.ConnectException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
@@ -39,7 +40,7 @@ public class ServerManager {
private static final Logger LOGGER = LoggerFactory.getLogger(ServerManager.class);
- private final List<TrackerServer> serverList = new LinkedList<>();
+ private final List<TrackerConnector> connectorList = new LinkedList<>();
private final Map<String, BaseProtocol> protocolList = new ConcurrentHashMap<>();
private void loadPackage(String packageName) throws IOException, URISyntaxException, ReflectiveOperationException {
@@ -75,7 +76,7 @@ public class ServerManager {
if (BaseProtocol.class.isAssignableFrom(protocolClass) && Context.getConfig().hasKey(
Keys.PROTOCOL_PORT.withPrefix(BaseProtocol.nameFromClass(protocolClass)))) {
BaseProtocol protocol = (BaseProtocol) protocolClass.getDeclaredConstructor().newInstance();
- serverList.addAll(protocol.getServerList());
+ connectorList.addAll(protocol.getConnectorList());
protocolList.put(protocol.getName(), protocol);
}
}
@@ -90,18 +91,20 @@ public class ServerManager {
}
public void start() throws Exception {
- for (TrackerServer server: serverList) {
+ for (TrackerConnector connector: connectorList) {
try {
- server.start();
+ connector.start();
} catch (BindException e) {
- LOGGER.warn("Port {} is disabled due to conflict", server.getPort());
+ LOGGER.warn("Port disabled due to conflict", e);
+ } catch (ConnectException e) {
+ LOGGER.warn("Connection failed", e);
}
}
}
public void stop() {
- for (TrackerServer server: serverList) {
- server.stop();
+ for (TrackerConnector connector: connectorList) {
+ connector.stop();
}
GlobalTimer.release();
}