本文整理汇总了Java中org.apache.mina.filter.codec.ProtocolCodecFactory类的典型用法代码示例。如果您正苦于以下问题:Java ProtocolCodecFactory类的具体用法?Java ProtocolCodecFactory怎么用?Java ProtocolCodecFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProtocolCodecFactory类属于org.apache.mina.filter.codec包,在下文中一共展示了ProtocolCodecFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.apache.mina.filter.codec.ProtocolCodecFactory; //导入依赖的package包/类
private void init(Config config) {
address = new InetSocketAddress(config.sourcePort);
acceptor = new NioSocketAcceptor();
if (acceptor.getFilterChain().get(LOGGER) == null) {
acceptor.getFilterChain().addLast(LOGGER, new LoggingFilter());
}
if (acceptor.getFilterChain().get(CODEC) == null) {
ProtocolCodecFactory codecFactory = config.codec == null ?
MinaUtil.getTextLineCodecFactory() : (ProtocolCodecFactory) config.codec;
acceptor.getFilterChain().addLast(CODEC, new ProtocolCodecFilter(codecFactory));
}
acceptor.setHandler(new MinaServerHandler());
acceptor.getSessionConfig().setReadBufferSize(config.bufferSize);
acceptor.getSessionConfig().setIdleTime(IdleStatus.WRITER_IDLE, 10);
acceptor.setReuseAddress(true); //避免重启时提示地址被占用
//设置主服务监听端口的监听队列的最大值为50,如果当前已经有50个连接,新的连接将被服务器拒绝
acceptor.setBacklog(50);
KeepAliveFilter keepAliveFilter = MinaUtil.initServerKeepAlive(config, this);
if (keepAliveFilter != null) {
acceptor.getFilterChain().addLast(HEARTBEAT, keepAliveFilter);
}
}
示例2: init
import org.apache.mina.filter.codec.ProtocolCodecFactory; //导入依赖的package包/类
private void init(Config config) {
connector = new NioDatagramConnector();
connector.setHandler(new MinaClientHandler());
DefaultIoFilterChainBuilder chain = connector.getFilterChain();
if (connector.getFilterChain().get(LOGGER) == null) {
chain.addLast(LOGGER, new LoggingFilter());
}
if (connector.getFilterChain().get(CODEC) == null) {
ProtocolCodecFactory codecFactory = config.codec == null ?
MinaUtil.getTextLineCodecFactory() : (ProtocolCodecFactory) config.codec;
chain.addLast(CODEC, new ProtocolCodecFilter(codecFactory));
}
connector.getSessionConfig().setReadBufferSize(config.bufferSize);
connector.getSessionConfig().setIdleTime(IdleStatus.WRITER_IDLE, 10);
connector.getSessionConfig().setBroadcast(true);
KeepAliveFilter keepAliveFilter = MinaUtil.initClientKeepAlive(config, this);
if (keepAliveFilter != null) {
connector.getFilterChain().addLast(HEARTBEAT, keepAliveFilter);
}
}
示例3: init
import org.apache.mina.filter.codec.ProtocolCodecFactory; //导入依赖的package包/类
private void init(Config config) {
address = new InetSocketAddress(config.targetIP, config.targetPort);
connector = new NioSocketConnector();
connector.setDefaultRemoteAddress(address);
if (connector.getFilterChain().get(LOGGER) == null) {
connector.getFilterChain().addLast(LOGGER, new LoggingFilter());
}
if (connector.getFilterChain().get(CODEC) == null) {
ProtocolCodecFactory codecFactory = config.codec == null ?
MinaUtil.getTextLineCodecFactory() : (ProtocolCodecFactory) config.codec;
connector.getFilterChain().addLast(CODEC, new ProtocolCodecFilter(codecFactory));
}
connector.setHandler(new MinaClientHandler());
connector.getSessionConfig().setReadBufferSize(config.bufferSize);
connector.getSessionConfig().setIdleTime(IdleStatus.WRITER_IDLE, 10);
KeepAliveFilter keepAliveFilter = MinaUtil.initClientKeepAlive(config, this);
if (keepAliveFilter != null) {
connector.getFilterChain().addLast(HEARTBEAT, keepAliveFilter);
}
}
示例4: init
import org.apache.mina.filter.codec.ProtocolCodecFactory; //导入依赖的package包/类
private void init(Config config) {
address = new InetSocketAddress(config.sourcePort);
acceptor = new NioDatagramAcceptor();
acceptor.setHandler(new MinaServerHandler());
DefaultIoFilterChainBuilder chain = acceptor.getFilterChain();
if (acceptor.getFilterChain().get(LOGGER) == null) {
chain.addLast(LOGGER, new LoggingFilter());
}
if (acceptor.getFilterChain().get(CODEC) == null) {
ProtocolCodecFactory codecFactory = config.codec == null ?
MinaUtil.getTextLineCodecFactory() : (ProtocolCodecFactory) config.codec;
chain.addLast(CODEC, new ProtocolCodecFilter(codecFactory));
}
DatagramSessionConfig dcfg = acceptor.getSessionConfig();
dcfg.setReuseAddress(true);
dcfg.setReadBufferSize(config.bufferSize);
dcfg.setIdleTime(IdleStatus.WRITER_IDLE, 10);
dcfg.setBroadcast(true);
KeepAliveFilter keepAliveFilter = MinaUtil.initServerKeepAlive(config, this);
if (keepAliveFilter != null) {
acceptor.getFilterChain().addLast(HEARTBEAT, keepAliveFilter);
}
}
示例5: sessionCreated
import org.apache.mina.filter.codec.ProtocolCodecFactory; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void sessionCreated(IoSession session) throws Exception {
log.debug("Session created");
// moved protocol state from connection object to RTMP object
RTMP rtmp = new RTMP();
session.setAttribute(ProtocolState.SESSION_KEY, rtmp);
//add rtmpe filter
session.getFilterChain().addFirst("rtmpeFilter", new RTMPEIoFilter());
//add protocol filter next
ProtocolCodecFactory codecFactory = (ProtocolCodecFactory) appCtx.getBean("rtmpCodecFactory");
session.getFilterChain().addLast("protocolFilter", new ProtocolCodecFilter(codecFactory));
if (log.isTraceEnabled()) {
session.getFilterChain().addLast("logger", new LoggingFilter());
}
//create a connection
RTMPMinaConnection conn = createRTMPMinaConnection();
conn.setIoSession(session);
conn.setState(rtmp);
//add the connection
session.setAttribute(RTMPConnection.RTMP_CONNECTION_KEY, conn);
//add the inbound handshake
session.setAttribute(RTMPConnection.RTMP_HANDSHAKE, new InboundHandshake());
}
示例6: StandaloneLdapApiService
import org.apache.mina.filter.codec.ProtocolCodecFactory; //导入依赖的package包/类
/**
* Creates a new instance of StandaloneLdapApiService.
*
* @param controls The list of controls to store
* @param extendedOperations The list of extended operations to store
* @throws Exception If we had an issue with one of the two lists
*/
public StandaloneLdapApiService( List<String> controls, List<String> extendedOperations ) throws Exception
{
CodecFactoryUtil.loadStockControls( getControlFactories(), this );
CodecFactoryUtil.loadStockExtendedOperations( getExtendedOperationsFactories(), this );
// Load the controls
loadControls( controls );
// Load the extended operations
loadExtendedOperations( extendedOperations );
if ( getProtocolCodecFactory() == null )
{
try
{
@SuppressWarnings("unchecked")
Class<? extends ProtocolCodecFactory> clazz = ( Class<? extends ProtocolCodecFactory> )
Class.forName( DEFAULT_PROTOCOL_CODEC_FACTORY );
Constructor<? extends ProtocolCodecFactory> constructor =
clazz.getConstructor( LdapApiService.class );
if ( constructor != null )
{
setProtocolCodecFactory( constructor.newInstance( this ) );
}
else
{
setProtocolCodecFactory( clazz.newInstance() );
}
}
catch ( Exception cause )
{
throw new RuntimeException( "Failed to load default codec factory.", cause );
}
}
}
示例7: registerProtocolCodecFactory
import org.apache.mina.filter.codec.ProtocolCodecFactory; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ProtocolCodecFactory registerProtocolCodecFactory( ProtocolCodecFactory protocolCodecFactory )
{
ProtocolCodecFactory oldFactory = this.protocolCodecFactory;
this.protocolCodecFactory = protocolCodecFactory;
return oldFactory;
}
示例8: configureDataGramCodecFactory
import org.apache.mina.filter.codec.ProtocolCodecFactory; //导入依赖的package包/类
/**
* For datagrams the entire message is available as a single ByteBuffer so lets just pass those around by default
* and try converting whatever they payload is into ByteBuffers unless some custom converter is specified
*/
protected void configureDataGramCodecFactory(final String type, final IoServiceConfig config, final MinaConfiguration configuration) {
ProtocolCodecFactory codecFactory = configuration.getCodec();
if (codecFactory == null) {
codecFactory = new MinaUdpProtocolCodecFactory(getCamelContext());
if (LOG.isDebugEnabled()) {
LOG.debug("{}: Using CodecFactory: {}", new Object[]{type, codecFactory});
}
}
addCodecFactory(config, codecFactory);
}
示例9: configureDataGramCodecFactory
import org.apache.mina.filter.codec.ProtocolCodecFactory; //导入依赖的package包/类
/**
* For datagrams the entire message is available as a single IoBuffer so lets just pass those around by default
* and try converting whatever they payload is into IoBuffer unless some custom converter is specified
*/
protected void configureDataGramCodecFactory(final String type, final IoService service, final Mina2Configuration configuration) {
ProtocolCodecFactory codecFactory = configuration.getCodec();
if (codecFactory == null) {
codecFactory = new Mina2UdpProtocolCodecFactory(this.getEndpoint().getCamelContext());
if (LOG.isDebugEnabled()) {
LOG.debug("{}: Using CodecFactory: {}", new Object[]{type, codecFactory});
}
}
addCodecFactory(service, codecFactory);
}
示例10: MinaServer
import org.apache.mina.filter.codec.ProtocolCodecFactory; //导入依赖的package包/类
public MinaServer(ServerMonitor serverMonitor, StubRetriever stubRetriever,
Authenticator authenticator,
ProtocolCodecFactory codecFactory,
ServerContextFactory contextFactory,
ClassLoader facadesClassLoader, InetSocketAddress addr) {
this(serverMonitor, defaultServerDelegate(serverMonitor, stubRetriever, authenticator, contextFactory),
codecFactory, facadesClassLoader, addr);
}
示例11: getProtocolCodecFactory
import org.apache.mina.filter.codec.ProtocolCodecFactory; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ProtocolCodecFactory getProtocolCodecFactory()
{
return protocolCodecFactory;
}
示例12: setProtocolCodecFactory
import org.apache.mina.filter.codec.ProtocolCodecFactory; //导入依赖的package包/类
/**
* @param protocolCodecFactory the protocolCodecFactory to set
*/
public void setProtocolCodecFactory( ProtocolCodecFactory protocolCodecFactory )
{
this.protocolCodecFactory = protocolCodecFactory;
}
示例13: getProtocolCodecFactory
import org.apache.mina.filter.codec.ProtocolCodecFactory; //导入依赖的package包/类
public ProtocolCodecFactory getProtocolCodecFactory()
{
return codecFactory;
}
示例14: getCodec
import org.apache.mina.filter.codec.ProtocolCodecFactory; //导入依赖的package包/类
public ProtocolCodecFactory getCodec() {
return codec;
}
示例15: setCodec
import org.apache.mina.filter.codec.ProtocolCodecFactory; //导入依赖的package包/类
/**
* To use a custom minda codec implementation.
*/
public void setCodec(ProtocolCodecFactory codec) {
this.codec = codec;
}