diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-15 19:08:58 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-15 19:08:58 -0700 |
commit | ca884b765f3f7a642c435be886dbec40f9d1f661 (patch) | |
tree | eb809ffe38faaf6e580fc2434beb9c4e0b3f90e5 /src/main/java/org/traccar/BaseProtocolDecoder.java | |
parent | 63ecf80c11ec9bce19df18fc24ad863a9c2cb212 (diff) | |
download | trackermap-server-ca884b765f3f7a642c435be886dbec40f9d1f661.tar.gz trackermap-server-ca884b765f3f7a642c435be886dbec40f9d1f661.tar.bz2 trackermap-server-ca884b765f3f7a642c435be886dbec40f9d1f661.zip |
Convert some config usages
Diffstat (limited to 'src/main/java/org/traccar/BaseProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/BaseProtocolDecoder.java | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/src/main/java/org/traccar/BaseProtocolDecoder.java b/src/main/java/org/traccar/BaseProtocolDecoder.java index 5b3f129de..cbcb429b3 100644 --- a/src/main/java/org/traccar/BaseProtocolDecoder.java +++ b/src/main/java/org/traccar/BaseProtocolDecoder.java @@ -17,7 +17,6 @@ package org.traccar; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; -import org.traccar.config.Config; import org.traccar.config.Keys; import org.traccar.database.CommandsManager; import org.traccar.database.IdentityManager; @@ -46,7 +45,6 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder { private final Protocol protocol; - private Config config; private IdentityManager identityManager; private ConnectionManager connectionManager; private StatisticsManager statisticsManager; @@ -57,22 +55,6 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder { this.protocol = protocol; } - /** - * Method called when config is initialized. - */ - protected void init() { - } - - public Config getConfig() { - return config; - } - - @Inject - public void setConfig(Config config) { - this.config = config; - init(); - } - public IdentityManager getIdentityManager() { return identityManager; } @@ -115,7 +97,7 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder { } public String getServer(Channel channel, char delimiter) { - String server = config.getString(Keys.PROTOCOL_SERVER.withPrefix(getProtocolName())); + String server = getConfig().getString(Keys.PROTOCOL_SERVER.withPrefix(getProtocolName())); if (server == null && channel != null) { InetSocketAddress address = (InetSocketAddress) channel.localAddress(); server = address.getAddress().getHostAddress() + ":" + address.getPort(); @@ -124,7 +106,7 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder { } protected double convertSpeed(double value, String defaultUnits) { - switch (config.getString(getProtocolName() + ".speed", defaultUnits)) { + switch (getConfig().getString(getProtocolName() + ".speed", defaultUnits)) { case "kmh": return UnitsConverter.knotsFromKph(value); case "mps": @@ -222,7 +204,7 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder { @Override protected Object handleEmptyMessage(Channel channel, SocketAddress remoteAddress, Object msg) { DeviceSession deviceSession = getDeviceSession(channel, remoteAddress); - if (config.getBoolean(Keys.DATABASE_SAVE_EMPTY) && deviceSession != null) { + if (getConfig().getBoolean(Keys.DATABASE_SAVE_EMPTY) && deviceSession != null) { Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); getLastLocation(position, null); |