aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/GenericPipelineFactory.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-01-13 18:19:27 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2013-01-13 18:19:27 +1300
commitcf72e8022b9fc27135aea8939e4aa508744dcfbb (patch)
treeaf52fb16731e66f2bbf6432aa348024a36804779 /src/org/traccar/GenericPipelineFactory.java
parent36c030fa027402b18e2f77027d407b04a867b4fc (diff)
downloadtrackermap-server-cf72e8022b9fc27135aea8939e4aa508744dcfbb.tar.gz
trackermap-server-cf72e8022b9fc27135aea8939e4aa508744dcfbb.tar.bz2
trackermap-server-cf72e8022b9fc27135aea8939e4aa508744dcfbb.zip
Reduced ServerManager size
Diffstat (limited to 'src/org/traccar/GenericPipelineFactory.java')
-rw-r--r--src/org/traccar/GenericPipelineFactory.java26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/org/traccar/GenericPipelineFactory.java b/src/org/traccar/GenericPipelineFactory.java
index 556d86e1d..4537ac4f7 100644
--- a/src/org/traccar/GenericPipelineFactory.java
+++ b/src/org/traccar/GenericPipelineFactory.java
@@ -34,7 +34,7 @@ public abstract class GenericPipelineFactory implements ChannelPipelineFactory {
private DataManager dataManager;
private Boolean loggerEnabled;
private Integer resetDelay;
- private ReverseGeocoder geocoder;
+ private ReverseGeocoder reverseGeocoder;
/**
* Open channel handler
@@ -65,7 +65,7 @@ public abstract class GenericPipelineFactory implements ChannelPipelineFactory {
if (e instanceof MessageEvent) {
MessageEvent event = (MessageEvent) e;
StringBuilder msg = new StringBuilder();
-
+
msg.append("[").append(((InetSocketAddress) e.getChannel().getLocalAddress()).getPort()).append(" - ");
msg.append(((InetSocketAddress) event.getRemoteAddress()).getAddress().getHostAddress()).append("]");
@@ -85,13 +85,16 @@ public abstract class GenericPipelineFactory implements ChannelPipelineFactory {
}
}
- public GenericPipelineFactory(
- TrackerServer server, DataManager dataManager, Boolean loggerEnabled, Integer resetDelay, ReverseGeocoder geocoder) {
+ public GenericPipelineFactory(ServerManager serverManager, TrackerServer server, String protocol) {
this.server = server;
- this.dataManager = dataManager;
- this.loggerEnabled = loggerEnabled;
- this.resetDelay = resetDelay;
- this.geocoder = geocoder;
+ dataManager = serverManager.getDataManager();
+ loggerEnabled = serverManager.isLoggerEnabled();
+ reverseGeocoder = serverManager.getReverseGeocoder();
+
+ String resetDelayProperty = serverManager.getProperties().getProperty(protocol + ".resetDelay");
+ if (resetDelayProperty != null) {
+ resetDelay = Integer.valueOf(resetDelayProperty);
+ }
}
protected DataManager getDataManager() {
@@ -100,9 +103,10 @@ public abstract class GenericPipelineFactory implements ChannelPipelineFactory {
protected abstract void addSpecificHandlers(ChannelPipeline pipeline);
+ @Override
public ChannelPipeline getPipeline() {
ChannelPipeline pipeline = Channels.pipeline();
- if (resetDelay != 0) {
+ if (resetDelay != null) {
pipeline.addLast("idleHandler", new IdleStateHandler(GlobalTimer.getTimer(), resetDelay, 0, 0));
}
pipeline.addLast("openHandler", new OpenChannelHandler(server));
@@ -110,8 +114,8 @@ public abstract class GenericPipelineFactory implements ChannelPipelineFactory {
pipeline.addLast("logger", new StandardLoggingHandler());
}
addSpecificHandlers(pipeline);
- if (geocoder != null) {
- pipeline.addLast("geocoder", new ReverseGeocoderHandler(geocoder));
+ if (reverseGeocoder != null) {
+ pipeline.addLast("geocoder", new ReverseGeocoderHandler(reverseGeocoder));
}
pipeline.addLast("handler", new TrackerEventHandler(dataManager));
return pipeline;