aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorIvan Martinez <ivanfmartinez@users.noreply.github.com>2015-11-16 23:50:14 -0200
committerIvan Martinez <ivanfmartinez@users.noreply.github.com>2015-11-16 23:50:14 -0200
commit65361d8f0359fe2c4e02e76892a565683743b796 (patch)
treeec6d4e1dd17ae56578bbf3fb21642438b887f816 /src/org/traccar
parent5e56a1fbf80033cf5cc30ec7767d3cd92ab41cde (diff)
downloadtrackermap-server-65361d8f0359fe2c4e02e76892a565683743b796.tar.gz
trackermap-server-65361d8f0359fe2c4e02e76892a565683743b796.tar.bz2
trackermap-server-65361d8f0359fe2c4e02e76892a565683743b796.zip
add support for configurable handlers
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/BasePipelineFactory.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java
index c0952db86..7273d51cf 100644
--- a/src/org/traccar/BasePipelineFactory.java
+++ b/src/org/traccar/BasePipelineFactory.java
@@ -19,6 +19,7 @@ import java.net.InetSocketAddress;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.ChannelEvent;
+import org.jboss.netty.channel.ChannelHandler;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
@@ -130,6 +131,9 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory {
pipeline.addLast("geocoder", reverseGeocoderHandler);
}
pipeline.addLast("remoteAddress", new RemoteAddressHandler());
+
+ addDynamicHandlers(pipeline, "extraHandler", "extra.handlers");
+
if (Context.getDataManager() != null) {
pipeline.addLast("dataHandler", new DefaultDataHandler());
}
@@ -140,4 +144,19 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory {
return pipeline;
}
+ private void addDynamicHandlers(ChannelPipeline pipeline, String id, String key) {
+ final String[] extraHandlers = Context.getConfig().getString(key,"").split(",");
+ int i = 0;
+ for (String extraHandler : extraHandlers) {
+ try {
+ Class c = Class.forName(extraHandler);
+ i++;
+ pipeline.addLast(id + "."+i, (ChannelHandler)c.newInstance());
+ } catch (Throwable e) {
+ Log.error("Error loading handler : " + extraHandler + " " + e);
+ }
+ }
+
+ }
+
}