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

import com.eactive.eai.adapter.socket2.config.SocketAdapterContext;
import com.eactive.eai.adapter.socket2.protocol.TcpAdapterServer;
import com.eactive.eai.adapter.socket2.protocol.fixedheader.codec.FixedHeaderCodecFactory;
import com.eactive.eai.adapter.socket2.protocol.xecure3.envelope.Xecure3EnvelopeServerFilter;
import org.apache.mina.filter.codec.ProtocolCodecFilter;


public class Xecure3Server extends TcpAdapterServer {
	public Xecure3Server(SocketAdapterContext context) throws Exception {
		super(context);

		if ("ENVELOPE".equals(context.getXecureType())) {
			this.handler = new Xecure3Handler(this);
			config.getFilterChain().addFirst("codec", new ProtocolCodecFilter(new FixedHeaderCodecFactory(this)));
			config.getFilterChain().addLast("xecure3.envelope", new Xecure3EnvelopeServerFilter(this));
		} else {
			throw new Exception(context.getAdapterName() + " | UNKNOWN Xecure3 Type - " + context.getXecureType());
		}
	}
}
