diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-07-09 22:48:54 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-07-09 22:48:54 -0700 |
commit | 63e1162d903fd06222f8e966d234f1b303aa0808 (patch) | |
tree | 3f801406a89750192b9f0ad370e597d91a1a216a /src/main/java/org | |
parent | b0d5474b5da7ba2a0fc32646ca893a9b553bcbc0 (diff) | |
download | trackermap-server-63e1162d903fd06222f8e966d234f1b303aa0808.tar.gz trackermap-server-63e1162d903fd06222f8e966d234f1b303aa0808.tar.bz2 trackermap-server-63e1162d903fd06222f8e966d234f1b303aa0808.zip |
Extract class loading method
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/traccar/ServerManager.java | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/ServerManager.java b/src/main/java/org/traccar/ServerManager.java index 6a3273402..68b133c98 100644 --- a/src/main/java/org/traccar/ServerManager.java +++ b/src/main/java/org/traccar/ServerManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2012 - 2020 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. @@ -19,8 +19,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; +import java.io.IOException; import java.net.BindException; import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.net.URLDecoder; import java.nio.charset.StandardCharsets; @@ -39,10 +41,9 @@ public class ServerManager { private final List<TrackerServer> serverList = new LinkedList<>(); private final Map<String, BaseProtocol> protocolList = new ConcurrentHashMap<>(); - public ServerManager() throws Exception { + private void loadPackage(String packageName) throws IOException, URISyntaxException, ReflectiveOperationException { List<String> names = new LinkedList<>(); - String packageName = "org.traccar.protocol"; String packagePath = packageName.replace('.', '/'); URL packageUrl = getClass().getClassLoader().getResource(packagePath); @@ -79,6 +80,10 @@ public class ServerManager { } } + public ServerManager() throws IOException, URISyntaxException, ReflectiveOperationException { + loadPackage("org.traccar.protocol"); + } + public BaseProtocol getProtocol(String name) { return protocolList.get(name); } |