aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/BasePipelineFactory.java
diff options
context:
space:
mode:
authorRafael Guterres <guterresrafael@gmail.com>2015-11-21 02:13:24 -0200
committerRafael Guterres <guterresrafael@gmail.com>2015-11-21 02:13:24 -0200
commit77cd23da84ebebcf99a97a8aef88aa9a4884ca40 (patch)
treef95fa042b4755e925be8d0c8416fcb648ea23aa3 /src/org/traccar/BasePipelineFactory.java
parentf5a266953e53a7f1785bcb584759582621ec9de3 (diff)
parent7623704e12a3e60420c86add5cfdc18b14061752 (diff)
downloadtrackermap-server-77cd23da84ebebcf99a97a8aef88aa9a4884ca40.tar.gz
trackermap-server-77cd23da84ebebcf99a97a8aef88aa9a4884ca40.tar.bz2
trackermap-server-77cd23da84ebebcf99a97a8aef88aa9a4884ca40.zip
Merge tananaev/master
Diffstat (limited to 'src/org/traccar/BasePipelineFactory.java')
-rw-r--r--src/org/traccar/BasePipelineFactory.java34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java
index c0952db86..c011fb015 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;
@@ -39,6 +40,7 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory {
private FilterHandler filterHandler;
private DistanceHandler distanceHandler;
private ReverseGeocoderHandler reverseGeocoderHandler;
+ private LocationProviderHandler locationProviderHandler;
private static final class OpenChannelHandler extends SimpleChannelHandler {
@@ -102,6 +104,10 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory {
Context.getReverseGeocoder(), Context.getConfig().getBoolean("geocode.processInvalidPositions"));
}
+ if (Context.getLocationProvider() != null) {
+ locationProviderHandler = new LocationProviderHandler(Context.getLocationProvider());
+ }
+
if (Context.getConfig().getBoolean("distance.enable")) {
distanceHandler = new DistanceHandler();
}
@@ -119,17 +125,26 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory {
if (Context.isLoggerEnabled()) {
pipeline.addLast("logger", new StandardLoggingHandler());
}
+
addSpecificHandlers(pipeline);
- if (filterHandler != null) {
- pipeline.addLast("filter", filterHandler);
- }
+
if (distanceHandler != null) {
pipeline.addLast("distance", distanceHandler);
}
if (reverseGeocoderHandler != null) {
pipeline.addLast("geocoder", reverseGeocoderHandler);
}
+ if (locationProviderHandler != null) {
+ pipeline.addLast("location", locationProviderHandler);
+ }
pipeline.addLast("remoteAddress", new RemoteAddressHandler());
+
+ addDynamicHandlers(pipeline);
+
+ if (filterHandler != null) {
+ pipeline.addLast("filter", filterHandler);
+ }
+
if (Context.getDataManager() != null) {
pipeline.addLast("dataHandler", new DefaultDataHandler());
}
@@ -140,4 +155,17 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory {
return pipeline;
}
+ private void addDynamicHandlers(ChannelPipeline pipeline) {
+ if (Context.getConfig().hasKey("extra.handlers")) {
+ String[] handlers = Context.getConfig().getString("extra.handlers").split(",");
+ for (int i = 0; i < handlers.length; i++) {
+ try {
+ pipeline.addLast("extraHandler." + i, (ChannelHandler) Class.forName(handlers[i]).newInstance());
+ } catch (ClassNotFoundException | InstantiationException | IllegalAccessException error) {
+ Log.warning(error);
+ }
+ }
+ }
+ }
+
}