package ua.com.fielden.platform.gis.gps.server;

import java.net.InetSocketAddress;
import java.util.concurrent.Executors;

import org.apache.log4j.Logger;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;

import ua.com.fielden.platform.gis.gps.factory.IGpsHandlerFactory;

public class ServerTeltonika implements Runnable {

	private final Logger log = Logger.getLogger(ServerTeltonika.class);
	private final String host;
	private final int port;
	private final IGpsHandlerFactory handlerFactory;

	public ServerTeltonika(final String host, final int port, final IGpsHandlerFactory handlerFactory) {
		this.host = host;
		this.port = port;
		this.handlerFactory = handlerFactory;
	}

	@Override
	public void run() {
		// Configure the server.
		final ServerBootstrap bootstrap = new ServerBootstrap(
				new NioServerSocketChannelFactory(
						Executors.newCachedThreadPool(),
						Executors.newCachedThreadPool()));

		// Set up the pipeline factory.
		bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
			public ChannelPipeline getPipeline() throws Exception {
			    System.out.println("new pipe is requested");
				return Channels.pipeline(
						new TransparentEncoder(),
						new AvlFrameDecoder(),
						handlerFactory.create());
			}
		});

		// Bind and start to accept incoming connections.
		bootstrap.bind(new InetSocketAddress(host, port));
		log.info("Server started on " + host + ":" + port);
	}
}

@@ -1130,16 +1130,65 @@
 ool()));
+%0A%09%09bootstrap.setOption(%22child.keepAlive%22, false);
 %0A%0A%09%09// S
@@ -1277,16 +1277,29 @@
 ory() %7B%0A
+%09%09%09@Override%0A
 %09%09%09publi

Set keep alive to false.