package com.eactive.eai.adapter.socket2.protocol;

import com.eactive.eai.adapter.socket2.config.SocketAdapterContext;
import edu.emory.mathcs.backport.java.util.concurrent.Executor;
import org.apache.mina.common.support.BaseIoConnector;
import org.apache.mina.common.support.BaseIoConnectorConfig;
import org.apache.mina.transport.socket.nio.DatagramConnector;
import org.apache.mina.transport.socket.nio.DatagramConnectorConfig;
import org.apache.mina.transport.socket.nio.support.DatagramConnectorDelegate;


public abstract class UdpAdapterClient extends SocketAdapterClient {
	protected UdpAdapterClient(SocketAdapterContext context) throws Exception {
		super(context);
	}

	protected BaseIoConnectorConfig createConnectorConfig() {
		DatagramConnectorConfig config = new DatagramConnectorConfig();
		//config.setSessionRecycler(new ExpiringSessionRecycler(24 * 60 * 60));
		return config;
	}
	
	protected BaseIoConnector createConnector(int ioProcessorCount, Executor ioProcessExecutor) {
		DatagramConnector dc = new DatagramConnector();
		DatagramConnectorDelegate connector = new DatagramConnectorDelegate(dc, ioProcessExecutor, this);
		return connector;
	}
}	
