use of org.apache.mina.filter.codec.serialization.ObjectSerializationCodecFactory in project camel by apache.
the class MinaComponent method configureDefaultCodecFactory.
protected void configureDefaultCodecFactory(String type, IoServiceConfig config, MinaConfiguration configuration) {
if (configuration.isTextline()) {
Charset charset = getEncodingParameter(type, configuration);
LineDelimiter delimiter = getLineDelimiterParameter(configuration.getTextlineDelimiter());
TextLineCodecFactory codecFactory = new TextLineCodecFactory(charset, delimiter);
if (configuration.getEncoderMaxLineLength() > 0) {
codecFactory.setEncoderMaxLineLength(configuration.getEncoderMaxLineLength());
}
if (configuration.getDecoderMaxLineLength() > 0) {
codecFactory.setDecoderMaxLineLength(configuration.getDecoderMaxLineLength());
}
addCodecFactory(config, codecFactory);
if (LOG.isDebugEnabled()) {
LOG.debug("{}: Using TextLineCodecFactory: {} using encoding: {} line delimiter: {}({})", new Object[] { type, codecFactory, charset, configuration.getTextlineDelimiter(), delimiter });
LOG.debug("Encoder maximum line length: {}. Decoder maximum line length: {}", codecFactory.getEncoderMaxLineLength(), codecFactory.getDecoderMaxLineLength());
}
} else {
ObjectSerializationCodecFactory codecFactory = new ObjectSerializationCodecFactory();
addCodecFactory(config, codecFactory);
LOG.debug("{}: Using ObjectSerializationCodecFactory: {}", type, codecFactory);
}
}
use of org.apache.mina.filter.codec.serialization.ObjectSerializationCodecFactory in project camel by apache.
the class Mina2Consumer method configureDefaultCodecFactory.
protected void configureDefaultCodecFactory(String type, IoService service, Mina2Configuration configuration) {
if (configuration.isTextline()) {
Charset charset = getEncodingParameter(type, configuration);
LineDelimiter delimiter = getLineDelimiterParameter(configuration.getTextlineDelimiter());
Mina2TextLineCodecFactory codecFactory = new Mina2TextLineCodecFactory(charset, delimiter);
if (configuration.getEncoderMaxLineLength() > 0) {
codecFactory.setEncoderMaxLineLength(configuration.getEncoderMaxLineLength());
}
if (configuration.getDecoderMaxLineLength() > 0) {
codecFactory.setDecoderMaxLineLength(configuration.getDecoderMaxLineLength());
}
addCodecFactory(service, codecFactory);
if (LOG.isDebugEnabled()) {
LOG.debug("{}: Using TextLineCodecFactory: {} using encoding: {} line delimiter: {}({})", new Object[] { type, codecFactory, charset, configuration.getTextlineDelimiter(), delimiter });
LOG.debug("Encoder maximum line length: {}. Decoder maximum line length: {}", codecFactory.getEncoderMaxLineLength(), codecFactory.getDecoderMaxLineLength());
}
} else {
ObjectSerializationCodecFactory codecFactory = new ObjectSerializationCodecFactory();
addCodecFactory(service, codecFactory);
LOG.debug("{}: Using ObjectSerializationCodecFactory: {}", type, codecFactory);
}
}
use of org.apache.mina.filter.codec.serialization.ObjectSerializationCodecFactory in project pancm_project by xuwujing.
the class ClientTestServer method creatClient.
public IoConnector creatClient() {
IoConnector connector = new NioSocketConnector();
connector.setConnectTimeoutMillis(30000);
connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new ObjectSerializationCodecFactory()));
connector.setHandler(new MinaClientHandler());
return connector;
}
use of org.apache.mina.filter.codec.serialization.ObjectSerializationCodecFactory in project pancm_project by xuwujing.
the class MinaClient method main.
/*
* 测试服务端与客户端程序!
a. 启动服务端,然后再启动客户端
b. 服务端接收消息并处理成功;
*/
@SuppressWarnings("deprecation")
public static void main(String[] args) {
// 设置链接超时时间
connector.setConnectTimeout(30000);
// 添加过滤器 可序列话的对象
connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new ObjectSerializationCodecFactory()));
// 添加业务逻辑处理器类
connector.setHandler(new MinaClientHandler());
ConnectFuture future = connector.connect(new InetSocketAddress(HOST, // 创建连接
PORT));
// 等待连接创建完成
future.awaitUninterruptibly();
// 获得session
session = future.getSession();
bindstart();
pushstart();
}
use of org.apache.mina.filter.codec.serialization.ObjectSerializationCodecFactory in project camel by apache.
the class Mina2Producer method configureDefaultCodecFactory.
protected void configureDefaultCodecFactory(String type, IoService service) {
if (configuration.isTextline()) {
Charset charset = getEncodingParameter(type, configuration);
LineDelimiter delimiter = getLineDelimiterParameter(configuration.getTextlineDelimiter());
Mina2TextLineCodecFactory codecFactory = new Mina2TextLineCodecFactory(charset, delimiter);
if (configuration.getEncoderMaxLineLength() > 0) {
codecFactory.setEncoderMaxLineLength(configuration.getEncoderMaxLineLength());
}
if (configuration.getDecoderMaxLineLength() > 0) {
codecFactory.setDecoderMaxLineLength(configuration.getDecoderMaxLineLength());
}
addCodecFactory(service, codecFactory);
LOG.debug("{}: Using TextLineCodecFactory: {} using encoding: {} line delimiter: {}({})", type, codecFactory, charset, configuration.getTextlineDelimiter(), delimiter);
LOG.debug("Encoder maximum line length: {}. Decoder maximum line length: {}", codecFactory.getEncoderMaxLineLength(), codecFactory.getDecoderMaxLineLength());
} else {
ObjectSerializationCodecFactory codecFactory = new ObjectSerializationCodecFactory();
addCodecFactory(service, codecFactory);
LOG.debug("{}: Using ObjectSerializationCodecFactory: {}", type, codecFactory);
}
}
Aggregations