aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/Server.java64
-rw-r--r--src/org/traccar/TrackerServer.java42
2 files changed, 69 insertions, 37 deletions
diff --git a/src/org/traccar/Server.java b/src/org/traccar/Server.java
index e4541aa43..9a4bcd1d4 100644
--- a/src/org/traccar/Server.java
+++ b/src/org/traccar/Server.java
@@ -30,6 +30,7 @@ import java.util.logging.FileHandler;
import java.util.logging.Formatter;
import java.util.logging.Level;
import java.util.logging.LogRecord;
+import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
@@ -245,7 +246,8 @@ public class Server {
String protocol = "xexun";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ TrackerServer server = new TrackerServer(new ServerBootstrap());
+ server.setPort(getProtocolPort(properties, protocol));
server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
@@ -269,7 +271,8 @@ public class Server {
String protocol = "gps103";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ TrackerServer server = new TrackerServer(new ServerBootstrap());
+ server.setPort(getProtocolPort(properties, protocol));
server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
@@ -296,7 +299,8 @@ public class Server {
String protocol = "tk103";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ TrackerServer server = new TrackerServer(new ServerBootstrap());
+ server.setPort(getProtocolPort(properties, protocol));
server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
@@ -323,7 +327,8 @@ public class Server {
String protocol = "gl100";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ TrackerServer server = new TrackerServer(new ServerBootstrap());
+ server.setPort(getProtocolPort(properties, protocol));
server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
@@ -350,7 +355,8 @@ public class Server {
String protocol = "gl200";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ TrackerServer server = new TrackerServer(new ServerBootstrap());
+ server.setPort(getProtocolPort(properties, protocol));
server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
@@ -377,7 +383,8 @@ public class Server {
String protocol = "t55";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ TrackerServer server = new TrackerServer(new ServerBootstrap());
+ server.setPort(getProtocolPort(properties, protocol));
server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
@@ -404,7 +411,8 @@ public class Server {
String protocol = "xexun2";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ TrackerServer server = new TrackerServer(new ServerBootstrap());
+ server.setPort(getProtocolPort(properties, protocol));
server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
@@ -430,7 +438,8 @@ public class Server {
String protocol = "avl08";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ TrackerServer server = new TrackerServer(new ServerBootstrap());
+ server.setPort(getProtocolPort(properties, protocol));
server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
@@ -456,7 +465,8 @@ public class Server {
String protocol = "enfora";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ TrackerServer server = new TrackerServer(new ServerBootstrap());
+ server.setPort(getProtocolPort(properties, protocol));
server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
@@ -479,7 +489,8 @@ public class Server {
String protocol = "meiligao";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ TrackerServer server = new TrackerServer(new ServerBootstrap());
+ server.setPort(getProtocolPort(properties, protocol));
server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
@@ -498,7 +509,8 @@ public class Server {
String protocol = "maxon";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ TrackerServer server = new TrackerServer(new ServerBootstrap());
+ server.setPort(getProtocolPort(properties, protocol));
server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
@@ -521,7 +533,8 @@ public class Server {
String protocol = "st210";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ TrackerServer server = new TrackerServer(new ServerBootstrap());
+ server.setPort(getProtocolPort(properties, protocol));
server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
@@ -543,7 +556,8 @@ public class Server {
String protocol = "progress";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(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);
@@ -567,7 +581,8 @@ public class Server {
String protocol = "h02";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ TrackerServer server = new TrackerServer(new ServerBootstrap());
+ server.setPort(getProtocolPort(properties, protocol));
server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
@@ -593,7 +608,8 @@ public class Server {
String protocol = "jt600";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ TrackerServer server = new TrackerServer(new ServerBootstrap());
+ server.setPort(getProtocolPort(properties, protocol));
server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
@@ -616,7 +632,8 @@ public class Server {
String protocol = "ev603";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ TrackerServer server = new TrackerServer(new ServerBootstrap());
+ server.setPort(getProtocolPort(properties, protocol));
server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
@@ -642,7 +659,8 @@ public class Server {
String protocol = "v680";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ TrackerServer server = new TrackerServer(new ServerBootstrap());
+ server.setPort(getProtocolPort(properties, protocol));
server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
@@ -668,7 +686,8 @@ public class Server {
String protocol = "pt502";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ TrackerServer server = new TrackerServer(new ServerBootstrap());
+ server.setPort(getProtocolPort(properties, protocol));
server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
@@ -695,7 +714,8 @@ public class Server {
String protocol = "tr20";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ TrackerServer server = new TrackerServer(new ServerBootstrap());
+ server.setPort(getProtocolPort(properties, protocol));
server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
@@ -722,7 +742,8 @@ public class Server {
String protocol = "navis";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(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);
@@ -746,7 +767,8 @@ public class Server {
String protocol = "meitrack";
if (isProtocolEnabled(properties, protocol)) {
- TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ TrackerServer server = new TrackerServer(new ServerBootstrap());
+ server.setPort(getProtocolPort(properties, protocol));
server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
diff --git a/src/org/traccar/TrackerServer.java b/src/org/traccar/TrackerServer.java
index 56a9a2946..c24e6494b 100644
--- a/src/org/traccar/TrackerServer.java
+++ b/src/org/traccar/TrackerServer.java
@@ -17,9 +17,12 @@ package org.traccar;
import java.net.InetSocketAddress;
import java.nio.ByteOrder;
+import org.jboss.netty.bootstrap.Bootstrap;
+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.ChannelPipelineFactory;
import org.jboss.netty.channel.group.ChannelGroup;
import org.jboss.netty.channel.group.ChannelGroupFuture;
import org.jboss.netty.channel.group.DefaultChannelGroup;
@@ -27,21 +30,15 @@ import org.jboss.netty.channel.group.DefaultChannelGroup;
/**
* Tracker server
*/
-public class TrackerServer extends ServerBootstrap {
+public class TrackerServer /*extends ServerBootstrap*/ {
+
+ Bootstrap bootstrap;
- /**
- * Initialization
- */
- private void init(Integer port) {
-
- setPort(port);
+ public TrackerServer(Bootstrap bootstrap) {
+ this.bootstrap = bootstrap;
// Create channel factory
- setFactory(GlobalChannelFactory.getFactory());
- }
-
- public TrackerServer(Integer port) {
- init(port);
+ bootstrap.setFactory(GlobalChannelFactory.getFactory());
}
/**
@@ -53,7 +50,7 @@ public class TrackerServer extends ServerBootstrap {
return port;
}
- private void setPort(Integer port) {
+ public void setPort(Integer port) {
this.port = port;
}
@@ -74,7 +71,7 @@ public class TrackerServer extends ServerBootstrap {
* Set endianness
*/
void setEndianness(ByteOrder byteOrder) {
- setOption("child.bufferFactory", new HeapChannelBufferFactory(byteOrder));
+ bootstrap.setOption("child.bufferFactory", new HeapChannelBufferFactory(byteOrder));
}
/**
@@ -86,6 +83,10 @@ public class TrackerServer extends ServerBootstrap {
return allChannels;
}
+ public void setPipelineFactory(ChannelPipelineFactory pipelineFactory) {
+ bootstrap.setPipelineFactory(pipelineFactory);
+ }
+
/**
* Start server
*/
@@ -96,8 +97,17 @@ public class TrackerServer extends ServerBootstrap {
} else {
endpoint = new InetSocketAddress(address, port);
}
- Channel channel = bind(endpoint);
- getChannelGroup().add(channel);
+
+ Channel channel = null;
+ if (bootstrap instanceof ServerBootstrap) {
+ channel = ((ServerBootstrap) bootstrap).bind(endpoint);
+ } else if (bootstrap instanceof ConnectionlessBootstrap) {
+ channel = ((ConnectionlessBootstrap) bootstrap).bind(endpoint);
+ }
+
+ if (channel != null) {
+ getChannelGroup().add(channel);
+ }
}
/**