aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/ServerManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/ServerManager.java')
-rw-r--r--src/org/traccar/ServerManager.java30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/org/traccar/ServerManager.java b/src/org/traccar/ServerManager.java
index cd6a071db..59bb88829 100644
--- a/src/org/traccar/ServerManager.java
+++ b/src/org/traccar/ServerManager.java
@@ -20,14 +20,19 @@ import java.net.URI;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.Enumeration;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
public class ServerManager {
+ private final Map<String, BaseProtocol> protocols = new HashMap<>();
private final List<TrackerServer> serverList = new LinkedList<>();
public ServerManager() throws Exception {
@@ -62,20 +67,22 @@ public class ServerManager {
for (String name : names) {
Class protocolClass = Class.forName(packageName + '.' + name);
if (BaseProtocol.class.isAssignableFrom(protocolClass)) {
- initProtocolServer((BaseProtocol) protocolClass.newInstance());
+ BaseProtocol baseProtocol = (BaseProtocol) protocolClass.newInstance();
+ protocols.put(baseProtocol.getName(), baseProtocol);
+ initProtocolServer(baseProtocol);
}
}
}
public void start() {
- for (Object server: serverList) {
- ((TrackerServer) server).start();
+ for (TrackerServer server: serverList) {
+ server.start();
}
}
public void stop() {
- for (Object server: serverList) {
- ((TrackerServer) server).stop();
+ for (TrackerServer server: serverList) {
+ server.stop();
}
// Release resources
@@ -89,4 +96,17 @@ public class ServerManager {
}
}
+ public Collection<String> getProtocolSuppportedCommands(String protocol) {
+ List<String> result = new ArrayList<>();
+
+ if (protocol != null) {
+ BaseProtocol baseProtocol = protocols.get(protocol);
+ for (String commandKey : baseProtocol.getSupportedCommands()) {
+ result.add(commandKey);
+ }
+ }
+
+ return result;
+ }
+
}