aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/Server.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/Server.java')
-rw-r--r--src/org/traccar/Server.java98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/org/traccar/Server.java b/src/org/traccar/Server.java
index 15514bffc..a36da81e4 100644
--- a/src/org/traccar/Server.java
+++ b/src/org/traccar/Server.java
@@ -49,6 +49,81 @@ import org.traccar.protocol.*;
*/
public class Server {
+<<<<<<< HEAD
+ /**
+ * Server list
+ */
+ private List<TrackerServer> serverList;
+
+ private boolean loggerEnabled;
+
+ public Server() {
+ serverList = new LinkedList<TrackerServer>();
+ loggerEnabled = false;
+ }
+
+ public boolean isLoggerEnabled() {
+ return loggerEnabled;
+ }
+
+ private DataManager dataManager;
+
+ private WebServer webServer;
+
+ private ReverseGeocoder geocoder;
+
+ /**
+ * Initialize
+ */
+ public void init(String[] arguments)
+ throws IOException, ClassNotFoundException, SQLException {
+
+ // Load properties
+ Properties properties = new Properties();
+ if (arguments.length > 0) {
+ properties.loadFromXML(new FileInputStream(arguments[0]));
+ }
+
+ dataManager = new DatabaseDataManager(properties);
+
+ initLogger(properties);
+ initGeocoder(properties);
+
+ initXexunServer(properties);
+ initGps103Server(properties);
+ initTk103Server(properties);
+ initGl100Server(properties);
+ initGl200Server(properties);
+ initT55Server(properties);
+ initXexun2Server(properties);
+ initAvl08Server(properties);
+ initEnforaServer(properties);
+ initMeiligaoServer(properties);
+ initMaxonServer(properties);
+
+ // Initialize web server
+ if (Boolean.valueOf(properties.getProperty("http.enable"))) {
+ Integer port = Integer.valueOf(properties.getProperty("http.port", "8082"));
+ String address = properties.getProperty("http.address");
+ if (address != null) {
+ webServer = new WebServer(address, port, dataManager);
+ } else {
+ webServer = new WebServer(port, dataManager);
+ }
+ }
+ }
+
+ /**
+ * Start
+ */
+ public void start() {
+ if (webServer != null) {
+ webServer.start();
+ }
+ for (Object server: serverList) {
+ ((TrackerServer) server).start();
+ }
+=======
/**
* Server list
*/
@@ -87,6 +162,7 @@ public class Server {
// System.out.println(type.getPort());
}
+>>>>>>> df91992080ee4db293e6f81882e95e72600d9bd8
}
/**
@@ -566,4 +642,26 @@ public class Server {
}
}
+ private void initMaxonServer(Properties properties) throws SQLException {
+ String protocol = "maxon";
+ if (isProtocolEnabled(properties, protocol)) {
+
+ TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ final Integer resetDelay = getProtocolResetDelay(properties, protocol);
+
+ server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), geocoder) {
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ byte delimiter[] = { (byte) '\r', (byte) '\n' };
+ pipeline.addLast("frameDecoder",
+ new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter)));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new MaxonProtocolDecoder(getDataManager(), resetDelay));
+ }
+ });
+
+ serverList.add(server);
+ }
+ }
+
}