com.github.dreamhead.moco.internal.MocoSocketServer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of moco-core Show documentation
Show all versions of moco-core Show documentation
Moco is an easy setup stub framework, mainly focusing on testing and integration.
package com.github.dreamhead.moco.internal;
import com.github.dreamhead.moco.SocketResponseSetting;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
public class MocoSocketServer extends BaseServerRunner {
private final ActualSocketServer serverSetting;
public MocoSocketServer(final ActualSocketServer serverSetting) {
this.serverSetting = serverSetting;
}
@Override
protected BaseActualServer serverSetting() {
return this.serverSetting;
}
@Override
protected ChannelInitializer channelInitializer() {
return new ChannelInitializer() {
@Override
protected void initChannel(final SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast("aggregator", new MocoAggregator());
pipeline.addLast("handler", new MocoSocketHandler(serverSetting));
}
};
}
}