aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/TaipPrefixEncoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-05-30 14:48:42 -0700
committerAnton Tananaev <anton@traccar.org>2022-05-30 14:48:42 -0700
commit0202dbf7258df8cbe8168ddc985e774b1cadf964 (patch)
tree4828e614e29715e6bdfd10c5db86b52e43229ab3 /src/main/java/org/traccar/protocol/TaipPrefixEncoder.java
parent014cf82a9e63a36e944e293932f9edf27e452919 (diff)
downloadtrackermap-server-0202dbf7258df8cbe8168ddc985e774b1cadf964.tar.gz
trackermap-server-0202dbf7258df8cbe8168ddc985e774b1cadf964.tar.bz2
trackermap-server-0202dbf7258df8cbe8168ddc985e774b1cadf964.zip
Decouple more tests from context
Diffstat (limited to 'src/main/java/org/traccar/protocol/TaipPrefixEncoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/TaipPrefixEncoder.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/protocol/TaipPrefixEncoder.java b/src/main/java/org/traccar/protocol/TaipPrefixEncoder.java
index 02c111b01..48419af2a 100644
--- a/src/main/java/org/traccar/protocol/TaipPrefixEncoder.java
+++ b/src/main/java/org/traccar/protocol/TaipPrefixEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2021 Anton Tananaev (anton@traccar.org)
+ * Copyright 2021 - 2022 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.
@@ -15,13 +15,14 @@
*/
package org.traccar.protocol;
+import com.google.inject.Inject;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;
-import org.traccar.Context;
import org.traccar.Protocol;
+import org.traccar.config.Config;
import org.traccar.config.Keys;
import java.util.List;
@@ -30,14 +31,20 @@ import java.util.List;
public class TaipPrefixEncoder extends MessageToMessageEncoder<ByteBuf> {
private final Protocol protocol;
+ private Config config;
public TaipPrefixEncoder(Protocol protocol) {
this.protocol = protocol;
}
+ @Inject
+ public void setConfig(Config config) {
+ this.config = config;
+ }
+
@Override
- protected void encode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) throws Exception {
- if (Context.getConfig().getBoolean(Keys.PROTOCOL_PREFIX.withPrefix(protocol.getName()))) {
+ protected void encode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) {
+ if (config.getBoolean(Keys.PROTOCOL_PREFIX.withPrefix(protocol.getName()))) {
out.add(Unpooled.wrappedBuffer(Unpooled.wrappedBuffer(new byte[] {0x20, 0x20, 0x06, 0x00}), msg.retain()));
} else {
out.add(msg.retain());