• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IoHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.mina.common.IoHandler的典型用法代码示例。如果您正苦于以下问题:Java IoHandler类的具体用法?Java IoHandler怎么用?Java IoHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IoHandler类属于org.apache.mina.common包,在下文中一共展示了IoHandler类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.mina.common.IoHandler; //导入依赖的package包/类
public static void main(String[] args) throws Exception{
	int port=9527;
	
	final IoAcceptor acceptor=new SocketAcceptor(Runtime.getRuntime().availableProcessors() + 1,
               							   Executors.newCachedThreadPool());
	acceptor.getFilterChain().addLast("stringserialize", new ProtocolCodecFilter(new ObjectSerializationCodecFactory()));
	IoHandler handler=new IoHandlerAdapter(){

		public void messageReceived(IoSession session, Object message)
				throws Exception {
			if("quit".equalsIgnoreCase(message.toString())){
				acceptor.unbindAll();
				System.out.println("Server has been shutdown!");
				System.exit(0);
			}
			System.out.println("Message from client: "+message);
			session.write("Server response��"+message);
		}
		
	};
	acceptor.bind(new InetSocketAddress(port), handler);
	System.out.println("Server listen on port: "+port);
}
 
开发者ID:java-scott,项目名称:java-project,代码行数:24,代码来源:Server.java


示例2: connectFederation

import org.apache.mina.common.IoHandler; //导入依赖的package包/类
/**
 * Create a connection to federation listener.
 */
private static IoSession connectFederation (Router router,
                                            EwafURI uri,
                                            IoHandler listener)
{
  SocketConnector connector = new SocketConnector (1, router.executor ());
  SocketConnectorConfig connectorConfig = new SocketConnectorConfig ();
  
  connector.setWorkerTimeout (0);
  
  connectorConfig.setThreadModel (ThreadModel.MANUAL);
  connectorConfig.setConnectTimeout (20);
  
  connectorConfig.getFilterChain ().addLast   
    ("codec", FederationFrameCodec.FILTER);
  
  ConnectFuture future = 
    connector.connect (new InetSocketAddress (uri.host, uri.port),
                       listener, connectorConfig);
  
  future.join ();
  
  return future.getSession ();
}
 
开发者ID:luv,项目名称:avis_zmqprx,代码行数:27,代码来源:JUTestFederation.java


示例3: doStart

