本文整理汇总了Java中org.apache.mina.filter.codec.textline.TextLineCodecFactory.setDecoderMaxLineLength方法的典型用法代码示例。如果您正苦于以下问题:Java TextLineCodecFactory.setDecoderMaxLineLength方法的具体用法?Java TextLineCodecFactory.setDecoderMaxLineLength怎么用?Java TextLineCodecFactory.setDecoderMaxLineLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.mina.filter.codec.textline.TextLineCodecFactory
的用法示例。
在下文中一共展示了TextLineCodecFactory.setDecoderMaxLineLength方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MinaCubeClient
import org.apache.mina.filter.codec.textline.TextLineCodecFactory; //导入方法依赖的package包/类
public MinaCubeClient(String hostname, int port) {
this.hostname = hostname;
this.port = port;
connector = new NioSocketConnector(1);
connector.setConnectTimeoutMillis(2000);
connector.getFilterChain().addLast("logger", new LoggingFilter());
TextLineCodecFactory codecFactory = new TextLineCodecFactory(UTF_8, LineDelimiter.CRLF, LineDelimiter.AUTO);
codecFactory.setDecoderMaxLineLength(4096);
codecFactory.setEncoderMaxLineLength(4096);
connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(codecFactory));
handler = new ConnectHandler();
connector.setHandler(handler);
}
示例2: emit
import org.apache.mina.filter.codec.textline.TextLineCodecFactory; //导入方法依赖的package包/类
@Override
public void emit() {
// TODO Auto-generated method stub
try {
// ssl 认证
if (sslEnable) {
SslFilter sslFilter = new SslFilter(getSslContext());
acceptor.getFilterChain().addLast("sslFilter", sslFilter);
logger.warn("ssl authenticate is open");
}
LoggingFilter loggingFilter = new LoggingFilter();
acceptor.getFilterChain().addLast("logger", loggingFilter);
TextLineCodecFactory textLineCodecFactory = new TextLineCodecFactory(
Charset.forName(encodiing));
textLineCodecFactory.setDecoderMaxLineLength(maxLineLength);
textLineCodecFactory.setEncoderMaxLineLength(maxLineLength);
acceptor.getFilterChain().addLast("codec",
new ProtocolCodecFilter(textLineCodecFactory));
acceptor.setHandler(minaBizHandler);
acceptor.getSessionConfig().setReadBufferSize(bufSize);
acceptor.getSessionConfig().setWriteTimeout(10);
// acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE,
// 10);//空闲状态
acceptor.bind(new InetSocketAddress(InetAddress.getByName(host),
port));
} catch (Exception e) {
// TODO Auto-generated catch block
logger.error(e.getMessage());
System.exit(1);
}
}
示例3: getTextLineCodecFactory
import org.apache.mina.filter.codec.textline.TextLineCodecFactory; //导入方法依赖的package包/类
@NonNull
static TextLineCodecFactory getTextLineCodecFactory() {
TextLineCodecFactory codec = new TextLineCodecFactory();
codec.setDecoderMaxLineLength(MAX_LINE_LENGTH);
codec.setEncoderMaxLineLength(MAX_LINE_LENGTH);
return codec;
}
示例4: startListening
import org.apache.mina.filter.codec.textline.TextLineCodecFactory; //导入方法依赖的package包/类
protected void startListening(boolean activateSSL)
{
try
{
this.acceptor = new NioSocketAcceptor();
((NioSocketAcceptor)this.acceptor).setReuseAddress(true);
if(activateSSL)
{
//Makes the tcp connection protected with SSL
SslFilter sslFilter = new SslFilter(this.getSSLContext());
this.acceptor.getFilterChain().addLast("ssl", sslFilter);
}
//
//TextLineCodecFactory textLine = new TextLineCodecFactory(Charset.forName("UTF-8"));
TextLineCodecFactory textLine = new TextLineCodecFactory(Charset.forName("UTF-8"),
LineDelimiter.UNIX.getValue(),
"EOF");
textLine.setDecoderMaxLineLength(Integer.MAX_VALUE);
textLine.setEncoderMaxLineLength(Integer.MAX_VALUE);
ProtocolCodecFilter codecFilter = new ProtocolCodecFilter(textLine);
this.acceptor.getFilterChain().addLast( "codec", codecFilter);
//
this.acceptor.getFilterChain().addLast("threadPool", new ExecutorFilter());
//Add Custom filters here
if(this.payloadFilter != null)
{
this.acceptor.getFilterChain().addLast("payloadFilter", this.payloadFilter);
}
if(this.requestFilter != null)
{
this.acceptor.getFilterChain().addLast("requestFilter", this.requestFilter);
}
if(this.transactionFilter != null)
{
this.acceptor.getFilterChain().addLast("transactionFilter", this.transactionFilter);
}
if(this.authenticationFilter != null)
{
this.acceptor.getFilterChain().addLast("authenticationFilter", this.authenticationFilter);
}
//session specific configuration
this.acceptor.getSessionConfig().setBothIdleTime(10);
this.acceptor.setHandler(this.handler);
this.acceptor.bind(new InetSocketAddress(this.port));
log.info("--------------------------------------------");
log.info("Mobile Data Server successfully loaded on port ("+this.port+").....");
log.info("--------------------------------------------");
}
catch(Exception e)
{
log.error(this, e);
this.stop();
throw new RuntimeException(e);
}
}