diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2012-10-31 23:27:09 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2012-10-31 23:27:09 +1300 |
commit | e2a855c53cad32d38a53ed65c0b899f59c99e646 (patch) | |
tree | 7e20ce16641392d6d769232f224e7454e20b53eb /src/org | |
parent | 68ef12c1844fd692aca86a848d268accadbe67be (diff) | |
download | traccar-server-e2a855c53cad32d38a53ed65c0b899f59c99e646.tar.gz traccar-server-e2a855c53cad32d38a53ed65c0b899f59c99e646.tar.bz2 traccar-server-e2a855c53cad32d38a53ed65c0b899f59c99e646.zip |
Properly handle connection closing (fix #62)
Diffstat (limited to 'src/org')
24 files changed, 177 insertions, 148 deletions
diff --git a/src/org/traccar/GenericPipelineFactory.java b/src/org/traccar/GenericPipelineFactory.java index c5e2cc812..d2012753e 100644 --- a/src/org/traccar/GenericPipelineFactory.java +++ b/src/org/traccar/GenericPipelineFactory.java @@ -19,6 +19,7 @@ import java.net.InetSocketAddress; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.*; import org.jboss.netty.handler.logging.LoggingHandler; +import org.jboss.netty.handler.timeout.IdleStateHandler; import org.traccar.geocode.ReverseGeocoder; import org.traccar.helper.Log; import org.traccar.model.DataManager; @@ -31,6 +32,7 @@ public abstract class GenericPipelineFactory implements ChannelPipelineFactory { private TrackerServer server; private DataManager dataManager; private Boolean loggerEnabled; + private Integer resetDelay; private ReverseGeocoder geocoder; /** @@ -86,10 +88,11 @@ public abstract class GenericPipelineFactory implements ChannelPipelineFactory { } public GenericPipelineFactory( - TrackerServer server, DataManager dataManager, Boolean loggerEnabled, ReverseGeocoder geocoder) { + TrackerServer server, DataManager dataManager, Boolean loggerEnabled, Integer resetDelay, ReverseGeocoder geocoder) { this.server = server; this.dataManager = dataManager; this.loggerEnabled = loggerEnabled; + this.resetDelay = resetDelay; this.geocoder = geocoder; } @@ -101,6 +104,9 @@ public abstract class GenericPipelineFactory implements ChannelPipelineFactory { public ChannelPipeline getPipeline() { ChannelPipeline pipeline = Channels.pipeline(); + if (resetDelay != 0) { + pipeline.addLast("idleHandler", new IdleStateHandler(GlobalTimer.getTimer(), resetDelay, 0, 0)); + } pipeline.addLast("openHandler", new OpenChannelHandler(server)); if (loggerEnabled) { pipeline.addLast("logger", new StandardLoggingHandler()); diff --git a/src/org/traccar/GenericProtocolDecoder.java b/src/org/traccar/GenericProtocolDecoder.java index b6755f95e..440b37dcb 100644 --- a/src/org/traccar/GenericProtocolDecoder.java +++ b/src/org/traccar/GenericProtocolDecoder.java @@ -46,18 +46,6 @@ public abstract class GenericProtocolDecoder extends OneToOneDecoder { } /** - * Reset connection delay - */ - private Integer resetDelay; - - /** - * Set reset connection delay - */ - public final void setResetDelay(Integer resetDelay) { - this.resetDelay = resetDelay; - } - - /** * Default constructor */ public GenericProtocolDecoder() { @@ -66,40 +54,8 @@ public abstract class GenericProtocolDecoder extends OneToOneDecoder { /** * Initialize */ - public GenericProtocolDecoder(DataManager dataManager, Integer resetDelay) { + public GenericProtocolDecoder(DataManager dataManager) { setDataManager(dataManager); - setResetDelay(resetDelay); - } - - /** - * Disconnect channel - */ - private class DisconnectTask extends TimerTask { - private Channel channel; - - public DisconnectTask(Channel channel) { - this.channel = channel; - } - - public void run() { - channel.disconnect(); - } - } - - /** - * Handle connect event - */ - @Override - public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent evt) throws Exception { - super.handleUpstream(ctx, evt); - - if (evt instanceof ChannelStateEvent) { - ChannelStateEvent event = (ChannelStateEvent) evt; - - if (event.getState() == ChannelState.CONNECTED && event.getValue() != null && resetDelay != 0) { - new Timer().schedule(new GenericProtocolDecoder.DisconnectTask(evt.getChannel()), resetDelay); - } - } } } diff --git a/src/org/traccar/GlobalChannelFactory.java b/src/org/traccar/GlobalChannelFactory.java index 0c4d11275..a93703286 100644 --- a/src/org/traccar/GlobalChannelFactory.java +++ b/src/org/traccar/GlobalChannelFactory.java @@ -28,6 +28,13 @@ public class GlobalChannelFactory { private GlobalChannelFactory() { } + + public static void release() { + if (instance != null) { + instance.releaseExternalResources(); + } + instance = null; + } public static ChannelFactory getFactory() { if(instance == null) { diff --git a/src/org/traccar/GlobalTimer.java b/src/org/traccar/GlobalTimer.java new file mode 100644 index 000000000..b5eea450e --- /dev/null +++ b/src/org/traccar/GlobalTimer.java @@ -0,0 +1,44 @@ +/* + * Copyright 2012 Anton Tananaev (anton.tananaev@gmail.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.traccar; + +import org.jboss.netty.util.HashedWheelTimer; +import org.jboss.netty.util.Timer; + +/** + * Global idle timer + */ +public class GlobalTimer { + + private static Timer instance = null; + + private GlobalTimer() { + } + + public static void release() { + if (instance != null) { + instance.stop(); + } + instance = null; + } + + public static Timer getTimer() { + if(instance == null) { + instance = new HashedWheelTimer(); + } + return instance; + } +} diff --git a/src/org/traccar/Server.java b/src/org/traccar/Server.java index 0cca284d0..8dd55431f 100644 --- a/src/org/traccar/Server.java +++ b/src/org/traccar/Server.java @@ -135,6 +135,11 @@ public class Server { for (Object server: serverList) { ((TrackerServer) server).stop(); } + + // Release resources + GlobalChannelFactory.release(); + GlobalTimer.release(); + if (webServer != null) { webServer.stop(); } @@ -226,11 +231,11 @@ public class Server { TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol)); final Integer resetDelay = getProtocolResetDelay(properties, protocol); - server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), geocoder) { + server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) { protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new XexunFrameDecoder()); pipeline.addLast("stringDecoder", new StringDecoder()); - pipeline.addLast("objectDecoder", new XexunProtocolDecoder(getDataManager(), resetDelay)); + pipeline.addLast("objectDecoder", new XexunProtocolDecoder(getDataManager())); } }); @@ -249,14 +254,14 @@ public class Server { TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol)); final Integer resetDelay = getProtocolResetDelay(properties, protocol); - server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), geocoder) { + server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) { protected void addSpecificHandlers(ChannelPipeline pipeline) { byte delimiter[] = { (byte) ';' }; pipeline.addLast("frameDecoder", new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter))); pipeline.addLast("stringDecoder", new StringDecoder()); pipeline.addLast("stringEncoder", new StringEncoder()); - pipeline.addLast("objectDecoder", new Gps103ProtocolDecoder(getDataManager(), resetDelay)); + pipeline.addLast("objectDecoder", new Gps103ProtocolDecoder(getDataManager())); } }); @@ -275,14 +280,14 @@ public class Server { TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol)); final Integer resetDelay = getProtocolResetDelay(properties, protocol); - server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), geocoder) { + server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) { protected void addSpecificHandlers(ChannelPipeline pipeline) { byte delimiter[] = { (byte) ')' }; pipeline.addLast("frameDecoder", new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter))); pipeline.addLast("stringDecoder", new StringDecoder()); pipeline.addLast("stringEncoder", new StringEncoder()); - pipeline.addLast("objectDecoder", new Tk103ProtocolDecoder(getDataManager(), resetDelay)); + pipeline.addLast("objectDecoder", new Tk103ProtocolDecoder(getDataManager())); } }); @@ -301,14 +306,14 @@ public class Server { TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol)); final Integer resetDelay = getProtocolResetDelay(properties, protocol); - server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), geocoder) { + server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) { protected void addSpecificHandlers(ChannelPipeline pipeline) { byte delimiter[] = { (byte) 0x0 }; pipeline.addLast("frameDecoder", new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter))); pipeline.addLast("stringDecoder", new StringDecoder()); pipeline.addLast("stringEncoder", new StringEncoder()); - pipeline.addLast("objectDecoder", new Gl100ProtocolDecoder(getDataManager(), resetDelay)); + pipeline.addLast("objectDecoder", new Gl100ProtocolDecoder(getDataManager())); } }); @@ -327,14 +332,14 @@ public class Server { TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol)); final Integer resetDelay = getProtocolResetDelay(properties, protocol); - server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), geocoder) { + server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) { protected void addSpecificHandlers(ChannelPipeline pipeline) { byte delimiter[] = { (byte) '$' }; pipeline.addLast("frameDecoder", new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter))); pipeline.addLast("stringDecoder", new StringDecoder()); pipeline.addLast("stringEncoder", new StringEncoder()); - pipeline.addLast("objectDecoder", new Gl200ProtocolDecoder(getDataManager(), resetDelay)); + pipeline.addLast("objectDecoder", new Gl200ProtocolDecoder(getDataManager())); } }); @@ -353,14 +358,14 @@ public class Server { TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol)); final Integer resetDelay = getProtocolResetDelay(properties, protocol); - server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), geocoder) { + server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) { protected void addSpecificHandlers(ChannelPipeline pipeline) { byte delimiter[] = { (byte) '\r', (byte) '\n' }; pipeline.addLast("frameDecoder", new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter))); pipeline.addLast("stringDecoder", new StringDecoder()); pipeline.addLast("stringEncoder", new StringEncoder()); - pipeline.addLast("objectDecoder", new T55ProtocolDecoder(getDataManager(), resetDelay)); + pipeline.addLast("objectDecoder", new T55ProtocolDecoder(getDataManager())); } }); @@ -379,13 +384,13 @@ public class Server { TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol)); final Integer resetDelay = getProtocolResetDelay(properties, protocol); - server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), geocoder) { + server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) { protected void addSpecificHandlers(ChannelPipeline pipeline) { byte delimiter[] = { (byte) '\n' }; // tracker bug \n\r pipeline.addLast("frameDecoder", new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter))); pipeline.addLast("stringDecoder", new StringDecoder()); - pipeline.addLast("objectDecoder", new Xexun2ProtocolDecoder(getDataManager(), resetDelay)); + pipeline.addLast("objectDecoder", new Xexun2ProtocolDecoder(getDataManager())); } }); @@ -404,13 +409,13 @@ public class Server { TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol)); final Integer resetDelay = getProtocolResetDelay(properties, protocol); - server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), geocoder) { + server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) { protected void addSpecificHandlers(ChannelPipeline pipeline) { byte delimiter[] = { (byte) '\r', (byte) '\n' }; pipeline.addLast("frameDecoder", new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter))); pipeline.addLast("stringDecoder", new StringDecoder()); - pipeline.addLast("objectDecoder", new Avl08ProtocolDecoder(getDataManager(), resetDelay)); + pipeline.addLast("objectDecoder", new Avl08ProtocolDecoder(getDataManager())); } }); @@ -429,10 +434,10 @@ public class Server { TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol)); final Integer resetDelay = getProtocolResetDelay(properties, protocol); - server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), geocoder) { + server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) { protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 0, 2, -2, 2)); - pipeline.addLast("objectDecoder", new EnforaProtocolDecoder(getDataManager(), resetDelay)); + pipeline.addLast("objectDecoder", new EnforaProtocolDecoder(getDataManager())); } }); @@ -451,10 +456,10 @@ public class Server { TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol)); final Integer resetDelay = getProtocolResetDelay(properties, protocol); - server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), geocoder) { + server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) { protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, -4, 4)); - pipeline.addLast("objectDecoder", new MeiligaoProtocolDecoder(getDataManager(), resetDelay)); + pipeline.addLast("objectDecoder", new MeiligaoProtocolDecoder(getDataManager())); } }); @@ -469,14 +474,14 @@ public class Server { TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol)); final Integer resetDelay = getProtocolResetDelay(properties, protocol); - server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), geocoder) { + server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) { protected void addSpecificHandlers(ChannelPipeline pipeline) { byte delimiter[] = { (byte) '\r', (byte) '\n' }; pipeline.addLast("frameDecoder", new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter))); pipeline.addLast("stringDecoder", new StringDecoder()); pipeline.addLast("stringEncoder", new StringEncoder()); - pipeline.addLast("objectDecoder", new MaxonProtocolDecoder(getDataManager(), resetDelay)); + pipeline.addLast("objectDecoder", new MaxonProtocolDecoder(getDataManager())); } }); @@ -491,13 +496,13 @@ public class Server { TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol)); final Integer resetDelay = getProtocolResetDelay(properties, protocol); - server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), geocoder) { + server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) { protected void addSpecificHandlers(ChannelPipeline pipeline) { byte delimiter[] = { (byte) '\r' }; pipeline.addLast("frameDecoder", new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter))); pipeline.addLast("stringDecoder", new StringDecoder()); - pipeline.addLast("objectDecoder", new ST210ProtocolDecoder(getDataManager(), resetDelay)); + pipeline.addLast("objectDecoder", new ST210ProtocolDecoder(getDataManager())); } }); @@ -513,10 +518,10 @@ public class Server { server.setEndianness(java.nio.ByteOrder.LITTLE_ENDIAN); final Integer resetDelay = getProtocolResetDelay(properties, protocol); - server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), geocoder) { + server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) { protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, 0, 0)); - pipeline.addLast("objectDecoder", new ProgressProtocolDecoder(getDataManager(), resetDelay)); + pipeline.addLast("objectDecoder", new ProgressProtocolDecoder(getDataManager())); } }); @@ -535,13 +540,13 @@ public class Server { TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol)); final Integer resetDelay = getProtocolResetDelay(properties, protocol); - server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), geocoder) { + server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) { protected void addSpecificHandlers(ChannelPipeline pipeline) { byte delimiter[] = { (byte) '#' }; pipeline.addLast("frameDecoder", new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter))); pipeline.addLast("stringDecoder", new StringDecoder()); - pipeline.addLast("objectDecoder", new H02ProtocolDecoder(getDataManager(), resetDelay)); + pipeline.addLast("objectDecoder", new H02ProtocolDecoder(getDataManager())); } }); @@ -560,10 +565,10 @@ public class Server { TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol)); final Integer resetDelay = getProtocolResetDelay(properties, protocol); - server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), geocoder) { + server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) { protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new Jt600FrameDecoder()); - pipeline.addLast("objectDecoder", new Jt600ProtocolDecoder(getDataManager(), resetDelay)); + pipeline.addLast("objectDecoder", new Jt600ProtocolDecoder(getDataManager())); } }); @@ -582,13 +587,13 @@ public class Server { TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol)); final Integer resetDelay = getProtocolResetDelay(properties, protocol); - server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), geocoder) { + server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) { protected void addSpecificHandlers(ChannelPipeline pipeline) { byte delimiter[] = { (byte) ';' }; pipeline.addLast("frameDecoder", new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter))); pipeline.addLast("stringDecoder", new StringDecoder()); - pipeline.addLast("objectDecoder", new Ev603ProtocolDecoder(getDataManager(), resetDelay)); + pipeline.addLast("objectDecoder", new Ev603ProtocolDecoder(getDataManager())); } }); @@ -607,13 +612,13 @@ public class Server { TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol)); final Integer resetDelay = getProtocolResetDelay(properties, protocol); - server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), geocoder) { + server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) { protected void addSpecificHandlers(ChannelPipeline pipeline) { byte delimiter[] = { (byte) '#', (byte) '#' }; pipeline.addLast("frameDecoder", new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter))); pipeline.addLast("stringDecoder", new StringDecoder()); - pipeline.addLast("objectDecoder", new V680ProtocolDecoder(getDataManager(), resetDelay)); + pipeline.addLast("objectDecoder", new V680ProtocolDecoder(getDataManager())); } }); diff --git a/src/org/traccar/TrackerEventHandler.java b/src/org/traccar/TrackerEventHandler.java index bd3e90160..6483e52e7 100644 --- a/src/org/traccar/TrackerEventHandler.java +++ b/src/org/traccar/TrackerEventHandler.java @@ -16,6 +16,8 @@ package org.traccar; import org.jboss.netty.channel.*; +import org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler; +import org.jboss.netty.handler.timeout.IdleStateEvent; import org.traccar.helper.Log; import org.traccar.model.DataManager; import org.traccar.model.Position; @@ -24,7 +26,7 @@ import org.traccar.model.Position; * Tracker message handler */ @ChannelHandler.Sharable -public class TrackerEventHandler extends SimpleChannelHandler { +public class TrackerEventHandler extends IdleStateAwareChannelHandler { /** * Data manager @@ -70,8 +72,21 @@ public class TrackerEventHandler extends SimpleChannelHandler { } @Override + public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) { + Log.info("Closing connection by disconnect"); + e.getChannel().close(); + } + + @Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) { + Log.info("Closing connection by exception"); e.getChannel().close(); } + @Override + public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) { + Log.info("Closing connection by timeout"); + e.getChannel().close(); + } + } diff --git a/src/org/traccar/TrackerServer.java b/src/org/traccar/TrackerServer.java index a29386c05..b2e8c0a7f 100644 --- a/src/org/traccar/TrackerServer.java +++ b/src/org/traccar/TrackerServer.java @@ -87,7 +87,6 @@ public class TrackerServer extends ServerBootstrap { public void stop() { ChannelGroupFuture future = getChannelGroup().close(); future.awaitUninterruptibly(); - getFactory().releaseExternalResources(); } } diff --git a/src/org/traccar/protocol/Avl08ProtocolDecoder.java b/src/org/traccar/protocol/Avl08ProtocolDecoder.java index 2dc711cd7..c8766b642 100644 --- a/src/org/traccar/protocol/Avl08ProtocolDecoder.java +++ b/src/org/traccar/protocol/Avl08ProtocolDecoder.java @@ -33,8 +33,8 @@ public class Avl08ProtocolDecoder extends GenericProtocolDecoder { /** * Initialize */ - public Avl08ProtocolDecoder(DataManager dataManager, Integer resetDelay) { - super(dataManager, resetDelay); + public Avl08ProtocolDecoder(DataManager dataManager) { + super(dataManager); } /** diff --git a/src/org/traccar/protocol/EnforaProtocolDecoder.java b/src/org/traccar/protocol/EnforaProtocolDecoder.java index 3b41592ea..fc40dcbba 100644 --- a/src/org/traccar/protocol/EnforaProtocolDecoder.java +++ b/src/org/traccar/protocol/EnforaProtocolDecoder.java @@ -37,8 +37,8 @@ public class EnforaProtocolDecoder extends GenericProtocolDecoder { /** * Initialize */ - public EnforaProtocolDecoder(DataManager dataManager, Integer resetDelay) { - super(dataManager, resetDelay); + public EnforaProtocolDecoder(DataManager dataManager) { + super(dataManager); } /** diff --git a/src/org/traccar/protocol/Ev603ProtocolDecoder.java b/src/org/traccar/protocol/Ev603ProtocolDecoder.java index 7730642f4..83689f760 100644 --- a/src/org/traccar/protocol/Ev603ProtocolDecoder.java +++ b/src/org/traccar/protocol/Ev603ProtocolDecoder.java @@ -39,8 +39,8 @@ public class Ev603ProtocolDecoder extends GenericProtocolDecoder{ /**
* Initialize
*/
- public Ev603ProtocolDecoder(DataManager dataManager, Integer resetDelay) {
- super(dataManager, resetDelay);
+ public Ev603ProtocolDecoder(DataManager dataManager) {
+ super(dataManager);
}
/**
diff --git a/src/org/traccar/protocol/Gl100ProtocolDecoder.java b/src/org/traccar/protocol/Gl100ProtocolDecoder.java index 8ac68f6f4..2e8b40a61 100644 --- a/src/org/traccar/protocol/Gl100ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl100ProtocolDecoder.java @@ -33,8 +33,8 @@ public class Gl100ProtocolDecoder extends GenericProtocolDecoder { /** * Initialize */ - public Gl100ProtocolDecoder(DataManager dataManager, Integer resetDelay) { - super(dataManager, resetDelay); + public Gl100ProtocolDecoder(DataManager dataManager) { + super(dataManager); } /** diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java index 63def5ddf..c109ea4c7 100644 --- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java @@ -33,8 +33,8 @@ public class Gl200ProtocolDecoder extends GenericProtocolDecoder { /** * Initialize */ - public Gl200ProtocolDecoder(DataManager dataManager, Integer resetDelay) { - super(dataManager, resetDelay); + public Gl200ProtocolDecoder(DataManager dataManager) { + super(dataManager); } /** diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java index 6a666fc86..cc0fcb9cb 100644 --- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java @@ -33,8 +33,8 @@ public class Gps103ProtocolDecoder extends GenericProtocolDecoder { /** * Initialize */ - public Gps103ProtocolDecoder(DataManager dataManager, Integer resetDelay) { - super(dataManager, resetDelay); + public Gps103ProtocolDecoder(DataManager dataManager) { + super(dataManager); } /** diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java index 183311817..bfdfc3758 100644 --- a/src/org/traccar/protocol/H02ProtocolDecoder.java +++ b/src/org/traccar/protocol/H02ProtocolDecoder.java @@ -33,8 +33,8 @@ public class H02ProtocolDecoder extends GenericProtocolDecoder { /** * Initialize */ - public H02ProtocolDecoder(DataManager dataManager, Integer resetDelay) { - super(dataManager, resetDelay); + public H02ProtocolDecoder(DataManager dataManager) { + super(dataManager); } /** diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java index 11932f8ce..907eabb4b 100644 --- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java +++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java @@ -36,8 +36,8 @@ public class Jt600ProtocolDecoder extends GenericProtocolDecoder { /** * Initialize */ - public Jt600ProtocolDecoder(DataManager dataManager, Integer resetDelay) { - super(dataManager, resetDelay); + public Jt600ProtocolDecoder(DataManager dataManager) { + super(dataManager); } /** diff --git a/src/org/traccar/protocol/MaxonProtocolDecoder.java b/src/org/traccar/protocol/MaxonProtocolDecoder.java index 7e26c9c19..e05ef0e30 100644 --- a/src/org/traccar/protocol/MaxonProtocolDecoder.java +++ b/src/org/traccar/protocol/MaxonProtocolDecoder.java @@ -42,8 +42,8 @@ public class MaxonProtocolDecoder extends GenericProtocolDecoder { /** * Initialize */ - public MaxonProtocolDecoder(DataManager dataManager, Integer resetDelay) { - super(dataManager, resetDelay); + public MaxonProtocolDecoder(DataManager dataManager) { + super(dataManager); } /** @@ -51,20 +51,19 @@ public class MaxonProtocolDecoder extends GenericProtocolDecoder { */ static private Pattern pattern = Pattern.compile( "\\$GPRMC," + - "(\\d{2})(\\d{2})(\\d{2}).(\\d{2})," + // Time (HHMMSS.SSS) - "([AV])," + // Validity - "(\\d{2})(\\d{2}.\\d{5})," + // Latitude (DDMM.MMMMM) + "(\\d{2})(\\d{2})(\\d{2})\\.(\\d{2})," + // Time (HHMMSS.SSS) + "([AV])," + // Validity + "(\\d{2})(\\d{2}\\.\\d{5})," + // Latitude (DDMM.MMMMM) "([NS])," + - "(\\d{3})(\\d{2}.\\d{5})," + // Longitude (DDDMM.MMMMM) + "(\\d{3})(\\d{2}\\.\\d{5})," + // Longitude (DDDMM.MMMMM) "([EW])," + - "(\\d+.\\d{3})?," + // Speed - "(\\d+.\\d{2})?," + // Course - "(\\d{2})(\\d{2})(\\d{2})" + // Date (DDMMYY) - ".+"); // Other (Checksumm) + "(\\d+\\.\\d{3})?," + // Speed + "(\\d+\\.\\d{2})?," + // Course + "(\\d{2})(\\d{2})(\\d{2})" + // Date (DDMMYY) + ".+"); // Other (Checksumm) static private Pattern gpfidPattern = Pattern.compile( - "\\$GPFID,(\\d+)$" - ); + "\\$GPFID,(\\d+)$"); /** * Decode message" diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index 388565207..27defde78 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -38,8 +38,8 @@ public class MeiligaoProtocolDecoder extends GenericProtocolDecoder { /** * Initialize */ - public MeiligaoProtocolDecoder(DataManager dataManager, Integer resetDelay) { - super(dataManager, resetDelay); + public MeiligaoProtocolDecoder(DataManager dataManager) { + super(dataManager); } /** @@ -55,7 +55,7 @@ public class MeiligaoProtocolDecoder extends GenericProtocolDecoder { "(\\d+.\\d+)," + // Speed "(\\d+\\.?\\d+)?," + // Course "(\\d{2})(\\d{2})(\\d{2})," + // Date (DDMMYY) - "[^\\|]+\\|(\\d+.\\d)\\|" + // Dilution of precision + "[^\\|]+\\|(\\d+\\.\\d)\\|" + // Dilution of precision "(\\d+)\\|" + // Altitude "([0-9a-fA-F]+)\\|" + // State ".*"); // TODO: parse ADC diff --git a/src/org/traccar/protocol/ProgressProtocolDecoder.java b/src/org/traccar/protocol/ProgressProtocolDecoder.java index 173dd083a..865e190e2 100644 --- a/src/org/traccar/protocol/ProgressProtocolDecoder.java +++ b/src/org/traccar/protocol/ProgressProtocolDecoder.java @@ -39,8 +39,8 @@ public class ProgressProtocolDecoder extends GenericProtocolDecoder { /** * Initialize */ - public ProgressProtocolDecoder(DataManager dataManager, Integer resetDelay) { - super(dataManager, resetDelay); + public ProgressProtocolDecoder(DataManager dataManager) { + super(dataManager); } /* diff --git a/src/org/traccar/protocol/ST210ProtocolDecoder.java b/src/org/traccar/protocol/ST210ProtocolDecoder.java index 9418293fc..642079361 100644 --- a/src/org/traccar/protocol/ST210ProtocolDecoder.java +++ b/src/org/traccar/protocol/ST210ProtocolDecoder.java @@ -1,13 +1,11 @@ package org.traccar.protocol; import java.util.Calendar; -import java.util.GregorianCalendar; import java.util.LinkedList; import java.util.List; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; - import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.GenericProtocolDecoder; @@ -18,8 +16,8 @@ import org.traccar.model.Position; public class ST210ProtocolDecoder extends GenericProtocolDecoder { - public ST210ProtocolDecoder(DataManager dataManager, Integer resetDelay) { - super(dataManager, resetDelay); + public ST210ProtocolDecoder(DataManager dataManager) { + super(dataManager); } private enum ST210FIELDS { diff --git a/src/org/traccar/protocol/T55ProtocolDecoder.java b/src/org/traccar/protocol/T55ProtocolDecoder.java index 9342433b7..d531f1adf 100644 --- a/src/org/traccar/protocol/T55ProtocolDecoder.java +++ b/src/org/traccar/protocol/T55ProtocolDecoder.java @@ -38,8 +38,8 @@ public class T55ProtocolDecoder extends GenericProtocolDecoder { /** * Initialize */ - public T55ProtocolDecoder(DataManager dataManager, Integer resetDelay) { - super(dataManager, resetDelay); + public T55ProtocolDecoder(DataManager dataManager) { + super(dataManager); } /** @@ -47,16 +47,16 @@ public class T55ProtocolDecoder extends GenericProtocolDecoder { */ static private Pattern pattern = Pattern.compile( "\\$GPRMC," + - "(\\d{2})(\\d{2})(\\d{2}).(\\d{3})," + // Time (HHMMSS.SSS) - "([AV])," + // Validity - "(\\d{2})(\\d{2}.\\d{4})," + // Latitude (DDMM.MMMM) + "(\\d{2})(\\d{2})(\\d{2})\\.(\\d{3})," + // Time (HHMMSS.SSS) + "([AV])," + // Validity + "(\\d{2})(\\d{2}\\.\\d{4})," + // Latitude (DDMM.MMMM) "([NS])," + - "(\\d{3})(\\d{2}.\\d{4})," + // Longitude (DDDMM.MMMM) + "(\\d{3})(\\d{2}\\.\\d{4})," + // Longitude (DDDMM.MMMM) "([EW])," + - "(\\d+.\\d{2})?," + // Speed - "(\\d+.\\d{2})?," + // Course - "(\\d{2})(\\d{2})(\\d{2})" + // Date (DDMMYY) - ".+"); // Other (Checksumm) + "(\\d+\\.\\d{2})?," + // Speed + "(\\d+\\.\\d{2})?," + // Course + "(\\d{2})(\\d{2})(\\d{2})" + // Date (DDMMYY) + ".+"); // Other (Checksumm) /** * Decode message diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java index a0129dd5a..4c0fd0c03 100644 --- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java @@ -33,8 +33,8 @@ public class Tk103ProtocolDecoder extends GenericProtocolDecoder { /** * Initialize */ - public Tk103ProtocolDecoder(DataManager dataManager, Integer resetDelay) { - super(dataManager, resetDelay); + public Tk103ProtocolDecoder(DataManager dataManager) { + super(dataManager); } /** @@ -47,13 +47,13 @@ public class Tk103ProtocolDecoder extends GenericProtocolDecoder { "(\\d{15})" + // IMEI (?) "(\\d{2})(\\d{2})(\\d{2})" + // Date (YYMMDD) "([AV])" + // Validity - "(\\d{2})(\\d{2}.\\d{4})" + // Latitude (DDMM.MMMM) + "(\\d{2})(\\d{2}\\.\\d{4})" + // Latitude (DDMM.MMMM) "([NS])" + - "(\\d{3})(\\d{2}.\\d{4})" + // Longitude (DDDMM.MMMM) + "(\\d{3})(\\d{2}\\.\\d{4})" + // Longitude (DDDMM.MMMM) "([EW])" + - "(\\d+.\\d)" + // Speed + "(\\d+\\.\\d)" + // Speed "(\\d{2})(\\d{2})(\\d{2})" + // Time (HHMMSS) - "(\\d+.\\d{2})" + // Course + "(\\d+\\.\\d{2})" + // Course "(\\d+)" + // State ".+"); // Mileage (?) diff --git a/src/org/traccar/protocol/V680ProtocolDecoder.java b/src/org/traccar/protocol/V680ProtocolDecoder.java index 5d2427ca4..10f17b184 100644 --- a/src/org/traccar/protocol/V680ProtocolDecoder.java +++ b/src/org/traccar/protocol/V680ProtocolDecoder.java @@ -33,8 +33,8 @@ public class V680ProtocolDecoder extends GenericProtocolDecoder { /** * Initialize */ - public V680ProtocolDecoder(DataManager dataManager, Integer resetDelay) { - super(dataManager, resetDelay); + public V680ProtocolDecoder(DataManager dataManager) { + super(dataManager); } /** diff --git a/src/org/traccar/protocol/Xexun2ProtocolDecoder.java b/src/org/traccar/protocol/Xexun2ProtocolDecoder.java index 1ee2737d1..e7b29b728 100644 --- a/src/org/traccar/protocol/Xexun2ProtocolDecoder.java +++ b/src/org/traccar/protocol/Xexun2ProtocolDecoder.java @@ -33,8 +33,8 @@ public class Xexun2ProtocolDecoder extends GenericProtocolDecoder { /** * Initialize */ - public Xexun2ProtocolDecoder(DataManager dataManager, Integer resetDelay) { - super(dataManager, resetDelay); + public Xexun2ProtocolDecoder(DataManager dataManager) { + super(dataManager); } /** @@ -45,14 +45,14 @@ public class Xexun2ProtocolDecoder extends GenericProtocolDecoder { "(\\d+)," + // Serial "(\\+\\d+)," + // Number "GPRMC," + - "(\\d{2})(\\d{2})(\\d{2}).(\\d{3})," + // Time (HHMMSS.SSS) + "(\\d{2})(\\d{2})(\\d{2})\\.(\\d{3})," + // Time (HHMMSS.SSS) "([AV])," + // Validity - "(\\d{2})(\\d{2}.\\d{4})," + // Latitude (DDMM.MMMM) + "(\\d{2})(\\d{2}\\.\\d{4})," + // Latitude (DDMM.MMMM) "([NS])," + - "(\\d{3})(\\d{2}.\\d{4})," + // Longitude (DDDMM.MMMM) + "(\\d{3})(\\d{2}\\.\\d{4})," + // Longitude (DDDMM.MMMM) "([EW])," + - "(\\d+.\\d+)," + // Speed - "(\\d+.\\d+)?," + // Course + "(\\d+\\.\\d+)," + // Speed + "(\\d+\\.\\d+)?," + // Course "(\\d{2})(\\d{2})(\\d{2})," + // Date (DDMMYY) ",,.\\*..," + // Checksum "([FL])," + // Signal @@ -60,8 +60,8 @@ public class Xexun2ProtocolDecoder extends GenericProtocolDecoder { ".*imei:" + "(\\d+)," + // IMEI "(\\d+)," + // Satellites - "(\\d+.\\d+)," + // Altitude - "F:(\\d+.\\d+)V," + // Power + "(\\d+\\.\\d+)," + // Altitude + "F:(\\d+\\.\\d+)V," + // Power ".*" + "[\r\n]*"); diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java index f6b7bcb44..cbff2dee3 100644 --- a/src/org/traccar/protocol/XexunProtocolDecoder.java +++ b/src/org/traccar/protocol/XexunProtocolDecoder.java @@ -34,8 +34,8 @@ public class XexunProtocolDecoder extends GenericProtocolDecoder { /** * Initialize */ - public XexunProtocolDecoder(DataManager dataManager, Integer resetDelay) { - super(dataManager, resetDelay); + public XexunProtocolDecoder(DataManager dataManager) { + super(dataManager); } /** |