aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--default.cfg136
-rw-r--r--opengts.cfg124
-rw-r--r--setup/linux/linux.cfg152
-rw-r--r--setup/windows/windows.cfg128
-rw-r--r--src/org/traccar/GenericPipelineFactory.java26
-rw-r--r--src/org/traccar/Main.java4
-rw-r--r--src/org/traccar/ServerManager.java (renamed from src/org/traccar/Server.java)511
-rw-r--r--src/org/traccar/TrackerServer.java39
8 files changed, 419 insertions, 701 deletions
diff --git a/default.cfg b/default.cfg
index 4b4685ce1..9920d4851 100644
--- a/default.cfg
+++ b/default.cfg
@@ -1,24 +1,24 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version='1.0' encoding='UTF-8'?>
-<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<!DOCTYPE properties SYSTEM 'http://java.sun.com/dtd/properties.dtd'>
<properties>
<!-- Global confiduration -->
- <entry key="database.driver">org.h2.Driver</entry>
- <entry key="database.dataSource">org.h2.jdbcx.JdbcDataSource</entry>
- <entry key="database.url">jdbc:h2:/home/user/Documents/traccar/target/database</entry>
- <entry key="database.user">sa</entry>
- <entry key="database.password"></entry>
+ <entry key='database.driver'>org.h2.Driver</entry>
+ <entry key='database.dataSource'>org.h2.jdbcx.JdbcDataSource</entry>
+ <entry key='database.url'>jdbc:h2:/home/user/Documents/traccar/target/database</entry>
+ <entry key='database.user'>sa</entry>
+ <entry key='database.password'></entry>
<!-- Database refresh delay in seconds -->
- <entry key="database.refreshDelay">300</entry>
+ <entry key='database.refreshDelay'>300</entry>
<!-->
id - Long
imei - String
<-->
- <entry key="database.selectDevice">
+ <entry key='database.selectDevice'>
SELECT id, uniqueId as imei
FROM devices;
</entry>
@@ -34,127 +34,127 @@
power - Double (NULL for some protocols)
extended_info - String (XML)
<-->
- <entry key="database.insertPosition">
+ <entry key='database.insertPosition'>
INSERT INTO positions (device_id, time, valid, latitude, longitude, altitude, speed, course, power)
- VALUES (:device_id, :time, :valid, :latitude, :longitude, :altitude, :speed, :course, :power);
+ VALUES (:device_id, :time, :valid, :latitude, :longitude, :altitude, :speed, :course, :power);
</entry>
<!-->
device_id - Long
id - Long
<-->
- <entry key="database.updateLatestPosition">
+ <entry key='database.updateLatestPosition'>
UPDATE devices SET latestPosition_id = :id WHERE id = :device_id;
</entry>
<!-- Web interface -->
- <entry key="http.enable">true</entry>
- <!--<entry key="http.address"></entry>-->
- <entry key="http.port">8082</entry>
- <entry key="http.application">/home/user/Documents/traccar-web/traccar-web.war</entry>
+ <entry key='http.enable'>true</entry>
+ <!--<entry key='http.address'></entry>-->
+ <entry key='http.port'>8082</entry>
+ <entry key='http.application'>/home/user/Documents/traccar-web/traccar-web.war</entry>
<!-- Geocoder options -->
- <entry key="geocoder.enable">false</entry>
+ <entry key='geocoder.enable'>false</entry>
<!-- Logging options -->
- <entry key="logger.enable">true</entry>
- <entry key="logger.file">/home/user/Documents/traccar/target/tracker-server.log</entry>
+ <entry key='logger.enable'>true</entry>
+ <entry key='logger.file'>/home/user/Documents/traccar/target/tracker-server.log</entry>
<!-- Xexun server configuration -->
- <entry key="xexun.enable">true</entry>
- <!--<entry key="xexun.address">localhost</entry>-->
- <entry key="xexun.port">5000</entry>
+ <entry key='xexun.enable'>true</entry>
+ <!--<entry key='xexun.address'>localhost</entry>-->
+ <entry key='xexun.port'>5000</entry>
<!-- Gps103 server configuration -->
- <entry key="gps103.enable">true</entry>
- <entry key="gps103.port">5001</entry>
+ <entry key='gps103.enable'>true</entry>
+ <entry key='gps103.port'>5001</entry>
<!-- Tk103 server configuration -->
- <entry key="tk103.enable">true</entry>
- <entry key="tk103.port">5002</entry>
+ <entry key='tk103.enable'>true</entry>
+ <entry key='tk103.port'>5002</entry>
<!-- Gl100 server configuration -->
- <entry key="gl100.enable">true</entry>
- <entry key="gl100.port">5003</entry>
+ <entry key='gl100.enable'>true</entry>
+ <entry key='gl100.port'>5003</entry>
<!-- Gl200 server configuration -->
- <entry key="gl200.enable">true</entry>
- <entry key="gl200.port">5004</entry>
+ <entry key='gl200.enable'>true</entry>
+ <entry key='gl200.port'>5004</entry>
<!-- T55 server configuration -->
- <entry key="t55.enable">true</entry>
- <entry key="t55.port">5005</entry>
+ <entry key='t55.enable'>true</entry>
+ <entry key='t55.port'>5005</entry>
<!-- Xexun 2 server configuration -->
- <entry key="xexun2.enable">true</entry>
- <entry key="xexun2.port">5006</entry>
+ <entry key='xexun2.enable'>true</entry>
+ <entry key='xexun2.port'>5006</entry>
<!-- AVL-08 server configuration -->
- <entry key="avl08.enable">true</entry>
- <entry key="avl08.port">5007</entry>
+ <entry key='avl08.enable'>true</entry>
+ <entry key='avl08.port'>5007</entry>
<!-- Enfora server configuration -->
- <entry key="enfora.enable">true</entry>
- <entry key="enfora.port">5008</entry>
+ <entry key='enfora.enable'>true</entry>
+ <entry key='enfora.port'>5008</entry>
<!-- Meiligao server configuration -->
- <entry key="meiligao.enable">true</entry>
- <entry key="meiligao.port">5009</entry>
+ <entry key='meiligao.enable'>true</entry>
+ <entry key='meiligao.port'>5009</entry>
<!-- Maxon server configuration -->
- <entry key="maxon.enable">true</entry>
- <entry key="maxon.port">5010</entry>
+ <entry key='maxon.enable'>true</entry>
+ <entry key='maxon.port'>5010</entry>
<!-- ST-210 server configuration -->
- <entry key="st210.enable">true</entry>
- <entry key="st210.port">5011</entry>
+ <entry key='st210.enable'>true</entry>
+ <entry key='st210.port'>5011</entry>
<!-- Progress server configuration -->
- <entry key="progress.enable">true</entry>
- <entry key="progress.port">5012</entry>
+ <entry key='progress.enable'>true</entry>
+ <entry key='progress.port'>5012</entry>
<!-- H02 server configuration -->
- <entry key="h02.enable">true</entry>
- <entry key="h02.port">5013</entry>
+ <entry key='h02.enable'>true</entry>
+ <entry key='h02.port'>5013</entry>
<!-- JT600 server configuration -->
- <entry key="jt600.enable">true</entry>
- <entry key="jt600.port">5014</entry>
+ <entry key='jt600.enable'>true</entry>
+ <entry key='jt600.port'>5014</entry>
<!-- EV603 server configuration -->
- <entry key="ev603.enable">true</entry>
- <entry key="ev603.port">5015</entry>
+ <entry key='ev603.enable'>true</entry>
+ <entry key='ev603.port'>5015</entry>
<!-- V680 server configuration -->
- <entry key="v680.enable">true</entry>
- <entry key="v680.port">5016</entry>
+ <entry key='v680.enable'>true</entry>
+ <entry key='v680.port'>5016</entry>
<!-- PT502 server configuration -->
- <entry key="pt502.enable">true</entry>
- <entry key="pt502.port">5017</entry>
+ <entry key='pt502.enable'>true</entry>
+ <entry key='pt502.port'>5017</entry>
<!-- TR20 server configuration -->
- <entry key="tr20.enable">true</entry>
- <entry key="tr20.port">5018</entry>
+ <entry key='tr20.enable'>true</entry>
+ <entry key='tr20.port'>5018</entry>
<!-- Navis server configuration -->
- <entry key="navis.enable">true</entry>
- <entry key="navis.port">5019</entry>
+ <entry key='navis.enable'>true</entry>
+ <entry key='navis.port'>5019</entry>
<!-- Meitrack server configuration -->
- <entry key="meitrack.enable">true</entry>
- <entry key="meitrack.port">5020</entry>
+ <entry key='meitrack.enable'>true</entry>
+ <entry key='meitrack.port'>5020</entry>
<!-- Skypatrol server configuration -->
- <entry key="skypatrol.enable">true</entry>
- <entry key="skypatrol.port">5021</entry>
+ <entry key='skypatrol.enable'>true</entry>
+ <entry key='skypatrol.port'>5021</entry>
<!-- GT02 server configuration -->
- <entry key="gt02.enable">true</entry>
- <entry key="gt02.port">5022</entry>
+ <entry key='gt02.enable'>true</entry>
+ <entry key='gt02.port'>5022</entry>
<!-- GT06 server configuration -->
- <entry key="gt06.enable">true</entry>
- <entry key="gt06.port">5023</entry>
+ <entry key='gt06.enable'>true</entry>
+ <entry key='gt06.port'>5023</entry>
</properties>
diff --git a/opengts.cfg b/opengts.cfg
index a34301aec..fbef33f87 100644
--- a/opengts.cfg
+++ b/opengts.cfg
@@ -1,23 +1,23 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version='1.0' encoding='UTF-8'?>
-<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<!DOCTYPE properties SYSTEM 'http://java.sun.com/dtd/properties.dtd'>
<properties>
<!-- Global confiduration -->
- <entry key="database.driver">com.mysql.jdbc.Driver</entry>
- <entry key="database.url">jdbc:mysql://localhost:3306/[DATABASE]?allowMultiQueries=true</entry>
- <entry key="database.user">[USER]</entry>
- <entry key="database.password">[PASSWORD]</entry>
+ <entry key='database.driver'>com.mysql.jdbc.Driver</entry>
+ <entry key='database.url'>jdbc:mysql://localhost:3306/[DATABASE]?allowMultiQueries=true</entry>
+ <entry key='database.user'>[USER]</entry>
+ <entry key='database.password'>[PASSWORD]</entry>
<!-- Database refresh delay in seconds -->
- <entry key="database.refreshDelay">300</entry>
+ <entry key='database.refreshDelay'>300</entry>
- <entry key="database.selectDevice">
+ <entry key='database.selectDevice'>
SELECT imeiNumber AS id, imeiNumber AS imei FROM Device WHERE imeiNumber &lt;&gt; '';
</entry>
- <entry key="database.insertPosition">
+ <entry key='database.insertPosition'>
START TRANSACTION;
UPDATE Device SET lastValidLatitude = :latitude, lastValidLongitude = :longitude, lastGPSTimestamp = UNIX_TIMESTAMP(:time), lastUpdateTime = UNIX_TIMESTAMP(NOW()) WHERE imeiNumber = :device_id;
SELECT @accountID := accountID, @deviceID := deviceID FROM Device WHERE imeiNumber = :device_id;
@@ -26,114 +26,114 @@
COMMIT;
</entry>
- <entry key="database.updateLatestPosition">
+ <entry key='database.updateLatestPosition'>
DO 0;
</entry>
<!-- Web interface port -->
- <entry key="http.enable">false</entry>
+ <entry key='http.enable'>false</entry>
<!-- Geocoder options -->
- <entry key="geocoder.enable">true</entry>
+ <entry key='geocoder.enable'>true</entry>
<!-- Logging options -->
- <entry key="logger.enable">true</entry>
- <entry key="logger.file">[LOG]</entry>
+ <entry key='logger.enable'>true</entry>
+ <entry key='logger.file'>[LOG]</entry>
<!-- Xexun server configuration -->
- <entry key="xexun.enable">true</entry>
- <entry key="xexun.port">5000</entry>
+ <entry key='xexun.enable'>true</entry>
+ <entry key='xexun.port'>5000</entry>
<!-- Gps103 server configuration -->
- <entry key="gps103.enable">true</entry>
- <entry key="gps103.port">5001</entry>
+ <entry key='gps103.enable'>true</entry>
+ <entry key='gps103.port'>5001</entry>
<!-- Tk103 server configuration -->
- <entry key="tk103.enable">true</entry>
- <entry key="tk103.port">5002</entry>
+ <entry key='tk103.enable'>true</entry>
+ <entry key='tk103.port'>5002</entry>
<!-- Gl100 server configuration -->
- <entry key="gl100.enable">true</entry>
- <entry key="gl100.port">5003</entry>
+ <entry key='gl100.enable'>true</entry>
+ <entry key='gl100.port'>5003</entry>
<!-- Gl200 server configuration -->
- <entry key="gl200.enable">true</entry>
- <entry key="gl200.port">5004</entry>
+ <entry key='gl200.enable'>true</entry>
+ <entry key='gl200.port'>5004</entry>
<!-- T55 server configuration -->
- <entry key="t55.enable">true</entry>
- <entry key="t55.port">5005</entry>
+ <entry key='t55.enable'>true</entry>
+ <entry key='t55.port'>5005</entry>
<!-- Xexun 2 server configuration -->
- <entry key="xexun2.enable">true</entry>
- <entry key="xexun2.port">5006</entry>
+ <entry key='xexun2.enable'>true</entry>
+ <entry key='xexun2.port'>5006</entry>
<!-- AVL-08 server configuration -->
- <entry key="avl08.enable">true</entry>
- <entry key="avl08.port">5007</entry>
+ <entry key='avl08.enable'>true</entry>
+ <entry key='avl08.port'>5007</entry>
<!-- Enfora server configuration -->
- <entry key="enfora.enable">true</entry>
- <entry key="enfora.port">5008</entry>
+ <entry key='enfora.enable'>true</entry>
+ <entry key='enfora.port'>5008</entry>
<!-- Meiligao server configuration -->
- <entry key="meiligao.enable">true</entry>
- <entry key="meiligao.port">5009</entry>
+ <entry key='meiligao.enable'>true</entry>
+ <entry key='meiligao.port'>5009</entry>
<!-- Maxon server configuration -->
- <entry key="maxon.enable">true</entry>
- <entry key="maxon.port">5010</entry>
+ <entry key='maxon.enable'>true</entry>
+ <entry key='maxon.port'>5010</entry>
<!-- ST-210 server configuration -->
- <entry key="st210.enable">true</entry>
- <entry key="st210.port">5011</entry>
+ <entry key='st210.enable'>true</entry>
+ <entry key='st210.port'>5011</entry>
<!-- Progress server configuration -->
- <entry key="progress.enable">true</entry>
- <entry key="progress.port">5012</entry>
+ <entry key='progress.enable'>true</entry>
+ <entry key='progress.port'>5012</entry>
<!-- H02 server configuration -->
- <entry key="h02.enable">true</entry>
- <entry key="h02.port">5013</entry>
+ <entry key='h02.enable'>true</entry>
+ <entry key='h02.port'>5013</entry>
<!-- JT600 server configuration -->
- <entry key="jt600.enable">true</entry>
- <entry key="jt600.port">5014</entry>
+ <entry key='jt600.enable'>true</entry>
+ <entry key='jt600.port'>5014</entry>
<!-- EV603 server configuration -->
- <entry key="ev603.enable">true</entry>
- <entry key="ev603.port">5015</entry>
+ <entry key='ev603.enable'>true</entry>
+ <entry key='ev603.port'>5015</entry>
<!-- V680 server configuration -->
- <entry key="v680.enable">true</entry>
- <entry key="v680.port">5016</entry>
+ <entry key='v680.enable'>true</entry>
+ <entry key='v680.port'>5016</entry>
<!-- PT502 server configuration -->
- <entry key="pt502.enable">true</entry>
- <entry key="pt502.port">5017</entry>
+ <entry key='pt502.enable'>true</entry>
+ <entry key='pt502.port'>5017</entry>
<!-- TR20 server configuration -->
- <entry key="tr20.enable">true</entry>
- <entry key="tr20.port">5018</entry>
+ <entry key='tr20.enable'>true</entry>
+ <entry key='tr20.port'>5018</entry>
<!-- Navis server configuration -->
- <entry key="navis.enable">true</entry>
- <entry key="navis.port">5019</entry>
+ <entry key='navis.enable'>true</entry>
+ <entry key='navis.port'>5019</entry>
<!-- Meitrack server configuration -->
- <entry key="meitrack.enable">true</entry>
- <entry key="meitrack.port">5020</entry>
+ <entry key='meitrack.enable'>true</entry>
+ <entry key='meitrack.port'>5020</entry>
<!-- Skypatrol server configuration -->
- <entry key="skypatrol.enable">true</entry>
- <entry key="skypatrol.port">5021</entry>
+ <entry key='skypatrol.enable'>true</entry>
+ <entry key='skypatrol.port'>5021</entry>
<!-- GT02 server configuration -->
- <entry key="gt02.enable">true</entry>
- <entry key="gt02.port">5022</entry>
+ <entry key='gt02.enable'>true</entry>
+ <entry key='gt02.port'>5022</entry>
<!-- GT06 server configuration -->
- <entry key="gt06.enable">true</entry>
- <entry key="gt06.port">5023</entry>
+ <entry key='gt06.enable'>true</entry>
+ <entry key='gt06.port'>5023</entry>
</properties>
diff --git a/setup/linux/linux.cfg b/setup/linux/linux.cfg
index 16dc51e6f..539921791 100644
--- a/setup/linux/linux.cfg
+++ b/setup/linux/linux.cfg
@@ -1,24 +1,24 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version='1.0' encoding='UTF-8'?>
-<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<!DOCTYPE properties SYSTEM 'http://java.sun.com/dtd/properties.dtd'>
<properties>
<!-- Global confiduration -->
- <entry key="database.driver">org.h2.Driver</entry>
- <entry key="database.dataSource">org.h2.jdbcx.JdbcDataSource</entry>
- <entry key="database.url">jdbc:h2:/opt/traccar/data/database</entry>
- <entry key="database.user">sa</entry>
- <entry key="database.password"></entry>
+ <entry key='database.driver'>org.h2.Driver</entry>
+ <entry key='database.dataSource'>org.h2.jdbcx.JdbcDataSource</entry>
+ <entry key='database.url'>jdbc:h2:/opt/traccar/data/database</entry>
+ <entry key='database.user'>sa</entry>
+ <entry key='database.password'></entry>
<!-- Database refresh delay in seconds -->
- <entry key="database.refreshDelay">300</entry>
+ <entry key='database.refreshDelay'>300</entry>
<!-->
id - Long
imei - String
<-->
- <entry key="database.selectDevice">
+ <entry key='database.selectDevice'>
SELECT id, uniqueId as imei
FROM devices;
</entry>
@@ -34,7 +34,7 @@
power - Double (NULL for some protocols)
extended_info - String (XML)
<-->
- <entry key="database.insertPosition">
+ <entry key='database.insertPosition'>
INSERT INTO positions (device_id, time, valid, latitude, longitude, altitude, speed, course, power)
VALUES (:device_id, :time, :valid, :latitude, :longitude, :altitude, :speed, :course, :power);
</entry>
@@ -43,137 +43,137 @@
device_id - Long
id - Long
<-->
- <entry key="database.updateLatestPosition">
+ <entry key='database.updateLatestPosition'>
UPDATE devices SET latestPosition_id = :id WHERE id = :device_id;
</entry>
<!-- Web interface port -->
- <entry key="http.enable">true</entry>
- <entry key="http.port">8082</entry>
- <entry key="http.application">/opt/traccar/traccar-web.war</entry>
+ <entry key='http.enable'>true</entry>
+ <entry key='http.port'>8082</entry>
+ <entry key='http.application'>/opt/traccar/traccar-web.war</entry>
<!-- Logging options -->
- <entry key="logger.enable">true</entry>
- <entry key="logger.file">/opt/traccar/logs/tracker-server.log</entry>
+ <entry key='logger.enable'>true</entry>
+ <entry key='logger.file'>/opt/traccar/logs/tracker-server.log</entry>
<!-- Xexun server configuration -->
- <entry key="xexun.enable">true</entry>
- <entry key="xexun.port">5000</entry>
+ <entry key='xexun.enable'>true</entry>
+ <entry key='xexun.port'>5000</entry>
<!-- Gps103 server configuration -->
- <entry key="gps103.enable">true</entry>
- <entry key="gps103.port">5001</entry>
+ <entry key='gps103.enable'>true</entry>
+ <entry key='gps103.port'>5001</entry>
<!-- Tk103 server configuration -->
- <entry key="tk103.enable">true</entry>
- <entry key="tk103.port">5002</entry>
+ <entry key='tk103.enable'>true</entry>
+ <entry key='tk103.port'>5002</entry>
<!-- Gl100 server configuration -->
- <entry key="gl100.enable">true</entry>
- <entry key="gl100.port">5003</entry>
+ <entry key='gl100.enable'>true</entry>
+ <entry key='gl100.port'>5003</entry>
<!-- Gl200 server configuration -->
- <entry key="gl200.enable">true</entry>
- <entry key="gl200.port">5004</entry>
+ <entry key='gl200.enable'>true</entry>
+ <entry key='gl200.port'>5004</entry>
<!-- T55 server configuration -->
- <entry key="t55.enable">true</entry>
- <entry key="t55.port">5005</entry>
+ <entry key='t55.enable'>true</entry>
+ <entry key='t55.port'>5005</entry>
<!-- Xexun 2 server configuration -->
- <entry key="xexun2.enable">true</entry>
- <entry key="xexun2.port">5006</entry>
+ <entry key='xexun2.enable'>true</entry>
+ <entry key='xexun2.port'>5006</entry>
<!-- AVL-08 server configuration -->
- <entry key="avl08.enable">true</entry>
- <entry key="avl08.port">5007</entry>
+ <entry key='avl08.enable'>true</entry>
+ <entry key='avl08.port'>5007</entry>
<!-- Enfora server configuration -->
- <entry key="enfora.enable">true</entry>
- <entry key="enfora.port">5008</entry>
+ <entry key='enfora.enable'>true</entry>
+ <entry key='enfora.port'>5008</entry>
<!-- Meiligao server configuration -->
- <entry key="meiligao.enable">true</entry>
- <entry key="meiligao.port">5009</entry>
+ <entry key='meiligao.enable'>true</entry>
+ <entry key='meiligao.port'>5009</entry>
<!-- Maxon server configuration -->
- <entry key="maxon.enable">true</entry>
- <entry key="maxon.port">5010</entry>
+ <entry key='maxon.enable'>true</entry>
+ <entry key='maxon.port'>5010</entry>
<!-- ST-210 server configuration -->
- <entry key="st210.enable">true</entry>
- <entry key="st210.port">5011</entry>
+ <entry key='st210.enable'>true</entry>
+ <entry key='st210.port'>5011</entry>
<!-- Progress server configuration -->
- <entry key="progress.enable">true</entry>
- <entry key="progress.port">5012</entry>
+ <entry key='progress.enable'>true</entry>
+ <entry key='progress.port'>5012</entry>
<!-- H02 server configuration -->
- <entry key="h02.enable">true</entry>
- <entry key="h02.port">5013</entry>
+ <entry key='h02.enable'>true</entry>
+ <entry key='h02.port'>5013</entry>
<!-- JT600 server configuration -->
- <entry key="jt600.enable">true</entry>
- <entry key="jt600.port">5014</entry>
+ <entry key='jt600.enable'>true</entry>
+ <entry key='jt600.port'>5014</entry>
<!-- EV603 server configuration -->
- <entry key="ev603.enable">true</entry>
- <entry key="ev603.port">5015</entry>
+ <entry key='ev603.enable'>true</entry>
+ <entry key='ev603.port'>5015</entry>
<!-- V680 server configuration -->
- <entry key="v680.enable">true</entry>
- <entry key="v680.port">5016</entry>
+ <entry key='v680.enable'>true</entry>
+ <entry key='v680.port'>5016</entry>
<!-- PT502 server configuration -->
- <entry key="pt502.enable">true</entry>
- <entry key="pt502.port">5017</entry>
+ <entry key='pt502.enable'>true</entry>
+ <entry key='pt502.port'>5017</entry>
<!-- TR20 server configuration -->
- <entry key="tr20.enable">true</entry>
- <entry key="tr20.port">5018</entry>
+ <entry key='tr20.enable'>true</entry>
+ <entry key='tr20.port'>5018</entry>
<!-- Navis server configuration -->
- <entry key="navis.enable">true</entry>
- <entry key="navis.port">5019</entry>
+ <entry key='navis.enable'>true</entry>
+ <entry key='navis.port'>5019</entry>
<!-- Meitrack server configuration -->
- <entry key="meitrack.enable">true</entry>
- <entry key="meitrack.port">5020</entry>
+ <entry key='meitrack.enable'>true</entry>
+ <entry key='meitrack.port'>5020</entry>
<!-- Skypatrol server configuration -->
- <entry key="skypatrol.enable">true</entry>
- <entry key="skypatrol.port">5021</entry>
+ <entry key='skypatrol.enable'>true</entry>
+ <entry key='skypatrol.port'>5021</entry>
<!-- GT02 server configuration -->
- <entry key="gt02.enable">true</entry>
- <entry key="gt02.port">5022</entry>
+ <entry key='gt02.enable'>true</entry>
+ <entry key='gt02.port'>5022</entry>
<!-- GT06 server configuration -->
- <entry key="gt06.enable">true</entry>
- <entry key="gt06.port">5023</entry>
+ <entry key='gt06.enable'>true</entry>
+ <entry key='gt06.port'>5023</entry>
<!-- TR20 server configuration -->
- <entry key="tr20.enable">true</entry>
- <entry key="tr20.port">5018</entry>
+ <entry key='tr20.enable'>true</entry>
+ <entry key='tr20.port'>5018</entry>
<!-- Navis server configuration -->
- <entry key="navis.enable">true</entry>
- <entry key="navis.port">5019</entry>
+ <entry key='navis.enable'>true</entry>
+ <entry key='navis.port'>5019</entry>
<!-- Meitrack server configuration -->
- <entry key="meitrack.enable">true</entry>
- <entry key="meitrack.port">5020</entry>
+ <entry key='meitrack.enable'>true</entry>
+ <entry key='meitrack.port'>5020</entry>
<!-- Skypatrol server configuration -->
- <entry key="skypatrol.enable">true</entry>
- <entry key="skypatrol.port">5021</entry>
+ <entry key='skypatrol.enable'>true</entry>
+ <entry key='skypatrol.port'>5021</entry>
<!-- GT02 server configuration -->
- <entry key="gt02.enable">true</entry>
- <entry key="gt02.port">5022</entry>
+ <entry key='gt02.enable'>true</entry>
+ <entry key='gt02.port'>5022</entry>
<!-- GT06 server configuration -->
- <entry key="gt06.enable">true</entry>
- <entry key="gt06.port">5023</entry>
+ <entry key='gt06.enable'>true</entry>
+ <entry key='gt06.port'>5023</entry>
</properties>
diff --git a/setup/windows/windows.cfg b/setup/windows/windows.cfg
index e6b620b0c..d3b4d1da4 100644
--- a/setup/windows/windows.cfg
+++ b/setup/windows/windows.cfg
@@ -1,24 +1,24 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version='1.0' encoding='UTF-8'?>
-<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<!DOCTYPE properties SYSTEM 'http://java.sun.com/dtd/properties.dtd'>
<properties>
<!-- Global confiduration -->
- <entry key="database.driver">org.h2.Driver</entry>
- <entry key="database.dataSource">org.h2.jdbcx.JdbcDataSource</entry>
- <entry key="database.url">jdbc:h2:[DATABASE]</entry>
- <entry key="database.user">sa</entry>
- <entry key="database.password"></entry>
+ <entry key='database.driver'>org.h2.Driver</entry>
+ <entry key='database.dataSource'>org.h2.jdbcx.JdbcDataSource</entry>
+ <entry key='database.url'>jdbc:h2:[DATABASE]</entry>
+ <entry key='database.user'>sa</entry>
+ <entry key='database.password'></entry>
<!-- Database refresh delay in seconds -->
- <entry key="database.refreshDelay">300</entry>
+ <entry key='database.refreshDelay'>300</entry>
<!-->
id - Long
imei - String
<-->
- <entry key="database.selectDevice">
+ <entry key='database.selectDevice'>
SELECT id, uniqueId as imei
FROM devices;
</entry>
@@ -34,7 +34,7 @@
power - Double (NULL for some protocols)
extended_info - String (XML)
<-->
- <entry key="database.insertPosition">
+ <entry key='database.insertPosition'>
INSERT INTO positions (device_id, time, valid, latitude, longitude, altitude, speed, course, power)
VALUES (:device_id, :time, :valid, :latitude, :longitude, :altitude, :speed, :course, :power);
</entry>
@@ -43,113 +43,113 @@
device_id - Long
id - Long
<-->
- <entry key="database.updateLatestPosition">
+ <entry key='database.updateLatestPosition'>
UPDATE devices SET latestPosition_id = :id WHERE id = :device_id;
</entry>
<!-- Web interface port -->
- <entry key="http.enable">true</entry>
- <entry key="http.port">8082</entry>
- <entry key="http.application">[WAR]</entry>
+ <entry key='http.enable'>true</entry>
+ <entry key='http.port'>8082</entry>
+ <entry key='http.application'>[WAR]</entry>
<!-- Logging options -->
- <entry key="logger.enable">true</entry>
- <entry key="logger.file">[LOG]</entry>
+ <entry key='logger.enable'>true</entry>
+ <entry key='logger.file'>[LOG]</entry>
<!-- Xexun server configuration -->
- <entry key="xexun.enable">true</entry>
- <entry key="xexun.port">5000</entry>
+ <entry key='xexun.enable'>true</entry>
+ <entry key='xexun.port'>5000</entry>
<!-- Gps103 server configuration -->
- <entry key="gps103.enable">true</entry>
- <entry key="gps103.port">5001</entry>
+ <entry key='gps103.enable'>true</entry>
+ <entry key='gps103.port'>5001</entry>
<!-- Tk103 server configuration -->
- <entry key="tk103.enable">true</entry>
- <entry key="tk103.port">5002</entry>
+ <entry key='tk103.enable'>true</entry>
+ <entry key='tk103.port'>5002</entry>
<!-- Gl100 server configuration -->
- <entry key="gl100.enable">true</entry>
- <entry key="gl100.port">5003</entry>
+ <entry key='gl100.enable'>true</entry>
+ <entry key='gl100.port'>5003</entry>
<!-- Gl200 server configuration -->
- <entry key="gl200.enable">true</entry>
- <entry key="gl200.port">5004</entry>
+ <entry key='gl200.enable'>true</entry>
+ <entry key='gl200.port'>5004</entry>
<!-- T55 server configuration -->
- <entry key="t55.enable">true</entry>
- <entry key="t55.port">5005</entry>
+ <entry key='t55.enable'>true</entry>
+ <entry key='t55.port'>5005</entry>
<!-- Xexun 2 server configuration -->
- <entry key="xexun2.enable">true</entry>
- <entry key="xexun2.port">5006</entry>
+ <entry key='xexun2.enable'>true</entry>
+ <entry key='xexun2.port'>5006</entry>
<!-- AVL-08 server configuration -->
- <entry key="avl08.enable">true</entry>
- <entry key="avl08.port">5007</entry>
+ <entry key='avl08.enable'>true</entry>
+ <entry key='avl08.port'>5007</entry>
<!-- Enfora server configuration -->
- <entry key="enfora.enable">true</entry>
- <entry key="enfora.port">5008</entry>
+ <entry key='enfora.enable'>true</entry>
+ <entry key='enfora.port'>5008</entry>
<!-- Meiligao server configuration -->
- <entry key="meiligao.enable">true</entry>
- <entry key="meiligao.port">5009</entry>
+ <entry key='meiligao.enable'>true</entry>
+ <entry key='meiligao.port'>5009</entry>
<!-- Maxon server configuration -->
- <entry key="maxon.enable">true</entry>
- <entry key="maxon.port">5010</entry>
+ <entry key='maxon.enable'>true</entry>
+ <entry key='maxon.port'>5010</entry>
<!-- ST-210 server configuration -->
- <entry key="st210.enable">true</entry>
- <entry key="st210.port">5011</entry>
+ <entry key='st210.enable'>true</entry>
+ <entry key='st210.port'>5011</entry>
<!-- Progress server configuration -->
- <entry key="progress.enable">true</entry>
- <entry key="progress.port">5012</entry>
+ <entry key='progress.enable'>true</entry>
+ <entry key='progress.port'>5012</entry>
<!-- H02 server configuration -->
- <entry key="h02.enable">true</entry>
- <entry key="h02.port">5013</entry>
+ <entry key='h02.enable'>true</entry>
+ <entry key='h02.port'>5013</entry>
<!-- JT600 server configuration -->
- <entry key="jt600.enable">true</entry>
- <entry key="jt600.port">5014</entry>
+ <entry key='jt600.enable'>true</entry>
+ <entry key='jt600.port'>5014</entry>
<!-- EV603 server configuration -->
- <entry key="ev603.enable">true</entry>
- <entry key="ev603.port">5015</entry>
+ <entry key='ev603.enable'>true</entry>
+ <entry key='ev603.port'>5015</entry>
<!-- V680 server configuration -->
- <entry key="v680.enable">true</entry>
- <entry key="v680.port">5016</entry>
+ <entry key='v680.enable'>true</entry>
+ <entry key='v680.port'>5016</entry>
<!-- PT502 server configuration -->
- <entry key="pt502.enable">true</entry>
- <entry key="pt502.port">5017</entry>
+ <entry key='pt502.enable'>true</entry>
+ <entry key='pt502.port'>5017</entry>
<!-- TR20 server configuration -->
- <entry key="tr20.enable">true</entry>
- <entry key="tr20.port">5018</entry>
+ <entry key='tr20.enable'>true</entry>
+ <entry key='tr20.port'>5018</entry>
<!-- Navis server configuration -->
- <entry key="navis.enable">true</entry>
- <entry key="navis.port">5019</entry>
+ <entry key='navis.enable'>true</entry>
+ <entry key='navis.port'>5019</entry>
<!-- Meitrack server configuration -->
- <entry key="meitrack.enable">true</entry>
- <entry key="meitrack.port">5020</entry>
+ <entry key='meitrack.enable'>true</entry>
+ <entry key='meitrack.port'>5020</entry>
<!-- Skypatrol server configuration -->
- <entry key="skypatrol.enable">true</entry>
- <entry key="skypatrol.port">5021</entry>
+ <entry key='skypatrol.enable'>true</entry>
+ <entry key='skypatrol.port'>5021</entry>
<!-- GT02 server configuration -->
- <entry key="gt02.enable">true</entry>
- <entry key="gt02.port">5022</entry>
+ <entry key='gt02.enable'>true</entry>
+ <entry key='gt02.port'>5022</entry>
<!-- GT06 server configuration -->
- <entry key="gt06.enable">true</entry>
- <entry key="gt06.port">5023</entry>
+ <entry key='gt06.enable'>true</entry>
+ <entry key='gt06.port'>5023</entry>
</properties>
diff --git a/src/org/traccar/GenericPipelineFactory.java b/src/org/traccar/GenericPipelineFactory.java
index 556d86e1d..4537ac4f7 100644
--- a/src/org/traccar/GenericPipelineFactory.java
+++ b/src/org/traccar/GenericPipelineFactory.java
@@ -34,7 +34,7 @@ public abstract class GenericPipelineFactory implements ChannelPipelineFactory {
private DataManager dataManager;
private Boolean loggerEnabled;
private Integer resetDelay;
- private ReverseGeocoder geocoder;
+ private ReverseGeocoder reverseGeocoder;
/**
* Open channel handler
@@ -65,7 +65,7 @@ public abstract class GenericPipelineFactory implements ChannelPipelineFactory {
if (e instanceof MessageEvent) {
MessageEvent event = (MessageEvent) e;
StringBuilder msg = new StringBuilder();
-
+
msg.append("[").append(((InetSocketAddress) e.getChannel().getLocalAddress()).getPort()).append(" - ");
msg.append(((InetSocketAddress) event.getRemoteAddress()).getAddress().getHostAddress()).append("]");
@@ -85,13 +85,16 @@ public abstract class GenericPipelineFactory implements ChannelPipelineFactory {
}
}
- public GenericPipelineFactory(
- TrackerServer server, DataManager dataManager, Boolean loggerEnabled, Integer resetDelay, ReverseGeocoder geocoder) {
+ public GenericPipelineFactory(ServerManager serverManager, TrackerServer server, String protocol) {
this.server = server;
- this.dataManager = dataManager;
- this.loggerEnabled = loggerEnabled;
- this.resetDelay = resetDelay;
- this.geocoder = geocoder;
+ dataManager = serverManager.getDataManager();
+ loggerEnabled = serverManager.isLoggerEnabled();
+ reverseGeocoder = serverManager.getReverseGeocoder();
+
+ String resetDelayProperty = serverManager.getProperties().getProperty(protocol + ".resetDelay");
+ if (resetDelayProperty != null) {
+ resetDelay = Integer.valueOf(resetDelayProperty);
+ }
}
protected DataManager getDataManager() {
@@ -100,9 +103,10 @@ public abstract class GenericPipelineFactory implements ChannelPipelineFactory {
protected abstract void addSpecificHandlers(ChannelPipeline pipeline);
+ @Override
public ChannelPipeline getPipeline() {
ChannelPipeline pipeline = Channels.pipeline();
- if (resetDelay != 0) {
+ if (resetDelay != null) {
pipeline.addLast("idleHandler", new IdleStateHandler(GlobalTimer.getTimer(), resetDelay, 0, 0));
}
pipeline.addLast("openHandler", new OpenChannelHandler(server));
@@ -110,8 +114,8 @@ public abstract class GenericPipelineFactory implements ChannelPipelineFactory {
pipeline.addLast("logger", new StandardLoggingHandler());
}
addSpecificHandlers(pipeline);
- if (geocoder != null) {
- pipeline.addLast("geocoder", new ReverseGeocoderHandler(geocoder));
+ if (reverseGeocoder != null) {
+ pipeline.addLast("geocoder", new ReverseGeocoderHandler(reverseGeocoder));
}
pipeline.addLast("handler", new TrackerEventHandler(dataManager));
return pipeline;
diff --git a/src/org/traccar/Main.java b/src/org/traccar/Main.java
index f4242d95e..918370266 100644
--- a/src/org/traccar/Main.java
+++ b/src/org/traccar/Main.java
@@ -24,8 +24,8 @@ public class Main {
// TODO: Temporary formatting workaround
Locale.setDefault(Locale.ENGLISH);
-
- final Server service = new Server();
+
+ final ServerManager service = new ServerManager();
service.init(args);
Log.info("starting server...");
diff --git a/src/org/traccar/Server.java b/src/org/traccar/ServerManager.java
index e1d9efa3d..68c537cba 100644
--- a/src/org/traccar/Server.java
+++ b/src/org/traccar/ServerManager.java
@@ -17,7 +17,6 @@ package org.traccar;
import java.io.FileInputStream;
import java.io.IOException;
-import java.nio.ByteOrder;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.FieldPosition;
@@ -29,6 +28,7 @@ import java.util.Properties;
import java.util.logging.FileHandler;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
+import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.ChannelPipeline;
@@ -45,31 +45,45 @@ import org.traccar.model.DatabaseDataManager;
import org.traccar.protocol.*;
/**
- * Server
+ * Server Manager
*/
-public class Server {
+public class ServerManager {
- /**
- * Server list
- */
- private List<TrackerServer> serverList;
+ private final List<TrackerServer> serverList = new LinkedList<TrackerServer>();
- private boolean loggerEnabled;
-
- public Server() {
- serverList = new LinkedList<TrackerServer>();
- loggerEnabled = false;
+ public void addTrackerServer(TrackerServer trackerServer) {
+ serverList.add(trackerServer);
}
+ private boolean loggerEnabled;
+
public boolean isLoggerEnabled() {
return loggerEnabled;
}
private DataManager dataManager;
+ public DataManager getDataManager() {
+ return dataManager;
+ }
+
+ private ReverseGeocoder reverseGeocoder;
+
+ public ReverseGeocoder getReverseGeocoder() {
+ return reverseGeocoder;
+ }
+
private WebServer webServer;
- private ReverseGeocoder geocoder;
+ public WebServer getWebServer() {
+ return webServer;
+ }
+
+ private Properties properties;
+
+ public Properties getProperties() {
+ return properties;
+ }
/**
* Initialize
@@ -78,7 +92,7 @@ public class Server {
throws IOException, ClassNotFoundException, SQLException {
// Load properties
- Properties properties = new Properties();
+ properties = new Properties();
if (arguments.length > 0) {
properties.loadFromXML(new FileInputStream(arguments[0]));
}
@@ -88,30 +102,30 @@ public class Server {
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);
- initST210Server(properties);
- initProgressServer(properties);
- initH02Server(properties);
- initJt600Server(properties);
- initEv603Server(properties);
- initV680Server(properties);
- initPt502Server(properties);
- initTr20Server(properties);
- initNavisServer(properties);
- initMeitrackServer(properties);
- initSkypatrolServer(properties);
- initGt02Server(properties);
- initGt06Server(properties);
+ initXexunServer("xexun");
+ initGps103Server("gps103");
+ initTk103Server("tk103");
+ initGl100Server("gl100");
+ initGl200Server("gl200");
+ initT55Server("t55");
+ initXexun2Server("xexun2");
+ initAvl08Server("avl08");
+ initEnforaServer("enfora");
+ initMeiligaoServer("meiligao");
+ initMaxonServer("maxon");
+ initST210Server("st210");
+ initProgressServer("progress");
+ initH02Server("h02");
+ initJt600Server("jt600");
+ initEv603Server("ev603");
+ initV680Server("v680");
+ initPt502Server("pt502");
+ initTr20Server("tr20");
+ initNavisServer("navis");
+ initMeitrackServer("meitrack");
+ initSkypatrolServer("skypatrol");
+ initGt02Server("gt02");
+ initGt06Server("gt06");
// Initialize web server
if (Boolean.valueOf(properties.getProperty("http.enable"))) {
@@ -177,6 +191,7 @@ public class Server {
private final DateFormat dateFormat =
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ @Override
public String format(LogRecord record) {
StringBuffer line = new StringBuffer();
dateFormat.format(new Date(record.getMillis()), line, new FieldPosition(0));
@@ -200,7 +215,7 @@ public class Server {
private void initGeocoder(Properties properties) throws IOException {
if (Boolean.parseBoolean(properties.getProperty("geocoder.enable"))) {
- geocoder = new GoogleReverseGeocoder();
+ reverseGeocoder = new GoogleReverseGeocoder();
}
}
@@ -212,40 +227,9 @@ public class Server {
return false;
}
- private String getProtocolInterface(Properties properties, String protocol) {
- return properties.getProperty(protocol + ".address");
- }
-
- private Integer getProtocolPort(Properties properties, String protocol) {
- String port = properties.getProperty(protocol + ".port");
- if (port != null) {
- return Integer.valueOf(port);
- }
- return 5000; // Magic number
- }
-
- private Integer getProtocolResetDelay(Properties properties, String protocol) {
- String resetDelay = properties.getProperty(protocol + ".resetDelay");
- if (resetDelay != null) {
- return Integer.valueOf(resetDelay);
- }
- return 0;
- }
-
- /**
- * Init Xexun server
- */
- private void initXexunServer(Properties properties) throws SQLException {
-
- String protocol = "xexun";
+ private void initXexunServer(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new XexunFrameDecoder());
@@ -253,25 +237,12 @@ public class Server {
pipeline.addLast("objectDecoder", new XexunProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- /**
- * Init Gps103 server
- */
- private void initGps103Server(Properties properties) throws SQLException {
-
- String protocol = "gps103";
+ private void initGps103Server(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
byte delimiter[] = { (byte) ';' };
@@ -282,25 +253,12 @@ public class Server {
pipeline.addLast("objectDecoder", new Gps103ProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- /**
- * Init Tk103 server
- */
- private void initTk103Server(Properties properties) throws SQLException {
-
- String protocol = "tk103";
+ private void initTk103Server(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
byte delimiter[] = { (byte) ')' };
@@ -311,25 +269,12 @@ public class Server {
pipeline.addLast("objectDecoder", new Tk103ProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- /**
- * Init Gl100 server
- */
- private void initGl100Server(Properties properties) throws SQLException {
-
- String protocol = "gl100";
+ private void initGl100Server(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
byte delimiter[] = { (byte) 0x0 };
@@ -340,25 +285,12 @@ public class Server {
pipeline.addLast("objectDecoder", new Gl100ProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- /**
- * Init Gl200 server
- */
- private void initGl200Server(Properties properties) throws SQLException {
-
- String protocol = "gl200";
+ private void initGl200Server(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
byte delimiter[] = { (byte) '$' };
@@ -369,25 +301,12 @@ public class Server {
pipeline.addLast("objectDecoder", new Gl200ProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- /**
- * Init T55 server
- */
- private void initT55Server(Properties properties) throws SQLException {
-
- String protocol = "t55";
+ private void initT55Server(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
byte delimiter[] = { (byte) '\r', (byte) '\n' };
@@ -398,25 +317,12 @@ public class Server {
pipeline.addLast("objectDecoder", new T55ProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- /**
- * Init Xexun 2 server
- */
- private void initXexun2Server(Properties properties) throws SQLException {
-
- String protocol = "xexun2";
+ private void initXexun2Server(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
byte delimiter[] = { (byte) '\n' }; // tracker bug \n\r
@@ -426,25 +332,12 @@ public class Server {
pipeline.addLast("objectDecoder", new Xexun2ProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- /**
- * Init AVL-08 server
- */
- private void initAvl08Server(Properties properties) throws SQLException {
-
- String protocol = "avl08";
+ private void initAvl08Server(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
byte delimiter[] = { (byte) '\r', (byte) '\n' };
@@ -454,71 +347,36 @@ public class Server {
pipeline.addLast("objectDecoder", new Avl08ProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- /**
- * Init Enfora server
- */
- private void initEnforaServer(Properties properties) throws SQLException {
-
- String protocol = "enfora";
+ private void initEnforaServer(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 0, 2, -2, 2));
pipeline.addLast("objectDecoder", new EnforaProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- /**
- * Init Meiligao server
- */
- private void initMeiligaoServer(Properties properties) throws SQLException {
-
- String protocol = "meiligao";
+ private void initMeiligaoServer(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, -4, 4));
pipeline.addLast("objectDecoder", new MeiligaoProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- private void initMaxonServer(Properties properties) throws SQLException {
- String protocol = "maxon";
+ private void initMaxonServer(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
byte delimiter[] = { (byte) '\r', (byte) '\n' };
@@ -529,21 +387,12 @@ public class Server {
pipeline.addLast("objectDecoder", new MaxonProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- private void initST210Server(Properties properties) throws SQLException {
- String protocol = "st210";
+ private void initST210Server(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
byte delimiter[] = { (byte) '\r' };
@@ -553,47 +402,24 @@ public class Server {
pipeline.addLast("objectDecoder", new ST210ProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- private void initProgressServer(Properties properties) throws SQLException {
- String protocol = "progress";
+ private void initProgressServer(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, 0, 0));
pipeline.addLast("objectDecoder", new ProgressProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- /**
- * Init H02 server
- */
- private void initH02Server(Properties properties) throws SQLException {
-
- String protocol = "h02";
+ private void initH02Server(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
byte delimiter[] = { (byte) '#' };
@@ -603,50 +429,24 @@ public class Server {
pipeline.addLast("objectDecoder", new H02ProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- /**
- * Init JT600 server
- */
- private void initJt600Server(Properties properties) throws SQLException {
-
- String protocol = "jt600";
+ private void initJt600Server(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new Jt600FrameDecoder());
pipeline.addLast("objectDecoder", new Jt600ProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- /**
- * Init EV603 server
- */
- private void initEv603Server(Properties properties) throws SQLException {
-
- String protocol = "ev603";
+ private void initEv603Server(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
byte delimiter[] = { (byte) ';' };
@@ -656,25 +456,12 @@ public class Server {
pipeline.addLast("objectDecoder", new Ev603ProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- /**
- * Init V680 server
- */
- private void initV680Server(Properties properties) throws SQLException {
-
- String protocol = "v680";
+ private void initV680Server(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
byte delimiter[] = { (byte) '#', (byte) '#' };
@@ -684,25 +471,12 @@ public class Server {
pipeline.addLast("objectDecoder", new V680ProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- /**
- * Init PT502 server
- */
- private void initPt502Server(Properties properties) throws SQLException {
-
- String protocol = "pt502";
+ private void initPt502Server(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
byte delimiter[] = { (byte) '\r', (byte) '\n' };
@@ -713,25 +487,12 @@ public class Server {
pipeline.addLast("objectDecoder", new Pt502ProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- /**
- * Init TR20 server
- */
- private void initTr20Server(Properties properties) throws SQLException {
-
- String protocol = "tr20";
+ private void initTr20Server(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
byte delimiter[] = { (byte) '\r', (byte) '\n' };
@@ -742,51 +503,24 @@ public class Server {
pipeline.addLast("objectDecoder", new Tr20ProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- /**
- * Init Navis server
- */
- private void initNavisServer(Properties properties) throws SQLException {
-
- String protocol = "navis";
+ private void initNavisServer(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(4 * 1024, 12, 2, 2, 0));
pipeline.addLast("objectDecoder", new NavisProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- /**
- * Init Meitrack server
- */
- private void initMeitrackServer(Properties properties) throws SQLException {
-
- String protocol = "meitrack";
+ private void initMeitrackServer(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
byte delimiter[] = { (byte) '\r', (byte) '\n' };
@@ -797,82 +531,41 @@ public class Server {
pipeline.addLast("objectDecoder", new MeitrackProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- /**
- * Init SkyPatrol server
- */
- private void initSkypatrolServer(Properties properties) throws SQLException {
-
- String protocol = "skypatrol";
+ private void initSkypatrolServer(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ConnectionlessBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("objectDecoder", new SkypatrolProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- /**
- * Init GT02 server
- */
- private void initGt02Server(Properties properties) throws SQLException {
-
- String protocol = "gt02";
+ private void initGt02Server(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 2, 1, 2, 0));
pipeline.addLast("objectDecoder", new Gt02ProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
- /**
- * Init GT06 server
- */
- private void initGt06Server(Properties properties) throws SQLException {
-
- String protocol = "gt06";
+ private void initGt06Server(String protocol) throws SQLException {
if (isProtocolEnabled(properties, protocol)) {
-
- TrackerServer server = new TrackerServer(new ServerBootstrap());
- server.setPort(getProtocolPort(properties, protocol));
- server.setAddress(getProtocolInterface(properties, protocol));
- final Integer resetDelay = getProtocolResetDelay(properties, protocol);
-
- server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
+ serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 2, 1, 2, 0));
pipeline.addLast("objectDecoder", new Gt06ProtocolDecoder(getDataManager()));
}
});
-
- serverList.add(server);
}
}
diff --git a/src/org/traccar/TrackerServer.java b/src/org/traccar/TrackerServer.java
index c24e6494b..36c0ce70e 100644
--- a/src/org/traccar/TrackerServer.java
+++ b/src/org/traccar/TrackerServer.java
@@ -22,6 +22,7 @@ import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.buffer.HeapChannelBufferFactory;
import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.group.ChannelGroup;
import org.jboss.netty.channel.group.ChannelGroupFuture;
@@ -30,17 +31,37 @@ import org.jboss.netty.channel.group.DefaultChannelGroup;
/**
* Tracker server
*/
-public class TrackerServer /*extends ServerBootstrap*/ {
-
- Bootstrap bootstrap;
+public abstract class TrackerServer {
- public TrackerServer(Bootstrap bootstrap) {
+ private ServerManager serverManager;
+ private Bootstrap bootstrap;
+ private String protocol;
+
+ public String getProtocol() {
+ return protocol;
+ }
+
+ public TrackerServer(ServerManager serverManager, Bootstrap bootstrap, String protocol) {
+ this.serverManager = serverManager;
this.bootstrap = bootstrap;
+ this.protocol = protocol;
- // Create channel factory
bootstrap.setFactory(GlobalChannelFactory.getFactory());
+
+ address = serverManager.getProperties().getProperty(protocol + ".address");
+ String portProperty = serverManager.getProperties().getProperty(protocol + ".port");
+ port = (portProperty != null) ? Integer.valueOf(portProperty) : 5000;
+
+ bootstrap.setPipelineFactory(new GenericPipelineFactory(serverManager, this, protocol) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ TrackerServer.this.addSpecificHandlers(pipeline);
+ }
+ });
}
+ protected abstract void addSpecificHandlers(ChannelPipeline pipeline);
+
/**
* Server port
*/
@@ -82,11 +103,11 @@ public class TrackerServer /*extends ServerBootstrap*/ {
public ChannelGroup getChannelGroup() {
return allChannels;
}
-
+
public void setPipelineFactory(ChannelPipelineFactory pipelineFactory) {
bootstrap.setPipelineFactory(pipelineFactory);
}
-
+
/**
* Start server
*/
@@ -97,7 +118,7 @@ public class TrackerServer /*extends ServerBootstrap*/ {
} else {
endpoint = new InetSocketAddress(address, port);
}
-
+
Channel channel = null;
if (bootstrap instanceof ServerBootstrap) {
channel = ((ServerBootstrap) bootstrap).bind(endpoint);
@@ -109,7 +130,7 @@ public class TrackerServer /*extends ServerBootstrap*/ {
getChannelGroup().add(channel);
}
}
-
+
/**
* Stop server
*/