aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/ServerManager.java
diff options
context:
space:
mode:
authorGábor Somogyi <gabor.g.somogyi@gmail.com>2016-04-27 22:22:08 +0200
committerGábor Somogyi <gabor.g.somogyi@gmail.com>2016-04-27 22:34:17 +0200
commitbf68718e05f811ffeb2b4b57acab56dca3e7de56 (patch)
tree5853e81ae5d08e996d1600504027c7a870202643 /src/org/traccar/ServerManager.java
parent44f026f881efa6207ab79fb5bada20ab67f018a0 (diff)
downloadtrackermap-server-bf68718e05f811ffeb2b4b57acab56dca3e7de56.tar.gz
trackermap-server-bf68718e05f811ffeb2b4b57acab56dca3e7de56.tar.bz2
trackermap-server-bf68718e05f811ffeb2b4b57acab56dca3e7de56.zip
Command framework ugly hack version
Diffstat (limited to 'src/org/traccar/ServerManager.java')
-rw-r--r--src/org/traccar/ServerManager.java26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/org/traccar/ServerManager.java b/src/org/traccar/ServerManager.java
index cd6a071db..dae693080 100644
--- a/src/org/traccar/ServerManager.java
+++ b/src/org/traccar/ServerManager.java
@@ -15,19 +15,20 @@
*/
package org.traccar;
+import org.traccar.model.SupportedCommand;
+
import java.io.File;
import java.net.URI;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
-import java.util.Enumeration;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.*;
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,7 +63,9 @@ 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);
}
}
}
@@ -89,4 +92,19 @@ public class ServerManager {
}
}
+ public Collection<SupportedCommand> getProtocolSuppportedCommands(String protocol) {
+ ArrayList<SupportedCommand> result = new ArrayList<>();
+
+ if (protocol != null) {
+ BaseProtocol baseProtocol = protocols.get(protocol);
+ for (String commandKey : baseProtocol.getSupportedCommands()) {
+ SupportedCommand supportedCommand = new SupportedCommand();
+ supportedCommand.setKey(commandKey);
+ supportedCommand.setName(commandKey);
+ result.add(supportedCommand);
+ }
+ }
+
+ return result;
+ }
}