/**
 * Copyright (c) 2011 Optimax Software Ltd
 * 
 * This file is part of ElasticInbox.
 * 
 * ElasticInbox is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 2 of the License, or (at your option) any later
 * version.
 * 
 * ElasticInbox is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * ElasticInbox. If not, see <http://www.gnu.org/licenses/>.
 */

package com.elasticinbox.lmtp;

import java.io.IOException;
import java.net.InetSocketAddress;

import org.apache.james.protocols.lmtp.LMTPConfigurationImpl;
import org.apache.james.protocols.lmtp.LMTPProtocolHandlerChain;
import org.apache.james.protocols.netty.NettyServer;
import org.apache.james.protocols.smtp.SMTPProtocol;

import com.elasticinbox.config.Configurator;
import com.elasticinbox.lmtp.delivery.IDeliveryAgent;
import com.elasticinbox.lmtp.server.api.Blob;
import com.elasticinbox.lmtp.server.api.LMTPEnvelope;
import com.elasticinbox.lmtp.server.api.handler.ElasticInboxDeliveryHandler;

/**
 * LMTP proxy main class which sends traffic to multiple registered handlers
 * 
 * @author Rustam Aliyev
 */
public class LMTPProxyServer {
	private NettyServer server;
	private IDeliveryAgent backend;

	protected LMTPProxyServer(IDeliveryAgent backend) {
	    this.backend = backend;
	}

	public void start() throws Exception {
		LMTPProtocolHandlerChain chain = new LMTPProtocolHandlerChain();
		chain.add(0,
				new ElasticInboxDeliveryHandler(backend));
		server = new NettyServer(new SMTPProtocol(chain,
				new LMTPConfigurationImpl()));

		server.setListenAddresses(new InetSocketAddress(Configurator
				.getLmtpPort()));
		// server.set().setMaxConnections(Configurator.getLmtpMaxConnections());
		// flush to tmp file if data > 32K
		// server.getConfig().setDataDeferredSize(32 * 1024);
		server.setUseExecutionHandler(true, 16);
		server.bind();
	}

	public void stop() {
		server.unbind();
	}
	
}

@@ -1759,21 +1759,17 @@
 n.add(0,
-%0A%09%09%09%09
+ 
 new Elas
@@ -1803,16 +1803,50 @@
 kend));%0A
+%09%09chain.wireExtensibleHandlers();%0A
 %09%09server
@@ -1978,39 +1978,12 @@
 ess(
-Configurator%0A%09%09%09%09.getLmtpPort()
+2400
 ));%0A
@@ -2262,8 +2262,337 @@
 %0A%09%7D%0A
-
 %09%0A
+%09public static void main(String%5B%5D args) throws Exception %7B%0A%09    new LMTPProxyServer(new IDeliveryAgent() %7B%0A            %0A            @Override%0A            public void deliver(LMTPEnvelope env, Blob blob) throws IOException %7B%0A                // TODO Auto-generated method stub%0A                %0A            %7D%0A        %7D).start();%0A%09%7D%0A
 %7D%0A

Make it possible to start LMTPPRoxyServer via eclipse