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/ExtendedObjectDecoder.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/ExtendedObjectDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/ExtendedObjectDecoder.java | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/ExtendedObjectDecoder.java b/src/main/java/org/traccar/ExtendedObjectDecoder.java index 46720da52..f79a36c85 100644 --- a/src/main/java/org/traccar/ExtendedObjectDecoder.java +++ b/src/main/java/org/traccar/ExtendedObjectDecoder.java @@ -21,18 +21,38 @@ import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.util.ReferenceCountUtil; +import org.traccar.config.Config; import org.traccar.config.Keys; import org.traccar.helper.DataConverter; import org.traccar.model.Position; +import javax.inject.Inject; import java.net.SocketAddress; import java.nio.charset.StandardCharsets; import java.util.Collection; public abstract class ExtendedObjectDecoder extends ChannelInboundHandlerAdapter { + private Config config; + + public Config getConfig() { + return config; + } + + @Inject + public void setConfig(Config config) { + this.config = config; + init(); + } + + /** + * Method called when config is initialized. + */ + protected void init() { + } + private void saveOriginal(Object decodedMessage, Object originalMessage) { - if (Context.getConfig().getBoolean(Keys.DATABASE_SAVE_ORIGINAL) && decodedMessage instanceof Position) { + if (getConfig().getBoolean(Keys.DATABASE_SAVE_ORIGINAL) && decodedMessage instanceof Position) { Position position = (Position) decodedMessage; if (originalMessage instanceof ByteBuf) { ByteBuf buf = (ByteBuf) originalMessage; |