aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/TrackerServer.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-12-28 23:09:40 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2022-01-14 21:01:16 -0800
commitc1121777969fc5f183e325ad672b581cbe881895 (patch)
tree8d874f0244ceb68c7bc9f440f44b20cca882fdad /src/main/java/org/traccar/TrackerServer.java
parent839751e76e329adb573150644bd6198beba0d3b6 (diff)
downloadtrackermap-server-c1121777969fc5f183e325ad672b581cbe881895.tar.gz
trackermap-server-c1121777969fc5f183e325ad672b581cbe881895.tar.bz2
trackermap-server-c1121777969fc5f183e325ad672b581cbe881895.zip
Extract connector interface
Diffstat (limited to 'src/main/java/org/traccar/TrackerServer.java')
-rw-r--r--src/main/java/org/traccar/TrackerServer.java29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/main/java/org/traccar/TrackerServer.java b/src/main/java/org/traccar/TrackerServer.java
index 59ba123e2..7b25e5cc5 100644
--- a/src/main/java/org/traccar/TrackerServer.java
+++ b/src/main/java/org/traccar/TrackerServer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2021 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.
@@ -28,11 +28,19 @@ import org.traccar.config.Keys;
import java.net.InetSocketAddress;
-public abstract class TrackerServer {
+public abstract class TrackerServer implements TrackerConnector {
private final boolean datagram;
+
+ @SuppressWarnings("rawtypes")
private final AbstractBootstrap bootstrap;
+ private final int port;
+ private final String address;
+
+ private final ChannelGroup channelGroup = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
+
+ @Override
public boolean isDatagram() {
return datagram;
}
@@ -69,32 +77,20 @@ public abstract class TrackerServer {
protected abstract void addProtocolHandlers(PipelineBuilder pipeline);
- private int port;
-
public int getPort() {
return port;
}
- public void setPort(int port) {
- this.port = port;
- }
-
- private String address;
-
public String getAddress() {
return address;
}
- public void setAddress(String address) {
- this.address = address;
- }
-
- private final ChannelGroup channelGroup = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
-
+ @Override
public ChannelGroup getChannelGroup() {
return channelGroup;
}
+ @Override
public void start() throws Exception {
InetSocketAddress endpoint;
if (address == null) {
@@ -109,6 +105,7 @@ public abstract class TrackerServer {
}
}
+ @Override
public void stop() {
channelGroup.close().awaitUninterruptibly();
}