import org.apache.mina.common.IoHandler; //导入依赖的package包/类
@Override
protected void doStart() throws Exception {
    super.doStart();
    LOG.info("Binding to server address: {} using acceptor: {}", address, acceptor);
    IoHandler handler = new ReceiveHandler();
    if (protocol.equals("tcp") && clientMode) {
        ConnectFuture future = connector.connect(address, handler, getEndpoint().getConnectorConfig());
        future.join();
        session = future.getSession();
    } else {
        acceptor.bind(address, handler, getEndpoint().getAcceptorConfig());
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:MinaConsumer.java


示例4: openConnection

import org.apache.mina.common.IoHandler; //导入依赖的package包/类
private void openConnection() {
    SocketAddress address = getEndpoint().getAddress();
    connector = getEndpoint().getConnector();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Creating connector to address: {} using connector: {} timeout: {} millis.", new Object[]{address, connector, timeout});
    }
    IoHandler ioHandler = new ResponseHandler(getEndpoint());
    // connect and wait until the connection is established
    ConnectFuture future = connector.connect(address, ioHandler, getEndpoint().getConnectorConfig());
    future.join();
    session = future.getSession();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:MinaProducer.java


示例5: bind

import org.apache.mina.common.IoHandler; //导入依赖的package包/类
/**
 * Bind to a set of URI's. This can be used by plugins to bind to
 * network addresses using the same network setup as the router
 * would, including TLS parameters.
 * 
 * @param uris The URI's to listen to.
 * @param handler The IO handler.
 * @param baseFilters The IO filters used by all connection types.
 * @param authRequired Hosts matched by this filter must be
 *                successfully authenticated via TLS or will be
 *                refused access.
 * 
 * @throws IOException if an error occurred during binding.
 */
public void bind (Set<? extends ElvinURI> uris, IoHandler handler,
                  DefaultIoFilterChainBuilder baseFilters, 
                  Filter<InetAddress> authRequired) 
  throws IOException
{
  SocketAcceptorConfig defaultAcceptorConfig = 
    createAcceptorConfig 
      (createStandardFilters (baseFilters, authRequired));
  SocketAcceptorConfig secureAcceptorConfig = null; // lazy init'ed
  
  for (ElvinURI uri : uris)
  {
    SocketAcceptorConfig bindConfig;
    
    if (uri.isSecure ())
    {
      if (secureAcceptorConfig == null)
      {
        secureAcceptorConfig = 
          createAcceptorConfig 
            (createSecureFilters (baseFilters, authRequired, false));
      }
      
      bindConfig = secureAcceptorConfig;
    } else
    {
      bindConfig = defaultAcceptorConfig;
    }
    
    for (InetSocketAddress address : addressesFor (uri))
      acceptor.bind (address, handler, bindConfig);
  }
}
 
开发者ID:luv,项目名称:avis_zmqprx,代码行数:48,代码来源:Router.java


示例6: connectFederationTLS

import org.apache.mina.common.IoHandler; //导入依赖的package包/类
/**
 * Create a connection to federation listener.
 */
private static IoSession connectFederationTLS (Router router,
                                               EwafURI uri,
                                               IoHandler listener)
  throws Exception
{
  SocketConnector connector = new SocketConnector (1, router.executor ());
  SocketConnectorConfig connectorConfig = new SocketConnectorConfig ();
  
  connector.setWorkerTimeout (0);
  
  connectorConfig.setThreadModel (ThreadModel.MANUAL);
  connectorConfig.setConnectTimeout (20);
  
  SSLFilter filter = new SSLFilter (defaultSSLContext ());
  
  filter.setUseClientMode (true);
  
  connectorConfig.getFilterChain ().addFirst ("ssl", filter);   
  
  connectorConfig.getFilterChain ().addLast   
    ("codec", FederationFrameCodec.FILTER);
  
  ConnectFuture future = 
    connector.connect (new InetSocketAddress (uri.host, uri.port),
                       listener, connectorConfig);
  
  future.join ();
  
  return future.getSession ();
}
 
开发者ID:luv,项目名称:avis_zmqprx,代码行数:34,代码来源:JUTestFederationTLS.java


示例7: connect

import org.apache.mina.common.IoHandler; //导入依赖的package包/类
public void connect (IoHandler acceptorListener, IoHandler connectorListener)
  throws IOException
{
  InetSocketAddress remoteAddress = new InetSocketAddress ("127.0.0.1", 29170);
  
  acceptor.bind (remoteAddress, acceptorListener, acceptorConfig);
  
  ConnectFuture future = 
    connector.connect (remoteAddress, connectorListener, connectorConfig);
  
  future.join ();
  
  session = future.getSession ();
}
 
开发者ID:luv,项目名称:avis_zmqprx,代码行数:15,代码来源:AcceptorConnectorSetup.java


示例8: getHandler

import org.apache.mina.common.IoHandler; //导入依赖的package包/类
/**
 * Does nothing.
 * @return 
 */
@Override
public IoHandler getHandler() {
    return null;
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:9,代码来源:MockIOSession.java


示例9: getHandler

import org.apache.mina.common.IoHandler; //导入依赖的package包/类
public IoHandler getHandler() {
    return null;
}
 
开发者ID:wso2,项目名称:andes,代码行数:4,代码来源:TestIoSession.java


示例10: getHandler

import org.apache.mina.common.IoHandler; //导入依赖的package包/类
@Override
public IoHandler getHandler() {
    return null;
}
 
开发者ID:betfair,项目名称:cougar,代码行数:5,代码来源:MyIoSession.java


示例11: createClient

import org.apache.mina.common.IoHandler; //导入依赖的package包/类
public IoSession createClient(NioConfig cfg, IoHandler handler) throws IOException {
    SocketConnector sc = new SocketConnector();
    ConnectFuture cf = sc.connect(new InetSocketAddress("127.0.0.1", 2227), handler, cfg.configureSocketSessionConfig());
    cf.join();
    return cf.getSession();
}
 
开发者ID:betfair,项目名称:cougar,代码行数:7,代码来源:CougarProtocolTest.java


示例12: getHandler

import org.apache.mina.common.IoHandler; //导入依赖的package包/类
@Override
public IoHandler getHandler() {
    return mock.getHandler();
}
 
开发者ID:betfair,项目名称:cougar,代码行数:5,代码来源:CougarProtocolTest.java


示例13: getHandler

import org.apache.mina.common.IoHandler; //导入依赖的package包/类
@Override
public IoHandler getHandler() {
    return null;  //To change body of implemented methods use File | Settings | File Templates.
}
 
开发者ID:betfair,项目名称:cougar,代码行数:5,代码来源:MyIoSession.java



注:本文中的org.apache.mina.common.IoHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ContainerBuilder类代码示例发布时间:2022-05-22
下一篇:
Java VersionUtil类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap