當前位置: 首頁>>代碼示例>>Java>>正文


Java ProtocolCodecFactory類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:EthanCo,項目名稱:Halo-Turbo,代碼行數:24,代碼來源:MinaTcpServerSocket.java

示例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);
    }
}
 
開發者ID:EthanCo,項目名稱:Halo-Turbo,代碼行數:21,代碼來源:MinaUdpClientSocket.java

示例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);
    }
}
 
開發者ID:EthanCo,項目名稱:Halo-Turbo,代碼行數:21,代碼來源:MinaTcpClientSocket.java

示例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);
    }
}
 
開發者ID:EthanCo,項目名稱:Halo-Turbo,代碼行數:26,代碼來源:MinaUdpServerSocket.java

示例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());
}
 
開發者ID:cwpenhale,項目名稱:red5-mobileconsole,代碼行數:25,代碼來源:RTMPMinaIoHandler.java

示例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 );
        }
    }
}
 
開發者ID:apache,項目名稱:directory-ldap-api,代碼行數:44,代碼來源:StandaloneLdapApiService.java

示例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;
}
 
開發者ID:apache,項目名稱:directory-ldap-api,代碼行數:11,代碼來源:DefaultLdapCodecService.java

示例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);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:17,代碼來源:MinaComponent.java

示例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);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:17,代碼來源:Mina2Producer.java

示例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);
}
 
開發者ID:paul-hammant,項目名稱:JRemoting,代碼行數:9,代碼來源:MinaServer.java

示例11: getProtocolCodecFactory

import org.apache.mina.filter.codec.ProtocolCodecFactory; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public ProtocolCodecFactory getProtocolCodecFactory()
{
    return protocolCodecFactory;
}
 
開發者ID:apache,項目名稱:directory-ldap-api,代碼行數:9,代碼來源:DefaultLdapCodecService.java

示例12: setProtocolCodecFactory

import org.apache.mina.filter.codec.ProtocolCodecFactory; //導入依賴的package包/類
/**
 * @param protocolCodecFactory the protocolCodecFactory to set
 */
public void setProtocolCodecFactory( ProtocolCodecFactory protocolCodecFactory )
{
    this.protocolCodecFactory = protocolCodecFactory;
}
 
開發者ID:apache,項目名稱:directory-ldap-api,代碼行數:8,代碼來源:DefaultLdapCodecService.java

示例13: getProtocolCodecFactory

import org.apache.mina.filter.codec.ProtocolCodecFactory; //導入依賴的package包/類
public ProtocolCodecFactory getProtocolCodecFactory()
{
    return codecFactory;
}
 
開發者ID:TremoloSecurity,項目名稱:MyVirtualDirectory,代碼行數:5,代碼來源:LdapServer.java

示例14: getCodec

import org.apache.mina.filter.codec.ProtocolCodecFactory; //導入依賴的package包/類
public ProtocolCodecFactory getCodec() {
    return codec;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:4,代碼來源:MinaConfiguration.java

示例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;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:7,代碼來源:MinaConfiguration.java


注:本文中的org.apache.mina.filter.codec.ProtocolCodecFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。