aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/ExtendedObjectDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-07-12 12:28:28 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-07-12 12:28:28 +1200
commit639b427eba5738534c10f591e285d707e8b060e5 (patch)
treebdafa0f9751c77561ade92ebed272b6d6545ea43 /src/org/traccar/ExtendedObjectDecoder.java
parent2badcd16f7ae0ce46f7c0cd241c635493d7e6508 (diff)
downloadtrackermap-server-639b427eba5738534c10f591e285d707e8b060e5.tar.gz
trackermap-server-639b427eba5738534c10f591e285d707e8b060e5.tar.bz2
trackermap-server-639b427eba5738534c10f591e285d707e8b060e5.zip
Re-factor decoder interface
Diffstat (limited to 'src/org/traccar/ExtendedObjectDecoder.java')
-rw-r--r--src/org/traccar/ExtendedObjectDecoder.java25
1 files changed, 6 insertions, 19 deletions
diff --git a/src/org/traccar/ExtendedObjectDecoder.java b/src/org/traccar/ExtendedObjectDecoder.java
index 55a75bb67..ad0210934 100644
--- a/src/org/traccar/ExtendedObjectDecoder.java
+++ b/src/org/traccar/ExtendedObjectDecoder.java
@@ -15,17 +15,15 @@
*/
package org.traccar;
+import java.net.SocketAddress;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelEvent;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.MessageEvent;
-import org.jboss.netty.handler.codec.oneone.OneToOneDecoder;
-
-import java.net.SocketAddress;
-
+import org.jboss.netty.channel.ChannelUpstreamHandler;
import static org.jboss.netty.channel.Channels.fireMessageReceived;
+import org.jboss.netty.channel.MessageEvent;
-public abstract class ExtendedObjectDecoder extends OneToOneDecoder {
+public abstract class ExtendedObjectDecoder implements ChannelUpstreamHandler {
@Override
public void handleUpstream(
@@ -37,7 +35,7 @@ public abstract class ExtendedObjectDecoder extends OneToOneDecoder {
MessageEvent e = (MessageEvent) evt;
Object originalMessage = e.getMessage();
- Object decodedMessage = decode(ctx, e.getChannel(), e.getRemoteAddress(), originalMessage);
+ Object decodedMessage = decode(e.getChannel(), e.getRemoteAddress(), originalMessage);
if (originalMessage == decodedMessage) {
ctx.sendUpstream(evt);
} else if (decodedMessage != null) {
@@ -45,17 +43,6 @@ public abstract class ExtendedObjectDecoder extends OneToOneDecoder {
}
}
- protected Object decode(
- ChannelHandlerContext ctx, Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
-
- return decode(ctx, channel, msg);
- }
-
- @Override
- protected Object decode(
- ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
-
- return null; // default implementation
- }
+ protected abstract Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception;
}